Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created August 19, 2020 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/2cbdb2f0cb13cdf94b00416345083fea to your computer and use it in GitHub Desktop.
Save dstogov/2cbdb2f0cb13cdf94b00416345083fea to your computer and use it in GitHub Desktop.
diff --git a/reserved_slot.c b/reserved_slot.c
index 4e418f9..16837b8 100644
--- a/reserved_slot.c
+++ b/reserved_slot.c
@@ -46,12 +46,25 @@ void reserved_slot_startup_fcall_begin_handler(zend_execute_data *ex) {
php_printf("Function %s is immutable\n", ZSTR_VAL(fbc->common.function_name));
}
if (fbc->type == ZEND_USER_FUNCTION) {
+ zend_op_array *op_array = &fbc->op_array;
+
+ if (op_array->fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
+ op_array = (op_array->fn_flags & ZEND_ACC_STATIC) ?
+ &op_array->scope->__callstatic->op_array :
+ &op_array->scope->__call->op_array;
+ if (op_array->type != ZEND_USER_FUNCTION) {
+ return;
+ }
+ if (!RUN_TIME_CACHE(op_array)) {
+ zend_init_func_run_time_cache(op_array);
+ }
+ }
reserved_slot_cache cache = {
- .ptr = ZEND_OP_ARRAY_EXTENSION(&fbc->op_array, reserved_slot_resource),
+ .ptr = ZEND_OP_ARRAY_EXTENSION(op_array, reserved_slot_resource),
};
- php_printf("Call %lu to %s\n", cache.num, ZSTR_VAL(fbc->common.function_name));
+ php_printf("Call %lu to %s\n", cache.num, ZSTR_VAL(op_array->function_name));
cache.num += 1;
- ZEND_OP_ARRAY_EXTENSION(&fbc->op_array, reserved_slot_resource) = cache.ptr;
+ ZEND_OP_ARRAY_EXTENSION(op_array, reserved_slot_resource) = cache.ptr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment