Skip to content

Commit 24489bf

Browse files
committed
Fix optimization of HAS_TYPE
1 parent ac3e72f commit 24489bf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Zend/Optimizer/block_pass.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,14 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
997997
}
998998
}
999999
break;
1000+
1001+
case ZEND_HAS_TYPE:
1002+
if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
1003+
/* Variable will be deleted later by FREE, so we can't optimize it */
1004+
Tsource[VAR_NUM(opline->op1.var)] = NULL;
1005+
break;
1006+
}
1007+
break;
10001008
}
10011009

10021010
/* get variable source */

Zend/zend_opcode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@ static bool keeps_op1_alive(zend_op *opline) {
906906
|| opline->opcode == ZEND_FETCH_LIST_R
907907
|| opline->opcode == ZEND_FETCH_LIST_W
908908
|| opline->opcode == ZEND_COPY_TMP
909-
|| opline->opcode == ZEND_EXT_STMT) {
909+
|| opline->opcode == ZEND_EXT_STMT
910+
|| opline->opcode == ZEND_HAS_TYPE) {
910911
return true;
911912
}
912913
ZEND_ASSERT(opline->opcode != ZEND_FE_FETCH_R

0 commit comments

Comments
 (0)