From: Dmitry Stogov Date: Tue, 10 Nov 2015 17:11:05 +0000 (+0300) Subject: Make FE_FETCH and following assignments to be a part of a loop. X-Git-Tag: php-7.1.0alpha1~826 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71092b7c2b61f4b172cea1ef1adf57123b3d426f;p=php Make FE_FETCH and following assignments to be a part of a loop. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 193370f48e..42225638c1 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3952,6 +3952,8 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */ opnum_reset = get_next_op_number(CG(active_op_array)); opline = zend_emit_op(&reset_node, by_ref ? ZEND_FE_RESET_RW : ZEND_FE_RESET_R, &expr_node, NULL); + zend_begin_loop(ZEND_FE_FREE, &reset_node); + opnum_fetch = get_next_op_number(CG(active_op_array)); opline = zend_emit_op(NULL, by_ref ? ZEND_FE_FETCH_RW : ZEND_FE_FETCH_R, &reset_node, NULL); @@ -3975,8 +3977,6 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */ zend_emit_assign_znode(key_ast, &key_node); } - zend_begin_loop(ZEND_FE_FREE, &reset_node); - zend_compile_stmt(stmt_ast); zend_emit_jump(opnum_fetch); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 3c7e20213b..55411de085 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6221,13 +6221,11 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR) * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) { /* reached end of iteration */ if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } ZEND_VM_C_GOTO(fe_fetch_r_exit); @@ -6235,7 +6233,6 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR) } value = iter->funcs->get_current_data(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (!value) { @@ -6246,7 +6243,6 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR) if (iter->funcs->get_current_key) { iter->funcs->get_current_key(iter, EX_VAR(opline->result.var)); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } } else { @@ -6413,13 +6409,11 @@ ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR) * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) { /* reached end of iteration */ if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } ZEND_VM_C_GOTO(fe_fetch_w_exit); @@ -6427,7 +6421,6 @@ ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR) } value = iter->funcs->get_current_data(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (!value) { @@ -6438,7 +6431,6 @@ ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR) if (iter->funcs->get_current_key) { iter->funcs->get_current_key(iter, EX_VAR(opline->result.var)); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 42bd60b620..9f2b247813 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -15771,13 +15771,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SPEC_VAR_HANDLER(ZE * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) { /* reached end of iteration */ if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } goto fe_fetch_r_exit; @@ -15785,7 +15783,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SPEC_VAR_HANDLER(ZE } value = iter->funcs->get_current_data(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (!value) { @@ -15796,7 +15793,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_R_SPEC_VAR_HANDLER(ZE if (iter->funcs->get_current_key) { iter->funcs->get_current_key(iter, EX_VAR(opline->result.var)); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } } else { @@ -15963,13 +15959,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_RW_SPEC_VAR_HANDLER(Z * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) { /* reached end of iteration */ if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } goto fe_fetch_w_exit; @@ -15977,7 +15971,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_RW_SPEC_VAR_HANDLER(Z } value = iter->funcs->get_current_data(iter); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } if (!value) { @@ -15988,7 +15981,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_FETCH_RW_SPEC_VAR_HANDLER(Z if (iter->funcs->get_current_key) { iter->funcs->get_current_key(iter, EX_VAR(opline->result.var)); if (UNEXPECTED(EG(exception) != NULL)) { - zval_ptr_dtor(array); HANDLE_EXCEPTION(); } } else {