rfc:zend-vm-pause-api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
rfc:zend-vm-pause-api [2017/11/01 01:14] – created lvhtrfc:zend-vm-pause-api [2017/11/01 01:35] lvht
Line 2: Line 2:
   * Version: 0.9   * Version: 0.9
   * Date: 2017-11-01   * Date: 2017-11-01
-  * Author: Haitao Lv php@lvht.net+  * Author: Haitao Lvphp@lvht.net
   * Status: Draft   * Status: Draft
   * First Published at: http://wiki.php.net/rfc/zend-vm-pause-api   * First Published at: http://wiki.php.net/rfc/zend-vm-pause-api
Line 11: Line 11:
  
 So it is impossible to change the Zend VM's execute flow in an zend extension. As a result, any feature, like Fiber, So it is impossible to change the Zend VM's execute flow in an zend extension. As a result, any feature, like Fiber,
-related to Zend VM's execute flow cannot be implemented by a standalone.+related to Zend VM's execute flow cannot be implemented by a standalone extension.
  
 ===== Proposal ===== ===== Proposal =====
-This PRFC propose a new zend_vm_pause API and an new EG(pause_op), by which some zend extension could make the +This PRFC propose a new zend_vm_pause API, by which some zend extension could make the zend vm execution paused. 
-zend vm execution paused.  As a result, we can implement feature like Fiber in a standalone extension.+As a result, we can implement feature like Fiber in a standalone extension.
  
 We need introduce a new vm global EG(pause_op) as zend_op and init it by the following code We need introduce a new vm global EG(pause_op) as zend_op and init it by the following code
Line 80: Line 80:
 You will see that we want to make the Zend VM execute the EG(pause_op) by changing the EX(prev_execute_data)->opline pointer. You will see that we want to make the Zend VM execute the EG(pause_op) by changing the EX(prev_execute_data)->opline pointer.
  
 +However, it does not work out of box. The reason is under the ZEND_DO_FCALL's handler.
 <code c> <code c>
 ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL)) ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
Line 92: Line 93:
         } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {         } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
                 // ...                 // ...
 +                
                 // the extension's method will enter this branch                 // the extension's method will enter this branch
                 // after its execution, we changed the EG(current_execute_data).opline                 // after its execution, we changed the EG(current_execute_data).opline
                 // However, as the value of EG(current_execute_data).opline has already been loade into the opline                 // However, as the value of EG(current_execute_data).opline has already been loade into the opline
-                // We need to reload the opline 
                                  
 +                // We need to reload the opline
                 LOAD_OPLINE(); // load the opline again                 LOAD_OPLINE(); // load the opline again
  
rfc/zend-vm-pause-api.txt · Last modified: 2017/11/21 10:56 by lvht