This commit is contained in:
Dmitry Stogov 2015-11-17 11:24:16 +03:00
parent 8112e34210
commit 7de190898d
3 changed files with 6 additions and 24 deletions

View File

@ -924,16 +924,12 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
if ((opline->opcode == ZEND_DIV || opline->opcode == ZEND_MOD) &&
zval_get_long(&ZEND_OP2_LITERAL(opline)) == 0) {
if (RESULT_USED(opline)) {
SET_VAR_SOURCE(opline);
}
SET_VAR_SOURCE(opline);
opline++;
continue;
} else if ((opline->opcode == ZEND_SL || opline->opcode == ZEND_SR) &&
zval_get_long(&ZEND_OP2_LITERAL(opline)) < 0) {
if (RESULT_USED(opline)) {
SET_VAR_SOURCE(opline);
}
SET_VAR_SOURCE(opline);
opline++;
continue;
}
@ -1057,7 +1053,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
MAKE_NOP(opline);
}
/* get variable source */
if (RESULT_USED(opline)) {
if (opline->result_type == IS_VAR || opline->result_type == IS_TMP_VAR) {
SET_VAR_SOURCE(opline);
}
if (opline->opcode != ZEND_NOP) {

View File

@ -93,7 +93,7 @@ void zend_optimizer_pass3(zend_op_array *op_array)
break;
}
if ((ZEND_OP2_TYPE(opline) == IS_VAR || ZEND_OP2_TYPE(opline) == IS_CV)
if ((ZEND_OP2_TYPE(opline) & (IS_VAR | IS_CV))
&& ZEND_OP2(opline).var == ZEND_OP1(next_opline).var &&
(opline->opcode == ZEND_ADD ||
opline->opcode == ZEND_MUL ||
@ -112,7 +112,7 @@ void zend_optimizer_pass3(zend_op_array *op_array)
COPY_NODE(opline->op2, tmp);
}
}
if ((ZEND_OP1_TYPE(opline) == IS_VAR || ZEND_OP1_TYPE(opline) == IS_CV)
if ((ZEND_OP1_TYPE(opline) & (IS_VAR | IS_CV))
&& ZEND_OP1(opline).var == ZEND_OP1(next_opline).var
&& ZEND_OP1_TYPE(opline) == ZEND_OP1_TYPE(next_opline)) {
switch (opline->opcode) {

View File

@ -41,22 +41,8 @@
#define INV_COND_EX(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX)
#define INV_EX_COND_EX(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX)
#undef MAKE_NOP
#define MAKE_NOP(opline) do { \
(opline)->op1.num = 0; \
(opline)->op2.num = 0; \
(opline)->result.num = 0; \
(opline)->opcode = ZEND_NOP; \
(opline)->op1_type = IS_UNUSED; \
(opline)->op2_type = IS_UNUSED; \
(opline)->result_type = IS_UNUSED; \
zend_vm_set_opcode_handler(opline); \
} while (0)
#define RESULT_USED(op) (((op->result_type & IS_VAR) && !(op->result_type & EXT_TYPE_UNUSED)) || op->result_type == IS_TMP_VAR)
#define RESULT_UNUSED(op) ((op->result_type & EXT_TYPE_UNUSED) != 0)
#define SAME_VAR(op1, op2) ((((op1 ## _type & IS_VAR) && (op2 ## _type & IS_VAR)) || (op1 ## _type == IS_TMP_VAR && op2 ## _type == IS_TMP_VAR)) && op1.var == op2.var)
#define SAME_VAR(op1, op2) (op1 ## _type == op2 ## _type && op1.var == op2.var)
typedef struct _zend_optimizer_ctx {
zend_arena *arena;