From cb3a018bc5eb0d96d0f927894b8e4edebc9caecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Fri, 18 Jun 2021 07:42:21 +0200 Subject: [PATCH] Do not expose fiber VM state management --- Zend/zend_fibers.c | 39 +++++++++++++++++++++++++++++++++++++++ Zend/zend_fibers.h | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c index 1ddf25a0c714f..e5fa46b68b927 100644 --- a/Zend/zend_fibers.c +++ b/Zend/zend_fibers.c @@ -74,6 +74,45 @@ struct _zend_fiber_stack { #endif }; +/* Zend VM state that needs to be captured / restored during fiber context switch. */ +typedef struct _zend_fiber_vm_state { + zend_vm_stack vm_stack; + zval *vm_stack_top; + zval *vm_stack_end; + size_t vm_stack_page_size; + zend_execute_data *current_execute_data; + int error_reporting; + uint32_t jit_trace_num; + JMP_BUF *bailout; + zend_fiber *active_fiber; +} zend_fiber_vm_state; + +static zend_always_inline void zend_fiber_capture_vm_state(zend_fiber_vm_state *state) +{ + state->vm_stack = EG(vm_stack); + state->vm_stack_top = EG(vm_stack_top); + state->vm_stack_end = EG(vm_stack_end); + state->vm_stack_page_size = EG(vm_stack_page_size); + state->current_execute_data = EG(current_execute_data); + state->error_reporting = EG(error_reporting); + state->jit_trace_num = EG(jit_trace_num); + state->bailout = EG(bailout); + state->active_fiber = EG(active_fiber); +} + +static zend_always_inline void zend_fiber_restore_vm_state(zend_fiber_vm_state *state) +{ + EG(vm_stack) = state->vm_stack; + EG(vm_stack_top) = state->vm_stack_top; + EG(vm_stack_end) = state->vm_stack_end; + EG(vm_stack_page_size) = state->vm_stack_page_size; + EG(current_execute_data) = state->current_execute_data; + EG(error_reporting) = state->error_reporting; + EG(jit_trace_num) = state->jit_trace_num; + EG(bailout) = state->bailout; + EG(active_fiber) = state->active_fiber; +} + /* boost_context_data is our customized definition of struct transfer_t as * provided by boost.context in fcontext.hpp: * diff --git a/Zend/zend_fibers.h b/Zend/zend_fibers.h index b0d59dc30c8e3..1512e61c2556c 100644 --- a/Zend/zend_fibers.h +++ b/Zend/zend_fibers.h @@ -82,19 +82,6 @@ struct _zend_fiber_context { uint8_t flags; }; -/* Zend VM state that needs to be captured / restored during fiber context switch. */ -typedef struct _zend_fiber_vm_state { - zend_vm_stack vm_stack; - zval *vm_stack_top; - zval *vm_stack_end; - size_t vm_stack_page_size; - zend_execute_data *current_execute_data; - int error_reporting; - uint32_t jit_trace_num; - JMP_BUF *bailout; - zend_fiber *active_fiber; -} zend_fiber_vm_state; - struct _zend_fiber { /* PHP object handle. */ zend_object std; @@ -144,30 +131,4 @@ static zend_always_inline zend_fiber_context *zend_fiber_get_context(zend_fiber return &fiber->context; } -static zend_always_inline void zend_fiber_capture_vm_state(zend_fiber_vm_state *state) -{ - state->vm_stack = EG(vm_stack); - state->vm_stack_top = EG(vm_stack_top); - state->vm_stack_end = EG(vm_stack_end); - state->vm_stack_page_size = EG(vm_stack_page_size); - state->current_execute_data = EG(current_execute_data); - state->error_reporting = EG(error_reporting); - state->jit_trace_num = EG(jit_trace_num); - state->bailout = EG(bailout); - state->active_fiber = EG(active_fiber); -} - -static zend_always_inline void zend_fiber_restore_vm_state(zend_fiber_vm_state *state) -{ - EG(vm_stack) = state->vm_stack; - EG(vm_stack_top) = state->vm_stack_top; - EG(vm_stack_end) = state->vm_stack_end; - EG(vm_stack_page_size) = state->vm_stack_page_size; - EG(current_execute_data) = state->current_execute_data; - EG(error_reporting) = state->error_reporting; - EG(jit_trace_num) = state->jit_trace_num; - EG(bailout) = state->bailout; - EG(active_fiber) = state->active_fiber; -} - #endif