Skip to content

Commit d4ead60

Browse files
authored
Do not expose fiber VM state management (php#7170)
1 parent acb7803 commit d4ead60

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

Zend/zend_fibers.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,45 @@ struct _zend_fiber_stack {
7474
#endif
7575
};
7676

77+
/* Zend VM state that needs to be captured / restored during fiber context switch. */
78+
typedef struct _zend_fiber_vm_state {
79+
zend_vm_stack vm_stack;
80+
zval *vm_stack_top;
81+
zval *vm_stack_end;
82+
size_t vm_stack_page_size;
83+
zend_execute_data *current_execute_data;
84+
int error_reporting;
85+
uint32_t jit_trace_num;
86+
JMP_BUF *bailout;
87+
zend_fiber *active_fiber;
88+
} zend_fiber_vm_state;
89+
90+
static zend_always_inline void zend_fiber_capture_vm_state(zend_fiber_vm_state *state)
91+
{
92+
state->vm_stack = EG(vm_stack);
93+
state->vm_stack_top = EG(vm_stack_top);
94+
state->vm_stack_end = EG(vm_stack_end);
95+
state->vm_stack_page_size = EG(vm_stack_page_size);
96+
state->current_execute_data = EG(current_execute_data);
97+
state->error_reporting = EG(error_reporting);
98+
state->jit_trace_num = EG(jit_trace_num);
99+
state->bailout = EG(bailout);
100+
state->active_fiber = EG(active_fiber);
101+
}
102+
103+
static zend_always_inline void zend_fiber_restore_vm_state(zend_fiber_vm_state *state)
104+
{
105+
EG(vm_stack) = state->vm_stack;
106+
EG(vm_stack_top) = state->vm_stack_top;
107+
EG(vm_stack_end) = state->vm_stack_end;
108+
EG(vm_stack_page_size) = state->vm_stack_page_size;
109+
EG(current_execute_data) = state->current_execute_data;
110+
EG(error_reporting) = state->error_reporting;
111+
EG(jit_trace_num) = state->jit_trace_num;
112+
EG(bailout) = state->bailout;
113+
EG(active_fiber) = state->active_fiber;
114+
}
115+
77116
/* boost_context_data is our customized definition of struct transfer_t as
78117
* provided by boost.context in fcontext.hpp:
79118
*

Zend/zend_fibers.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,6 @@ struct _zend_fiber_context {
8282
uint8_t flags;
8383
};
8484

85-
/* Zend VM state that needs to be captured / restored during fiber context switch. */
86-
typedef struct _zend_fiber_vm_state {
87-
zend_vm_stack vm_stack;
88-
zval *vm_stack_top;
89-
zval *vm_stack_end;
90-
size_t vm_stack_page_size;
91-
zend_execute_data *current_execute_data;
92-
int error_reporting;
93-
uint32_t jit_trace_num;
94-
JMP_BUF *bailout;
95-
zend_fiber *active_fiber;
96-
} zend_fiber_vm_state;
97-
9885
struct _zend_fiber {
9986
/* PHP object handle. */
10087
zend_object std;
@@ -144,30 +131,4 @@ static zend_always_inline zend_fiber_context *zend_fiber_get_context(zend_fiber
144131
return &fiber->context;
145132
}
146133

147-
static zend_always_inline void zend_fiber_capture_vm_state(zend_fiber_vm_state *state)
148-
{
149-
state->vm_stack = EG(vm_stack);
150-
state->vm_stack_top = EG(vm_stack_top);
151-
state->vm_stack_end = EG(vm_stack_end);
152-
state->vm_stack_page_size = EG(vm_stack_page_size);
153-
state->current_execute_data = EG(current_execute_data);
154-
state->error_reporting = EG(error_reporting);
155-
state->jit_trace_num = EG(jit_trace_num);
156-
state->bailout = EG(bailout);
157-
state->active_fiber = EG(active_fiber);
158-
}
159-
160-
static zend_always_inline void zend_fiber_restore_vm_state(zend_fiber_vm_state *state)
161-
{
162-
EG(vm_stack) = state->vm_stack;
163-
EG(vm_stack_top) = state->vm_stack_top;
164-
EG(vm_stack_end) = state->vm_stack_end;
165-
EG(vm_stack_page_size) = state->vm_stack_page_size;
166-
EG(current_execute_data) = state->current_execute_data;
167-
EG(error_reporting) = state->error_reporting;
168-
EG(jit_trace_num) = state->jit_trace_num;
169-
EG(bailout) = state->bailout;
170-
EG(active_fiber) = state->active_fiber;
171-
}
172-
173134
#endif

0 commit comments

Comments
 (0)