Last active
January 4, 2018 05:56
-
-
Save laruence/264b2970c92e7890d415e186c7ef4999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c | |
index 25b51b6..14daac2 100644 | |
--- a/ext/opcache/Optimizer/sccp.c | |
+++ b/ext/opcache/Optimizer/sccp.c | |
@@ -329,6 +329,25 @@ static zend_bool try_replace_op2( | |
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((opline + 1)->op2.var == opline->result.var); | |
+ if (zend_optimizer_update_op2_const(ctx->scdf.op_array, opline + 1, &zv)) { | |
+ zend_ssa_op *next_op = ssa_op + 1; | |
+ zend_optimizer_remove_live_range_ex(ctx->scdf.op_array, opline->result.var, ssa_op - ctx->scdf.ssa->ops); | |
+ 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); | |
} | |
} | |
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c | |
index 97be113..d5975f1 100644 | |
--- a/ext/opcache/Optimizer/zend_optimizer.c | |
+++ b/ext/opcache/Optimizer/zend_optimizer.c | |
@@ -347,6 +347,10 @@ int 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; | |
+ } | |
case ZEND_INIT_FCALL_BY_NAME: | |
/*case ZEND_INIT_NS_FCALL_BY_NAME:*/ | |
case ZEND_ADD_INTERFACE: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment