xref: /PHP-5.4/Zend/zend_vm_gen.php (revision 716d2a39)
1<?php
2/*
3   +----------------------------------------------------------------------+
4   | Zend Engine                                                          |
5   +----------------------------------------------------------------------+
6   | Copyright (c) 1998-2014 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-2014 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, EX_Ts(), &free_op1, \\1)",
122	"TMP"    => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
123	"VAR"    => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
124	"CONST"  => "opline->op1.zv",
125	"UNUSED" => "NULL",
126	"CV"     => "_get_zval_ptr_cv_\\1(EX_CVs(), opline->op1.var TSRMLS_CC)",
127);
128
129$op2_get_zval_ptr = array(
130	"ANY"    => "get_zval_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \\1)",
131	"TMP"    => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
132	"VAR"    => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
133	"CONST"  => "opline->op2.zv",
134	"UNUSED" => "NULL",
135	"CV"     => "_get_zval_ptr_cv_\\1(EX_CVs(), 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, EX_Ts(), &free_op1, \\1)",
140	"TMP"    => "NULL",
141	"VAR"    => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
142	"CONST"  => "NULL",
143	"UNUSED" => "NULL",
144	"CV"     => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), 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, EX_Ts(), &free_op2, \\1)",
149	"TMP"    => "NULL",
150	"VAR"    => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
151	"CONST"  => "NULL",
152	"UNUSED" => "NULL",
153	"CV"     => "_get_zval_ptr_ptr_cv_\\1(EX_CVs(), 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, EX_Ts(), &free_op1, \\1)",
158	"TMP"    => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
159	"VAR"    => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &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(EX_CVs(), 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, EX_Ts(), &free_op2, \\1)",
167	"TMP"    => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
168	"VAR"    => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &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(EX_CVs(), 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, EX_Ts(), &free_op1, \\1)",
176	"TMP"    => "NULL",
177	"VAR"    => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &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(EX_CVs(), 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, EX_Ts(), &free_op2, \\1)",
185	"TMP"    => "NULL",
186	"VAR"    => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &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(EX_CVs(), 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(
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*\)/me",
395					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*[A-Za-z_]*\s*,\s*(.*)\s*\);/me",
396				),
397				array(
398					"execute_data",
399					"return \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)",
400					"'return '.helper_name('\\1',$spec,'$op1','$op2').'(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)'",
401					"'return '.helper_name('\\1',$spec,'$op1','$op2').'(\\2, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);'",
402				),
403				$code);
404			break;
405		case ZEND_VM_KIND_SWITCH:
406			$code = preg_replace(
407				array(
408					"/EXECUTE_DATA/m",
409					"/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m",
410					"/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/me",
411					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/me",
412				),
413				array(
414					"execute_data",
415					"goto \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_LABEL",
416					"'goto '.helper_name('\\1',$spec,'$op1','$op2')",
417					"'\\2 = \\3; goto '.helper_name('\\1',$spec,'$op1','$op2').';'",
418				),
419				$code);
420			break;
421		case ZEND_VM_KIND_GOTO:
422			$code = preg_replace(
423				array(
424					"/EXECUTE_DATA/m",
425					"/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m",
426					"/ZEND_VM_DISPATCH_TO_HELPER\(\s*([A-Za-z_]*)\s*\)/me",
427					"/ZEND_VM_DISPATCH_TO_HELPER_EX\(\s*([A-Za-z_]*)\s*,\s*([A-Za-z_]*)\s*,\s*(.*)\s*\);/me",
428				),
429				array(
430					"execute_data",
431					"goto \\1".($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER",
432					"'goto '.helper_name('\\1',$spec,'$op1','$op2')",
433					"'\\2 = \\3; goto '.helper_name('\\1',$spec,'$op1','$op2').';'",
434				),
435				$code);
436			break;
437	}
438
439	/* Remove unused free_op1 and free_op2 declarations */
440	if ($spec && preg_match_all('/^\s*zend_free_op\s+[^;]+;\s*$/me', $code, $matches, PREG_SET_ORDER)) {
441		$n = 0;
442		foreach ($matches as $match) {
443		  $code = preg_replace('/'.preg_quote($match[0],'/').'/', "\$D$n", $code);
444		  ++$n;
445		}
446		$del_free_op1 = (strpos($code, "free_op1") === false);
447		$del_free_op2 = (strpos($code, "free_op2") === false);
448		$n = 0;
449		foreach ($matches as $match) {
450			$dcl = $match[0];
451			$changed = 0;
452			if ($del_free_op1 && strpos($dcl, "free_op1") !== false) {
453				$dcl = preg_replace("/free_op1\s*,\s*/", "", $dcl);
454				$dcl = preg_replace("/free_op1\s*;/", ";", $dcl);
455				$changed = 1;
456			}
457			if ($del_free_op2 && strpos($dcl, "free_op2") !== false) {
458				$dcl = preg_replace("/free_op2\s*,\s*/", "", $dcl);
459				$dcl = preg_replace("/free_op2\s*;/", ";", $dcl);
460				$changed = 1;
461			}
462			if ($changed) {
463				$dcl = preg_replace("/,\s*;/", ";", $dcl);
464				$dcl = preg_replace("/zend_free_op\s*;/", "", $dcl);
465			}
466		  $code = preg_replace("/\\\$D$n/", $dcl, $code);
467		  ++$n;
468		}
469	}
470
471	/* Remove unnecessary ';' */
472	$code = preg_replace('/^\s*;\s*$/m', '', $code);
473
474	/* Remove WS */
475	$code = preg_replace('/[ \t]+\n/m', "\n", $code);
476
477	out($f, $code);
478}
479
480// Generates opcode handler
481function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno) {
482	global $definition_file, $prefix, $typecode, $opnames;
483
484	if (ZEND_VM_LINES) {
485		out($f, "#line $lineno \"$definition_file\"\n");
486	}
487
488	// Generate opcode handler's entry point according to selected threading model
489	switch($kind) {
490		case ZEND_VM_KIND_CALL:
491			out($f,"static int ZEND_FASTCALL  ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
492			break;
493		case ZEND_VM_KIND_SWITCH:
494			if ($spec) {
495				out($f,"case ".((string)($opnames[$name]*25+($typecode[$op1]*5)+$typecode[$op2])).": /*".$name."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER*/");
496			} else {
497				out($f,"case ".$name.":");
498			}
499			if ($use) {
500				// This handler is used by other handlers. We will add label to call it.
501				out($f," ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_LABEL:\n");
502			} else {
503				out($f,"\n");
504			}
505			break;
506		case ZEND_VM_KIND_GOTO:
507			out($f,$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."_HANDLER: ZEND_VM_GUARD(".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].");\n");
508			break;
509	}
510
511	// Generate opcode handler's code
512	gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name);
513}
514
515// Generates helper
516function gen_helper($f, $spec, $kind, $name, $op1, $op2, $param, $code, $lineno) {
517	global $definition_file, $prefix;
518
519	if (ZEND_VM_LINES) {
520		out($f, "#line $lineno \"$definition_file\"\n");
521	}
522
523	// Generate helper's entry point according to selected threading model
524	switch($kind) {
525		case ZEND_VM_KIND_CALL:
526			if ($param == null) {
527			  // Helper without parameters
528				out($f, "static int ZEND_FASTCALL ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."(ZEND_OPCODE_HANDLER_ARGS)\n");
529			} else {
530			  // Helper with parameter
531				out($f, "static int ZEND_FASTCALL ".$name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2]."(".$param.", ZEND_OPCODE_HANDLER_ARGS)\n");
532			}
533			break;
534		case ZEND_VM_KIND_SWITCH:
535			out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
536			break;
537		case ZEND_VM_KIND_GOTO:
538			out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
539			break;
540	}
541
542	// Generate helper's code
543	gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name);
544}
545
546// Generates array of opcode handlers (specialized or unspecialized)
547function gen_labels($f, $spec, $kind, $prolog) {
548	global $opcodes, $op_types, $prefix, $typecode;
549
550	$next = 0;
551	if ($spec) {
552	  // Emit labels for specialized executor
553
554	  // For each opcode in opcode number order
555		foreach($opcodes as $num => $dsc) {
556			while ($next != $num) {
557			  // If some opcode numbers are not used then fill hole with pointers
558			  // to handler of undefined opcode
559				$op1t = $op_types;
560				// For each op1.op_type except ANY
561				foreach($op1t as $op1) {
562					if ($op1 != "ANY") {
563						$op2t = $op_types;
564						// For each op2.op_type except ANY
565						foreach($op2t as $op2) {
566							if ($op2 != "ANY") {
567							  // Emit pointer to handler of undefined opcode
568								switch ($kind) {
569									case ZEND_VM_KIND_CALL:
570										out($f,$prolog."ZEND_NULL_HANDLER,\n");
571										break;
572									case ZEND_VM_KIND_SWITCH:
573										out($f,$prolog."(opcode_handler_t)-1,\n");
574										break;
575									case ZEND_VM_KIND_GOTO:
576										out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
577										break;
578								}
579							}
580						}
581					}
582				}
583				$next++;
584			}
585			$next = $num + 1;
586			$op1t = $op_types;
587			// For each op1.op_type except ANY
588			foreach($op1t as $op1) {
589				if ($op1 != "ANY") {
590					if (!isset($dsc["op1"][$op1])) {
591						// Try to use unspecialized handler
592						$op1 = "ANY";
593					}
594					$op2t = $op_types;
595					// For each op2.op_type except ANY
596					foreach($op2t as $op2) {
597						if ($op2 != "ANY") {
598							if (!isset($dsc["op2"][$op2])) {
599								// Try to use unspecialized handler
600								$op2 = "ANY";
601							}
602							// Check if specialized handler is defined
603							if (isset($dsc["op1"][$op1]) &&
604							    isset($dsc["op2"][$op2])) {
605							  // Emit pointer to specialized handler
606								switch ($kind) {
607									case ZEND_VM_KIND_CALL:
608										out($f,$prolog.$dsc["op"]."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER,\n");
609										break;
610									case ZEND_VM_KIND_SWITCH:
611										out($f,$prolog."(opcode_handler_t)".((string)($num*25+$typecode[$op1]*5+$typecode[$op2])).",\n");
612										break;
613									case ZEND_VM_KIND_GOTO:
614										out($f,$prolog."(opcode_handler_t)&&".$dsc["op"]."_SPEC".$prefix[$op1].$prefix[$op2]."_HANDLER,\n");
615										break;
616								}
617							} else {
618							  // Emit pinter to handler of undefined opcode
619								switch ($kind) {
620									case ZEND_VM_KIND_CALL:
621										out($f,$prolog."ZEND_NULL_HANDLER,\n");
622										break;
623									case ZEND_VM_KIND_SWITCH:
624										out($f,$prolog."(opcode_handler_t)-1,\n");
625										break;
626									case ZEND_VM_KIND_GOTO:
627										out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
628										break;
629								}
630							}
631						}
632					}
633				}
634			}
635		}
636	} else {
637	  // Emit labels for unspecialized executor
638
639	  // For each opcode in opcode number order
640		foreach($opcodes as $num => $dsc) {
641			while ($next != $num) {
642			  // If some opcode numbers are not used then fill hole with pointers
643			  // to handler of undefined opcode
644				switch ($kind) {
645					case ZEND_VM_KIND_CALL:
646						out($f,$prolog."ZEND_NULL_HANDLER,\n");
647						break;
648					case ZEND_VM_KIND_SWITCH:
649						out($f,$prolog."(opcode_handler_t)-1,\n");
650						break;
651					case ZEND_VM_KIND_GOTO:
652						out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER,\n");
653						break;
654				}
655				$next++;
656			}
657			$next = $num+1;
658		  // Emit pointer to unspecialized handler
659			switch ($kind) {
660				case ZEND_VM_KIND_CALL:
661					out($f,$prolog.$dsc["op"]."_HANDLER,\n");
662					break;
663				case ZEND_VM_KIND_SWITCH:
664					out($f,$prolog."(opcode_handler_t)".((string)$num).",\n");
665					break;
666				case ZEND_VM_KIND_GOTO:
667					out($f,$prolog."(opcode_handler_t)&&".$dsc["op"]."_HANDLER,\n");
668					break;
669			}
670		}
671	}
672
673	// Emit last handler's label (undefined opcode)
674	switch ($kind) {
675		case ZEND_VM_KIND_CALL:
676			out($f,$prolog."ZEND_NULL_HANDLER\n");
677			break;
678		case ZEND_VM_KIND_SWITCH:
679			out($f,$prolog."(opcode_handler_t)-1\n");
680			break;
681		case ZEND_VM_KIND_GOTO:
682			out($f,$prolog."(opcode_handler_t)&&ZEND_NULL_HANDLER\n");
683			break;
684	}
685}
686
687// Generates handler for undefined opcodes (CALL threading model)
688function gen_null_handler($f) {
689	static $done = 0;
690
691	// New and all executors with CALL threading model can use the same handler
692	// for undefined opcodes, do we emit code for it only once
693	if (!$done) {
694		$done = 1;
695		out($f,"static int ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
696		out($f,"{\n");
697		out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
698		out($f,"}\n\n");
699	}
700}
701
702// Generates all opcode handlers and helpers (specialized or unspecilaized)
703function gen_executor_code($f, $spec, $kind, $prolog) {
704	global $list, $opcodes, $helpers, $op_types;
705
706	if ($spec) {
707		// Produce specialized executor
708		$op1t = $op_types;
709		// for each op1.op_type
710		foreach($op1t as $op1) {
711			$op2t = $op_types;
712			// for each op2.op_type
713			foreach($op2t as $op2) {
714				// for each handlers in helpers in original order
715				foreach ($list as $lineno => $dsc) {
716					if (isset($dsc["handler"])) {
717						$num = $dsc["handler"];
718						// Check if handler accepts such types of operands (op1 and op2)
719						if (isset($opcodes[$num]["op1"][$op1]) &&
720						    isset($opcodes[$num]["op2"][$op2])) {
721						  // Generate handler code
722							gen_handler($f, 1, $kind, $opcodes[$num]["op"], $op1, $op2, isset($opcodes[$num]["use"]), $opcodes[$num]["code"], $lineno);
723						}
724					} else if (isset($dsc["helper"])) {
725						$num = $dsc["helper"];
726						// Check if handler accepts such types of operands (op1 and op2)
727						if (isset($helpers[$num]["op1"][$op1]) &&
728						    isset($helpers[$num]["op2"][$op2])) {
729						  // Generate helper code
730							gen_helper($f, 1, $kind, $num, $op1, $op2, $helpers[$num]["param"], $helpers[$num]["code"], $lineno);
731						}
732					} else {
733						var_dump($dsc);
734						die("??? $kind:$num\n");
735					}
736				}
737			}
738		}
739	} else {
740		// Produce unspecialized executor
741
742		// for each handlers in helpers in original order
743		foreach ($list as $lineno => $dsc) {
744			if (isset($dsc["handler"])) {
745				$num = $dsc["handler"];
746			  // Generate handler code
747				gen_handler($f, 0, $kind, $opcodes[$num]["op"], "ANY", "ANY", isset($opcodes[$num]["use"]), $opcodes[$num]["code"], $lineno);
748			} else if (isset($dsc["helper"])) {
749				$num = $dsc["helper"];
750			  // Generate helper code
751				gen_helper($f, 0, $kind, $num, "ANY", "ANY", $helpers[$num]["param"], $helpers[$num]["code"], $lineno);
752			} else {
753				var_dump($dsc);
754				die("??? $kind:$num\n");
755			}
756		}
757	}
758
759	if (ZEND_VM_LINES) {
760		// Reset #line directives
761		out_line($f);
762	}
763
764	// Generate handler for undefined opcodes
765	switch ($kind) {
766		case ZEND_VM_KIND_CALL:
767			gen_null_handler($f);
768			break;
769		case ZEND_VM_KIND_SWITCH:
770			out($f,"default:\n");
771			out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
772			break;
773		case ZEND_VM_KIND_GOTO:
774			out($f,"ZEND_NULL_HANDLER:\n");
775			out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
776			break;
777	}
778}
779
780function skip_blanks($f, $prolog, $epilog) {
781	if (trim($prolog) != "" || trim($epilog) != "") {
782		out($f, $prolog.$epilog);
783	}
784}
785
786// Generates executor from skeleton file and definition (specialized or unspecialized)
787function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, $old) {
788	global $params, $skeleton_file, $line_no;
789
790	$lineno      = 0;
791	foreach ($skl as $line) {
792	  // Skeleton file contains special markers in form %NAME% those are
793	  // substituted by custom code
794		if (preg_match("/(.*)[{][%]([A-Z_]*)[%][}](.*)/", $line, $m)) {
795			switch ($m[2]) {
796				case "DEFINES":
797					if (ZEND_VM_OLD_EXECUTOR && $spec) {
798						out($f,"static int zend_vm_old_executor = 0;\n\n");
799					}
800					out($f,"static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);\n\n");
801					switch ($kind) {
802						case ZEND_VM_KIND_CALL:
803							out($f,"\n");
804							out($f,"#undef OPLINE\n");
805							out($f,"#undef DCL_OPLINE\n");
806							out($f,"#undef USE_OPLINE\n");
807							out($f,"#undef LOAD_OPLINE\n");
808							out($f,"#undef SAVE_OPLINE\n");
809							out($f,"#define OPLINE EX(opline)\n");
810							out($f,"#define DCL_OPLINE\n");
811							out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
812							out($f,"#define LOAD_OPLINE()\n");
813							out($f,"#define SAVE_OPLINE()\n");
814							out($f,"#undef CHECK_EXCEPTION\n");
815							out($f,"#undef HANDLE_EXCEPTION\n");
816							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
817							out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
818							out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
819							out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
820							out($f,"#define LOAD_REGS()\n");
821							out($f,"#define ZEND_VM_CONTINUE()         return 0\n");
822							out($f,"#define ZEND_VM_RETURN()           return 1\n");
823							out($f,"#define ZEND_VM_ENTER()            return 2\n");
824							out($f,"#define ZEND_VM_LEAVE()            return 3\n");
825							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
826							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
827							out($f,"#undef EX\n");
828							out($f,"#define EX(element) execute_data->element\n\n");
829							out($f,"#undef EX_CV\n");
830							out($f,"#define EX_CV(var) EX(CVs)[var]\n");
831							out($f,"#undef EX_CVs\n");
832							out($f,"#define EX_CVs() EX(CVs)\n");
833							out($f,"#undef EX_T\n");
834							out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n");
835							out($f,"#undef EX_Ts\n");
836							out($f,"#define EX_Ts() EX(Ts)\n\n");
837							break;
838						case ZEND_VM_KIND_SWITCH:
839							out($f,"\n");
840							out($f,"#undef OPLINE\n");
841							out($f,"#undef DCL_OPLINE\n");
842							out($f,"#undef USE_OPLINE\n");
843							out($f,"#undef LOAD_OPLINE\n");
844							out($f,"#undef SAVE_OPLINE\n");
845							out($f,"#define OPLINE opline\n");
846							out($f,"#define DCL_OPLINE zend_op *opline;\n");
847							out($f,"#define USE_OPLINE\n");
848							out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
849							out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
850							out($f,"#undef CHECK_EXCEPTION\n");
851							out($f,"#undef HANDLE_EXCEPTION\n");
852							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
853							out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
854							out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
855							out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
856							out($f,"#define LOAD_REGS()                do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n");
857							out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
858							out($f,"#define ZEND_VM_RETURN()   EG(in_execution) = original_in_execution; return\n");
859							out($f,"#define ZEND_VM_ENTER()    op_array = EG(active_op_array); goto zend_vm_enter\n");
860							out($f,"#define ZEND_VM_LEAVE()    ZEND_VM_CONTINUE()\n");
861							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n");
862							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
863							out($f,"#undef EX\n");
864							out($f,"#define EX(element) execute_data->element\n\n");
865							out($f,"#undef EX_CV\n");
866							out($f,"#define EX_CV(var) CVs[var]\n");
867							out($f,"#undef EX_CVs\n");
868							out($f,"#define EX_CVs() CVs\n");
869							out($f,"#undef EX_T\n");
870							out($f,"#define EX_T(offset) T(offset)\n");
871							out($f,"#undef EX_Ts\n");
872							out($f,"#define EX_Ts() Ts\n\n");
873							break;
874						case ZEND_VM_KIND_GOTO:
875							out($f,"\n");
876							out($f,"#undef OPLINE\n");
877							out($f,"#undef DCL_OPLINE\n");
878							out($f,"#undef USE_OPLINE\n");
879							out($f,"#undef LOAD_OPLINE\n");
880							out($f,"#undef SAVE_OPLINE\n");
881							out($f,"#define OPLINE opline\n");
882							out($f,"#define DCL_OPLINE zend_op *opline;\n");
883							out($f,"#define USE_OPLINE\n");
884							out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
885							out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
886							out($f,"#undef CHECK_EXCEPTION\n");
887							out($f,"#undef HANDLE_EXCEPTION\n");
888							out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
889							if (ZEND_VM_SPEC) {
890								out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
891								out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
892								out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
893							} else {
894								out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
895								out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
896								out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
897							}
898
899							out($f,"#define LOAD_REGS()                do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n");
900							out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
901							out($f,"#define ZEND_VM_RETURN()   EG(in_execution) = original_in_execution; return\n");
902							out($f,"#define ZEND_VM_ENTER()    op_array = EG(active_op_array); goto zend_vm_enter\n");
903							out($f,"#define ZEND_VM_LEAVE()    ZEND_VM_CONTINUE()\n");
904							out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n");
905							out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
906							out($f,"#undef EX\n");
907							out($f,"#define EX(element) execute_data->element\n\n");
908							out($f,"#undef EX_CV\n");
909							out($f,"#define EX_CV(var) CVs[var]\n");
910							out($f,"#undef EX_CVs\n");
911							out($f,"#define EX_CVs() CVs\n");
912							out($f,"#undef EX_T\n");
913							out($f,"#define EX_T(offset) T(offset)\n\n");
914							out($f,"#undef EX_Ts\n");
915							out($f,"#define EX_Ts() Ts\n\n");
916							break;
917					}
918					break;
919				case "EXECUTOR_NAME":
920					out($f, $m[1].$executor_name.$m[3]."\n");
921					break;
922				case "HELPER_VARS":
923					if ($kind != ZEND_VM_KIND_CALL) {
924						out($f,$m[1]."temp_variable *Ts;\n");
925						out($f,$m[1]."zval ***CVs;\n");
926						if ($kind == ZEND_VM_KIND_SWITCH) {
927							out($f,$m[1]."opcode_handler_t dispatch_handler;\n");
928						}
929					  // Emit local variables those are used for helpers' parameters
930						foreach ($params as $param => $x) {
931							out($f,$m[1].$param.";\n");
932						}
933					} else {
934						skip_blanks($f, $m[1], $m[3]."\n");
935					}
936					break;
937				case "EXECUTION_STATUS":
938					if ($kind != ZEND_VM_KIND_GOTO) {
939						out($f, $m[1] . "zend_bool original_in_execution = EG(in_execution);\n");
940					} else {
941						out($f, $m[1] . "zend_bool original_in_execution = op_array? EG(in_execution) : 0;\n");
942					}
943					break;
944				case "INTERNAL_LABELS":
945					if ($kind == ZEND_VM_KIND_GOTO) {
946					  // Emit array of labels of opcode handlers and code for
947					  // zend_opcode_handlers initialization
948						$prolog = $m[1];
949						out($f,$prolog."if (op_array == NULL) {\n");
950						out($f,$prolog."\tstatic const opcode_handler_t labels[] = {\n");
951						gen_labels($f, $spec, $kind, $prolog."\t\t");
952						out($f,$prolog."\t};\n");
953						out($f,$prolog."\tzend_opcode_handlers = (opcode_handler_t*)labels;\n");
954						out($f,$prolog."\treturn;\n");
955						out($f,$prolog."}\n");
956					} else {
957						skip_blanks($f, $m[1], $m[3]);
958					}
959					break;
960				case "ZEND_VM_CONTINUE_LABEL":
961					if ($kind == ZEND_VM_KIND_CALL) {
962					  // Only SWITCH dispatch method use it
963						out($f,$m[1]."\tint ret;".$m[3]."\n");
964					} else if ($kind == ZEND_VM_KIND_SWITCH) {
965					  // Only SWITCH dispatch method use it
966						out($f,"zend_vm_continue:".$m[3]."\n");
967					} else {
968						skip_blanks($f, $m[1], $m[3]);
969					}
970					break;
971				case "ZEND_VM_DISPATCH":
972				  // Emit code that dispatches to opcode handler
973					switch ($kind) {
974						case ZEND_VM_KIND_CALL:
975							out($f, $m[1]."if ((ret = OPLINE->handler(execute_data TSRMLS_CC)) > 0)".$m[3]."\n");
976							break;
977						case ZEND_VM_KIND_SWITCH:
978							out($f, $m[1]."dispatch_handler = OPLINE->handler;\nzend_vm_dispatch:\n".$m[1]."switch ((int)dispatch_handler)".$m[3]."\n");
979							break;
980						case ZEND_VM_KIND_GOTO:
981							out($f, $m[1]."goto *(void**)(OPLINE->handler);".$m[3]."\n");
982							break;
983					}
984					break;
985				case "INTERNAL_EXECUTOR":
986					if ($kind == ZEND_VM_KIND_CALL) {
987					  // Executor is defined as a set of functions
988						out($f, $m[1]."switch (ret) {\n" .
989						        $m[1]."\tcase 1:\n" .
990						        $m[1]."\t\tEG(in_execution) = original_in_execution;\n".
991						        $m[1]."\t\treturn;\n".
992						        $m[1]."\tcase 2:\n" .
993						        $m[1]."\t\top_array = EG(active_op_array);\n".
994						        $m[1]."\t\tgoto zend_vm_enter;\n".
995						        $m[1]."\tcase 3:\n" .
996						        $m[1]."\t\texecute_data = EG(current_execute_data);\n".
997						        $m[1]."\tdefault:\n".
998						        $m[1]."\t\tbreak;\n".
999						        $m[1]."}".$m[3]."\n");
1000					} else {
1001					  // Emit executor code
1002						gen_executor_code($f, $spec, $kind, $m[1]);
1003					}
1004					break;
1005				case "EXTERNAL_EXECUTOR":
1006					if ($kind == ZEND_VM_KIND_CALL) {
1007					  // Unspecialized executor with CALL threading is the same as the
1008					  // old one, so we don't need to produce code twitch
1009						if (!$old || ZEND_VM_SPEC || (ZEND_VM_KIND != ZEND_VM_KIND_CALL)) {
1010							// Emit executor code
1011							gen_executor_code($f, $spec, $kind, $m[1]);
1012						}
1013					}
1014					break;
1015				case "INITIALIZER_NAME":
1016					out($f, $m[1].$initializer_name.$m[3]."\n");
1017					break;
1018				case "EXTERNAL_LABELS":
1019				  // Emit code that initializes zend_opcode_handlers array
1020					$prolog = $m[1];
1021					if ($kind == ZEND_VM_KIND_GOTO) {
1022					  // Labels are defined in the executor itself, so we call it
1023					  // with op_array NULL and it sets zend_opcode_handlers array
1024						out($f,$prolog."TSRMLS_FETCH();\n");
1025						out($f,$prolog."zend_execute(NULL TSRMLS_CC);\n");
1026					} else {
1027						if ($old) {
1028						  // Reserving space for user-defined opcodes
1029							out($f,$prolog."static opcode_handler_t labels[512] = {\n");
1030						} else {
1031							out($f,$prolog."static const opcode_handler_t labels[] = {\n");
1032						}
1033						gen_labels($f, $spec, $kind, $prolog."\t");
1034						out($f,$prolog."};\n");
1035						out($f,$prolog."zend_opcode_handlers = (opcode_handler_t*)labels;\n");
1036						if ($old) {
1037						  // Setup old executor
1038							out($f,$prolog."zend_vm_old_executor = 1;\n");
1039							out($f,$prolog."zend_execute = old_execute;\n");
1040						}
1041					}
1042					break;
1043				default:
1044					die("ERROR: Unknown keyword ".$m[2]." in skeleton file.\n");
1045			}
1046		} else {
1047		  // Copy the line as is
1048			out($f, $line);
1049		}
1050	}
1051}
1052
1053function gen_vm($def, $skel) {
1054	global $definition_file, $skeleton_file, $executor_file,
1055		$op_types, $list, $opcodes, $helpers, $params, $opnames;
1056
1057	// Load definition file
1058	$in = @file($def);
1059	if (!$in) {
1060		die("ERROR: Can not open definition file '$def'\n");
1061	}
1062	// We need absolute path to definition file to use it in #line directives
1063	$definition_file = realpath($def);
1064
1065	// Load skeleton file
1066	$skl = @file($skel);
1067	if (!$skl) {
1068		die("ERROR: Can not open skeleton file '$skel'\n");
1069	}
1070	// We need absolute path to skeleton file to use it in #line directives
1071	$skeleton_file = realpath($skel);
1072
1073	// Parse definition file into tree
1074	$lineno         = 0;
1075	$handler        = null;
1076	$helper         = null;
1077	$max_opcode_len = 0;
1078	$max_opcode     = 0;
1079	$export         = array();
1080	foreach ($in as $line) {
1081		++$lineno;
1082		if (strpos($line,"ZEND_VM_HANDLER(") === 0) {
1083		  // Parsing opcode handler's definition
1084			if (preg_match(
1085					"/^ZEND_VM_HANDLER\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*\)/",
1086					$line,
1087					$m) == 0) {
1088				die("ERROR ($def:$lineno): Invalid ZEND_VM_HANDLER definition.\n");
1089			}
1090			$code = (int)$m[1];
1091			$op   = $m[2];
1092			$len  = strlen($op);
1093			$op1  = array_flip(explode("|",$m[3]));
1094			$op2  = array_flip(explode("|",$m[4]));
1095
1096			if ($len > $max_opcode_len) {
1097				$max_opcode_len = $len;
1098			}
1099			if ($code > $max_opcode) {
1100				$max_opcode = $code;
1101			}
1102			if (isset($opcodes[$code])) {
1103				die("ERROR ($def:$lineno): Opcode with code '$code' is already defined.\n");
1104			}
1105			if (isset($opnames[$op])) {
1106				die("ERROR ($def:$lineno): Opcode with name '$op' is already defined.\n");
1107			}
1108			$opcodes[$code] = array("op"=>$op,"op1"=>$op1,"op2"=>$op2,"code"=>"");
1109			$opnames[$op] = $code;
1110			$handler = $code;
1111			$helper = null;
1112			$list[$lineno] = array("handler"=>$handler);
1113		} else if (strpos($line,"ZEND_VM_HELPER(") === 0) {
1114		  // Parsing helper's definition
1115			if (preg_match(
1116					"/^ZEND_VM_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*\)/",
1117					$line,
1118					$m) == 0) {
1119				die("ERROR ($def:$lineno): Invalid ZEND_VM_HELPER definition.\n");
1120			}
1121			$helper = $m[1];
1122			$op1    = array_flip(explode("|",$m[2]));
1123			$op2    = array_flip(explode("|",$m[3]));
1124			if (isset($helpers[$helper])) {
1125				die("ERROR ($def:$lineno): Helper with name '$helper' is already defined.\n");
1126			}
1127			$helpers[$helper] = array("op1"=>$op1,"op2"=>$op2,"param"=>null,"code"=>"");
1128			$handler = null;
1129			$list[$lineno] = array("helper"=>$helper);
1130		} else if (strpos($line,"ZEND_VM_HELPER_EX(") === 0) {
1131		  // Parsing helper with parameter definition
1132			if (preg_match(
1133					"/^ZEND_VM_HELPER_EX\(\s*([A-Za-z_]+)\s*,\s*([A-Z|]+)\s*,\s*([A-Z|]+)\s*,\s*(.*)\s*\)/",
1134					$line,
1135					$m) == 0) {
1136				die("ERROR ($def:$lineno): Invalid ZEND_VM_HELPER definition.\n");
1137			}
1138			$helper = $m[1];
1139			$op1    = array_flip(explode("|",$m[2]));
1140			$op2    = array_flip(explode("|",$m[3]));
1141			$param  = $m[4];
1142			if (isset($helpers[$helper])) {
1143				die("ERROR ($def:$lineno): Helper with name '$helper' is already defined.\n");
1144			}
1145
1146			// Store parameter
1147			$params[$param] = 1;
1148
1149			$helpers[$helper] = array("op1"=>$op1,"op2"=>$op2,"param"=>$param,"code"=>"");
1150			$handler = null;
1151			$list[$lineno] = array("helper"=>$helper);
1152		} else if (strpos($line,"ZEND_VM_EXPORT_HANDLER(") === 0) {
1153			if (preg_match(
1154					"/^ZEND_VM_EXPORT_HANDLER\(\s*([A-Za-z_]+)\s*,\s*([A-Z_]+)\s*\)/",
1155					$line,
1156					$m) == 0) {
1157				die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HANDLER definition.\n");
1158			}
1159			if (!isset($opnames[$m[2]])) {
1160				die("ERROR ($def:$lineno): opcode '{$m[2]}' is not defined.\n");
1161			}
1162			$export[] = array("handler",$m[1],$m[2]);
1163		} else if (strpos($line,"ZEND_VM_EXPORT_HELPER(") === 0) {
1164			if (preg_match(
1165					"/^ZEND_VM_EXPORT_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Za-z_]+)\s*\)/",
1166					$line,
1167					$m) == 0) {
1168				die("ERROR ($def:$lineno): Invalid ZEND_VM_EXPORT_HELPER definition.\n");
1169			}
1170			if (!isset($helpers[$m[2]])) {
1171				die("ERROR ($def:$lineno): helper '{$m[2]}' is not defined.\n");
1172			}
1173			$export[] = array("helper",$m[1],$m[2]);
1174		} else if ($handler !== null) {
1175		  // Add line of code to current opcode handler
1176			$opcodes[$handler]["code"] .= $line;
1177		} else if ($helper !== null) {
1178		  // Add line of code to current helper
1179			$helpers[$helper]["code"] .= $line;
1180		}
1181	}
1182
1183	ksort($opcodes);
1184
1185	// Search for opcode handlers those are used by other opcode handlers
1186	foreach ($opcodes as $dsc) {
1187		if (preg_match("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $m)) {
1188			$op = $m[1];
1189			if (!isset($opnames[$op])) {
1190				die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
1191			}
1192			$code = $opnames[$op];
1193			$opcodes[$code]['use'] = 1;
1194		}
1195	}
1196
1197	// Generate opcode #defines (zend_vm_opcodes.h)
1198	$code_len = strlen((string)$max_opcode);
1199	$f = fopen("zend_vm_opcodes.h", "w+") or die("ERROR: Cannot create zend_vm_opcodes.h\n");
1200
1201	// Insert header
1202	out($f, $GLOBALS['header_text']);
1203
1204	fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
1205	fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n\n");
1206
1207	foreach ($opcodes as $code => $dsc) {
1208		$code = str_pad((string)$code,$code_len," ",STR_PAD_LEFT);
1209		$op = str_pad($dsc["op"],$max_opcode_len);
1210		fputs($f,"#define $op $code\n");
1211	}
1212
1213	fputs($f, "\n#endif\n");
1214	fclose($f);
1215	echo "zend_vm_opcodes.h generated successfully.\n";
1216
1217	// zend_vm_opcodes.c
1218	$f = fopen("zend_vm_opcodes.c", "w+") or die("ERROR: Cannot create zend_vm_opcodes.c\n");
1219
1220	// Insert header
1221	out($f, $GLOBALS['header_text']);
1222	fputs($f,"#include <stdio.h>\n");
1223	fputs($f,"#include <zend.h>\n\n");
1224
1225	fputs($f,"const char *zend_vm_opcodes_map[".($max_opcode + 1)."] = {\n");
1226	for ($i = 0; $i <= $max_opcode; $i++) {
1227		fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
1228	}
1229	fputs($f, "};\n\n");
1230
1231    fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
1232    fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
1233    fputs($f, "}\n");
1234
1235	fclose($f);
1236	echo "zend_vm_opcodes.c generated successfully.\n";
1237
1238	// Generate zend_vm_execute.h
1239	$f = fopen("zend_vm_execute.h", "w+") or die("ERROR: Cannot create zend_vm_execute.h\n");
1240	$executor_file = realpath("zend_vm_execute.h");
1241
1242	// Insert header
1243	out($f, $GLOBALS['header_text']);
1244
1245	// Suppress free_op1 warnings on Windows
1246	out($f, "#ifdef ZEND_WIN32\n# pragma warning(once : 4101)\n#endif\n");
1247
1248	// Support for ZEND_USER_OPCODE
1249	out($f, "static user_opcode_handler_t zend_user_opcode_handlers[256] = {\n");
1250	for ($i = 0; $i < 255; ++$i) {
1251		out($f, "\t(user_opcode_handler_t)NULL,\n");
1252	}
1253	out($f, "\t(user_opcode_handler_t)NULL\n};\n\n");
1254
1255	out($f, "static zend_uchar zend_user_opcodes[256] = {");
1256	for ($i = 0; $i < 255; ++$i) {
1257		if ($i % 16 == 1) out($f, "\n\t");
1258		out($f, "$i,");
1259	}
1260	out($f, "255\n};\n\n");
1261
1262	// Generate specialized executor
1263	gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_KIND, "execute", "zend_init_opcodes_handlers", 0);
1264
1265	// Generate un-specialized executor
1266	if (ZEND_VM_OLD_EXECUTOR) {
1267		out($f,"\n/* Old executor */\n\n");
1268		out($f,"#undef EX\n");
1269		out($f,"#define EX(element) execute_data.element\n\n");
1270		out($f,"#undef EX_CV\n");
1271		out($f,"#define EX_CV(var) EX(CVs)[var]\n");
1272		out($f,"#undef EX_CVs\n");
1273		out($f,"#define EX_CVs() EX(CVs)\n");
1274		out($f,"#undef EX_T\n");
1275		out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n");
1276		out($f,"#undef ZEND_VM_CONTINUE\n\n");
1277		out($f,"#undef ZEND_VM_RETURN\n\n");
1278		out($f,"#undef ZEND_VM_ENTER\n\n");
1279		out($f,"#undef ZEND_VM_LEAVE\n\n");
1280		out($f,"#undef ZEND_VM_DISPATCH\n\n");
1281		out($f,"#undef ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL\n\n");
1282		gen_executor($f, $skl, 0, ZEND_VM_KIND_CALL, "old_execute", "zend_vm_use_old_executor", 1);
1283	}
1284
1285	// Generate zend_vm_get_opcode_handler() function
1286	out($f, "static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)\n");
1287	out($f, "{\n");
1288	if (!ZEND_VM_SPEC) {
1289		out($f, "\treturn zend_opcode_handlers[opcode];\n");
1290	} else {
1291		if (ZEND_VM_OLD_EXECUTOR) {
1292			out($f, "\tif (zend_vm_old_executor) {\n");
1293			out($f, "\t\treturn zend_opcode_handlers[opcode];\n");
1294			out($f, "\t} else {\n");
1295		}
1296		out($f, "\t\tstatic const int zend_vm_decode[] = {\n");
1297		out($f, "\t\t\t_UNUSED_CODE, /* 0              */\n");
1298		out($f, "\t\t\t_CONST_CODE,  /* 1 = IS_CONST   */\n");
1299		out($f, "\t\t\t_TMP_CODE,    /* 2 = IS_TMP_VAR */\n");
1300		out($f, "\t\t\t_UNUSED_CODE, /* 3              */\n");
1301		out($f, "\t\t\t_VAR_CODE,    /* 4 = IS_VAR     */\n");
1302		out($f, "\t\t\t_UNUSED_CODE, /* 5              */\n");
1303		out($f, "\t\t\t_UNUSED_CODE, /* 6              */\n");
1304		out($f, "\t\t\t_UNUSED_CODE, /* 7              */\n");
1305		out($f, "\t\t\t_UNUSED_CODE, /* 8 = IS_UNUSED  */\n");
1306		out($f, "\t\t\t_UNUSED_CODE, /* 9              */\n");
1307		out($f, "\t\t\t_UNUSED_CODE, /* 10             */\n");
1308		out($f, "\t\t\t_UNUSED_CODE, /* 11             */\n");
1309		out($f, "\t\t\t_UNUSED_CODE, /* 12             */\n");
1310		out($f, "\t\t\t_UNUSED_CODE, /* 13             */\n");
1311		out($f, "\t\t\t_UNUSED_CODE, /* 14             */\n");
1312		out($f, "\t\t\t_UNUSED_CODE, /* 15             */\n");
1313		out($f, "\t\t\t_CV_CODE      /* 16 = IS_CV     */\n");
1314		out($f, "\t\t};\n");
1315		out($f, "\t\treturn zend_opcode_handlers[opcode * 25 + zend_vm_decode[op->op1_type] * 5 + zend_vm_decode[op->op2_type]];\n");
1316		if (ZEND_VM_OLD_EXECUTOR) {
1317			out($f, "\t}\n");
1318		}
1319	}
1320	out($f, "}\n\n");
1321
1322	// Generate zend_vm_get_opcode_handler() function
1323	out($f, "ZEND_API void zend_vm_set_opcode_handler(zend_op* op)\n");
1324	out($f, "{\n");
1325	out($f, "\top->handler = zend_vm_get_opcode_handler(zend_user_opcodes[op->opcode], op);\n");
1326	out($f, "}\n\n");
1327
1328	// Export handlers and helpers
1329	if (count($export) > 0 &&
1330	    !ZEND_VM_OLD_EXECUTOR &&
1331	    ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
1332		out($f,"#undef OPLINE\n");
1333		out($f,"#undef DCL_OPLINE\n");
1334		out($f,"#undef USE_OPLINE\n");
1335		out($f,"#undef LOAD_OPLINE\n");
1336		out($f,"#undef SAVE_OPLINE\n");
1337		out($f,"#define OPLINE EX(opline)\n");
1338		out($f,"#define DCL_OPLINE\n");
1339		out($f,"#define USE_OPLINE zend_op *opline = EX(opline);\n");
1340		out($f,"#define LOAD_OPLINE()\n");
1341		out($f,"#define SAVE_OPLINE()\n");
1342		out($f,"#undef CHECK_EXCEPTION\n");
1343		out($f,"#undef HANDLE_EXCEPTION\n");
1344		out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
1345		out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
1346		out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
1347		out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
1348		out($f,"#undef EX\n");
1349		out($f,"#define EX(element) execute_data->element\n\n");
1350		out($f,"#undef EX_CV\n");
1351		out($f,"#define EX_CV(var) EX(CVs)[var]\n");
1352		out($f,"#undef EX_CVs\n");
1353		out($f,"#define EX_CVs() EX(CVs)\n");
1354		out($f,"#undef EX_T\n");
1355		out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n");
1356		out($f,"#undef ZEND_VM_CONTINUE\n");
1357		out($f,"#undef ZEND_VM_RETURN\n");
1358		out($f,"#undef ZEND_VM_ENTER\n");
1359		out($f,"#undef ZEND_VM_LEAVE\n");
1360		out($f,"#undef ZEND_VM_DISPATCH\n");
1361		out($f,"#undef ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL\n\n");
1362		out($f,"#define ZEND_VM_CONTINUE()   return 0\n");
1363		out($f,"#define ZEND_VM_RETURN()     return 1\n");
1364		out($f,"#define ZEND_VM_ENTER()      return 2\n");
1365		out($f,"#define ZEND_VM_LEAVE()      return 3\n");
1366		out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
1367		out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n\n");
1368	}
1369	foreach ($export as $dsk) {
1370		list($kind, $func, $name) = $dsk;
1371		out($f, "ZEND_API int $func(");
1372		if ($kind == "handler") {
1373			out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
1374			$code = $opcodes[$opnames[$name]]['code'];
1375		} else {
1376			$h = $helpers[$name];
1377			if ($h['param'] == null) {
1378				out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
1379			} else {
1380				out($f, $h['param']. ", ZEND_OPCODE_HANDLER_ARGS)\n");
1381			}
1382			$code = $h['code'];
1383		}
1384		$done = 0;
1385		if (ZEND_VM_OLD_EXECUTOR) {
1386			if ($kind == "handler") {
1387				out($f, "{\n\treturn ".$name."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1388				$done = 1;
1389			} else if ($helpers[$name]["param"] == null) {
1390				out($f, "{\n\treturn ".$name."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1391				$done = 1;
1392			}
1393		} else if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
1394			if ($kind == "handler") {
1395				$op = $opcodes[$opnames[$name]];
1396				if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
1397					out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1398					$done = 1;
1399				}
1400			} else if ($helpers[$name]["param"] == null) {
1401				$h = $helpers[$name];
1402				if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
1403					out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
1404					$done = 1;
1405				}
1406			}
1407		}
1408		if (!$done) {
1409			gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
1410		}
1411	}
1412
1413	fclose($f);
1414	echo "zend_vm_execute.h generated successfully.\n";
1415}
1416
1417function usage() {
1418	echo("\nUsage: php zend_vm_gen.php [options]\n".
1419	     "\nOptions:".
1420	     "\n  --with-vm-kind=CALL|SWITCH|GOTO - select threading model (default is CALL)".
1421	     "\n  --without-specializer           - disable executor specialization".
1422	     "\n  --with-old-executor             - enable old executor".
1423	     "\n  --with-lines                    - enable #line directives".
1424	     "\n\n");
1425}
1426
1427// Parse arguments
1428for ($i = 1;  $i < $argc; $i++) {
1429	if (strpos($argv[$i],"--with-vm-kind=") === 0) {
1430		$kind = substr($argv[$i], strlen("--with-vm-kind="));
1431		switch ($kind) {
1432			case "CALL":
1433				define("ZEND_VM_KIND", ZEND_VM_KIND_CALL);
1434				break;
1435			case "SWITCH":
1436				define("ZEND_VM_KIND", ZEND_VM_KIND_SWITCH);
1437				break;
1438			case "GOTO":
1439				define("ZEND_VM_KIND", ZEND_VM_KIND_GOTO);
1440				break;
1441			default:
1442				echo("ERROR: Invalid vm kind '$kind'\n");
1443				usage();
1444				die();
1445		}
1446	} else if ($argv[$i] == "--without-specializer") {
1447	  // Disabling specialization
1448		define("ZEND_VM_SPEC", 0);
1449	} else if ($argv[$i] == "--with-old-executor") {
1450	  // Disabling code for old-style executor
1451		define("ZEND_VM_OLD_EXECUTOR", 1);
1452	} else if ($argv[$i] == "--with-lines") {
1453		// Enabling debugging using original zend_vm_def.h
1454		define("ZEND_VM_LINES", 1);
1455	} else if ($argv[$i] == "--help") {
1456		usage();
1457		exit();
1458	} else {
1459		echo("ERROR: Invalid option '".$argv[$i]."'\n");
1460		usage();
1461		die();
1462	}
1463}
1464
1465// Using defaults
1466if (!defined("ZEND_VM_KIND")) {
1467  // Using CALL threading by default
1468	define("ZEND_VM_KIND", ZEND_VM_KIND_CALL);
1469}
1470if (!defined("ZEND_VM_SPEC")) {
1471  // Using specialized executor by default
1472	define("ZEND_VM_SPEC", 1);
1473}
1474if (!defined("ZEND_VM_OLD_EXECUTOR")) {
1475  // Include old-style executor by default
1476	define("ZEND_VM_OLD_EXECUTOR", 0);
1477}
1478if (!defined("ZEND_VM_LINES")) {
1479  // Disabling #line directives
1480	define("ZEND_VM_LINES", 0);
1481}
1482
1483gen_vm("zend_vm_def.h", "zend_vm_execute.skl");
1484
1485?>
1486