]> granicus.if.org Git - php/commitdiff
Properly define ZEND_OP_DATA in zend_vm_def.h
authorBob Weinand <bobwei9@hotmail.com>
Sun, 19 Apr 2015 21:21:57 +0000 (23:21 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 19 Apr 2015 21:21:57 +0000 (23:21 +0200)
This allows zend_vm_gen.php to define them in zend_vm_opcodes.{c,h} without further hacks.

Zend/zend_compile.h
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

index 980a06c1997ad5498618d284f3bde7c948644201..754b78669559a8eedb684518349be99f250ea5a1 100644 (file)
@@ -766,8 +766,6 @@ ZEND_API void zend_assert_valid_class_name(const zend_string *const_name);
 
 #include "zend_vm_opcodes.h"
 
-#define ZEND_OP_DATA                           137
-
 /* END: OPCODES */
 
 /* class fetches */
index 811de533c52da0ce30b6155c00e79f63c2a051ee..25f6bf85d62984b38142ed3d617c5bed3105ed9e 100644 (file)
@@ -7875,3 +7875,5 @@ ZEND_VM_C_LABEL(call_trampoline_end):
        ZEND_VM_INC_OPCODE();
        ZEND_VM_LEAVE();
 }
+
+ZEND_VM_DEFINE_OP(137, ZEND_OP_DATA);
index 7775c83894fca4ce2966d38542366e22b143b19d..56a40f8dc828c23db75e09d661e1a53785769d2b 100644 (file)
@@ -1911,6 +1911,7 @@ call_trampoline_end:
        ZEND_VM_INC_OPCODE();
        ZEND_VM_LEAVE();
 }
+
 static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 {
        USE_OPLINE
index 75ed95338fd04890636f2723512eeca822d6fa38..7d49bea509816208e932ef8029c50e8e9e60a119 100644 (file)
@@ -1353,6 +1353,31 @@ function gen_vm($def, $skel) {
                                die("ERROR ($def:$lineno): helper '{$m[2]}' is not defined.\n");
                        }
                        $export[] = array("helper",$m[1],$m[2]);
+               } else if (strpos($line,"ZEND_VM_DEFINE_OP(") === 0) {
+                       if (preg_match(
+                                       "/^ZEND_VM_DEFINE_OP\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*\);/",
+                                       $line,
+                                       $m) == 0) {
+                               die("ERROR ($def:$lineno): Invalid ZEND_VM_DEFINE_OP definition.\n");
+                       }
+                       $code = (int)$m[1];
+                       $op   = $m[2];
+                       $len  = strlen($op);
+
+                       if ($len > $max_opcode_len) {
+                               $max_opcode_len = $len;
+                       }
+                       if ($code > $max_opcode) {
+                               $max_opcode = $code;
+                       }
+                       if (isset($opcodes[$code])) {
+                               die("ERROR ($def:$lineno): Opcode with code '$code' is already defined.\n");
+                       }
+                       if (isset($opnames[$op])) {
+                               die("ERROR ($def:$lineno): Opcode with name '$op' is already defined.\n");
+                       }
+                       $opcodes[$code] = array("op"=>$op,"code"=>"");
+                       $opnames[$op] = $code;
                } else if ($handler !== null) {
                  // Add line of code to current opcode handler
                        $opcodes[$handler]["code"] .= $line;
@@ -1418,9 +1443,9 @@ function gen_vm($def, $skel) {
        }
        fputs($f, "};\n\n");
        
-    fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
-    fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
-    fputs($f, "}\n");
+       fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
+       fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
+       fputs($f, "}\n");
     
        fclose($f);
        echo "zend_vm_opcodes.c generated successfully.\n";
index ff986d1855c154ac0a735f9a758e93537974e895..e8337404bba15cdcbefd492cfee0a0be1a0eac73 100644 (file)
@@ -159,7 +159,7 @@ const char *zend_vm_opcodes_map[171] = {
        "ZEND_POST_INC_OBJ",
        "ZEND_POST_DEC_OBJ",
        "ZEND_ASSIGN_OBJ",
-       NULL,
+       "ZEND_OP_DATA",
        "ZEND_INSTANCEOF",
        "ZEND_DECLARE_CLASS",
        "ZEND_DECLARE_INHERITED_CLASS",
index edee61f6c9baf58a7b162c86277b360c819dd2db..a5620370bb8482816af09cd05551b333e09721e5 100644 (file)
@@ -169,6 +169,7 @@ END_EXTERN_C()
 #define ZEND_POST_INC_OBJ                    134
 #define ZEND_POST_DEC_OBJ                    135
 #define ZEND_ASSIGN_OBJ                      136
+#define ZEND_OP_DATA                         137
 #define ZEND_INSTANCEOF                      138
 #define ZEND_DECLARE_CLASS                   139
 #define ZEND_DECLARE_INHERITED_CLASS         140