com php-src: Add result op for ASSERT_CHECK to fix SSA : Zend/zend_compile.c Zend/zend_opcode.c Zend/z end_vm_def.h Zend/zend_vm_execute.h

From: Date: Mon, 14 Dec 2015 11:31:00 +0000
Subject: com php-src: Add result op for ASSERT_CHECK to fix SSA : Zend/zend_compile.c Zend/zend_opcode.c Zend/z end_vm_def.h Zend/zend_vm_execute.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90268@lists.php.net to get a copy of this message
Commit: 091917896364be52f35be5aafcccacb8b8a908ce Author: Nikita Popov <nikic@php.net> Mon, 14 Dec 2015 12:31:00 +0100 Parents: 732fe984f2e49a33ad995c03815b5d5ebe29fc60 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=091917896364be52f35be5aafcccacb8b8a908ce Log: Add result op for ASSERT_CHECK to fix SSA Otherwise one source of the phi node at the join point will be borked. I'm marking the ASSERT_CHECK result as unused in pass2, which is a bit ugly. Changed paths: M Zend/zend_compile.c M Zend/zend_opcode.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7a7d22f..ce9477f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3359,7 +3359,9 @@ static int zend_compile_assert(znode *result, zend_ast_list *args, zend_string * zend_compile_call_common(result, (zend_ast*)args, fbc); - CG(active_op_array)->opcodes[check_op_number].op2.opline_num = get_next_op_number(CG(active_op_array)); + opline = &CG(active_op_array)->opcodes[check_op_number]; + opline->op2.opline_num = get_next_op_number(CG(active_op_array)); + SET_NODE(opline->result, result); } else { if (!fbc) { zend_string_release(name); diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index f6ac06e..0ce6b85 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -687,7 +687,13 @@ ZEND_API int pass_two(zend_op_array *op_array) case ZEND_NEW: case ZEND_FE_RESET_R: case ZEND_FE_RESET_RW: + ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2); + break; case ZEND_ASSERT_CHECK: + /* If result of assert is unused, result of check is unused as well */ + if (op_array->opcodes[opline->op2.opline_num - 1].result_type & EXT_TYPE_UNUSED) { + opline->result_type |= EXT_TYPE_UNUSED; + } ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2); break; case ZEND_FE_FETCH_R: diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 7864054..9d1b1c5 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -7954,10 +7954,8 @@ ZEND_VM_HANDLER(151, ZEND_ASSERT_CHECK, ANY, JMP_ADDR) if (EG(assertions) <= 0) { zend_op *target = OP_JMP_ADDR(opline, opline->op2); - zend_op *result = target - 1; - SKIP_EXT_OPLINE(result); - if (RETURN_VALUE_USED(result)) { - ZVAL_TRUE(EX_VAR(result->result.var)); + if (RETURN_VALUE_USED(opline)) { + ZVAL_TRUE(EX_VAR(opline->result.var)); } ZEND_VM_JMP(target); } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 8391544..c28bc9c 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1675,10 +1675,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSERT_CHECK_SPEC_HANDLER(ZEND if (EG(assertions) <= 0) { zend_op *target = OP_JMP_ADDR(opline, opline->op2); - zend_op *result = target - 1; - SKIP_EXT_OPLINE(result); - if (RETURN_VALUE_USED(result)) { - ZVAL_TRUE(EX_VAR(result->result.var)); + if (RETURN_VALUE_USED(opline)) { + ZVAL_TRUE(EX_VAR(opline->result.var)); } ZEND_VM_JMP(target); } else {

« previous php.cvs (#90268) next »