Re: RFC - Zend VM Pause API
| From: | Haitao Lv | Date: | Sun, 05 Nov 2017 13:04:10 +0000 |
| Subject: | Re: RFC - Zend VM Pause API | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101064@lists.php.net to get a copy of this message | ||
After discussion with Dmitry, I update my RFC. The RFC url is here
https://wiki.php.net/rfc/zend-vm-pause-api
And I propose to introduce a new interrupt type to make vm pause-and-return, not pause-and-continue.
As mentioned by Dmitry, features like Fiber could be implemented by current vm_interrupt
implementation, theoretically. By using it, even init a function call will need to make our own op
array.
So I propose this patch.
Thank you.
> On 1 Nov 2017, at 17:13, Haitao Lv <i@lvht.net> wrote:
>
> Would it proper to introduce the following path?
>
> diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
> index 9bed9f86bb..cf0935df74 100644
> --- a/Zend/zend_vm_def.h
> +++ b/Zend/zend_vm_def.h
> @@ -8920,13 +8920,19 @@ ZEND_VM_DEFINE_OP(137, ZEND_OP_DATA);
>
> ZEND_VM_HELPER(zend_interrupt_helper, ANY, ANY)
> {
> + int8_t interrupt_type = EG(vm_interrupt);
> +
> EG(vm_interrupt) = 0;
> if (EG(timed_out)) {
> zend_timeout(0);
> } else if (zend_interrupt_function) {
> SAVE_OPLINE();
> zend_interrupt_function(execute_data);
> - ZEND_VM_ENTER();
> + if (interrupt_type == 2) {
> + ZEND_VM_RETURN();
> + } else {
> + ZEND_VM_ENTER();
> + }
> }
> ZEND_VM_CONTINUE();
> }
>
>> On 1 Nov 2017, at 16:54, Haitao Lv <i@lvht.net> wrote:
>>
>> It seems that set EG(vm_interrupt) to 1 could not stop the vm execution but only execute
>> the interrupt_function and continue the current execution.
>>
>> However, my RFC propose to stop the current execution.
>>
>>> On 1 Nov 2017, at 16:07, Dmitry Stogov <dmitry@zend.com> wrote:
>>>
>>> Hi,
>>>
>>> It should be possible do similar things using EG(vm_interrupt) and
>>> zend_interrupt_function() callback (introduced in php-7.1)
>>> ext/pcntl implements asynchronous signal handling using this.
>>>
>>> Thanks. Dmitry.
>>> From: Haitao Lv <i@lvht.net>
>>> Sent: Wednesday, November 1, 2017 4:19:07 AM
>>> To: PHP Internals
>>> Subject: [PHP-DEV] RFC - Zend VM Pause API
>>>
>>> Hi, internals,
>>>
>>> I propose to introduce a new zend vm pause api, and here is the RPF
>>>
>>> https://wiki.php.net/rfc/zend-vm-pause-api
>>> <https://wiki.php.net/rfc/zend-vm-pause-api>
>>>
>>> Please gave your comment.
>>>
>>> Thank you.
>>>
>>>
>>>
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> <http://www.php.net/unsub.php>
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php