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