xref: /PHP-5.4/Zend/zend_vm_execute.skl (revision d92a89fe)
1{%DEFINES%}
2
3ZEND_API void {%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC)
4{
5	DCL_OPLINE
6	zend_execute_data *execute_data;
7	zend_bool nested = 0;
8	{%HELPER_VARS%}
9	{%EXECUTION_STATUS%}
10
11	{%INTERNAL_LABELS%}
12
13	if (EG(exception)) {
14		return;
15	}
16
17	EG(in_execution) = 1;
18
19zend_vm_enter:
20	/* Initialize execute_data */
21	execute_data = (zend_execute_data *)zend_vm_stack_alloc(
22		ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) +
23		ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) +
24		ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC);
25
26	EX(CVs) = (zval***)((char*)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)));
27	memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var);
28	EX(Ts) = (temp_variable *)(((char*)EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)));
29	EX(fbc) = NULL;
30	EX(called_scope) = NULL;
31	EX(object) = NULL;
32	EX(old_error_reporting) = NULL;
33	EX(op_array) = op_array;
34	EX(symbol_table) = EG(active_symbol_table);
35	EX(prev_execute_data) = EG(current_execute_data);
36	EG(current_execute_data) = execute_data;
37	EX(nested) = nested;
38	nested = 1;
39
40	LOAD_REGS();
41
42	if (!op_array->run_time_cache && op_array->last_cache_slot) {
43		op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
44	}
45
46	if (op_array->this_var != -1 && EG(This)) {
47 		Z_ADDREF_P(EG(This)); /* For $this pointer */
48		if (!EG(active_symbol_table)) {
49			EX_CV(op_array->this_var) = (zval**)EX_CVs() + (op_array->last_var + op_array->this_var);
50			*EX_CV(op_array->this_var) = EG(This);
51		} else {
52			if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void**)&EX_CV(op_array->this_var))==FAILURE) {
53				Z_DELREF_P(EG(This));
54			}
55		}
56	}
57
58	EX(opline) = UNEXPECTED((op_array->fn_flags & ZEND_ACC_INTERACTIVE) != 0) && EG(start_op) ? EG(start_op) : op_array->opcodes;
59	EG(opline_ptr) = &EX(opline);
60	LOAD_OPLINE();
61
62	EX(function_state).function = (zend_function *) op_array;
63	EX(function_state).arguments = NULL;
64
65	while (1) {
66    {%ZEND_VM_CONTINUE_LABEL%}
67#ifdef ZEND_WIN32
68		if (EG(timed_out)) {
69			zend_timeout(0);
70		}
71#endif
72
73		{%ZEND_VM_DISPATCH%} {
74			{%INTERNAL_EXECUTOR%}
75		}
76
77	}
78	zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen");
79}
80
81{%EXTERNAL_EXECUTOR%}
82
83void {%INITIALIZER_NAME%}(void)
84{
85  {%EXTERNAL_LABELS%}
86}
87