Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 469 lines (388 sloc) 15.379 kb
573b460 andigutmans Zend Library
andigutmans authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
8775a37 Felipe Pena - Year++
felipensp authored
5 | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
573b460 andigutmans Zend Library
andigutmans authored
6 +----------------------------------------------------------------------+
d863d52 Update headers.
Sebastian Bergmann authored
7 | This source file is subject to version 2.00 of the Zend license, |
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff updating license information in the headers.
James Cox authored
9 | available through the world-wide-web at the following url: |
d863d52 Update headers.
Sebastian Bergmann authored
10 | http://www.zend.com/license/2_00.txt. |
b5b1117 Zeev Suraski License update
zsuraski authored
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
573b460 andigutmans Zend Library
andigutmans authored
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
20 /* $Id$ */
b5b1117 Zeev Suraski License update
zsuraski authored
21
a617217 Replace macros which begin with an underscore through an appropiately
Sascha Schumann authored
22 #ifndef ZEND_EXECUTE_H
23 #define ZEND_EXECUTE_H
573b460 andigutmans Zend Library
andigutmans authored
24
25 #include "zend_compile.h"
26 #include "zend_hash.h"
51b9245 andigutmans - More object junk
andigutmans authored
27 #include "zend_operators.h"
637a404 - MFH as discussed
Marcus Boerger authored
28 #include "zend_variables.h"
573b460 andigutmans Zend Library
andigutmans authored
29
1250c43 Zeev Suraski * Add struct name to all typedef's so that they can be debugged with MSV...
zsuraski authored
30 typedef union _temp_variable {
573b460 andigutmans Zend Library
andigutmans authored
31 zval tmp_var;
4fff038 andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
32 struct {
33 zval **ptr_ptr;
b56fd46 andigutmans - First part of the patch which makes reads use ptr and not ptr_ptr.
andigutmans authored
34 zval *ptr;
3a42bab Zeev Suraski Fix behavior of return-by-reference functions. Remove erroneous warning...
zsuraski authored
35 zend_bool fcall_returned_reference;
4fff038 andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
36 } var;
21f0964 andigutmans - Hopefully fix bug #26696.
andigutmans authored
37 struct {
68e154b reduced size of temp_variariable
Dmitry Stogov authored
38 zval **ptr_ptr; /* shared with var.ptr_ptr */
21f0964 andigutmans - Hopefully fix bug #26696.
andigutmans authored
39 zval *str;
40 zend_uint offset;
41 } str_offset;
e470e22 - Fixed bug #35106 (nested foreach fails when array variable has a refer...
Dmitry Stogov authored
42 struct {
68e154b reduced size of temp_variariable
Dmitry Stogov authored
43 zval **ptr_ptr; /* shared with var.ptr_ptr */
44 zval *ptr; /* shared with var.ptr */
e470e22 - Fixed bug #35106 (nested foreach fails when array variable has a refer...
Dmitry Stogov authored
45 HashPointer fe_pos;
46 } fe;
e94e3e1 Zeev Suraski Some cleanup
zsuraski authored
47 zend_class_entry *class_entry;
573b460 andigutmans Zend Library
andigutmans authored
48 } temp_variable;
49
50
0450ab9 Zeev Suraski MFZE1 (Expose more C++ APIs)
zsuraski authored
51 BEGIN_EXTERN_C()
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
52 struct _zend_fcall_info;
2c254ba Zeev Suraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
53 ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
54 ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
573b460 andigutmans Zend Library
andigutmans authored
55
b4f3b9d Zeev Suraski Redesigned thread safety mechanism - nua nua
zsuraski authored
56 void init_executor(TSRMLS_D);
2c254ba Zeev Suraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
57 void shutdown_executor(TSRMLS_D);
0cd2da0 - Execute destructors earlier (Florian Schaper, fschaper at intux org)
Marcus Boerger authored
58 void shutdown_destructors(TSRMLS_D);
c9709bf Nikita Popov Remove asterix modifier (*) for generators
nikic authored
59 zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC);
2c254ba Zeev Suraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
60 ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
f627be5 Nikita Popov Add support for executing a zend_execute_data
nikic authored
61 ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC);
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
62 ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
573b460 andigutmans Zend Library
andigutmans authored
63 ZEND_API int zend_is_true(zval *op);
3df0288 Improove debug capabilities
Marcus Boerger authored
64 #define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
65 static zend_always_inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
66 {
2c254ba Zeev Suraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
67 TSRMLS_FETCH();
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
68
69 if (p!=EG(uninitialized_zval_ptr)) {
3df0288 Improove debug capabilities
Marcus Boerger authored
70 FREE_ZVAL_REL(p);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
71 }
72 }
6c810b0 Improved memory usage by movig constants to read only memory. (Dmitry, P...
Dmitry Stogov authored
73 ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
94dd837 Changed the structure of op_array.opcodes. The constant values are moved...
Dmitry Stogov authored
74 ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
b4f3b9d Zeev Suraski Redesigned thread safety mechanism - nua nua
zsuraski authored
75 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
d553002 MFH: Added zend_eval_stringl and made create_function(), etc. binary-saf...
Matt Wilmas authored
76 ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *string_name TSRMLS_DC);
d3473d1 - Provide a unified way to display uncaught exceptions, which shows
Marcus Boerger authored
77 ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
d553002 MFH: Added zend_eval_stringl and made create_function(), etc. binary-saf...
Matt Wilmas authored
78 ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
6608f07 Stanislav Malyshev Mega-commit: Enter the new object model
smalyshev authored
79
0e24a7c - Strip out the typehint *checks* only. They are still parsed, and they ...
Derick Rethans authored
80 ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, const char **class_name, zend_class_entry **pce TSRMLS_DC);
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored
81 ZEND_API int zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind TSRMLS_DC);
0e24a7c - Strip out the typehint *checks* only. They are still parsed, and they ...
Derick Rethans authored
82
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
83 static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
84 {
85 if (!Z_DELREF_P(zval_ptr)) {
86 TSRMLS_FETCH();
87
88 if (zval_ptr != &EG(uninitialized_zval)) {
89 GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
90 zval_dtor(zval_ptr);
91 efree_rel(zval_ptr);
92 }
93 } else {
94 TSRMLS_FETCH();
95
96 if (Z_REFCOUNT_P(zval_ptr) == 1) {
97 Z_UNSET_ISREF_P(zval_ptr);
98 }
99
100 GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
101 }
102 }
103
104 static zend_always_inline int i_zend_is_true(zval *op)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
105 {
106 int result;
107
637a404 - MFH as discussed
Marcus Boerger authored
108 switch (Z_TYPE_P(op)) {
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
109 case IS_NULL:
110 result = 0;
111 break;
112 case IS_LONG:
113 case IS_BOOL:
114 case IS_RESOURCE:
637a404 - MFH as discussed
Marcus Boerger authored
115 result = (Z_LVAL_P(op)?1:0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
116 break;
117 case IS_DOUBLE:
637a404 - MFH as discussed
Marcus Boerger authored
118 result = (Z_DVAL_P(op) ? 1 : 0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
119 break;
120 case IS_STRING:
637a404 - MFH as discussed
Marcus Boerger authored
121 if (Z_STRLEN_P(op) == 0
122 || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
123 result = 0;
124 } else {
125 result = 1;
126 }
127 break;
128 case IS_ARRAY:
637a404 - MFH as discussed
Marcus Boerger authored
129 result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
130 break;
131 case IS_OBJECT:
97e7ce7 Stanislav Malyshev fix the fix
smalyshev authored
132 if(IS_ZEND_STD_OBJECT(*op)) {
f9c6520 Stanislav Malyshev Fix object true value: if we are in compat mode and it's Zend object -
smalyshev authored
133 TSRMLS_FETCH();
9d1f2f3 Fixed bug #34199 (if($obj)/if(!$obj) inconsistency)
Dmitry Stogov authored
134
135 if (Z_OBJ_HT_P(op)->cast_object) {
136 zval tmp;
637a404 - MFH as discussed
Marcus Boerger authored
137 if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL TSRMLS_CC) == SUCCESS) {
9d1f2f3 Fixed bug #34199 (if($obj)/if(!$obj) inconsistency)
Dmitry Stogov authored
138 result = Z_LVAL(tmp);
139 break;
140 }
141 } else if (Z_OBJ_HT_P(op)->get) {
142 zval *tmp = Z_OBJ_HT_P(op)->get(op TSRMLS_CC);
143 if(Z_TYPE_P(tmp) != IS_OBJECT) {
144 /* for safety - avoid loop */
145 convert_to_boolean(tmp);
146 result = Z_LVAL_P(tmp);
147 zval_ptr_dtor(&tmp);
148 break;
149 }
150 }
f9c6520 Stanislav Malyshev Fix object true value: if we are in compat mode and it's Zend object -
smalyshev authored
151 }
2b10c53 Felipe Pena MFH: Dropped zend.ze1_compatibility_mode
felipensp authored
152 result = 1;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
153 break;
154 default:
155 result = 0;
156 break;
157 }
158 return result;
159 }
160
d76cf1d Zeev Suraski More TSRMLS_FETCH work
zsuraski authored
161 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
79d2aaf Felipe Pena - Fixed bug #51905 (ReflectionParameter fails if default value is an arr...
felipensp authored
162 ZEND_API int zval_update_constant_inline_change(zval **pp, void *arg TSRMLS_DC);
163 ZEND_API int zval_update_constant_no_inline_change(zval **pp, void *arg TSRMLS_DC);
dcf2490 Johannes Schlüter - MFH: Fix #38465 (ReflectionParameter fails if default value is an acce...
johannes authored
164 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC);
573b460 andigutmans Zend Library
andigutmans authored
165
39a7f4c Zeev Suraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
166 /* dedicated Zend executor functions - do not use! */
d3efe97 Reduced initial VM stack size to fit into zend_mm segment and eliminate ...
Dmitry Stogov authored
167 #define ZEND_VM_STACK_PAGE_SIZE ((16 * 1024) - 16)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
168
169 struct _zend_vm_stack {
170 void **top;
171 void **end;
172 zend_vm_stack prev;
173 };
174
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
175 #define ZEND_VM_STACK_ELEMETS(stack) \
176 ((void**)(((char*)(stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(struct _zend_vm_stack))))
177
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
178 #define ZEND_VM_STACK_GROW_IF_NEEDED(count) \
179 do { \
c33db5c Fixed warning
Dmitry Stogov authored
180 if (UNEXPECTED((count) > \
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
181 EG(argument_stack)->end - EG(argument_stack)->top)) { \
c33db5c Fixed warning
Dmitry Stogov authored
182 zend_vm_stack_extend((count) TSRMLS_CC); \
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
183 } \
184 } while (0)
185
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
186 static zend_always_inline zend_vm_stack zend_vm_stack_new_page(int count) {
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
187 zend_vm_stack page = (zend_vm_stack)emalloc(ZEND_MM_ALIGNED_SIZE(sizeof(*page)) + sizeof(void*) * count);
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
188
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
189 page->top = ZEND_VM_STACK_ELEMETS(page);
190 page->end = page->top + count;
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
191 page->prev = NULL;
192 return page;
193 }
194
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
195 static zend_always_inline void zend_vm_stack_init(TSRMLS_D)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
196 {
197 EG(argument_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE);
198 }
199
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
200 static zend_always_inline void zend_vm_stack_destroy(TSRMLS_D)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
201 {
202 zend_vm_stack stack = EG(argument_stack);
203
204 while (stack != NULL) {
205 zend_vm_stack p = stack->prev;
206 efree(stack);
207 stack = p;
208 }
209 }
210
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
211 static zend_always_inline void zend_vm_stack_extend(int count TSRMLS_DC)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
212 {
213 zend_vm_stack p = zend_vm_stack_new_page(count >= ZEND_VM_STACK_PAGE_SIZE ? count : ZEND_VM_STACK_PAGE_SIZE);
214 p->prev = EG(argument_stack);
215 EG(argument_stack) = p;
216 }
217
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
218 static zend_always_inline void **zend_vm_stack_top(TSRMLS_D)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
219 {
220 return EG(argument_stack)->top;
221 }
222
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
223 static zend_always_inline void zend_vm_stack_push(void *ptr TSRMLS_DC)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
224 {
225 ZEND_VM_STACK_GROW_IF_NEEDED(1);
226 *(EG(argument_stack)->top++) = ptr;
227 }
228
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
229 static zend_always_inline void zend_vm_stack_push_nocheck(void *ptr TSRMLS_DC)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
230 {
231 *(EG(argument_stack)->top++) = ptr;
232 }
233
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
234 static zend_always_inline void *zend_vm_stack_pop(TSRMLS_D)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
235 {
236 void *el = *(--EG(argument_stack)->top);
237
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
238 if (UNEXPECTED(EG(argument_stack)->top == ZEND_VM_STACK_ELEMETS(EG(argument_stack)))) {
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
239 zend_vm_stack p = EG(argument_stack);
240 EG(argument_stack) = p->prev;
241 efree(p);
242 }
243 return el;
244 }
245
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
246 static zend_always_inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
247 {
248 void *ret;
249
250 size = (size + (sizeof(void*) - 1)) / sizeof(void*);
251
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
252 /* the following comparison must be optimized out at compile time */
253 if (ZEND_MM_ALIGNMENT > sizeof(void*)) {
254 int extra = (ZEND_MM_ALIGNMENT - ((zend_uintptr_t)EG(argument_stack)->top & (ZEND_MM_ALIGNMENT - 1))) / sizeof(void*);
255
256 if (UNEXPECTED(size + extra + ZEND_MM_ALIGNED_SIZE(sizeof(void*)) / sizeof(void*) >
694a72c Fixed bug #50723 (Bug in garbage collector causes crash)
Dmitry Stogov authored
257 (zend_uintptr_t)(EG(argument_stack)->end - EG(argument_stack)->top))) {
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
258 zend_vm_stack_extend(size TSRMLS_CC);
259 } else {
260 void **old_top = EG(argument_stack)->top;
261
262 EG(argument_stack)->top += extra;
263 /* store old top on the stack */
264 *EG(argument_stack)->top = (void*)old_top;
265 EG(argument_stack)->top += ZEND_MM_ALIGNED_SIZE(sizeof(void*)) / sizeof(void*);
266 }
267 } else {
268 ZEND_VM_STACK_GROW_IF_NEEDED((int)size);
269 }
e0ca3b2 Fixed types
Dmitry Stogov authored
270 ret = (void*)EG(argument_stack)->top;
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
271 EG(argument_stack)->top += size;
272 return ret;
273 }
274
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
275 static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC)
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
276 {
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
277 if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) {
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
278 zend_vm_stack p = EG(argument_stack);
279
280 EG(argument_stack) = p->prev;
281 efree(p);
282 } else {
e0ca3b2 Fixed types
Dmitry Stogov authored
283 EG(argument_stack)->top = (void**)ptr;
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
284 }
285 }
286
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
287 static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC)
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
288 {
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
289 if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) {
290 zend_vm_stack p = EG(argument_stack);
291
292 EG(argument_stack) = p->prev;
293 efree(p);
294 } else {
295 /* the following comparison must be optimized out at compile time */
296 if (ZEND_MM_ALIGNMENT > sizeof(void*)) {
297 ptr = (void*)(((char*)ptr) - ZEND_MM_ALIGNED_SIZE(sizeof(void*)));
298 EG(argument_stack)->top = *(void***)ptr;
299 } else {
300 EG(argument_stack)->top = (void**)ptr;
301 }
302 }
303 }
304
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
305 static zend_always_inline void** zend_vm_stack_push_args(int count TSRMLS_DC)
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
306 {
307
531e253 Stanislav Malyshev Use zend_execute_internal always to call internal functions
smalyshev authored
308 if (UNEXPECTED(EG(argument_stack)->top - ZEND_VM_STACK_ELEMETS(EG(argument_stack)) < count) ||
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
309 UNEXPECTED(EG(argument_stack)->top == EG(argument_stack)->end)) {
310 zend_vm_stack p = EG(argument_stack);
311
312 zend_vm_stack_extend(count + 1 TSRMLS_CC);
313
314 EG(argument_stack)->top += count;
315 *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count;
316 while (count-- > 0) {
317 void *data = *(--p->top);
318
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
319 if (UNEXPECTED(p->top == ZEND_VM_STACK_ELEMETS(p))) {
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
320 zend_vm_stack r = p;
321
322 EG(argument_stack)->prev = p->prev;
323 p = p->prev;
324 efree(r);
325 }
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
326 *(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + count) = data;
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
327 }
328 return EG(argument_stack)->top++;
329 }
330 *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count;
331 return EG(argument_stack)->top++;
332 }
333
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
334 static zend_always_inline void zend_vm_stack_clear_multiple(TSRMLS_D)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
335 {
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
336 void **p = EG(argument_stack)->top - 1;
e1814f0 WIN64 support
Dmitry Stogov authored
337 int delete_count = (int)(zend_uintptr_t) *p;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
338
339 while (--delete_count>=0) {
8df40bd Keeping consistent arg_stack during arguments freeing (Exception from de...
Dmitry Stogov authored
340 zval *q = *(zval **)(--p);
341 *p = NULL;
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
342 i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
343 }
4016bfc Fixed bug #46074 (Bus error during running PHP CLI under IRIX 6.5.30)
Dmitry Stogov authored
344 zend_vm_stack_free_int(p TSRMLS_CC);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
345 }
346
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
347 static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
348 {
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
349 void **p = EG(current_execute_data)->prev_execute_data->function_state.arguments;
e1814f0 WIN64 support
Dmitry Stogov authored
350 int arg_count = (int)(zend_uintptr_t) *p;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
351
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
352 if (UNEXPECTED(requested_arg > arg_count)) {
353 return NULL;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
354 }
0b68251 Changed EG(argument_stack) implementation.
Dmitry Stogov authored
355 return (zval**)p - arg_count + requested_arg - 1;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
356 }
39a7f4c Zeev Suraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
357
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
358 static zend_always_inline void zend_arg_types_stack_2_pop(zend_ptr_stack *stack, zval **object, zend_function **fbc)
85b9327 Arnaud Le Blanc MFH: better fix for #48409 , #48428 , #48228
arnaud-lb authored
359 {
360 void *a, *b;
361
362 zend_ptr_stack_2_pop(stack, &a, &b);
363
ba79cd5 pierrejoye - fix build (void alarm)
pierrejoye authored
364 *object = (zval *) a;
365 *fbc = (zend_function *) b;
85b9327 Arnaud Le Blanc MFH: better fix for #48409 , #48428 , #48228
arnaud-lb authored
366 }
367
453b49e Added a number of small performance tweaks and optimizations
Dmitry Stogov authored
368 static zend_always_inline void zend_arg_types_stack_3_pop(zend_ptr_stack *stack, zend_class_entry **called_scope, zval **object, zend_function **fbc)
85b9327 Arnaud Le Blanc MFH: better fix for #48409 , #48428 , #48228
arnaud-lb authored
369 {
370 void *a, *b, *c;
371
372 zend_ptr_stack_3_pop(stack, &a, &b, &c);
373
ba79cd5 pierrejoye - fix build (void alarm)
pierrejoye authored
374 *called_scope = (zend_class_entry *) a;
375 *object = (zval *) b;
376 *fbc = (zend_function *) c;
85b9327 Arnaud Le Blanc MFH: better fix for #48409 , #48428 , #48228
arnaud-lb authored
377 }
378
b4f3b9d Zeev Suraski Redesigned thread safety mechanism - nua nua
zsuraski authored
379 void execute_new_code(TSRMLS_D);
573b460 andigutmans Zend Library
andigutmans authored
380
381
382 /* services */
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored
383 ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC);
384 ZEND_API const char *get_active_function_name(TSRMLS_D);
385 ZEND_API const char *zend_get_executed_filename(TSRMLS_D);
2c254ba Zeev Suraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
386 ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
4187439 Zeev Suraski More TSRMLS_FETCH work
zsuraski authored
387 ZEND_API zend_bool zend_is_executing(TSRMLS_D);
573b460 andigutmans Zend Library
andigutmans authored
388
6c15837 Rasmus Lerdorf exit_on_timeout patch
rlerdorf authored
389 ZEND_API void zend_set_timeout(long seconds, int reset_signals);
4187439 Zeev Suraski More TSRMLS_FETCH work
zsuraski authored
390 ZEND_API void zend_unset_timeout(TSRMLS_D);
b72a273 andigutmans - Forgot ZEND_API
andigutmans authored
391 ZEND_API void zend_timeout(int dummy);
6c810b0 Improved memory usage by movig constants to read only memory. (Dmitry, P...
Dmitry Stogov authored
392 ZEND_API zend_class_entry *zend_fetch_class(const char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
94dd837 Changed the structure of op_array.opcodes. The constant values are moved...
Dmitry Stogov authored
393 ZEND_API zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC);
c5d8422 Zeev Suraski Reinstate early-binding for classes.
zsuraski authored
394 void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
84eb48f Zeev Suraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
395
ef0bd3d Zeev Suraski - Move timeout code to Zend
zsuraski authored
396 #ifdef ZEND_WIN32
226c56f MFH: Fixed compiler warnings
Jani Taskinen authored
397 void zend_init_timeout_thread(void);
398 void zend_shutdown_timeout_thread(void);
84eb48f Zeev Suraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
399 #define WM_REGISTER_ZEND_TIMEOUT (WM_USER+1)
400 #define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2)
ef0bd3d Zeev Suraski - Move timeout code to Zend
zsuraski authored
401 #endif
402
573b460 andigutmans Zend Library
andigutmans authored
403 #define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
404 #define zendi_zval_dtor(p) zval_dtor(&(p))
405
406 #define active_opline (*EG(opline_ptr))
407
e8214a3 andigutmans - Commit Marcus' cleanup of abstract and static inheritance and improve
andigutmans authored
408 /* The following tries to resolve the classname of a zval of type object.
409 * Since it is slow it should be only used in error messages.
410 */
637a404 - MFH as discussed
Marcus Boerger authored
411 #define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : "")
e8214a3 andigutmans - Commit Marcus' cleanup of abstract and static inheritance and improve
andigutmans authored
412
cf7384a Felipe Pena - MFH: Constness (Added const qualifier to several function parameters)
felipensp authored
413 ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, zend_uint var);
8838c0f andigutmans - Two new API calls for Derick (retreive CV name and value) by Dmitry
andigutmans authored
414
84b96e9 Fix so that extensions like xdebug, can overload opcodes in all executio...
Dmitry Stogov authored
415 #define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
416 #define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
417 #define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */
f1ab855 Fixed ability to call user functions from user opcodes without recursion
Dmitry Stogov authored
418 #define ZEND_USER_OPCODE_ENTER 3 /* enter into new op_array without recursion */
419 #define ZEND_USER_OPCODE_LEAVE 4 /* return to calling op_array within the same executor */
84b96e9 Fix so that extensions like xdebug, can overload opcodes in all executio...
Dmitry Stogov authored
420
3c1a774 USER_OPCODE API is improvet.
Dmitry Stogov authored
421 #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
422
76a9a42 - Removed direct executor recursion.
Dmitry Stogov authored
423 ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler);
424 ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
84b96e9 Fix so that extensions like xdebug, can overload opcodes in all executio...
Dmitry Stogov authored
425
87c9e68 Stanislav Malyshev export zval getters
smalyshev authored
426 /* former zend_execute_locks.h */
427 typedef struct _zend_free_op {
428 zval* var;
429 /* int is_var; */
430 } zend_free_op;
431
94dd837 Changed the structure of op_array.opcodes. The constant values are moved...
Dmitry Stogov authored
432 ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
433 ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
87c9e68 Stanislav Malyshev export zval getters
smalyshev authored
434
61b9ded Export zend_do_fcall() helper from executor
Dmitry Stogov authored
435 ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
87c9e68 Stanislav Malyshev export zval getters
smalyshev authored
436
6233408 Nikita Popov Fix thread safe build
nikic authored
437 void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC);
4aab08b Nikita Popov Properly free resources when generator return value not used
nikic authored
438 void zend_free_compiled_variables(zval ***CVs, int num);
f169b26 Nikita Popov Fix backtraces and func_get_args()
nikic authored
439 void **zend_copy_arguments(void **arguments_end);
4aab08b Nikita Popov Properly free resources when generator return value not used
nikic authored
440
c5237d8 Added caches to eliminate repeatable run-time bindings of functions, cla...
Dmitry Stogov authored
441 #define CACHED_PTR(num) \
442 EG(active_op_array)->run_time_cache[(num)]
443
444 #define CACHE_PTR(num, ptr) do { \
445 EG(active_op_array)->run_time_cache[(num)] = (ptr); \
446 } while (0)
447
448 #define CACHED_POLYMORPHIC_PTR(num, ce) \
449 ((EG(active_op_array)->run_time_cache[(num)] == (ce)) ? \
450 EG(active_op_array)->run_time_cache[(num) + 1] : \
451 NULL)
452
453 #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
454 EG(active_op_array)->run_time_cache[(num)] = (ce); \
455 EG(active_op_array)->run_time_cache[(num) + 1] = (ptr); \
456 } while (0)
457
0450ab9 Zeev Suraski MFZE1 (Expose more C++ APIs)
zsuraski authored
458 END_EXTERN_C()
459
a617217 Replace macros which begin with an underscore through an appropiately
Sascha Schumann authored
460 #endif /* ZEND_EXECUTE_H */
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
461
462 /*
463 * Local variables:
464 * tab-width: 4
465 * c-basic-offset: 4
466 * indent-tabs-mode: t
467 * End:
468 */
Something went wrong with that request. Please try again.