com php-src: Allow an experimental VM with tail call dispatch technique (disabled by default). This VM may work only if all tail calls are optimized,
otherwaise it will crach because of stack overflow. Unfortunately, we can't guarantee tail call optimization in C.: Zend/zend_vm_execute.h
Zend/zend_vm_gen.php
| From: | Dmitry Stogov | Date: | Fri, 25 Sep 2015 09:54:51 +0000 |
| Subject: | com php-src: Allow an experimental VM with tail call dispatch technique (disabled by default). This VM may work only if all tail calls are optimized, otherwaise it will crach because of stack overflow. Unfortunately, we can't guarantee tail call optimization in C.: Zend/zend_vm_execute.h Zend/zend_vm_gen.php |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89178@lists.php.net to get a copy of this message | ||
Commit: 7e797f13026440c54e24f89cf29f46bb0b262a39
Author: Dmitry Stogov <dmitry@zend.com> Fri, 25 Sep 2015 12:54:51 +0300
Parents: 37c85ebb9469b4411bb5d144e6d9ec525ea552a1
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e797f13026440c54e24f89cf29f46bb0b262a39
Log:
Allow an experimental VM with tail call dispatch technique (disabled by default).
This VM may work only if all tail calls are optimized, otherwaise it will crach because of stack
overflow.
Unfortunately, we can't guarantee tail call optimization in C.
Changed paths:
M Zend/zend_vm_execute.h
M Zend/zend_vm_gen.php
Diff:
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 253a2d7..035f4ab 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -337,8 +337,12 @@ register const zend_op* volatile opline __asm__(ZEND_VM_IP_GLOBAL_REG);
#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)
# define ZEND_OPCODE_HANDLER_RET void
# define ZEND_VM_TAIL_CALL(call) call; return
-# define ZEND_VM_CONTINUE() return
-# define ZEND_VM_RETURN() opline = NULL; ZEND_VM_CONTINUE()
+# ifdef ZEND_VM_TAIL_CALL_DISPATCH
+# define ZEND_VM_CONTINUE()
((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); return
+# else
+# define ZEND_VM_CONTINUE() return
+# endif
+# define ZEND_VM_RETURN() opline = NULL; return
#else
# define ZEND_OPCODE_HANDLER_RET int
# define ZEND_VM_TAIL_CALL(call) return call
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index 8f06bb4..613b4c9 100644
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -1058,8 +1058,12 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name,
$initializer_name)
out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG) &&
defined(ZEND_VM_IP_GLOBAL_REG)\n");
out($f,"# define ZEND_OPCODE_HANDLER_RET void\n");
out($f,"# define ZEND_VM_TAIL_CALL(call) call; return\n");
- out($f,"# define ZEND_VM_CONTINUE() return\n");
- out($f,"# define ZEND_VM_RETURN() opline = NULL; ZEND_VM_CONTINUE()\n");
+ out($f,"# ifdef ZEND_VM_TAIL_CALL_DISPATCH\n");
+ out($f,"# define ZEND_VM_CONTINUE()
((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); return\n");
+ out($f,"# else\n");
+ out($f,"# define ZEND_VM_CONTINUE() return\n");
+ out($f,"# endif\n");
+ out($f,"# define ZEND_VM_RETURN() opline = NULL; return\n");
out($f,"#else\n");
out($f,"# define ZEND_OPCODE_HANDLER_RET int\n");
out($f,"# define ZEND_VM_TAIL_CALL(call) return call\n");