]> granicus.if.org Git - php/commitdiff
Changed ZEND_CLONE->extended_value meaning to relative offset (previously it was...
authorDmitry Stogov <dmitry@zend.com>
Fri, 30 Oct 2015 11:53:53 +0000 (14:53 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 30 Oct 2015 11:53:53 +0000 (14:53 +0300)
Zend/zend_opcode.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
Zend/zend_vm_gen.php
Zend/zend_vm_opcodes.c
Zend/zend_vm_opcodes.h
ext/opcache/Optimizer/zend_optimizer.c

index 8abfd7a56c3329e7058b9f17cdbd4944d857e76d..4cf131af53b57e6044f07fe2e8944982be385d9a 100644 (file)
@@ -646,6 +646,10 @@ ZEND_API int pass_two(zend_op_array *op_array)
                        case ZEND_DECLARE_ANON_CLASS:
                                ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
                                break;
+                       case ZEND_CATCH:
+                               /* absolute index to relative offset */
+                               opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
+                               break;
                        case ZEND_JMPZNZ:
                                /* absolute index to relative offset */
                                opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
index 3e34be18cddaf6b775e75f40354861e78bce3d3d..561d79354b749a61da11d7423a878f94060770ef 100644 (file)
@@ -2591,7 +2591,7 @@ ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMPVAR|CV, JMP_ADDR)
        ZEND_VM_JMP(opline);
 }
 
-ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_REL)
+ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_ADDR)
 {
        USE_OPLINE
        zend_free_op free_op1;
@@ -4205,7 +4205,7 @@ ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
        HANDLE_EXCEPTION();
 }
 
-ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
+ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ADDR)
 {
        USE_OPLINE
        zend_class_entry *ce, *catch_ce;
@@ -4215,8 +4215,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
        /* Check whether an exception has been thrown, if not, jump over code */
        zend_exception_restore();
        if (EG(exception) == NULL) {
-               ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
-               ZEND_VM_CONTINUE(); /* CHECK_ME */
+               ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
+               ZEND_VM_CONTINUE();
        }
        catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
        if (UNEXPECTED(catch_ce == NULL)) {
@@ -4238,8 +4238,8 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ABS)
                                zend_throw_exception_internal(NULL);
                                HANDLE_EXCEPTION();
                        }
-                       ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
-                       ZEND_VM_CONTINUE(); /* CHECK_ME */
+                       ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
+                       ZEND_VM_CONTINUE();
                }
        }
 
@@ -6097,7 +6097,7 @@ ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
        }
 }
 
-ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_REL)
+ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR)
 {
        USE_OPLINE
        zval *array;
@@ -6274,7 +6274,7 @@ ZEND_VM_C_LABEL(fe_fetch_r_exit):
        ZEND_VM_NEXT_OPCODE();
 }
 
-ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_REL)
+ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
 {
        USE_OPLINE
        zval *array;
index 5d5db9130e954b97619e79ebeeb8e19863fe5dc9..34f5fbe90e8aa2f2d57772ec5ba0913d54fa07a7 100644 (file)
@@ -9395,8 +9395,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
        /* Check whether an exception has been thrown, if not, jump over code */
        zend_exception_restore();
        if (EG(exception) == NULL) {
-               ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
-               ZEND_VM_CONTINUE(); /* CHECK_ME */
+               ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
+               ZEND_VM_CONTINUE();
        }
        catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
        if (UNEXPECTED(catch_ce == NULL)) {
@@ -9418,8 +9418,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
                                zend_throw_exception_internal(NULL);
                                HANDLE_EXCEPTION();
                        }
-                       ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
-                       ZEND_VM_CONTINUE(); /* CHECK_ME */
+                       ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
+                       ZEND_VM_CONTINUE();
                }
        }
 
index 5c5a9aa289ef8a7231515c8bf4f9cb75613a0303..d55b876dba48a827993d30f971df9f5cf116be85 100644 (file)
@@ -71,18 +71,17 @@ $vm_op_flags = array(
 
        "ZEND_VM_EXT_NUM"         => 1<<16,
        "ZEND_VM_EXT_VAR"         => 1<<17,
-       "ZEND_VM_EXT_JMP_ABS"     => 1<<18,
-       "ZEND_VM_EXT_JMP_REL"     => 1<<19,
-       "ZEND_VM_EXT_DIM_OBJ"     => 1<<20,
-       "ZEND_VM_EXT_CLASS_FETCH" => 1<<21,
-       "ZEND_VM_EXT_CONST_FETCH" => 1<<22,
-       "ZEND_VM_EXT_VAR_FETCH"   => 1<<23,
-       "ZEND_VM_EXT_ARRAY_INIT"  => 1<<24,
-       "ZEND_VM_EXT_TYPE"        => 1<<25,
-       "ZEND_VM_EXT_EVAL"        => 1<<26,
-       "ZEND_VM_EXT_FAST_CALL"   => 1<<27,
-       "ZEND_VM_EXT_FAST_RET"    => 1<<28,
-       "ZEND_VM_EXT_ISSET"       => 1<<29,
+       "ZEND_VM_EXT_JMP_ADDR"    => 1<<18,
+       "ZEND_VM_EXT_DIM_OBJ"     => 1<<19,
+       "ZEND_VM_EXT_CLASS_FETCH" => 1<<20,
+       "ZEND_VM_EXT_CONST_FETCH" => 1<<21,
+       "ZEND_VM_EXT_VAR_FETCH"   => 1<<22,
+       "ZEND_VM_EXT_ARRAY_INIT"  => 1<<23,
+       "ZEND_VM_EXT_TYPE"        => 1<<24,
+       "ZEND_VM_EXT_EVAL"        => 1<<25,
+       "ZEND_VM_EXT_FAST_CALL"   => 1<<26,
+       "ZEND_VM_EXT_FAST_RET"    => 1<<27,
+       "ZEND_VM_EXT_ISSET"       => 1<<28,
 );
 
 foreach ($vm_op_flags as $name => $val) {
@@ -105,8 +104,7 @@ $vm_op_decode = array(
 $vm_ext_decode = array(
        "NUM"                  => ZEND_VM_EXT_NUM,
        "VAR"                  => ZEND_VM_EXT_VAR,
-       "JMP_ABS"              => ZEND_VM_EXT_JMP_ABS,
-       "JMP_REL"              => ZEND_VM_EXT_JMP_REL,
+       "JMP_ADDR"             => ZEND_VM_EXT_JMP_ADDR,
        "DIM_OBJ"              => ZEND_VM_EXT_DIM_OBJ,
        "CLASS_FETCH"          => ZEND_VM_EXT_CLASS_FETCH,
        "CONST_FETCH"          => ZEND_VM_EXT_CONST_FETCH,
index d575e04a28218208c439de2a1c57150d6ca36293..70b3e81f843d81a78f33862f0ec3bd1c531b55c5 100644 (file)
@@ -228,19 +228,19 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000707,
        0x00000707,
        0x00000707,
-       0x02000003,
+       0x01000003,
        0x00000003,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
-       0x00100701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
+       0x00080701,
        0x00000001,
        0x00000001,
        0x00000001,
@@ -252,7 +252,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000010,
        0x00001007,
        0x00001007,
-       0x00081007,
+       0x00041007,
        0x00001007,
        0x00001007,
        0x00000707,
@@ -278,35 +278,35 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00011003,
        0x00010300,
        0x00000005,
-       0x01000703,
+       0x00800703,
        0x00010703,
-       0x04000007,
-       0x00800107,
+       0x02000007,
+       0x00400107,
        0x00000701,
        0x00000701,
        0x00001003,
-       0x00080001,
+       0x00040001,
        0x00000007,
-       0x00800107,
+       0x00400107,
        0x00000707,
        0x00000703,
-       0x00800107,
+       0x00400107,
        0x00000701,
        0x00000701,
-       0x00800107,
+       0x00400107,
        0x00000701,
        0x00000701,
-       0x00800107,
+       0x00400107,
        0x00000707,
        0x00000707,
-       0x00800107,
+       0x00400107,
        0x00000703,
        0x00000703,
-       0x00800107,
+       0x00400107,
        0x00000701,
        0x00000701,
        0x00000307,
-       0x00400301,
+       0x00200301,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -316,13 +316,13 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000801,
        0x00040103,
        0x00000003,
-       0x00200700,
+       0x00100700,
        0x00000007,
        0x00000003,
        0x00010707,
        0x00010703,
-       0x20800107,
-       0x20000707,
+       0x10400107,
+       0x10000707,
        0x00000803,
        0x00000801,
        0x00010703,
@@ -330,10 +330,10 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000801,
        0x00000007,
        0x00000003,
-       0x02000003,
+       0x01000003,
        0x00000103,
        0x00001003,
-       0x00080001,
+       0x00040001,
        0x00000005,
        0x00010700,
        0x00000000,
@@ -355,7 +355,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00020000,
        0x00000000,
        0x00000701,
-       0x20000707,
+       0x10000707,
        0x00000000,
        0x00000000,
        0x00001000,
@@ -364,17 +364,17 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000000,
        0x00000000,
        0x00000101,
-       0x00200000,
+       0x00100000,
        0x00000000,
        0x00000000,
        0x00000303,
        0x00000003,
-       0x08002010,
-       0x10002000,
+       0x04002010,
+       0x08002000,
        0x00000008,
        0x00000000,
        0x00000707,
-       0x00100701,
+       0x00080701,
        0x00000301,
        0x00001003,
        0x00000707,
@@ -387,7 +387,7 @@ static uint32_t zend_vm_opcodes_flags[182] = {
        0x00000307,
        0x00000307,
        0x00000307,
-       0x20000307,
+       0x10000307,
        0x00000303,
 };
 
index 612406fb8be26e4a56f343d168dc1acbf55fe42f..62dbe2205d51ebc6cb91d64c12bc9fe35fa2e115 100644 (file)
 #define ZEND_VM_OP2_JMP_ABS      0x00002000
 #define ZEND_VM_EXT_NUM          0x00010000
 #define ZEND_VM_EXT_VAR          0x00020000
-#define ZEND_VM_EXT_JMP_ABS      0x00040000
-#define ZEND_VM_EXT_JMP_REL      0x00080000
-#define ZEND_VM_EXT_DIM_OBJ      0x00100000
-#define ZEND_VM_EXT_CLASS_FETCH  0x00200000
-#define ZEND_VM_EXT_CONST_FETCH  0x00400000
-#define ZEND_VM_EXT_VAR_FETCH    0x00800000
-#define ZEND_VM_EXT_ARRAY_INIT   0x01000000
-#define ZEND_VM_EXT_TYPE         0x02000000
-#define ZEND_VM_EXT_EVAL         0x04000000
-#define ZEND_VM_EXT_FAST_CALL    0x08000000
-#define ZEND_VM_EXT_FAST_RET     0x10000000
-#define ZEND_VM_EXT_ISSET        0x20000000
+#define ZEND_VM_EXT_JMP_ADDR     0x00040000
+#define ZEND_VM_EXT_DIM_OBJ      0x00080000
+#define ZEND_VM_EXT_CLASS_FETCH  0x00100000
+#define ZEND_VM_EXT_CONST_FETCH  0x00200000
+#define ZEND_VM_EXT_VAR_FETCH    0x00400000
+#define ZEND_VM_EXT_ARRAY_INIT   0x00800000
+#define ZEND_VM_EXT_TYPE         0x01000000
+#define ZEND_VM_EXT_EVAL         0x02000000
+#define ZEND_VM_EXT_FAST_CALL    0x04000000
+#define ZEND_VM_EXT_FAST_RET     0x08000000
+#define ZEND_VM_EXT_ISSET        0x10000000
 
 BEGIN_EXTERN_C()
 
index f37b5f72413fd6a0b76051d57168614dfb37928f..b4bc971286169020104d3da995ed5cb7df823036 100644 (file)
@@ -516,6 +516,10 @@ static void zend_accel_optimize(zend_op_array      *op_array,
                        case ZEND_DECLARE_ANON_INHERITED_CLASS:
                                ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
                                break;
+                       case ZEND_CATCH:
+                               /* relative offset into absolute index */
+                               opline->extended_value = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value);
+                               break;
                        case ZEND_JMPZNZ:
                                /* relative offset into absolute index */
                                opline->extended_value = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value);
@@ -560,6 +564,10 @@ static void zend_accel_optimize(zend_op_array      *op_array,
                        case ZEND_DECLARE_ANON_INHERITED_CLASS:
                                ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, ZEND_OP1(opline));
                                break;
+                       case ZEND_CATCH:
+                               /* absolute index to relative offset */
+                               opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);
+                               break;
                        case ZEND_JMPZNZ:
                                /* absolute index to relative offset */
                                opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value);