mirror of
https://github.com/php/php-src.git
synced 2026-04-05 15:12:39 +02:00
Move FETCH_CLASS+INSTANCEOF special case out of update_op1_const()
The generic code was rejecting this to go into a special code path in SCCP. We should directly do that in SCCP instead, to still allow the generic (and valid) replacement.
This commit is contained in:
@@ -305,29 +305,24 @@ static bool try_replace_op2(
|
||||
if (ssa_op->op2_use == var && can_replace_op2(ctx->scdf.op_array, opline, ssa_op)) {
|
||||
zval zv;
|
||||
ZVAL_COPY(&zv, value);
|
||||
|
||||
if (opline->opcode == ZEND_FETCH_CLASS && (opline + 1)->opcode == ZEND_INSTANCEOF &&
|
||||
ssa_op->result_def == (ssa_op + 1)->op2_use && Z_TYPE(zv) == IS_STRING) {
|
||||
if (zend_optimizer_update_op2_const(ctx->scdf.op_array, opline + 1, &zv)) {
|
||||
zend_ssa_op *next_op = ssa_op + 1;
|
||||
zend_ssa_unlink_use_chain(ctx->scdf.ssa, next_op - ctx->scdf.ssa->ops, next_op->op2_use);
|
||||
next_op->op2_use = -1;
|
||||
next_op->op2_use_chain = -1;
|
||||
zend_ssa_remove_result_def(ctx->scdf.ssa, ssa_op);
|
||||
MAKE_NOP(opline);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (zend_optimizer_update_op2_const(ctx->scdf.op_array, opline, &zv)) {
|
||||
return 1;
|
||||
} else {
|
||||
switch (opline->opcode) {
|
||||
case ZEND_FETCH_CLASS:
|
||||
if (Z_TYPE(zv) == IS_STRING) {
|
||||
ZEND_ASSERT((opline + 1)->opcode == ZEND_INSTANCEOF);
|
||||
ZEND_ASSERT(ssa_op->result_def == (ssa_op + 1)->op2_use);
|
||||
if (zend_optimizer_update_op2_const(ctx->scdf.op_array, opline + 1, &zv)) {
|
||||
zend_ssa_op *next_op = ssa_op + 1;
|
||||
zend_ssa_unlink_use_chain(ctx->scdf.ssa, next_op - ctx->scdf.ssa->ops, next_op->op2_use);
|
||||
next_op->op2_use = -1;
|
||||
next_op->op2_use_chain = -1;
|
||||
zend_ssa_remove_result_def(ctx->scdf.ssa, ssa_op);
|
||||
MAKE_NOP(opline);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
zval_ptr_dtor_nogc(&zv);
|
||||
}
|
||||
zval_ptr_dtor_nogc(&zv);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -351,11 +351,6 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array,
|
||||
case ZEND_FAST_CALL:
|
||||
return 0;
|
||||
case ZEND_FETCH_CLASS:
|
||||
if ((opline + 1)->opcode == ZEND_INSTANCEOF &&
|
||||
(opline + 1)->op2.var == opline->result.var) {
|
||||
return 0;
|
||||
}
|
||||
ZEND_FALLTHROUGH;
|
||||
case ZEND_INSTANCEOF:
|
||||
REQUIRES_STRING(val);
|
||||
drop_leading_backslash(val);
|
||||
|
||||
Reference in New Issue
Block a user