Re: 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 c

From: Date: Wed, 30 Sep 2015 01:02:07 +0000
Subject: Re: 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 c
References: 1 2  Groups: php.cvs php.internals 
Request: Send a blank email to php-cvs+get-89230@lists.php.net to get a copy of this message
On Wed, Sep 30, 2015 at 1:16 AM, Matt Wilmas <php_lists@realplain.com> wrote: > Hi Dmitry, > > Just curious about this. :-) For dispatching next opcode, isn't a tail > call an indirect jmp instruction, just like a computed goto? So how is it > different than GOTO executor...? Debugging/compatibility? (Unless it can > work with MSVC -- oh nevermind, looks like it's only with global registers > anyway.) > > Wondering what you had in mind when adding it, etc. So it'd be cool if > there's anything else you could tell us about it, or who should use it and > why... > Hi Matt, GOTO executor is faster on small benchmarks, but doesn't make speedup on real apps. May be TAIL-CALL would make a difference. Anyway this is an experimental option, that doesn't work yet. May be someone could make it work. Thanks. Dmitry. > > > Thanks, > Matt > > > ----- Original Message ----- > From: "Dmitry Stogov" > Sent: Friday, September 25, 2015 > > 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");

« previous php.cvs (#89230) next »