]> granicus.if.org Git - php/commitdiff
Make FE_FETCH and following assignments to be a part of a loop.
authorDmitry Stogov <dmitry@zend.com>
Tue, 10 Nov 2015 17:11:05 +0000 (20:11 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 10 Nov 2015 17:11:05 +0000 (20:11 +0300)
Zend/zend_compile.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 193370f48ec87b1067ad0d54d057164ee3662b98..42225638c1b3db4ddbbe3c7f234be70304749e69 100644 (file)
@@ -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);
index 3c7e20213bb9941c81b1935e8ad9f13789130067..55411de0859f89d53e4bc0fe6f7b20f6032e3e2c 100644 (file)
@@ -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 {
index 42bd60b620d8bad66e0e2d48743ff33c664ffa88..9f2b247813f2879a023721ef92c3c6328de88741 100644 (file)
@@ -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 {