-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix zend_separate_if_call_and_write for FUNC_ARGs #12140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e184f86
to
3361eb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look good. Please check the comments. (May be I didn't understand all the details).
Zend/Optimizer/optimize_func_calls.c
Outdated
@@ -272,6 +281,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) | |||
opline->opcode = ZEND_FETCH_STATIC_PROP_R; | |||
} | |||
} | |||
MAKE_NOP(call_stack[call - 1].last_check_func_arg_opline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the right place for MAKE_NOP
.
I would move it into ZEND_SEND_FUNC_ARG
.
case ZEND_SEND_FUNC_ARG:
/* Don't transform SEND_FUNC_ARG if any FETCH opcodes weren't transformed. */
if (call_stack[call - 1].last_check_func_arg_opline == NULL) {
if (opline->op2_type == IS_CONST) {
call_stack[call - 1].try_inline = 0;
}
break;
+ } else {
+ MAKE_NOP(call_stack[call - 1].last_check_func_arg_opline);
}
call_stack[call - 1].last_check_func_arg_opline = NULL;
ZEND_FALLTHROUGH;
case ZEND_SEND_VAR_EX:
Thanks for the reviews @dstogov! |
Merged as 748adf1 (misspelled "closes") |
Fixes GH-12102
Note on the optimizer changes: Zend/tests/gh12102_3.phpt demonstrates an existing issue in the optimizer. Namely, we're always converting
FETCH_DIM_FUNC_ARG
/FETCH_OBJ_FUNC_ARG
intoFETCH_DIM_W
/FETCH_OBJ_W
if the parameter is known to be by-ref. However, this is incorrect for containers that areTMP
, as there's no such specialization.If we don't convert these fetches, we also need to keep the
CHECK_FUNC_ARG
opcode, so that we're actually aware of the fetch-mode in theFUNC_ARG
opcodes.