|
25 | 25 | #define ENFORCE_SAFE_MODE 0 |
26 | 26 | #endif |
27 | 27 |
|
| 28 | +/** |
| 29 | + * Runs a required file's op_array. zend_execute() leaves EG(jit_trace_num) at |
| 30 | + * whatever trace the file's code entered last; when the require itself runs |
| 31 | + * inside a tracing-JIT trace, that trace's next side exit then deoptimizes with |
| 32 | + * another trace's exit table (a crash in zend_jit_trace_exit() or a frame resumed |
| 33 | + * at a wrong opline). zend_call_function() restores it the same way. |
| 34 | + */ |
| 35 | +static void zephir_require_execute(zend_op_array *op_array, zval *retval) |
| 36 | +{ |
| 37 | + uint32_t orig_jit_trace_num = EG(jit_trace_num); |
| 38 | + |
| 39 | + zend_execute(op_array, retval); |
| 40 | + EG(jit_trace_num) = orig_jit_trace_num; |
| 41 | +} |
| 42 | + |
28 | 43 | /** |
29 | 44 | * Do an internal require to a plain php file taking care of the value returned by the file |
30 | 45 | */ |
@@ -75,7 +90,7 @@ int zephir_require_ret(zval *return_value_ptr, const char *require_path) |
75 | 90 | * made `const zend_class_entry *` in PHP 8.5. The cast is safe: the |
76 | 91 | * class entry itself is the same object — only the access path differs. */ |
77 | 92 | new_op_array->scope = (zend_class_entry *) (EG(fake_scope) ? EG(fake_scope) : zend_get_executed_scope()); |
78 | | - zend_execute(new_op_array, &local_retval); |
| 93 | + zephir_require_execute(new_op_array, &local_retval); |
79 | 94 |
|
80 | 95 | if (return_value_ptr) { |
81 | 96 | zval_ptr_dtor(return_value_ptr); |
@@ -166,7 +181,7 @@ int zephir_require_once_ret(zval *return_value_ptr, const char *require_path) |
166 | 181 | * made `const zend_class_entry *` in PHP 8.5. The cast is safe: the |
167 | 182 | * class entry itself is the same object — only the access path differs. */ |
168 | 183 | new_op_array->scope = (zend_class_entry *) (EG(fake_scope) ? EG(fake_scope) : zend_get_executed_scope()); |
169 | | - zend_execute(new_op_array, &local_retval); |
| 184 | + zephir_require_execute(new_op_array, &local_retval); |
170 | 185 |
|
171 | 186 | if (return_value_ptr) { |
172 | 187 | zval_ptr_dtor(return_value_ptr); |
|
0 commit comments