]> granicus.if.org Git - php/commitdiff
Changed FETCH_CONSTANT instruction format (extended_value moved into op1)
authorDmitry Stogov <dmitry@zend.com>
Wed, 31 Jan 2018 15:15:25 +0000 (18:15 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 31 Jan 2018 15:15:25 +0000 (18:15 +0300)
Zend/zend_compile.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/compact_literals.c
ext/opcache/Optimizer/zend_dump.c
ext/opcache/Optimizer/zend_optimizer.c

index fe2874e511cac6dd310000876fcf490545c84f24..e8a16c4ef04a53e04e628581d4f8c457a8d36eb8 100644 (file)
@@ -7724,9 +7724,9 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
                opline->op2.constant = zend_add_const_name_literal(
                        CG(active_op_array), resolved_name, 0);
        } else {
-               opline->extended_value = IS_CONSTANT_UNQUALIFIED;
+               opline->op1.num = IS_CONSTANT_UNQUALIFIED;
                if (FC(current_namespace)) {
-                       opline->extended_value |= IS_CONSTANT_IN_NAMESPACE;
+                       opline->op1.num |= IS_CONSTANT_IN_NAMESPACE;
                        opline->op2.constant = zend_add_const_name_literal(
                                CG(active_op_array), resolved_name, 1);
                } else {
index a093f5dcf49d5e4890ca7720fac9145844c96f90..a7fa49c4334bc041005f2e3165010b46b9cf0074 100644 (file)
@@ -4987,17 +4987,17 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY)
        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
 }
 
-ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, UNUSED, CONST, CONST_FETCH)
+ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, UNUSED|CONST_FETCH, CONST)
 {
        USE_OPLINE
        zend_constant *c;
 
        if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(RT_CONSTANT(opline, opline->op2))))) {
                c = CACHED_PTR(Z_CACHE_SLOT_P(RT_CONSTANT(opline, opline->op2)));
-       } else if ((c = zend_quick_get_constant(RT_CONSTANT(opline, opline->op2) + 1, opline->extended_value)) == NULL) {
+       } else if ((c = zend_quick_get_constant(RT_CONSTANT(opline, opline->op2) + 1, opline->op1.num)) == NULL) {
                SAVE_OPLINE();
 
-               if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
+               if ((opline->op1.num & IS_CONSTANT_UNQUALIFIED) != 0) {
                        char *actual = (char *)zend_memrchr(Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)), '\\', Z_STRLEN_P(RT_CONSTANT(opline, opline->op2)));
                        if (!actual) {
                                ZVAL_STR_COPY(EX_VAR(opline->result.var), Z_STR_P(RT_CONSTANT(opline, opline->op2)));
index 5c694e4feaacf2fc753f7d324808acf561d2d49d..1277156fdf26a4aad95c513ab31d54f02f1c1f58 100644 (file)
@@ -33271,10 +33271,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CON
 
        if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(RT_CONSTANT(opline, opline->op2))))) {
                c = CACHED_PTR(Z_CACHE_SLOT_P(RT_CONSTANT(opline, opline->op2)));
-       } else if ((c = zend_quick_get_constant(RT_CONSTANT(opline, opline->op2) + 1, opline->extended_value)) == NULL) {
+       } else if ((c = zend_quick_get_constant(RT_CONSTANT(opline, opline->op2) + 1, opline->op1.num)) == NULL) {
                SAVE_OPLINE();
 
-               if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
+               if ((opline->op1.num & IS_CONSTANT_UNQUALIFIED) != 0) {
                        char *actual = (char *)zend_memrchr(Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)), '\\', Z_STRLEN_P(RT_CONSTANT(opline, opline->op2)));
                        if (!actual) {
                                ZVAL_STR_COPY(EX_VAR(opline->result.var), Z_STR_P(RT_CONSTANT(opline, opline->op2)));
index 33e63180417437d2eb04740a11e5415fe106f077..75afa99624ced8a5ed101fe211282f5cd73ed723 100644 (file)
@@ -69,6 +69,7 @@ $vm_op_flags = array(
        "ZEND_VM_OP_NEXT"         => 0x60,
        "ZEND_VM_OP_CLASS_FETCH"  => 0x70,
        "ZEND_VM_OP_CONSTRUCTOR"  => 0x80,
+       "ZEND_VM_OP_CONST_FETCH"  => 0x90,
 
        "ZEND_VM_EXT_VAR_FETCH"   => 1<<16,
        "ZEND_VM_EXT_ISSET"       => 1<<17,
@@ -81,7 +82,7 @@ $vm_op_flags = array(
        "ZEND_VM_EXT_JMP_ADDR"    => 0x03000000,
        "ZEND_VM_EXT_DIM_OBJ"     => 0x04000000,
     // unused 0x5000000
-       "ZEND_VM_EXT_CONST_FETCH" => 0x06000000,
+    // unused 0x6000000
        "ZEND_VM_EXT_TYPE"        => 0x07000000,
        "ZEND_VM_EXT_EVAL"        => 0x08000000,
        "ZEND_VM_EXT_TYPE_MASK"   => 0x09000000,
@@ -113,13 +114,13 @@ $vm_op_decode = array(
        "NEXT"                 => ZEND_VM_OP_NEXT,
        "CLASS_FETCH"          => ZEND_VM_OP_CLASS_FETCH,
        "CONSTRUCTOR"          => ZEND_VM_OP_CONSTRUCTOR,
+       "CONST_FETCH"          => ZEND_VM_OP_CONST_FETCH,
 );
 
 $vm_ext_decode = array(
        "NUM"                  => ZEND_VM_EXT_NUM,
        "JMP_ADDR"             => ZEND_VM_EXT_JMP_ADDR,
        "DIM_OBJ"              => ZEND_VM_EXT_DIM_OBJ,
-       "CONST_FETCH"          => ZEND_VM_EXT_CONST_FETCH,
        "VAR_FETCH"            => ZEND_VM_EXT_VAR_FETCH,
        "ARRAY_INIT"           => ZEND_VM_EXT_ARRAY_INIT,
        "TYPE"                 => ZEND_VM_EXT_TYPE,
index e0ddd8ab7cb409d9cadd18f78f5dbb72ddfe5733..876dfef315b525187e8817e0c958d3594bbb2c4b 100644 (file)
@@ -323,7 +323,7 @@ static uint32_t zend_vm_opcodes_flags[199] = {
        0x00000701,
        0x00000751,
        0x0000070b,
-       0x06000301,
+       0x00000391,
        0x00000000,
        0x00000000,
        0x00000000,
index 05de3a4a9e59b4e068049b26b4483cfafa6326a9..a1191cac2949c45d51ee83a0f79b7a3473fa4217 100644 (file)
@@ -47,6 +47,7 @@
 #define ZEND_VM_OP_NEXT          0x00000060
 #define ZEND_VM_OP_CLASS_FETCH   0x00000070
 #define ZEND_VM_OP_CONSTRUCTOR   0x00000080
+#define ZEND_VM_OP_CONST_FETCH   0x00000090
 #define ZEND_VM_EXT_VAR_FETCH    0x00010000
 #define ZEND_VM_EXT_ISSET        0x00020000
 #define ZEND_VM_EXT_ARG_NUM      0x00040000
@@ -56,7 +57,6 @@
 #define ZEND_VM_EXT_NUM          0x01000000
 #define ZEND_VM_EXT_JMP_ADDR     0x03000000
 #define ZEND_VM_EXT_DIM_OBJ      0x04000000
-#define ZEND_VM_EXT_CONST_FETCH  0x06000000
 #define ZEND_VM_EXT_TYPE         0x07000000
 #define ZEND_VM_EXT_EVAL         0x08000000
 #define ZEND_VM_EXT_TYPE_MASK    0x09000000
index 7dfc2fadbf3591a091b1700809d5a4b8b190b581..63102beaac4986ad6cf559dd7e8a3b2b062ab0cc 100644 (file)
@@ -181,7 +181,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
                                        LITERAL_INFO(opline->op1.constant, LITERAL_CONST, 1, 1, 2);
                                        break;
                                case ZEND_FETCH_CONSTANT:
-                                       if ((opline->extended_value & (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) == (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) {
+                                       if ((opline->op1.num & (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) == (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) {
                                                LITERAL_INFO(opline->op2.constant, LITERAL_CONST, 1, 1, 5);
                                        } else {
                                                LITERAL_INFO(opline->op2.constant, LITERAL_CONST, 1, 1, 3);
index 07e5dfe9f759b54a7928eafe8e64995518bbc3a9..8f874d8bdb40992fe25a9fd641a739ca97cdd164 100644 (file)
@@ -130,6 +130,13 @@ static void zend_dump_unused_op(const zend_op *opline, znode_op op, uint32_t fla
                zend_dump_class_fetch_type(op.num);
        } else if (ZEND_VM_OP_CONSTRUCTOR == (flags & ZEND_VM_OP_MASK)) {
                fprintf(stderr, " CONSTRUCTOR");
+       } else if (ZEND_VM_OP_CONST_FETCH == (flags & ZEND_VM_EXT_MASK)) {
+               if (op.num & IS_CONSTANT_UNQUALIFIED) {
+                       fprintf(stderr, " (unqualified)");
+               }
+               if (op.num & IS_CONSTANT_IN_NAMESPACE) {
+                       fprintf(stderr, " (in-namespace)");
+               }
        }
 }
 
@@ -449,13 +456,6 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *
                } else if (opline->extended_value == ZEND_ASSIGN_OBJ) {
                        fprintf(stderr, " (obj)");
                }
-       } else if (ZEND_VM_EXT_CONST_FETCH == (flags & ZEND_VM_EXT_MASK)) {
-               if (opline->extended_value & IS_CONSTANT_UNQUALIFIED) {
-                               fprintf(stderr, " (unqualified)");
-               }
-               if (opline->extended_value & IS_CONSTANT_IN_NAMESPACE) {
-                               fprintf(stderr, " (in-namespace)");
-               }
        } else if (ZEND_VM_EXT_TYPE == (flags & ZEND_VM_EXT_MASK)) {
                switch (opline->extended_value) {
                        case IS_NULL:
index 70f45882be742f73ba2b7f5bd8f9f79bac4f680c..1bf05a50a98f2508c99fd416d3227aca9892fbc6 100644 (file)
@@ -276,7 +276,6 @@ int zend_optimizer_update_op1_const(zend_op_array *op_array,
                        return 0;
                case ZEND_INIT_STATIC_METHOD_CALL:
                case ZEND_CATCH:
-               case ZEND_FETCH_CONSTANT:
                case ZEND_FETCH_CLASS_CONSTANT:
                case ZEND_DEFINED:
                case ZEND_NEW: