Skip to content

Commit ae9e956

Browse files
committed
Reorder conditions
1 parent e5fcea0 commit ae9e956

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

Zend/zend_vm_execute.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64460,26 +64460,29 @@ static const void* ZEND_FASTCALL zend_vm_get_opcode_handler_ex(uint32_t spec, co
6446064460
if (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type];
6446164461
if (spec & SPEC_RULE_OP2) offset = offset * 5 + zend_vm_decode[op->op2_type];
6446264462
if (spec & SPEC_EXTRA_MASK) {
64463-
if (spec & SPEC_RULE_OP_DATA) offset = offset * 5 + zend_vm_decode[(op + 1)->op1_type];
64464-
else if (spec & SPEC_RULE_RETVAL) offset = offset * 2 + (op->result_type != IS_UNUSED);
64465-
else if (spec & SPEC_RULE_QUICK_ARG) offset = offset * 2 + (op->op2.num <= MAX_ARG_FLAG_NUM);
64466-
else if (spec & SPEC_RULE_SMART_BRANCH) {
64463+
if (spec & SPEC_RULE_RETVAL) {
64464+
offset = offset * 2 + (op->result_type != IS_UNUSED);
64465+
} else if (spec & SPEC_RULE_QUICK_ARG) {
64466+
offset = offset * 2 + (op->op2.num <= MAX_ARG_FLAG_NUM);
64467+
} else if (spec & SPEC_RULE_OP_DATA) {
64468+
offset = offset * 5 + zend_vm_decode[(op + 1)->op1_type];
64469+
} else if (spec & SPEC_RULE_DIM_OBJ) {
6446764470
offset = offset * 3;
64468-
if ((op+1)->opcode == ZEND_JMPZ) {
64471+
if (op->extended_value == ZEND_ASSIGN_DIM) {
6446964472
offset += 1;
64470-
} else if ((op+1)->opcode == ZEND_JMPNZ) {
64473+
} else if (op->extended_value == ZEND_ASSIGN_OBJ) {
6447164474
offset += 2;
6447264475
}
64473-
}
64474-
else if (spec & SPEC_RULE_DIM_OBJ) {
64476+
} else if (spec & SPEC_RULE_ISSET) {
64477+
offset = offset * 2 + (op->extended_value & ZEND_ISEMPTY);
64478+
} else if (spec & SPEC_RULE_SMART_BRANCH) {
6447564479
offset = offset * 3;
64476-
if (op->extended_value == ZEND_ASSIGN_DIM) {
64480+
if ((op+1)->opcode == ZEND_JMPZ) {
6447764481
offset += 1;
64478-
} else if (op->extended_value == ZEND_ASSIGN_OBJ) {
64482+
} else if ((op+1)->opcode == ZEND_JMPNZ) {
6447964483
offset += 2;
6448064484
}
6448164485
}
64482-
else if (spec & SPEC_RULE_ISSET) offset = offset * 2 + (op->extended_value & ZEND_ISEMPTY);
6448364486
}
6448464487
return zend_opcode_handlers[(spec & SPEC_START_MASK) + offset];
6448564488
}

Zend/zend_vm_gen.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,28 +2705,20 @@ function gen_vm($def, $skel) {
27052705
$else = "";
27062706
out($f, "\tif (spec & SPEC_EXTRA_MASK) {\n");
27072707

2708-
if (isset($used_extra_spec["OP_DATA"])) {
2709-
out($f, "\t\t{$else}if (spec & SPEC_RULE_OP_DATA) offset = offset * 5 + zend_vm_decode[(op + 1)->op1_type];\n");
2710-
$else = "else ";
2711-
}
27122708
if (isset($used_extra_spec["RETVAL"])) {
2713-
out($f, "\t\t{$else}if (spec & SPEC_RULE_RETVAL) offset = offset * 2 + (op->result_type != IS_UNUSED);\n");
2714-
$else = "else ";
2709+
out($f, "\t\t{$else}if (spec & SPEC_RULE_RETVAL) {\n");
2710+
out($f, "\t\t\toffset = offset * 2 + (op->result_type != IS_UNUSED);\n");
2711+
$else = "} else ";
27152712
}
27162713
if (isset($used_extra_spec["QUICK_ARG"])) {
2717-
out($f, "\t\t{$else}if (spec & SPEC_RULE_QUICK_ARG) offset = offset * 2 + (op->op2.num <= MAX_ARG_FLAG_NUM);\n");
2718-
$else = "else ";
2714+
out($f, "\t\t{$else}if (spec & SPEC_RULE_QUICK_ARG) {\n");
2715+
out($f, "\t\t\toffset = offset * 2 + (op->op2.num <= MAX_ARG_FLAG_NUM);\n");
2716+
$else = "} else ";
27192717
}
2720-
if (isset($used_extra_spec["SMART_BRANCH"])) {
2721-
out($f, "\t\t{$else}if (spec & SPEC_RULE_SMART_BRANCH) {\n");
2722-
out($f, "\t\t\toffset = offset * 3;\n");
2723-
out($f, "\t\t\tif ((op+1)->opcode == ZEND_JMPZ) {\n");
2724-
out($f, "\t\t\t\toffset += 1;\n");
2725-
out($f, "\t\t\t} else if ((op+1)->opcode == ZEND_JMPNZ) {\n");
2726-
out($f, "\t\t\t\toffset += 2;\n");
2727-
out($f, "\t\t\t}\n");
2728-
out($f, "\t\t}\n");
2729-
$else = "else ";
2718+
if (isset($used_extra_spec["OP_DATA"])) {
2719+
out($f, "\t\t{$else}if (spec & SPEC_RULE_OP_DATA) {\n");
2720+
out($f, "\t\t\toffset = offset * 5 + zend_vm_decode[(op + 1)->op1_type];\n");
2721+
$else = "} else ";
27302722
}
27312723
if (isset($used_extra_spec["DIM_OBJ"])) {
27322724
out($f, "\t\t{$else}if (spec & SPEC_RULE_DIM_OBJ) {\n");
@@ -2736,12 +2728,25 @@ function gen_vm($def, $skel) {
27362728
out($f, "\t\t\t} else if (op->extended_value == ZEND_ASSIGN_OBJ) {\n");
27372729
out($f, "\t\t\t\toffset += 2;\n");
27382730
out($f, "\t\t\t}\n");
2739-
out($f, "\t\t}\n");
2740-
$else = "else ";
2731+
$else = "} else ";
27412732
}
27422733
if (isset($used_extra_spec["ISSET"])) {
2743-
out($f, "\t\t{$else}if (spec & SPEC_RULE_ISSET) offset = offset * 2 + (op->extended_value & ZEND_ISEMPTY);\n");
2744-
$else = "else ";
2734+
out($f, "\t\t{$else}if (spec & SPEC_RULE_ISSET) {\n");
2735+
out($f, "\t\t\toffset = offset * 2 + (op->extended_value & ZEND_ISEMPTY);\n");
2736+
$else = "} else ";
2737+
}
2738+
if (isset($used_extra_spec["SMART_BRANCH"])) {
2739+
out($f, "\t\t{$else}if (spec & SPEC_RULE_SMART_BRANCH) {\n");
2740+
out($f, "\t\t\toffset = offset * 3;\n");
2741+
out($f, "\t\t\tif ((op+1)->opcode == ZEND_JMPZ) {\n");
2742+
out($f, "\t\t\t\toffset += 1;\n");
2743+
out($f, "\t\t\t} else if ((op+1)->opcode == ZEND_JMPNZ) {\n");
2744+
out($f, "\t\t\t\toffset += 2;\n");
2745+
out($f, "\t\t\t}\n");
2746+
$else = "} else ";
2747+
}
2748+
if ($else !== "") {
2749+
out($f, "\t\t}\n");
27452750
}
27462751
out($f, "\t}\n");
27472752
}

0 commit comments

Comments
 (0)