Skip to content

Commit 002c264

Browse files
committed
Remove ZEND_VM_EXPORT functionality
This hasn't been used since forever and makes things more confusing than they already are.
1 parent eaf6303 commit 002c264

File tree

1 file changed

+4
-103
lines changed

1 file changed

+4
-103
lines changed

Zend/zend_vm_gen.php

Lines changed: 4 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ function format_condition($condition) {
738738
}
739739

740740
// Generates code for opcode handler or helper
741-
function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name, $extra_spec=null) {
741+
function gen_code($f, $spec, $kind, $code, $op1, $op2, $name, $extra_spec=null) {
742742
global $op1_type, $op2_type, $op1_get_zval_ptr, $op2_get_zval_ptr,
743743
$op1_get_zval_ptr_deref, $op2_get_zval_ptr_deref,
744744
$op1_get_zval_ptr_undef, $op2_get_zval_ptr_undef,
@@ -796,8 +796,6 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name, $extra_sp
796796
"/^#(\s*)if\s+0\s*&&.*[^\\\\]$/m" => "#\\1if 0",
797797
"/^#(\s*)elif\s+1\s*\\|\\|.*[^\\\\]$/m" => "#\\1elif 1",
798798
"/^#(\s*)elif\s+0\s*&&.*[^\\\\]$/m" => "#\\1elif 0",
799-
"/^#(\s*)ifdef\s+ZEND_VM_EXPORT\s*\n/m" => $export?"#\\1if 1\n":"#\\1if 0\n",
800-
"/^#(\s*)ifndef\s+ZEND_VM_EXPORT\s*\n/m" => $export?"#\\1if 0\n":"#\\1if 1\n",
801799
"/OP_DATA_TYPE/" => $op_data_type[isset($extra_spec['OP_DATA']) ? $extra_spec['OP_DATA'] : "ANY"],
802800
"/GET_OP_DATA_ZVAL_PTR\(([^)]*)\)/" => $op_data_get_zval_ptr[isset($extra_spec['OP_DATA']) ? $extra_spec['OP_DATA'] : "ANY"],
803801
"/GET_OP_DATA_ZVAL_PTR_DEREF\(([^)]*)\)/" => $op_data_get_zval_ptr_deref[isset($extra_spec['OP_DATA']) ? $extra_spec['OP_DATA'] : "ANY"],
@@ -1064,7 +1062,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
10641062
case ZEND_VM_KIND_HYBRID:
10651063
if (is_inline_hybrid_handler($name, $opcode["hot"], $op1, $op2, $extra_spec)) {
10661064
$out = fopen('php://memory', 'w+');
1067-
gen_code($out, $spec, $kind, 0, $code, $op1, $op2, $name, $extra_spec);
1065+
gen_code($out, $spec, $kind, $code, $op1, $op2, $name, $extra_spec);
10681066
rewind($out);
10691067
$code =
10701068
"\t\t\tHYBRID_CASE({$spec_name}):\n"
@@ -1123,7 +1121,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
11231121
}
11241122

11251123
// Generate opcode handler's code
1126-
gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name, $extra_spec);
1124+
gen_code($f, $spec, $kind, $code, $op1, $op2, $name, $extra_spec);
11271125

11281126
if ($additional_func) {
11291127
out($f,"static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL {$spec_name}_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
@@ -1186,7 +1184,7 @@ function gen_helper($f, $spec, $kind, $name, $op1, $op2, $param, $code, $lineno,
11861184
}
11871185

11881186
// Generate helper's code
1189-
gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name, $extra_spec);
1187+
gen_code($f, $spec, $kind, $code, $op1, $op2, $name, $extra_spec);
11901188
}
11911189

11921190

@@ -2332,7 +2330,6 @@ function gen_vm($def, $skel) {
23322330
$max_opcode_len = 0;
23332331
$max_opcode = 0;
23342332
$extra_num = 256;
2335-
$export = array();
23362333
foreach ($in as $line) {
23372334
++$lineno;
23382335
if (strpos($line,"ZEND_VM_HANDLER(") === 0 ||
@@ -2482,28 +2479,6 @@ function gen_vm($def, $skel) {
24822479

24832480
$handler = null;
24842481
$list[$lineno] = array("helper"=>$helper);
2485-
} else if (strpos($line,"ZEND_VM_EXPORT_HANDLER(") === 0) {
2486-
if (preg_match(
2487-
"/^ZEND_VM_EXPORT_HANDLER\(\s*([A-Za-z_]+)\s*,\s*([A-Z_]+)\s*\)/",
2488-
$line,
2489-
$m) == 0) {
2490-
die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HANDLER definition.\n");
2491-
}
2492-
if (!isset($opnames[$m[2]])) {
2493-
die("ERROR ($def:$lineno): opcode '{$m[2]}' is not defined.\n");
2494-
}
2495-
$export[] = array("handler",$m[1],$m[2]);
2496-
} else if (strpos($line,"ZEND_VM_EXPORT_HELPER(") === 0) {
2497-
if (preg_match(
2498-
"/^ZEND_VM_EXPORT_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Za-z_]+)\s*\)/",
2499-
$line,
2500-
$m) == 0) {
2501-
die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HELPER definition.\n");
2502-
}
2503-
if (!isset($helpers[$m[2]])) {
2504-
die("ERROR ($def:$lineno): helper '{$m[2]}' is not defined.\n");
2505-
}
2506-
$export[] = array("helper",$m[1],$m[2]);
25072482
} else if (strpos($line,"ZEND_VM_DEFINE_OP(") === 0) {
25082483
if (preg_match(
25092484
"/^ZEND_VM_DEFINE_OP\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*\);/",
@@ -2949,80 +2924,6 @@ function gen_vm($def, $skel) {
29492924
out($f, "}\n\n");
29502925
}
29512926

2952-
// Export handlers and helpers
2953-
if (count($export) > 0 &&
2954-
ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
2955-
out($f,"#undef OPLINE\n");
2956-
out($f,"#undef DCL_OPLINE\n");
2957-
out($f,"#undef USE_OPLINE\n");
2958-
out($f,"#undef LOAD_OPLINE\n");
2959-
out($f,"#undef LOAD_OPLINE_EX\n");
2960-
out($f,"#undef LOAD_NEXT_OPLINE\n");
2961-
out($f,"#undef SAVE_OPLINE\n");
2962-
out($f,"#undef SAVE_OPLINE_EX\n");
2963-
out($f,"#define OPLINE EX(opline)\n");
2964-
out($f,"#define DCL_OPLINE\n");
2965-
out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
2966-
out($f,"#define LOAD_OPLINE()\n");
2967-
out($f,"#define LOAD_OPLINE_EX()\n");
2968-
out($f,"#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
2969-
out($f,"#define SAVE_OPLINE()\n");
2970-
out($f,"#define SAVE_OPLINE_EX()\n");
2971-
out($f,"#undef HANDLE_EXCEPTION\n");
2972-
out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
2973-
out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
2974-
out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
2975-
out($f,"#undef ZEND_VM_CONTINUE\n");
2976-
out($f,"#undef ZEND_VM_RETURN\n");
2977-
out($f,"#undef ZEND_VM_ENTER_EX\n");
2978-
out($f,"#undef ZEND_VM_ENTER\n");
2979-
out($f,"#undef ZEND_VM_LEAVE\n");
2980-
out($f,"#undef ZEND_VM_DISPATCH\n");
2981-
out($f,"#define ZEND_VM_CONTINUE() return 0\n");
2982-
out($f,"#define ZEND_VM_RETURN() return -1\n");
2983-
out($f,"#define ZEND_VM_ENTER_EX() return 1\n");
2984-
out($f,"#define ZEND_VM_ENTER() return 1\n");
2985-
out($f,"#define ZEND_VM_LEAVE() return 2\n");
2986-
out($f,"#define ZEND_VM_INTERRUPT() return zend_interrupt_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
2987-
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
2988-
out($f,"\n");
2989-
}
2990-
foreach ($export as $dsk) {
2991-
list($kind, $func, $name) = $dsk;
2992-
out($f, "ZEND_API int $func(");
2993-
if ($kind == "handler") {
2994-
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
2995-
$code = $opcodes[$opnames[$name]]['code'];
2996-
} else {
2997-
$h = $helpers[$name];
2998-
if ($h['param'] == null) {
2999-
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
3000-
} else {
3001-
out($f, $h['param']. " ZEND_OPCODE_HANDLER_ARGS_DC)\n");
3002-
}
3003-
$code = $h['code'];
3004-
}
3005-
$done = 0;
3006-
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
3007-
if ($kind == "handler") {
3008-
$op = $opcodes[$opnames[$name]];
3009-
if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
3010-
out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
3011-
$done = 1;
3012-
}
3013-
} else if ($helpers[$name]["param"] == null) {
3014-
$h = $helpers[$name];
3015-
if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
3016-
out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
3017-
$done = 1;
3018-
}
3019-
}
3020-
}
3021-
if (!$done) {
3022-
gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
3023-
}
3024-
}
3025-
30262927
fclose($f);
30272928
echo "zend_vm_execute.h generated successfully.\n";
30282929
}

0 commit comments

Comments
 (0)