xref: /PHP-5.5/Zend/zend_vm_gen.php (revision 73c1be26)
1<?php
2/*
3   +----------------------------------------------------------------------+
4   | Zend Engine                                                          |
5   +----------------------------------------------------------------------+
6   | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
7   +----------------------------------------------------------------------+
8   | This source file is subject to version 2.00 of the Zend license,     |
9   | that is bundled with this package in the file LICENSE, and is        |
10   | available through the world-wide-web at the following url:           |
11   | http://www.zend.com/license/2_00.txt.                                |
12   | If you did not receive a copy of the Zend license and are unable to  |
13   | obtain it through the world-wide-web, please send a note to          |
14   | license@zend.com so we can mail you a copy immediately.              |
15   +----------------------------------------------------------------------+
16   | Authors: Dmitry Stogov <dmitry@zend.com>                             |
17   +----------------------------------------------------------------------+
18
19	 $Id$
20*/
21
22$header_text = <<< DATA
23/*
24   +----------------------------------------------------------------------+
25   | Zend Engine                                                          |
26   +----------------------------------------------------------------------+
27   | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
28   +----------------------------------------------------------------------+
29   | This source file is subject to version 2.00 of the Zend license,     |
30   | that is bundled with this package in the file LICENSE, and is        |
31   | available through the world-wide-web at the following url:           |
32   | http://www.zend.com/license/2_00.txt.                                |
33   | If you did not receive a copy of the Zend license and are unable to  |
34   | obtain it through the world-wide-web, please send a note to          |
35   | license@zend.com so we can mail you a copy immediately.              |
36   +----------------------------------------------------------------------+
37   | Authors: Andi Gutmans <andi@zend.com>                                |
38   |          Zeev Suraski <zeev@zend.com>                                |
39   |          Dmitry Stogov <dmitry@zend.com>                             |
40   +----------------------------------------------------------------------+
41*/
42
43
44DATA;
45
46/*
47	This script creates zend_vm_execute.h and zend_vm_opcodes.h
48	from existing zend_vm_def.h and zend_vm_execute.skl
49*/
50
51error_reporting(E_ALL);
52
53define("ZEND_VM_KIND_CALL",   1);
54define("ZEND_VM_KIND_SWITCH", 2);
55define("ZEND_VM_KIND_GOTO",   3);
56
57$op_types = array(
58	"ANY",
59	"CONST",
60	"TMP",
61	"VAR",
62	"UNUSED",
63	"CV"
64);
65
66$prefix = array(
67	"ANY"    => "",
68	"TMP"    => "_TMP",
69	"VAR"    => "_VAR",
70	"CONST"  => "_CONST",
71	"UNUSED" => "_UNUSED",
72	"CV"     => "_CV",
73);
74
75$typecode = array(
76	"ANY"    => 0,
77	"TMP"    => 1,
78	"VAR"    => 2,
79	"CONST"  => 0,
80	"UNUSED" => 3,
81	"CV"     => 4,
82);
83
84$op1_type = array(
85	"ANY"    => "opline->op1_type",
86	"TMP"    => "IS_TMP_VAR",
87	"VAR"    => "IS_VAR",
88	"CONST"  => "IS_CONST",
89	"UNUSED" => "IS_UNUSED",
90	"CV"     => "IS_CV",
91);
92
93$op2_type = array(
94	"ANY"    => "opline->op2_type",
95	"TMP"    => "IS_TMP_VAR",
96	"VAR"    => "IS_VAR",
97	"CONST"  => "IS_CONST",
98	"UNUSED" => "IS_UNUSED",
99	"CV"     => "IS_CV",
100);
101
102$op1_free = array(
103	"ANY"    => "(free_op1.var != NULL)",
104	"TMP"    => "1",
105	"VAR"    => "(free_op1.var != NULL)",
106	"CONST"  => "0",
107	"UNUSED" => "0",
108	"CV"     => "0",
109);
110
111$op2_free = array(
112	"ANY"    => "(free_op2.var != NULL)",
113	"TMP"    => "1",
114	"VAR"    => "(free_op2.var != NULL)",
115	"CONST"  => "0",
116	"UNUSED" => "0",
117	"CV"     => "0",
118);
119
120$op1_get_zval_ptr = array(
121	"ANY"    => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
122	"TMP"    => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
123	"VAR"    => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
124	"CONST"  => "opline->op1.zv",
125	"UNUSED" => "NULL",
126	"CV"     => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
127);
128
129$op2_get_zval_ptr = array(
130	"ANY"    => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
131	"TMP"    => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
132	"VAR"    => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
133	"CONST"  => "opline->op2.zv",
134	"UNUSED" => "NULL",
135	"CV"     => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
136);
137
138$op1_get_zval_ptr_ptr = array(
139	"ANY"    => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
140	"TMP"    => "NULL",
141	"VAR"    => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
142	"CONST"  => "NULL",
143	"UNUSED" => "NULL",
144	"CV"     => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
145);
146
147$op2_get_zval_ptr_ptr = array(
148	"ANY"    => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
149	"TMP"    => "NULL",
150	"VAR"    => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
151	"CONST"  => "NULL",
152	"UNUSED" => "NULL",
153	"CV"     => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
154);
155
156$op1_get_obj_zval_ptr = array(
157	"ANY"    => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
158	"TMP"    => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
159	"VAR"    => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
160	"CONST"  => "opline->op1.zv",
161	"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
162	"CV"     => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
163);
164
165$op2_get_obj_zval_ptr = array(
166	"ANY"    => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
167	"TMP"    => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
168	"VAR"    => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
169	"CONST"  => "opline->op2.zv",
170	"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
171	"CV"     => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
172);
173
174$op1_get_obj_zval_ptr_ptr = array(
175	"ANY"    => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
176	"TMP"    => "NULL",
177	"VAR"    => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
178	"CONST"  => "NULL",
179	"UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)",
180	"CV"     => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
181);
182
183$op2_get_obj_zval_ptr_ptr = array(
184	"ANY"    => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
185	"TMP"    => "NULL",
186	"VAR"    => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
187	"CONST"  => "NULL",
188	"UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)",
189	"CV"     => "_get_zval_ptr_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
190);
191
192$op1_is_tmp_free = array(
193	"ANY"    => "IS_TMP_FREE(free_op1)",
194	"TMP"    => "1",
195	"VAR"    => "0",
196	"CONST"  => "0",
197	"UNUSED" => "0",
198	"CV"     => "0",
199);
200
201$op2_is_tmp_free = array(
202	"ANY"    => "IS_TMP_FREE(free_op2)",
203	"TMP"    => "1",
204	"VAR"    => "0",
205	"CONST"  => "0",
206	"UNUSED" => "0",
207	"CV"     => "0",
208);
209
210$op1_free_op = array(
211	"ANY"    => "FREE_OP(free_op1)",
212	"TMP"    => "zval_dtor(free_op1.var)",
213	"VAR"    => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
214	"CONST"  => "",
215	"UNUSED" => "",
216	"CV"     => "",
217);
218
219$op2_free_op = array(
220	"ANY"    => "FREE_OP(free_op2)",
221	"TMP"    => "zval_dtor(free_op2.var)",
222	"VAR"    => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
223	"CONST"  => "",
224	"UNUSED" => "",
225	"CV"     => "",
226);
227
228$op1_free_op_if_var = array(
229	"ANY"    => "FREE_OP_IF_VAR(free_op1)",
230	"TMP"    => "",
231	"VAR"    => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
232	"CONST"  => "",
233	"UNUSED" => "",
234	"CV"     => "",
235);
236
237$op2_free_op_if_var = array(
238	"ANY"    => "FREE_OP_IF_VAR(free_op2)",
239	"TMP"    => "",
240	"VAR"    => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
241	"CONST"  => "",
242	"UNUSED" => "",
243	"CV"     => "",
244);
245
246$op1_free_op_var_ptr = array(
247	"ANY"    => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
248	"TMP"    => "",
249	"VAR"    => "if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}",
250	"CONST"  => "",
251	"UNUSED" => "",
252	"CV"     => "",
253);
254
255$op2_free_op_var_ptr = array(
256	"ANY"    => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
257	"TMP"    => "",
258	"VAR"    => "if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}",
259	"CONST"  => "",
260	"UNUSED" => "",
261	"CV"     => "",
262);
263
264$list    = array(); // list of opcode handlers and helpers in original order
265$opcodes = array(); // opcode handlers by code
266$helpers = array(); // opcode helpers by name
267$params  = array(); // parameters of helpers
268$opnames = array(); // opcode name to code mapping
269$line_no = 1;
270
271// Writes $s into resulting executor
272function out($f, $s) {
273	global $line_no;
274
275	fputs($f,$s);
276	$line_no += substr_count($s, "\n");
277}
278
279// Resets #line directives in resulting executor
280function out_line($f) {
281	global $line_no, $executor_file;
282
283	fputs($f,"#line ".($line_no+1)." \"".$executor_file."\"\n");
284	++$line_no;
285}
286
287// Returns name of specialized helper
288function helper_name($name, $spec, $op1, $op2) {
289	global $prefix, $helpers;
290
291	if (isset($helpers[$name])) {
292		// If we haven't helper with specified spicialized operands then
293		// using unspecialized helper
294		if (!isset($helpers[$name]["op1"][$op1]) &&
295		    isset($helpers[$name]["op1"]["ANY"])) {
296			$op1 = "ANY";
297		}
298		if (!isset($helpers[$name]["op2"][$op2]) &&
299		    isset($helpers[$name]["op2"]["ANY"])) {
300			$op2 = "ANY";
301		}
302	}
303	return $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2];
304}
305
306// Generates code for opcode handler or helper
307function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name) {
308	global $op1_type, $op2_type, $op1_get_zval_ptr, $op2_get_zval_ptr,
309		$op1_get_zval_ptr_ptr, $op2_get_zval_ptr_ptr,
310		$op1_get_obj_zval_ptr, $op2_get_obj_zval_ptr,
311		$op1_get_obj_zval_ptr_ptr, $op2_get_obj_zval_ptr_ptr,
312		$op1_is_tmp_free, $op2_is_tmp_free, $op1_free, $op2_free,
313		$op1_free_op, $op2_free_op, $op1_free_op_if_var, $op2_free_op_if_var,
314		$op1_free_op_var_ptr, $op2_free_op_var_ptr, $prefix;
315
316	// Specializing
317	$code = preg_replace(
318		array(
319			"/OP1_TYPE/",
320			"/OP2_TYPE/",
321			"/OP1_FREE/",
322			"/OP2_FREE/",
323			"/GET_OP1_ZVAL_PTR\(([^)]*)\)/",
324			"/GET_OP2_ZVAL_PTR\(([^)]*)\)/",
325			"/GET_OP1_ZVAL_PTR_PTR\(([^)]*)\)/",
326			"/GET_OP2_ZVAL_PTR_PTR\(([^)]*)\)/",
327			"/GET_OP1_OBJ_ZVAL_PTR\(([^)]*)\)/",
328			"/GET_OP2_OBJ_ZVAL_PTR\(([^)]*)\)/",
329			"/GET_OP1_OBJ_ZVAL_PTR_PTR\(([^)]*)\)/",
330			"/GET_OP2_OBJ_ZVAL_PTR_PTR\(([^)]*)\)/",
331			"/IS_OP1_TMP_FREE\(\)/",
332			"/IS_OP2_TMP_FREE\(\)/",
333			"/FREE_OP1\(\)/",
334			"/FREE_OP2\(\)/",
335			"/FREE_OP1_IF_VAR\(\)/",
336			"/FREE_OP2_IF_VAR\(\)/",
337			"/FREE_OP1_VAR_PTR\(\)/",
338			"/FREE_OP2_VAR_PTR\(\)/",
339			"/^#ifdef\s+ZEND_VM_SPEC\s*\n/m",
340			"/^#ifndef\s+ZEND_VM_SPEC\s*\n/m",
341			"/\!defined\(ZEND_VM_SPEC\)/m",
342			"/defined\(ZEND_VM_SPEC\)/m",
343			"/ZEND_VM_C_LABEL\(\s*([A-Za-z_]*)\s*\)/m",
344			"/ZEND_VM_C_GOTO\(\s*([A-Za-z_]*)\s*\)/m",
345			"/^#if\s+1\s*\\|\\|.*[^\\\\]$/m",
346			"/^#if\s+0\s*&&.*[^\\\\]$/m",
347			"/^#ifdef\s+ZEND_VM_EXPORT\s*\n/m",
348			"/^#ifndef\s+ZEND_VM_EXPORT\s*\n/m"
349		),
350		array(
351			$op1_type[$op1],
352			$op2_type[$op2],
353			$op1_free[$op1],
354			$op2_free[$op2],
355			$op1_get_zval_ptr[$op1],
356			$op2_get_zval_ptr[$op2],
357			$op1_get_zval_ptr_ptr[$op1],
358			$op2_get_zval_ptr_ptr[$op2],
359			$op1_get_obj_zval_ptr[$op1],
360			$op2_get_obj_zval_ptr[$op2],
361			$op1_get_obj_zval_ptr_ptr[$op1],
362			$op2_get_obj_zval_ptr_ptr[$op2],
363			$op1_is_tmp_free[$op1],
364			$op2_is_tmp_free[$op2],
365			$op1_free_op[$op1],
366			$op2_free_op[$op2],
367			$op1_free_op_if_var[$op1],
368			$op2_free_op_if_var[$op2],
369			$op1_free_op_var_ptr[$op1],
370			$op2_free_op_var_ptr[$op2],
371			($op1!="ANY"||$op2!="ANY")?"#if 1\n":"#if 0\n",
372			($op1!="ANY"||$op2!="ANY")?"#if 0\n":"#if 1\n",
373			($op1!="ANY"||$op2!="ANY")?"0":"1",
374			($op1!="ANY"||$op2!="ANY")?"1":"0",
375			"\\1".(($spec && $kind != ZEND_VM_KIND_CALL)?("_SPEC".$prefix[$op1].$prefix[$op2]):""),
376			"goto \\1".(($spec && $kind != ZEND_VM_KIND_CALL)?("_SPEC".$prefix[$op1].$prefix[$op2]):""),
377			"#if 1",
378			"#if 0",
379			$export?"#if 1\n":"#if 0\n",
380			$export?"#if 0\n":"#if 1\n"
381		),
382		$code);
383
384	if (0 && strpos($code, '{') === 0) {
385		$code = "{\n\tfprintf(stderr, \"$name\\n\");\n" . substr($code, 1);
386	}
387	// Updating code according to selected threading model
388	switch($kind) {
389		case ZEND_VM_KIND_CALL:
390			$code = preg_replace_callback(
391				array(
392					"/EXECUTE_DATA/m",
393					"/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m",
394					"/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m",
395					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*[A-Za-z_]*\s*,\s*(.*)\s*\);/m",
396				),
397				function($matches) use ($spec, $prefix, $op1, $op2) {
398					if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) {
399						return "execute_data";
400					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) {
401						return "return " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)";
402					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) {
403						return "return " . helper_name($matches[1], $spec, $op1, $op2) . "(" . $matches[2]. ", ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);";
404					} else {
405						return "return " . helper_name($matches[1], $spec, $op1, $op2) . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)";
406					}
407				},
408				$code);
409			break;
410		case ZEND_VM_KIND_SWITCH:
411			$code = preg_replace_callback(
412				array(
413					"/EXECUTE_DATA/m",
414					"/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m",
415					"/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m",
416					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/m",
417				),
418				function($matches) use ($spec, $prefix, $op1, $op2) {
419					if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) {
420						return "execute_data";
421					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) {
422						return "goto " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_LABEL";
423					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) {
424						return $matches[2] . " = " . $matches[3] .  "; goto " . helper_name($matches[1], $spec, $op1, $op2) . ";";
425					} else {
426						return "goto " . helper_name($matches[1], $spec, $op1, $op2);
427					}
428				},
429					$code);
430			break;
431		case ZEND_VM_KIND_GOTO:
432			$code = preg_replace_callback(
433				array(
434					"/EXECUTE_DATA/m",
435					"/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m",
436					"/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/m",
437					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/m",
438				),
439				function($matches) use ($spec, $prefix, $op1, $op2) {
440					if (strncasecmp($matches[0], "EXECUTE_DATA", strlen("EXECUTE_DATA")) == 0) {
441						return "execute_data";
442					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HANDLER", strlen("ZEND_VM_DISPATCH_TO_HANDLER")) == 0) {
443						return "goto " . $matches[1] . ($spec?"_SPEC":"") . $prefix[$op1] . $prefix[$op2] . "_HANDLER";
444					} else if (strncasecmp($matches[0], "ZEND_VM_DISPATCH_TO_HELPER_EX", strlen("ZEND_VM_DISPATCH_TO_HELPER_EX")) == 0) {
445						return $matches[2] . " = " . $matches[3] .  "; goto " . helper_name($matches[1], $spec, $op1, $op2) . ";";
446					} else {
447						return "goto " . helper_name($matches[1], $spec, $op1, $op2);
448					}
449				},
450					$code);
451			break;
452	}
453
454	/* Remove unused free_op1 and free_op2 declarations */
455	if ($spec && preg_match_all('/^\s*zend_free_op\s+[^;]+;\s*$/me', $code, $matches, PREG_SET_ORDER)) {
456		$n = 0;
457		foreach ($matches as $match) {
458		  $code = preg_replace('/'.preg_quote($match[0],'/').'/', "\$D$n", $code);
459		  ++$n;
460		}
461		$del_free_op1 = (strpos($code, "free_op1") === false);
462		$del_free_op2 = (strpos($code, "free_op2") === false);
463		$n = 0;
464		foreach ($matches as $match) {
465			$dcl = $match[0];
466			$changed = 0;
467			if ($del_free_op1 && strpos($dcl, "free_op1") !== false) {
468				$dcl = preg_replace("/free_op1\s*,\s*/", "", $dcl);
469				$dcl = preg_replace("/free_op1\s*;/", ";", $dcl);
470				$changed = 1;
471			}
472			if ($del_free_op2 && strpos($dcl, "free_op2") !== false) {
473				$dcl = preg_replace("/free_op2\s*,\s*/", "", $dcl);
474				$dcl = preg_replace("/free_op2\s*;/", ";", $dcl);
475				$changed = 1;
476			}
477			if ($changed) {
478				$dcl = preg_replace("/,\s*;/", ";", $dcl);
479				$dcl = preg_replace("/zend_free_op\s*;/", "", $dcl);
480			}
481		  $code = preg_replace("/\\\$D$n/", $dcl, $code);
482		  ++$n;
483		}
484	}
485
486	/* Remove unnecessary ';' */
487	$code = preg_replace('/^\s*;\s*$/m', '', $code);
488
489	/* Remove WS */
490	$code = preg_replace('/[ \t]+\n/m', "\n", $code);
491
492	out($f, $code);
493}
494
495// Generates opcode handler
496function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno) {
497	global $definition_file, $prefix, $typecode, $opnames;
498
499	if (ZEND_VM_LINES) {
500		out($f, "#line $lineno \"$definition_file\"\n");
501	}
502
503	// Generate opcode handler's entry point according to selected threading model
504	switch($kind) {
505		case ZEND_VM_KIND_CALL:
506			out($f,"static int ZEND_FASTCALL  ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
507			break;
508		case ZEND_VM_KIND_SWITCH:
509			if ($spec) {
510				out($f,"case ".((string)($opnames[$name]*25+($typecode[$op1]*5)+$typecode[$op2])).": /*".$name."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER*/");
511			} else {
512				out($f,"case ".$name.":");
513			}
514			if ($use) {
515				// This handler is used by other handlers. We will add label to call it.
516				out($f," ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_LABEL:\n");
517			} else {
518				out($f,"\n");
519			}
520			break;
521		case ZEND_VM_KIND_GOTO:
522			out($f,$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER: ZEND_VM_GUARD(".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].");\n");
523			break;
524	}
525
526	// Generate opcode handler's code
527	gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name);
528}
529
530// Generates helper
531function gen_helper($f, $spec, $kind, $name, $op1, $op2, $param, $code, $lineno) {
532	global $definition_file, $prefix;
533
534	if (ZEND_VM_LINES) {
535		out($f, "#line $lineno \"$definition_file\"\n");
536	}
537
538	// Generate helper's entry point according to selected threading model
539	switch($kind) {
540		case ZEND_VM_KIND_CALL:
541			if ($param == null) {
542			  // Helper without parameters
543				out($f, "static int ZEND_FASTCALL ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."(ZEND_OPCODE_HANDLER_ARGS)\n");
544			} else {
545			  // Helper with parameter
546				out($f, "static int ZEND_FASTCALL ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."(".$param.", ZEND_OPCODE_HANDLER_ARGS)\n");
547			}
548			break;
549		case ZEND_VM_KIND_SWITCH:
550			out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
551			break;
552		case ZEND_VM_KIND_GOTO:
553			out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
554			break;
555	}
556
557	// Generate helper's code
558	gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name);
559}
560
561// Generates array of opcode handlers (specialized or unspecialized)
562function gen_labels($f, $spec, $kind, $prolog) {
563	global $opcodes, $op_types, $prefix, $typecode;
564
565	$next = 0;
566	if ($spec) {
567	  // Emit labels for specialized executor
568
569	  // For each opcode in opcode number order
570		foreach($opcodes as $num => $dsc) {
571			while ($next != $num) {
572			  // If some opcode numbers are not used then fill hole with pointers
573			  // to handler of undefined opcode
574				$op1t = $op_types;
575				// For each op1.op_type except ANY
576				foreach($op1t as $op1) {
577					if ($op1 != "ANY") {
578						$op2t = $op_types;
579						// For each op2.op_type except ANY
580						foreach($op2t as $op2) {
581							if ($op2 != "ANY") {
582							  // Emit pointer to handler of undefined opcode
583								switch ($kind) {
584									case ZEND_VM_KIND_CALL:
585										out($f,$prolog."ZEND_NULL_HANDLER,\n");
586										break;
587									case ZEND_VM_KIND_SWITCH:
588										out($f,$prolog."(opcode_handler_t)-1,\n");
589										break;
590									case ZEND_VM_KIND_GOTO:
591										out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
592										break;
593								}
594							}
595						}
596					}
597				}
598				$next++;
599			}
600			$next = $num + 1;
601			$op1t = $op_types;
602			// For each op1.op_type except ANY
603			foreach($op1t as $op1) {
604				if ($op1 != "ANY") {
605					if (!isset($dsc["op1"][$op1])) {
606						// Try to use unspecialized handler
607						$op1 = "ANY";
608					}
609					$op2t = $op_types;
610					// For each op2.op_type except ANY
611					foreach($op2t as $op2) {
612						if ($op2 != "ANY") {
613							if (!isset($dsc["op2"][$op2])) {
614								// Try to use unspecialized handler
615								$op2 = "ANY";
616							}
617							// Check if specialized handler is defined
618							if (isset($dsc["op1"][$op1]) &&
619							    isset($dsc["op2"][$op2])) {
620							  // Emit pointer to specialized handler
621								switch ($kind) {
622									case ZEND_VM_KIND_CALL:
623										out($f,$prolog.$dsc["op"]."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER,\n");
624										break;
625									case ZEND_VM_KIND_SWITCH:
626										out($f,$prolog."(opcode_handler_t)".((string)($num*25+$typecode[$op1]*5+$typecode[$op2])).",\n");
627										break;
628									case ZEND_VM_KIND_GOTO:
629										out($f,$prolog."(opcode_handler_t)&&".$dsc["op"]."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER,\n");
630										break;
631								}
632							} else {
633							  // Emit pinter to handler of undefined opcode
634								switch ($kind) {
635									case ZEND_VM_KIND_CALL:
636										out($f,$prolog."ZEND_NULL_HANDLER,\n");
637										break;
638									case ZEND_VM_KIND_SWITCH:
639										out($f,$prolog."(opcode_handler_t)-1,\n");
640										break;
641									case ZEND_VM_KIND_GOTO:
642										out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
643										break;
644								}
645							}
646						}
647					}
648				}
649			}
650		}
651	} else {
652	  // Emit labels for unspecialized executor
653
654	  // For each opcode in opcode number order
655		foreach($opcodes as $num => $dsc) {
656			while ($next != $num) {
657			  // If some opcode numbers are not used then fill hole with pointers
658			  // to handler of undefined opcode
659				switch ($kind) {
660					case ZEND_VM_KIND_CALL:
661						out($f,$prolog."ZEND_NULL_HANDLER,\n");
662						break;
663					case ZEND_VM_KIND_SWITCH:
664						out($f,$prolog."(opcode_handler_t)-1,\n");
665						break;
666					case ZEND_VM_KIND_GOTO:
667						out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
668						break;
669				}
670				$next++;
671			}
672			$next = $num+1;
673		  // Emit pointer to unspecialized handler
674			switch ($kind) {
675				case ZEND_VM_KIND_CALL:
676					out($f,$prolog.$dsc["op"]."_HANDLER,\n");
677					break;
678				case ZEND_VM_KIND_SWITCH:
679					out($f,$prolog."(opcode_handler_t)".((string)$num).",\n");
680					break;
681				case ZEND_VM_KIND_GOTO:
682					out($f,$prolog."(opcode_handler_t)&&".$dsc["op"]."_HANDLER,\n");
683					break;
684			}
685		}
686	}
687
688	// Emit last handler's label (undefined opcode)
689	switch ($kind) {
690		case ZEND_VM_KIND_CALL:
691			out($f,$prolog."ZEND_NULL_HANDLER\n");
692			break;
693		case ZEND_VM_KIND_SWITCH:
694			out($f,$prolog."(opcode_handler_t)-1\n");
695			break;
696		case ZEND_VM_KIND_GOTO:
697			out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER\n");
698			break;
699	}
700}
701
702// Generates handler for undefined opcodes (CALL threading model)
703function gen_null_handler($f) {
704	static $done = 0;
705
706	// New and all executors with CALL threading model can use the same handler
707	// for undefined opcodes, do we emit code for it only once
708	if (!$done) {
709		$done = 1;
710		out($f,"static int ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
711		out($f,"{\n");
712		out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
713		out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
714		out($f,"}\n\n");
715	}
716}
717
718// Generates all opcode handlers and helpers (specialized or unspecilaized)
719function gen_executor_code($f, $spec, $kind, $prolog) {
720	global $list, $opcodes, $helpers, $op_types;
721
722	if ($spec) {
723		// Produce specialized executor
724		$op1t = $op_types;
725		// for each op1.op_type
726		foreach($op1t as $op1) {
727			$op2t = $op_types;
728			// for each op2.op_type
729			foreach($op2t as $op2) {
730				// for each handlers in helpers in original order
731				foreach ($list as $lineno => $dsc) {
732					if (isset($dsc["handler"])) {
733						$num = $dsc["handler"];
734						// Check if handler accepts such types of operands (op1 and op2)
735						if (isset($opcodes[$num]["op1"][$op1]) &&
736						    isset($opcodes[$num]["op2"][$op2])) {
737						  // Generate handler code
738							gen_handler($f, 1, $kind, $opcodes[$num]["op"], $op1, $op2, isset($opcodes[$num]["use"]), $opcodes[$num]["code"], $lineno);
739						}
740					} else if (isset($dsc["helper"])) {
741						$num = $dsc["helper"];
742						// Check if handler accepts such types of operands (op1 and op2)
743						if (isset($helpers[$num]["op1"][$op1]) &&
744						    isset($helpers[$num]["op2"][$op2])) {
745						  // Generate helper code
746							gen_helper($f, 1, $kind, $num, $op1, $op2, $helpers[$num]["param"], $helpers[$num]["code"], $lineno);
747						}
748					} else {
749						var_dump($dsc);
750						die("??? $kind:$num\n");
751					}
752				}
753			}
754		}
755	} else {
756		// Produce unspecialized executor
757
758		// for each handlers in helpers in original order
759		foreach ($list as $lineno => $dsc) {
760			if (isset($dsc["handler"])) {
761				$num = $dsc["handler"];
762			  // Generate handler code
763				gen_handler($f, 0, $kind, $opcodes[$num]["op"], "ANY", "ANY", isset($opcodes[$num]["use"]), $opcodes[$num]["code"], $lineno);
764			} else if (isset($dsc["helper"])) {
765				$num = $dsc["helper"];
766			  // Generate helper code
767				gen_helper($f, 0, $kind, $num, "ANY", "ANY", $helpers[$num]["param"], $helpers[$num]["code"], $lineno);
768			} else {
769				var_dump($dsc);
770				die("??? $kind:$num\n");
771			}
772		}
773	}
774
775	if (ZEND_VM_LINES) {
776		// Reset #line directives
777		out_line($f);
778	}
779
780	// Generate handler for undefined opcodes
781	switch ($kind) {
782		case ZEND_VM_KIND_CALL:
783			gen_null_handler($f);
784			break;
785		case ZEND_VM_KIND_SWITCH:
786			out($f,"default:\n");
787			out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
788			out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
789			break;
790		case ZEND_VM_KIND_GOTO:
791			out($f,"ZEND_NULL_HANDLER:\n");
792			out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
793			out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
794			break;
795	}
796}
797
798function skip_blanks($f, $prolog, $epilog) {
799	if (trim($prolog) != "" || trim($epilog) != "") {
800		out($f, $prolog.$epilog);
801	}
802}
803
804// Generates executor from skeleton file and definition (specialized or unspecialized)
805function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, $old) {
806	global $params, $skeleton_file, $line_no;
807
808	$lineno      = 0;
809	foreach ($skl as $line) {
810	  // Skeleton file contains special markers in form %NAME% those are
811	  // substituted by custom code
812		if (preg_match("/(.*)[{][%]([A-Z_]*)[%][}](.*)/", $line, $m)) {
813			switch ($m[2]) {
814				case "DEFINES":
815					if (ZEND_VM_OLD_EXECUTOR && $spec) {
816						out($f,"static int zend_vm_old_executor = 0;\n\n");
817					}
818					out($f,"static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);\n\n");
819					switch ($kind) {
820						case ZEND_VM_KIND_CALL:
821							out($f,"\n");
822							out($f,"#undef OPLINE\n");
823							out($f,"#undef DCL_OPLINE\n");
824							out($f,"#undef USE_OPLINE\n");
825							out($f,"#undef LOAD_OPLINE\n");
826							out($f,"#undef SAVE_OPLINE\n");
827							out($f,"#define OPLINE EX(opline)\n");
828							out($f,"#define DCL_OPLINE\n");
829							out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
830							out($f,"#define LOAD_OPLINE()\n");
831							out($f,"#define SAVE_OPLINE()\n");
832							out($f,"#undef CHECK_EXCEPTION\n");
833							out($f,"#undef HANDLE_EXCEPTION\n");
834							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
835							out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
836							out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
837							out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
838							out($f,"#define LOAD_REGS()\n");
839							out($f,"#define ZEND_VM_CONTINUE()         return 0\n");
840							out($f,"#define ZEND_VM_RETURN()           return 1\n");
841							out($f,"#define ZEND_VM_ENTER()            return 2\n");
842							out($f,"#define ZEND_VM_LEAVE()            return 3\n");
843							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
844							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
845							break;
846						case ZEND_VM_KIND_SWITCH:
847							out($f,"\n");
848							out($f,"#undef OPLINE\n");
849							out($f,"#undef DCL_OPLINE\n");
850							out($f,"#undef USE_OPLINE\n");
851							out($f,"#undef LOAD_OPLINE\n");
852							out($f,"#undef SAVE_OPLINE\n");
853							out($f,"#define OPLINE opline\n");
854							out($f,"#define DCL_OPLINE zend_op *opline;\n");
855							out($f,"#define USE_OPLINE\n");
856							out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
857							out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
858							out($f,"#undef CHECK_EXCEPTION\n");
859							out($f,"#undef HANDLE_EXCEPTION\n");
860							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
861							out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
862							out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
863							out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
864							out($f,"#define LOAD_REGS()\n");
865							out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
866							out($f,"#define ZEND_VM_RETURN()   EG(in_execution) = original_in_execution; return\n");
867							out($f,"#define ZEND_VM_ENTER()    goto zend_vm_enter\n");
868							out($f,"#define ZEND_VM_LEAVE()    ZEND_VM_CONTINUE()\n");
869							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n");
870							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
871							break;
872						case ZEND_VM_KIND_GOTO:
873							out($f,"\n");
874							out($f,"#undef OPLINE\n");
875							out($f,"#undef DCL_OPLINE\n");
876							out($f,"#undef USE_OPLINE\n");
877							out($f,"#undef LOAD_OPLINE\n");
878							out($f,"#undef SAVE_OPLINE\n");
879							out($f,"#define OPLINE opline\n");
880							out($f,"#define DCL_OPLINE zend_op *opline;\n");
881							out($f,"#define USE_OPLINE\n");
882							out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
883							out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
884							out($f,"#undef CHECK_EXCEPTION\n");
885							out($f,"#undef HANDLE_EXCEPTION\n");
886							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
887							if (ZEND_VM_SPEC) {
888								out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
889								out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
890								out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
891							} else {
892								out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
893								out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
894								out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
895							}
896							out($f,"#define LOAD_REGS()\n");
897							out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
898							out($f,"#define ZEND_VM_RETURN()   EG(in_execution) = original_in_execution; return\n");
899							out($f,"#define ZEND_VM_ENTER()    goto zend_vm_enter\n");
900							out($f,"#define ZEND_VM_LEAVE()    ZEND_VM_CONTINUE()\n");
901							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n");
902							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
903							break;
904					}
905					break;
906				case "EXECUTOR_NAME":
907					out($f, $m[1].$executor_name.$m[3]."\n");
908					break;
909				case "HELPER_VARS":
910					if ($kind != ZEND_VM_KIND_CALL) {
911						if ($kind == ZEND_VM_KIND_SWITCH) {
912							out($f,$m[1]."opcode_handler_t dispatch_handler;\n");
913						}
914					  // Emit local variables those are used for helpers' parameters
915						foreach ($params as $param => $x) {
916							out($f,$m[1].$param.";\n");
917						}
918					} else {
919						skip_blanks($f, $m[1], $m[3]."\n");
920					}
921					break;
922				case "INTERNAL_LABELS":
923					if ($kind == ZEND_VM_KIND_GOTO) {
924					  // Emit array of labels of opcode handlers and code for
925					  // zend_opcode_handlers initialization
926						$prolog = $m[1];
927						out($f,$prolog."if (execute_data == NULL) {\n");
928						out($f,$prolog."\tstatic const opcode_handler_t labels[] = {\n");
929						gen_labels($f, $spec, $kind, $prolog."\t\t");
930						out($f,$prolog."\t};\n");
931						out($f,$prolog."\tzend_opcode_handlers = (opcode_handler_t*)labels;\n");
932						out($f,$prolog."\treturn;\n");
933						out($f,$prolog."}\n");
934					} else {
935						skip_blanks($f, $m[1], $m[3]);
936					}
937					break;
938				case "ZEND_VM_CONTINUE_LABEL":
939					if ($kind == ZEND_VM_KIND_CALL) {
940					  // Only SWITCH dispatch method use it
941						out($f,$m[1]."\tint ret;".$m[3]."\n");
942					} else if ($kind == ZEND_VM_KIND_SWITCH) {
943					  // Only SWITCH dispatch method use it
944						out($f,"zend_vm_continue:".$m[3]."\n");
945					} else {
946						skip_blanks($f, $m[1], $m[3]);
947					}
948					break;
949				case "ZEND_VM_DISPATCH":
950				  // Emit code that dispatches to opcode handler
951					switch ($kind) {
952						case ZEND_VM_KIND_CALL:
953							out($f, $m[1]."if ((ret = OPLINE->handler(execute_data TSRMLS_CC)) > 0)".$m[3]."\n");
954							break;
955						case ZEND_VM_KIND_SWITCH:
956							out($f, $m[1]."dispatch_handler = OPLINE->handler;\nzend_vm_dispatch:\n".$m[1]."switch ((int)dispatch_handler)".$m[3]."\n");
957							break;
958						case ZEND_VM_KIND_GOTO:
959							out($f, $m[1]."goto *(void**)(OPLINE->handler);".$m[3]."\n");
960							break;
961					}
962					break;
963				case "INTERNAL_EXECUTOR":
964					if ($kind == ZEND_VM_KIND_CALL) {
965					  // Executor is defined as a set of functions
966						out($f, $m[1]."switch (ret) {\n" .
967						        $m[1]."\tcase 1:\n" .
968						        $m[1]."\t\tEG(in_execution) = original_in_execution;\n".
969						        $m[1]."\t\treturn;\n".
970						        $m[1]."\tcase 2:\n" .
971						        $m[1]."\t\tgoto zend_vm_enter;\n".
972						        $m[1]."\t\tbreak;\n" .
973						        $m[1]."\tcase 3:\n" .
974						        $m[1]."\t\texecute_data = EG(current_execute_data);\n".
975						        $m[1]."\t\tbreak;\n" .
976						        $m[1]."\tdefault:\n".
977						        $m[1]."\t\tbreak;\n".
978						        $m[1]."}".$m[3]."\n");
979					} else {
980					  // Emit executor code
981						gen_executor_code($f, $spec, $kind, $m[1]);
982					}
983					break;
984				case "EXTERNAL_EXECUTOR":
985					if ($kind == ZEND_VM_KIND_CALL) {
986					  // Unspecialized executor with CALL threading is the same as the
987					  // old one, so we don't need to produce code twitch
988						if (!$old || ZEND_VM_SPEC || (ZEND_VM_KIND != ZEND_VM_KIND_CALL)) {
989							// Emit executor code
990							gen_executor_code($f, $spec, $kind, $m[1]);
991						}
992					}
993					break;
994				case "INITIALIZER_NAME":
995					out($f, $m[1].$initializer_name.$m[3]."\n");
996					break;
997				case "EXTERNAL_LABELS":
998				  // Emit code that initializes zend_opcode_handlers array
999					$prolog = $m[1];
1000					if ($kind == ZEND_VM_KIND_GOTO) {
1001					  // Labels are defined in the executor itself, so we call it
1002					  // with execute_data NULL and it sets zend_opcode_handlers array
1003						out($f,$prolog."TSRMLS_FETCH();\n");
1004						out($f,$prolog.$executor_name."_ex(NULL TSRMLS_CC);\n");
1005					} else {
1006						if ($old) {
1007						  // Reserving space for user-defined opcodes
1008							out($f,$prolog."static opcode_handler_t labels[512] = {\n");
1009						} else {
1010							out($f,$prolog."static const opcode_handler_t labels[] = {\n");
1011						}
1012						gen_labels($f, $spec, $kind, $prolog."\t");
1013						out($f,$prolog."};\n");
1014						out($f,$prolog."zend_opcode_handlers = (opcode_handler_t*)labels;\n");
1015						if ($old) {
1016						  // Setup old executor
1017							out($f,$prolog."zend_vm_old_executor = 1;\n");
1018							out($f,$prolog."zend_execute = old_execute;\n");
1019						}
1020					}
1021					break;
1022				default:
1023					die("ERROR: Unknown keyword ".$m[2]." in skeleton file.\n");
1024			}
1025		} else {
1026		  // Copy the line as is
1027			out($f, $line);
1028		}
1029	}
1030}
1031
1032function gen_vm($def, $skel) {
1033	global $definition_file, $skeleton_file, $executor_file,
1034		$op_types, $list, $opcodes, $helpers, $params, $opnames;
1035
1036	// Load definition file
1037	$in = @file($def);
1038	if (!$in) {
1039		die("ERROR: Can not open definition file '$def'\n");
1040	}
1041	// We need absolute path to definition file to use it in #line directives
1042	$definition_file = realpath($def);
1043
1044	// Load skeleton file
1045	$skl = @file($skel);
1046	if (!$skl) {
1047		die("ERROR: Can not open skeleton file '$skel'\n");
1048	}
1049	// We need absolute path to skeleton file to use it in #line directives
1050	$skeleton_file = realpath($skel);
1051
1052	// Parse definition file into tree
1053	$lineno         = 0;
1054	$handler        = null;
1055	$helper         = null;
1056	$max_opcode_len = 0;
1057	$max_opcode     = 0;
1058	$export         = array();
1059	foreach ($in as $line) {
1060		++$lineno;
1061		if (strpos($line,"ZEND_VM_HANDLER(") === 0) {
1062		  // Parsing opcode handler's definition
1063			if (preg_match(
1064					"/^ZEND_VM_HANDLER\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*\)/",
1065					$line,
1066					$m) == 0) {
1067				die("ERROR ($def:$lineno): Invalid ZEND_VM_HANDLER definition.\n");
1068			}
1069			$code = (int)$m[1];
1070			$op   = $m[2];
1071			$len  = strlen($op);
1072			$op1  = array_flip(explode("|",$m[3]));
1073			$op2  = array_flip(explode("|",$m[4]));
1074
1075			if ($len > $max_opcode_len) {
1076				$max_opcode_len = $len;
1077			}
1078			if ($code > $max_opcode) {
1079				$max_opcode = $code;
1080			}
1081			if (isset($opcodes[$code])) {
1082				die("ERROR ($def:$lineno): Opcode with code '$code' is already defined.\n");
1083			}
1084			if (isset($opnames[$op])) {
1085				die("ERROR ($def:$lineno): Opcode with name '$op' is already defined.\n");
1086			}
1087			$opcodes[$code] = array("op"=>$op,"op1"=>$op1,"op2"=>$op2,"code"=>"");
1088			$opnames[$op] = $code;
1089			$handler = $code;
1090			$helper = null;
1091			$list[$lineno] = array("handler"=>$handler);
1092		} else if (strpos($line,"ZEND_VM_HELPER(") === 0) {
1093		  // Parsing helper's definition
1094			if (preg_match(
1095					"/^ZEND_VM_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*\)/",
1096					$line,
1097					$m) == 0) {
1098				die("ERROR ($def:$lineno): Invalid ZEND_VM_HELPER definition.\n");
1099			}
1100			$helper = $m[1];
1101			$op1    = array_flip(explode("|",$m[2]));
1102			$op2    = array_flip(explode("|",$m[3]));
1103			if (isset($helpers[$helper])) {
1104				die("ERROR ($def:$lineno): Helper with name '$helper' is already defined.\n");
1105			}
1106			$helpers[$helper] = array("op1"=>$op1,"op2"=>$op2,"param"=>null,"code"=>"");
1107			$handler = null;
1108			$list[$lineno] = array("helper"=>$helper);
1109		} else if (strpos($line,"ZEND_VM_HELPER_EX(") === 0) {
1110		  // Parsing helper with parameter definition
1111			if (preg_match(
1112					"/^ZEND_VM_HELPER_EX\(\s*([A-Za-z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*,\s*(.*)\s*\)/",
1113					$line,
1114					$m) == 0) {
1115				die("ERROR ($def:$lineno): Invalid ZEND_VM_HELPER definition.\n");
1116			}
1117			$helper = $m[1];
1118			$op1    = array_flip(explode("|",$m[2]));
1119			$op2    = array_flip(explode("|",$m[3]));
1120			$param  = $m[4];
1121			if (isset($helpers[$helper])) {
1122				die("ERROR ($def:$lineno): Helper with name '$helper' is already defined.\n");
1123			}
1124
1125			// Store parameter
1126			$params[$param] = 1;
1127
1128			$helpers[$helper] = array("op1"=>$op1,"op2"=>$op2,"param"=>$param,"code"=>"");
1129			$handler = null;
1130			$list[$lineno] = array("helper"=>$helper);
1131		} else if (strpos($line,"ZEND_VM_EXPORT_HANDLER(") === 0) {
1132			if (preg_match(
1133					"/^ZEND_VM_EXPORT_HANDLER\(\s*([A-Za-z_]+)\s*,\s*([A-Z_]+)\s*\)/",
1134					$line,
1135					$m) == 0) {
1136				die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HANDLER definition.\n");
1137			}
1138			if (!isset($opnames[$m[2]])) {
1139				die("ERROR ($def:$lineno): opcode '{$m[2]}' is not defined.\n");
1140			}
1141			$export[] = array("handler",$m[1],$m[2]);
1142		} else if (strpos($line,"ZEND_VM_EXPORT_HELPER(") === 0) {
1143			if (preg_match(
1144					"/^ZEND_VM_EXPORT_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Za-z_]+)\s*\)/",
1145					$line,
1146					$m) == 0) {
1147				die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HELPER definition.\n");
1148			}
1149			if (!isset($helpers[$m[2]])) {
1150				die("ERROR ($def:$lineno): helper '{$m[2]}' is not defined.\n");
1151			}
1152			$export[] = array("helper",$m[1],$m[2]);
1153		} else if ($handler !== null) {
1154		  // Add line of code to current opcode handler
1155			$opcodes[$handler]["code"] .= $line;
1156		} else if ($helper !== null) {
1157		  // Add line of code to current helper
1158			$helpers[$helper]["code"] .= $line;
1159		}
1160	}
1161
1162	ksort($opcodes);
1163
1164	// Search for opcode handlers those are used by other opcode handlers
1165	foreach ($opcodes as $dsc) {
1166		if (preg_match("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $m)) {
1167			$op = $m[1];
1168			if (!isset($opnames[$op])) {
1169				die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
1170			}
1171			$code = $opnames[$op];
1172			$opcodes[$code]['use'] = 1;
1173		}
1174	}
1175
1176	// Generate opcode #defines (zend_vm_opcodes.h)
1177	$code_len = strlen((string)$max_opcode);
1178	$f = fopen(__DIR__ . "/zend_vm_opcodes.h", "w+") or die("ERROR: Cannot create zend_vm_opcodes.h\n");
1179
1180	// Insert header
1181	out($f, $GLOBALS['header_text']);
1182
1183	fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
1184	fputs($f, "BEGIN_EXTERN_C()\n\n");
1185	fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n\n");
1186	fputs($f, "END_EXTERN_C()\n\n");
1187
1188	foreach ($opcodes as $code => $dsc) {
1189		$code = str_pad((string)$code,$code_len," ",STR_PAD_LEFT);
1190		$op = str_pad($dsc["op"],$max_opcode_len);
1191		fputs($f,"#define $op $code\n");
1192	}
1193
1194	fputs($f, "\n#endif\n");
1195	fclose($f);
1196	echo "zend_vm_opcodes.h generated successfully.\n";
1197
1198	// zend_vm_opcodes.c
1199	$f = fopen(__DIR__ . "/zend_vm_opcodes.c", "w+") or die("ERROR: Cannot create zend_vm_opcodes.c\n");
1200
1201	// Insert header
1202	out($f, $GLOBALS['header_text']);
1203	fputs($f,"#include <stdio.h>\n");
1204	fputs($f,"#include <zend.h>\n\n");
1205
1206	fputs($f,"const char *zend_vm_opcodes_map[".($max_opcode + 1)."] = {\n");
1207	for ($i = 0; $i <= $max_opcode; $i++) {
1208		fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
1209	}
1210	fputs($f, "};\n\n");
1211
1212    fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
1213    fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
1214    fputs($f, "}\n");
1215
1216	fclose($f);
1217	echo "zend_vm_opcodes.c generated successfully.\n";
1218
1219	// Generate zend_vm_execute.h
1220	$f = fopen(__DIR__ . "/zend_vm_execute.h", "w+") or die("ERROR: Cannot create zend_vm_execute.h\n");
1221	$executor_file = realpath(__DIR__ . "/zend_vm_execute.h");
1222
1223	// Insert header
1224	out($f, $GLOBALS['header_text']);
1225
1226	out($f, "#ifdef ZEND_WIN32\n");
1227	// Suppress free_op1 warnings on Windows
1228	out($f, "# pragma warning(once : 4101)\n");
1229	if (ZEND_VM_SPEC) {
1230		// Suppress (<non-zero constant> || <expression>) warnings on windows
1231		out($f, "# pragma warning(once : 6235)\n");
1232		// Suppress (<zero> && <expression>) warnings on windows
1233		out($f, "# pragma warning(once : 6237)\n");
1234		// Suppress (<non-zero constant> && <expression>) warnings on windows
1235		out($f, "# pragma warning(once : 6239)\n");
1236		// Suppress (<expression> && <non-zero constant>) warnings on windows
1237		out($f, "# pragma warning(once : 6240)\n");
1238		// Suppress (<non-zero constant> || <non-zero constant>) warnings on windows
1239		out($f, "# pragma warning(once : 6285)\n");
1240		// Suppress (<non-zero constant> || <expression>) warnings on windows
1241		out($f, "# pragma warning(once : 6286)\n");
1242		// Suppress constant with constant comparison warnings on windows
1243		out($f, "# pragma warning(once : 6326)\n");
1244	}
1245	out($f, "#endif\n");
1246
1247	// Support for ZEND_USER_OPCODE
1248	out($f, "static user_opcode_handler_t zend_user_opcode_handlers[256] = {\n");
1249	for ($i = 0; $i < 255; ++$i) {
1250		out($f, "\t(user_opcode_handler_t)NULL,\n");
1251	}
1252	out($f, "\t(user_opcode_handler_t)NULL\n};\n\n");
1253
1254	out($f, "static zend_uchar zend_user_opcodes[256] = {");
1255	for ($i = 0; $i < 255; ++$i) {
1256		if ($i % 16 == 1) out($f, "\n\t");
1257		out($f, "$i,");
1258	}
1259	out($f, "255\n};\n\n");
1260
1261	// Generate specialized executor
1262	gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_KIND, "execute", "zend_init_opcodes_handlers", 0);
1263
1264	// Generate un-specialized executor
1265	if (ZEND_VM_OLD_EXECUTOR) {
1266		out($f,"\n/* Old executor */\n\n");
1267		out($f,"#undef ZEND_VM_CONTINUE\n\n");
1268		out($f,"#undef ZEND_VM_RETURN\n\n");
1269		out($f,"#undef ZEND_VM_ENTER\n\n");
1270		out($f,"#undef ZEND_VM_LEAVE\n\n");
1271		out($f,"#undef ZEND_VM_DISPATCH\n\n");
1272		out($f,"#undef ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL\n\n");
1273		gen_executor($f, $skl, 0, ZEND_VM_KIND_CALL, "old_execute", "zend_vm_use_old_executor", 1);
1274	}
1275
1276	// Generate zend_vm_get_opcode_handler() function
1277	out($f, "static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)\n");
1278	out($f, "{\n");
1279	if (!ZEND_VM_SPEC) {
1280		out($f, "\treturn zend_opcode_handlers[opcode];\n");
1281	} else {
1282		if (ZEND_VM_OLD_EXECUTOR) {
1283			out($f, "\tif (zend_vm_old_executor) {\n");
1284			out($f, "\t\treturn zend_opcode_handlers[opcode];\n");
1285			out($f, "\t} else {\n");
1286		}
1287		out($f, "\t\tstatic const int zend_vm_decode[] = {\n");
1288		out($f, "\t\t\t_UNUSED_CODE, /* 0              */\n");
1289		out($f, "\t\t\t_CONST_CODE,  /* 1 = IS_CONST   */\n");
1290		out($f, "\t\t\t_TMP_CODE,    /* 2 = IS_TMP_VAR */\n");
1291		out($f, "\t\t\t_UNUSED_CODE, /* 3              */\n");
1292		out($f, "\t\t\t_VAR_CODE,    /* 4 = IS_VAR     */\n");
1293		out($f, "\t\t\t_UNUSED_CODE, /* 5              */\n");
1294		out($f, "\t\t\t_UNUSED_CODE, /* 6              */\n");
1295		out($f, "\t\t\t_UNUSED_CODE, /* 7              */\n");
1296		out($f, "\t\t\t_UNUSED_CODE, /* 8 = IS_UNUSED  */\n");
1297		out($f, "\t\t\t_UNUSED_CODE, /* 9              */\n");
1298		out($f, "\t\t\t_UNUSED_CODE, /* 10             */\n");
1299		out($f, "\t\t\t_UNUSED_CODE, /* 11             */\n");
1300		out($f, "\t\t\t_UNUSED_CODE, /* 12             */\n");
1301		out($f, "\t\t\t_UNUSED_CODE, /* 13             */\n");
1302		out($f, "\t\t\t_UNUSED_CODE, /* 14             */\n");
1303		out($f, "\t\t\t_UNUSED_CODE, /* 15             */\n");
1304		out($f, "\t\t\t_CV_CODE      /* 16 = IS_CV     */\n");
1305		out($f, "\t\t};\n");
1306		out($f, "\t\treturn zend_opcode_handlers[opcode * 25 + zend_vm_decode[op->op1_type] * 5 + zend_vm_decode[op->op2_type]];\n");
1307		if (ZEND_VM_OLD_EXECUTOR) {
1308			out($f, "\t}\n");
1309		}
1310	}
1311	out($f, "}\n\n");
1312
1313	// Generate zend_vm_get_opcode_handler() function
1314	out($f, "ZEND_API void zend_vm_set_opcode_handler(zend_op* op)\n");
1315	out($f, "{\n");
1316	out($f, "\top->handler = zend_vm_get_opcode_handler(zend_user_opcodes[op->opcode], op);\n");
1317	out($f, "}\n\n");
1318
1319	// Export handlers and helpers
1320	if (count($export) > 0 &&
1321	    !ZEND_VM_OLD_EXECUTOR &&
1322	    ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
1323		out($f,"#undef OPLINE\n");
1324		out($f,"#undef DCL_OPLINE\n");
1325		out($f,"#undef USE_OPLINE\n");
1326		out($f,"#undef LOAD_OPLINE\n");
1327		out($f,"#undef SAVE_OPLINE\n");
1328		out($f,"#define OPLINE EX(opline)\n");
1329		out($f,"#define DCL_OPLINE\n");
1330		out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
1331		out($f,"#define LOAD_OPLINE()\n");
1332		out($f,"#define SAVE_OPLINE()\n");
1333		out($f,"#undef CHECK_EXCEPTION\n");
1334		out($f,"#undef HANDLE_EXCEPTION\n");
1335		out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
1336		out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
1337		out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
1338		out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
1339		out($f,"#undef ZEND_VM_CONTINUE\n");
1340		out($f,"#undef ZEND_VM_RETURN\n");
1341		out($f,"#undef ZEND_VM_ENTER\n");
1342		out($f,"#undef ZEND_VM_LEAVE\n");
1343		out($f,"#undef ZEND_VM_DISPATCH\n");
1344		out($f,"#undef ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL\n\n");
1345		out($f,"#define ZEND_VM_CONTINUE()   return 0\n");
1346		out($f,"#define ZEND_VM_RETURN()     return 1\n");
1347		out($f,"#define ZEND_VM_ENTER()      return 2\n");
1348		out($f,"#define ZEND_VM_LEAVE()      return 3\n");
1349		out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
1350		out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n\n");
1351	}
1352	foreach ($export as $dsk) {
1353		list($kind, $func, $name) = $dsk;
1354		out($f, "ZEND_API int $func(");
1355		if ($kind == "handler") {
1356			out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
1357			$code = $opcodes[$opnames[$name]]['code'];
1358		} else {
1359			$h = $helpers[$name];
1360			if ($h['param'] == null) {
1361				out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
1362			} else {
1363				out($f, $h['param']. ", ZEND_OPCODE_HANDLER_ARGS)\n");
1364			}
1365			$code = $h['code'];
1366		}
1367		$done = 0;
1368		if (ZEND_VM_OLD_EXECUTOR) {
1369			if ($kind == "handler") {
1370				out($f, "{\n\treturn ".$name."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1371				$done = 1;
1372			} else if ($helpers[$name]["param"] == null) {
1373				out($f, "{\n\treturn ".$name."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1374				$done = 1;
1375			}
1376		} else if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
1377			if ($kind == "handler") {
1378				$op = $opcodes[$opnames[$name]];
1379				if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
1380					out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1381					$done = 1;
1382				}
1383			} else if ($helpers[$name]["param"] == null) {
1384				$h = $helpers[$name];
1385				if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
1386					out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1387					$done = 1;
1388				}
1389			}
1390		}
1391		if (!$done) {
1392			gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
1393		}
1394	}
1395
1396	fclose($f);
1397	echo "zend_vm_execute.h generated successfully.\n";
1398}
1399
1400function usage() {
1401	echo("\nUsage: php zend_vm_gen.php [options]\n".
1402	     "\nOptions:".
1403	     "\n  --with-vm-kind=CALL|SWITCH|GOTO - select threading model (default is CALL)".
1404	     "\n  --without-specializer           - disable executor specialization".
1405	     "\n  --with-old-executor             - enable old executor".
1406	     "\n  --with-lines                    - enable #line directives".
1407	     "\n\n");
1408}
1409
1410// Parse arguments
1411for ($i = 1;  $i < $argc; $i++) {
1412	if (strpos($argv[$i],"--with-vm-kind=") === 0) {
1413		$kind = substr($argv[$i], strlen("--with-vm-kind="));
1414		switch ($kind) {
1415			case "CALL":
1416				define("ZEND_VM_KIND", ZEND_VM_KIND_CALL);
1417				break;
1418			case "SWITCH":
1419				define("ZEND_VM_KIND", ZEND_VM_KIND_SWITCH);
1420				break;
1421			case "GOTO":
1422				define("ZEND_VM_KIND", ZEND_VM_KIND_GOTO);
1423				break;
1424			default:
1425				echo("ERROR: Invalid vm kind '$kind'\n");
1426				usage();
1427				die();
1428		}
1429	} else if ($argv[$i] == "--without-specializer") {
1430	  // Disabling specialization
1431		define("ZEND_VM_SPEC", 0);
1432	} else if ($argv[$i] == "--with-old-executor") {
1433	  // Disabling code for old-style executor
1434		define("ZEND_VM_OLD_EXECUTOR", 1);
1435	} else if ($argv[$i] == "--with-lines") {
1436		// Enabling debugging using original zend_vm_def.h
1437		define("ZEND_VM_LINES", 1);
1438	} else if ($argv[$i] == "--help") {
1439		usage();
1440		exit();
1441	} else {
1442		echo("ERROR: Invalid option '".$argv[$i]."'\n");
1443		usage();
1444		die();
1445	}
1446}
1447
1448// Using defaults
1449if (!defined("ZEND_VM_KIND")) {
1450  // Using CALL threading by default
1451	define("ZEND_VM_KIND", ZEND_VM_KIND_CALL);
1452}
1453if (!defined("ZEND_VM_SPEC")) {
1454  // Using specialized executor by default
1455	define("ZEND_VM_SPEC", 1);
1456}
1457if (!defined("ZEND_VM_OLD_EXECUTOR")) {
1458  // Include old-style executor by default
1459	define("ZEND_VM_OLD_EXECUTOR", 0);
1460}
1461if (!defined("ZEND_VM_LINES")) {
1462  // Disabling #line directives
1463	define("ZEND_VM_LINES", 0);
1464}
1465
1466gen_vm(__DIR__ . "/zend_vm_def.h", __DIR__ . "/zend_vm_execute.skl");
1467
1468?>
1469