@@ -74,6 +74,45 @@ struct _zend_fiber_stack {
74
74
#endif
75
75
};
76
76
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
+
77
116
/* boost_context_data is our customized definition of struct transfer_t as
78
117
* provided by boost.context in fcontext.hpp:
79
118
*
0 commit comments