]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.2' into PHP-7.3
authorDmitry Stogov <dmitry@zend.com>
Mon, 8 Apr 2019 22:11:02 +0000 (01:11 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 8 Apr 2019 22:11:02 +0000 (01:11 +0300)
* PHP-7.2:
  Repare SWITCH VM

1  2 
Zend/zend_vm_gen.php

index d708612c9d22b68026f43f3fee60da7c9bc7280f,fa620d73ca2642c0393ac8045fdd0a63e7f54d9f..431d39e5a45d95b2023d7c69042d3f78ed4a502f
@@@ -1757,7 -1530,7 +1757,7 @@@ function gen_executor_code($f, $spec, $
                        gen_null_handler($f);
                        break;
                case ZEND_VM_KIND_SWITCH:
--                      out($f,"default:\n");
++                      out($f,"default: ZEND_NULL_LABEL:\n");
                        out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
                        out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
                        break;
@@@ -2068,8 -1804,8 +2068,8 @@@ function gen_executor($f, $skl, $spec, 
                                            }
                                                $prolog = $m[1];
                                                out($f,$prolog."if (UNEXPECTED(execute_data == NULL)) {\n");
 -                                              out($f,$prolog."\tstatic const void* labels[] = {\n");
 +                                              out($f,$prolog."\tstatic const void * const labels[] = {\n");
-                                               gen_labels($f, $spec, ZEND_VM_KIND_GOTO, $prolog."\t\t", $specs);
+                                               gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_GOTO : $kind, $prolog."\t\t", $specs);
                                                out($f,$prolog."\t};\n");
                                                out($f,$prolog."\tzend_opcode_handlers = (const void **) labels;\n");
                                                out($f,$prolog."\tzend_handlers_count = sizeof(labels) / sizeof(void*);\n");
                                                out($f,$prolog."zend_spec_handlers = specs;\n");
                                                out($f,$prolog.$executor_name."_ex(NULL);\n");
                                        } else {
 -                                              out($f,$prolog."static const void *labels[] = {\n");
 +                                              out($f,$prolog."static const void * const labels[] = {\n");
-                                               gen_labels($f, $spec, ZEND_VM_KIND_CALL, $prolog."\t", $specs, $switch_labels);
+                                               gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_CALL : $kind, $prolog."\t", $specs, $switch_labels);
                                                out($f,$prolog."};\n");
                                                out($f,$prolog."static const uint32_t specs[] = {\n");
                                                gen_specs($f, $prolog."\t", $specs);
@@@ -2528,13 -2247,13 +2528,15 @@@ function gen_vm($def, $skel) 
  
        // Search for opcode handlers those are used by other opcode handlers
        foreach ($opcodes as $dsc) {
--              if (preg_match("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $m)) {
--                      $op = $m[1];
--                      if (!isset($opnames[$op])) {
--                              die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
++              if (preg_match_all("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $mm, PREG_SET_ORDER)) {
++                      foreach ($mm as $m) {
++                              $op = $m[1];
++                              if (!isset($opnames[$op])) {
++                                      die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
++                              }
++                              $code = $opnames[$op];
++                              $opcodes[$code]['use'] = 1;
                        }
--                      $code = $opnames[$op];
--                      $opcodes[$code]['use'] = 1;
                }
        }