1/*
2   +----------------------------------------------------------------------+
3   | Zend Engine                                                          |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 2.00 of the Zend license,     |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.zend.com/license/2_00.txt.                                |
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.              |
14   +----------------------------------------------------------------------+
15   | Authors: Andi Gutmans <andi@zend.com>                                |
16   |          Zeev Suraski <zeev@zend.com>                                |
17   |          Dmitry Stogov <dmitry@zend.com>                             |
18   +----------------------------------------------------------------------+
19*/
20
21#ifdef ZEND_WIN32
22# pragma warning(once : 4101)
23# pragma warning(once : 6235)
24# pragma warning(once : 6237)
25# pragma warning(once : 6239)
26# pragma warning(once : 6240)
27# pragma warning(once : 6285)
28# pragma warning(once : 6286)
29# pragma warning(once : 6326)
30#endif
31static user_opcode_handler_t zend_user_opcode_handlers[256] = {
32    (user_opcode_handler_t)NULL,
33    (user_opcode_handler_t)NULL,
34    (user_opcode_handler_t)NULL,
35    (user_opcode_handler_t)NULL,
36    (user_opcode_handler_t)NULL,
37    (user_opcode_handler_t)NULL,
38    (user_opcode_handler_t)NULL,
39    (user_opcode_handler_t)NULL,
40    (user_opcode_handler_t)NULL,
41    (user_opcode_handler_t)NULL,
42    (user_opcode_handler_t)NULL,
43    (user_opcode_handler_t)NULL,
44    (user_opcode_handler_t)NULL,
45    (user_opcode_handler_t)NULL,
46    (user_opcode_handler_t)NULL,
47    (user_opcode_handler_t)NULL,
48    (user_opcode_handler_t)NULL,
49    (user_opcode_handler_t)NULL,
50    (user_opcode_handler_t)NULL,
51    (user_opcode_handler_t)NULL,
52    (user_opcode_handler_t)NULL,
53    (user_opcode_handler_t)NULL,
54    (user_opcode_handler_t)NULL,
55    (user_opcode_handler_t)NULL,
56    (user_opcode_handler_t)NULL,
57    (user_opcode_handler_t)NULL,
58    (user_opcode_handler_t)NULL,
59    (user_opcode_handler_t)NULL,
60    (user_opcode_handler_t)NULL,
61    (user_opcode_handler_t)NULL,
62    (user_opcode_handler_t)NULL,
63    (user_opcode_handler_t)NULL,
64    (user_opcode_handler_t)NULL,
65    (user_opcode_handler_t)NULL,
66    (user_opcode_handler_t)NULL,
67    (user_opcode_handler_t)NULL,
68    (user_opcode_handler_t)NULL,
69    (user_opcode_handler_t)NULL,
70    (user_opcode_handler_t)NULL,
71    (user_opcode_handler_t)NULL,
72    (user_opcode_handler_t)NULL,
73    (user_opcode_handler_t)NULL,
74    (user_opcode_handler_t)NULL,
75    (user_opcode_handler_t)NULL,
76    (user_opcode_handler_t)NULL,
77    (user_opcode_handler_t)NULL,
78    (user_opcode_handler_t)NULL,
79    (user_opcode_handler_t)NULL,
80    (user_opcode_handler_t)NULL,
81    (user_opcode_handler_t)NULL,
82    (user_opcode_handler_t)NULL,
83    (user_opcode_handler_t)NULL,
84    (user_opcode_handler_t)NULL,
85    (user_opcode_handler_t)NULL,
86    (user_opcode_handler_t)NULL,
87    (user_opcode_handler_t)NULL,
88    (user_opcode_handler_t)NULL,
89    (user_opcode_handler_t)NULL,
90    (user_opcode_handler_t)NULL,
91    (user_opcode_handler_t)NULL,
92    (user_opcode_handler_t)NULL,
93    (user_opcode_handler_t)NULL,
94    (user_opcode_handler_t)NULL,
95    (user_opcode_handler_t)NULL,
96    (user_opcode_handler_t)NULL,
97    (user_opcode_handler_t)NULL,
98    (user_opcode_handler_t)NULL,
99    (user_opcode_handler_t)NULL,
100    (user_opcode_handler_t)NULL,
101    (user_opcode_handler_t)NULL,
102    (user_opcode_handler_t)NULL,
103    (user_opcode_handler_t)NULL,
104    (user_opcode_handler_t)NULL,
105    (user_opcode_handler_t)NULL,
106    (user_opcode_handler_t)NULL,
107    (user_opcode_handler_t)NULL,
108    (user_opcode_handler_t)NULL,
109    (user_opcode_handler_t)NULL,
110    (user_opcode_handler_t)NULL,
111    (user_opcode_handler_t)NULL,
112    (user_opcode_handler_t)NULL,
113    (user_opcode_handler_t)NULL,
114    (user_opcode_handler_t)NULL,
115    (user_opcode_handler_t)NULL,
116    (user_opcode_handler_t)NULL,
117    (user_opcode_handler_t)NULL,
118    (user_opcode_handler_t)NULL,
119    (user_opcode_handler_t)NULL,
120    (user_opcode_handler_t)NULL,
121    (user_opcode_handler_t)NULL,
122    (user_opcode_handler_t)NULL,
123    (user_opcode_handler_t)NULL,
124    (user_opcode_handler_t)NULL,
125    (user_opcode_handler_t)NULL,
126    (user_opcode_handler_t)NULL,
127    (user_opcode_handler_t)NULL,
128    (user_opcode_handler_t)NULL,
129    (user_opcode_handler_t)NULL,
130    (user_opcode_handler_t)NULL,
131    (user_opcode_handler_t)NULL,
132    (user_opcode_handler_t)NULL,
133    (user_opcode_handler_t)NULL,
134    (user_opcode_handler_t)NULL,
135    (user_opcode_handler_t)NULL,
136    (user_opcode_handler_t)NULL,
137    (user_opcode_handler_t)NULL,
138    (user_opcode_handler_t)NULL,
139    (user_opcode_handler_t)NULL,
140    (user_opcode_handler_t)NULL,
141    (user_opcode_handler_t)NULL,
142    (user_opcode_handler_t)NULL,
143    (user_opcode_handler_t)NULL,
144    (user_opcode_handler_t)NULL,
145    (user_opcode_handler_t)NULL,
146    (user_opcode_handler_t)NULL,
147    (user_opcode_handler_t)NULL,
148    (user_opcode_handler_t)NULL,
149    (user_opcode_handler_t)NULL,
150    (user_opcode_handler_t)NULL,
151    (user_opcode_handler_t)NULL,
152    (user_opcode_handler_t)NULL,
153    (user_opcode_handler_t)NULL,
154    (user_opcode_handler_t)NULL,
155    (user_opcode_handler_t)NULL,
156    (user_opcode_handler_t)NULL,
157    (user_opcode_handler_t)NULL,
158    (user_opcode_handler_t)NULL,
159    (user_opcode_handler_t)NULL,
160    (user_opcode_handler_t)NULL,
161    (user_opcode_handler_t)NULL,
162    (user_opcode_handler_t)NULL,
163    (user_opcode_handler_t)NULL,
164    (user_opcode_handler_t)NULL,
165    (user_opcode_handler_t)NULL,
166    (user_opcode_handler_t)NULL,
167    (user_opcode_handler_t)NULL,
168    (user_opcode_handler_t)NULL,
169    (user_opcode_handler_t)NULL,
170    (user_opcode_handler_t)NULL,
171    (user_opcode_handler_t)NULL,
172    (user_opcode_handler_t)NULL,
173    (user_opcode_handler_t)NULL,
174    (user_opcode_handler_t)NULL,
175    (user_opcode_handler_t)NULL,
176    (user_opcode_handler_t)NULL,
177    (user_opcode_handler_t)NULL,
178    (user_opcode_handler_t)NULL,
179    (user_opcode_handler_t)NULL,
180    (user_opcode_handler_t)NULL,
181    (user_opcode_handler_t)NULL,
182    (user_opcode_handler_t)NULL,
183    (user_opcode_handler_t)NULL,
184    (user_opcode_handler_t)NULL,
185    (user_opcode_handler_t)NULL,
186    (user_opcode_handler_t)NULL,
187    (user_opcode_handler_t)NULL,
188    (user_opcode_handler_t)NULL,
189    (user_opcode_handler_t)NULL,
190    (user_opcode_handler_t)NULL,
191    (user_opcode_handler_t)NULL,
192    (user_opcode_handler_t)NULL,
193    (user_opcode_handler_t)NULL,
194    (user_opcode_handler_t)NULL,
195    (user_opcode_handler_t)NULL,
196    (user_opcode_handler_t)NULL,
197    (user_opcode_handler_t)NULL,
198    (user_opcode_handler_t)NULL,
199    (user_opcode_handler_t)NULL,
200    (user_opcode_handler_t)NULL,
201    (user_opcode_handler_t)NULL,
202    (user_opcode_handler_t)NULL,
203    (user_opcode_handler_t)NULL,
204    (user_opcode_handler_t)NULL,
205    (user_opcode_handler_t)NULL,
206    (user_opcode_handler_t)NULL,
207    (user_opcode_handler_t)NULL,
208    (user_opcode_handler_t)NULL,
209    (user_opcode_handler_t)NULL,
210    (user_opcode_handler_t)NULL,
211    (user_opcode_handler_t)NULL,
212    (user_opcode_handler_t)NULL,
213    (user_opcode_handler_t)NULL,
214    (user_opcode_handler_t)NULL,
215    (user_opcode_handler_t)NULL,
216    (user_opcode_handler_t)NULL,
217    (user_opcode_handler_t)NULL,
218    (user_opcode_handler_t)NULL,
219    (user_opcode_handler_t)NULL,
220    (user_opcode_handler_t)NULL,
221    (user_opcode_handler_t)NULL,
222    (user_opcode_handler_t)NULL,
223    (user_opcode_handler_t)NULL,
224    (user_opcode_handler_t)NULL,
225    (user_opcode_handler_t)NULL,
226    (user_opcode_handler_t)NULL,
227    (user_opcode_handler_t)NULL,
228    (user_opcode_handler_t)NULL,
229    (user_opcode_handler_t)NULL,
230    (user_opcode_handler_t)NULL,
231    (user_opcode_handler_t)NULL,
232    (user_opcode_handler_t)NULL,
233    (user_opcode_handler_t)NULL,
234    (user_opcode_handler_t)NULL,
235    (user_opcode_handler_t)NULL,
236    (user_opcode_handler_t)NULL,
237    (user_opcode_handler_t)NULL,
238    (user_opcode_handler_t)NULL,
239    (user_opcode_handler_t)NULL,
240    (user_opcode_handler_t)NULL,
241    (user_opcode_handler_t)NULL,
242    (user_opcode_handler_t)NULL,
243    (user_opcode_handler_t)NULL,
244    (user_opcode_handler_t)NULL,
245    (user_opcode_handler_t)NULL,
246    (user_opcode_handler_t)NULL,
247    (user_opcode_handler_t)NULL,
248    (user_opcode_handler_t)NULL,
249    (user_opcode_handler_t)NULL,
250    (user_opcode_handler_t)NULL,
251    (user_opcode_handler_t)NULL,
252    (user_opcode_handler_t)NULL,
253    (user_opcode_handler_t)NULL,
254    (user_opcode_handler_t)NULL,
255    (user_opcode_handler_t)NULL,
256    (user_opcode_handler_t)NULL,
257    (user_opcode_handler_t)NULL,
258    (user_opcode_handler_t)NULL,
259    (user_opcode_handler_t)NULL,
260    (user_opcode_handler_t)NULL,
261    (user_opcode_handler_t)NULL,
262    (user_opcode_handler_t)NULL,
263    (user_opcode_handler_t)NULL,
264    (user_opcode_handler_t)NULL,
265    (user_opcode_handler_t)NULL,
266    (user_opcode_handler_t)NULL,
267    (user_opcode_handler_t)NULL,
268    (user_opcode_handler_t)NULL,
269    (user_opcode_handler_t)NULL,
270    (user_opcode_handler_t)NULL,
271    (user_opcode_handler_t)NULL,
272    (user_opcode_handler_t)NULL,
273    (user_opcode_handler_t)NULL,
274    (user_opcode_handler_t)NULL,
275    (user_opcode_handler_t)NULL,
276    (user_opcode_handler_t)NULL,
277    (user_opcode_handler_t)NULL,
278    (user_opcode_handler_t)NULL,
279    (user_opcode_handler_t)NULL,
280    (user_opcode_handler_t)NULL,
281    (user_opcode_handler_t)NULL,
282    (user_opcode_handler_t)NULL,
283    (user_opcode_handler_t)NULL,
284    (user_opcode_handler_t)NULL,
285    (user_opcode_handler_t)NULL,
286    (user_opcode_handler_t)NULL,
287    (user_opcode_handler_t)NULL
288};
289
290static zend_uchar zend_user_opcodes[256] = {0,
291    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
292    17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
293    33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
294    49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
295    65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
296    81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
297    97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
298    113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
299    129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,
300    145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,
301    161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
302    177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,
303    193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,
304    209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,
305    225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,
306    241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
307};
308
309static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op);
310
311
312#undef OPLINE
313#undef DCL_OPLINE
314#undef USE_OPLINE
315#undef LOAD_OPLINE
316#undef SAVE_OPLINE
317#define OPLINE EX(opline)
318#define DCL_OPLINE
319#define USE_OPLINE const zend_op *opline = EX(opline);
320#define LOAD_OPLINE()
321#define SAVE_OPLINE()
322#undef CHECK_EXCEPTION
323#undef HANDLE_EXCEPTION
324#undef HANDLE_EXCEPTION_LEAVE
325#define CHECK_EXCEPTION() LOAD_OPLINE()
326#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()
327#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()
328#define ZEND_VM_CONTINUE()         return  0
329#define ZEND_VM_RETURN()           return -1
330#define ZEND_VM_ENTER()            return  1
331#define ZEND_VM_LEAVE()            return  2
332#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
333
334#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC
335
336ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC)
337{
338    DCL_OPLINE
339
340
341
342    LOAD_OPLINE();
343
344    while (1) {
345        int ret;
346#ifdef ZEND_WIN32
347        if (EG(timed_out)) {
348            zend_timeout(0);
349        }
350#endif
351
352        if (UNEXPECTED((ret = OPLINE->handler(execute_data TSRMLS_CC)) != 0)) {
353            if (EXPECTED(ret > 0)) {
354                execute_data = EG(current_execute_data);
355            } else {
356                return;
357            }
358        }
359
360    }
361    zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen");
362}
363
364ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value TSRMLS_DC)
365{
366    zend_execute_data *execute_data;
367
368    if (EG(exception) != NULL) {
369        return;
370    }
371
372    execute_data = zend_vm_stack_push_call_frame(
373        (zend_function*)op_array, 0, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, Z_OBJ(EG(This)), NULL TSRMLS_CC);
374    if (EG(current_execute_data)) {
375        execute_data->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
376    } else {
377        execute_data->symbol_table = &EG(symbol_table);
378    }
379    EX(prev_execute_data) = EG(current_execute_data);
380    i_init_execute_data(execute_data, op_array, return_value, VM_FRAME_TOP_CODE TSRMLS_CC);
381    zend_execute_ex(execute_data TSRMLS_CC);
382}
383
384static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
385{
386    vm_frame_kind frame_kind = EX(frame_kind);
387
388    if (frame_kind == VM_FRAME_NESTED_FUNCTION) {
389        i_free_compiled_variables(execute_data TSRMLS_CC);
390        if (UNEXPECTED(EX(symbol_table) != NULL)) {
391            zend_clean_and_cache_symbol_table(EX(symbol_table) TSRMLS_CC);
392        }
393        zend_vm_stack_free_extra_args(execute_data TSRMLS_CC);
394        EG(current_execute_data) = EX(prev_execute_data);
395        if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_CLOSURE) != 0) && EX(func)->op_array.prototype) {
396            OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
397        }
398        zend_vm_stack_free_call_frame(execute_data TSRMLS_CC);
399
400        execute_data = EG(current_execute_data);
401
402        if (Z_OBJ(EG(This))) {
403            if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
404                if (!(EX(opline)->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
405                    Z_DELREF(EG(This));
406                }
407                if (Z_REFCOUNT(EG(This)) == 1) {
408                    zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC);
409                }
410            }
411            if (!Z_DELREF(EG(This))) {
412                _zval_dtor_func_for_ptr(Z_COUNTED(EG(This)) ZEND_FILE_LINE_CC);
413            } else if (UNEXPECTED(!Z_GC_INFO(EG(This)))) {
414                gc_possible_root(Z_COUNTED(EG(This)) TSRMLS_CC);
415            }
416        }
417        Z_OBJ(EG(This)) = EX(object);
418        EG(scope) = EX(scope);
419
420        if (UNEXPECTED(EG(exception) != NULL)) {
421            const zend_op *opline = EX(opline);
422            zend_throw_exception_internal(NULL TSRMLS_CC);
423            if (RETURN_VALUE_USED(opline)) {
424                zval_ptr_dtor(EX_VAR(opline->result.var));
425            }
426            HANDLE_EXCEPTION_LEAVE();
427        }
428
429        LOAD_OPLINE();
430        ZEND_VM_INC_OPCODE();
431        ZEND_VM_LEAVE();
432    } else if (frame_kind == VM_FRAME_NESTED_CODE) {
433        zend_detach_symbol_table(execute_data);
434        destroy_op_array(&EX(func)->op_array TSRMLS_CC);
435        efree_size(EX(func), sizeof(zend_op_array));
436        EG(current_execute_data) = EX(prev_execute_data);
437        zend_vm_stack_free_call_frame(execute_data TSRMLS_CC);
438
439        execute_data = EG(current_execute_data);
440        zend_attach_symbol_table(execute_data);
441        if (UNEXPECTED(EG(exception) != NULL)) {
442            zend_throw_exception_internal(NULL TSRMLS_CC);
443            HANDLE_EXCEPTION_LEAVE();
444        }
445
446        LOAD_OPLINE();
447        ZEND_VM_INC_OPCODE();
448        ZEND_VM_LEAVE();
449    } else {
450        if (frame_kind == VM_FRAME_TOP_FUNCTION) {
451            i_free_compiled_variables(execute_data TSRMLS_CC);
452            if (UNEXPECTED(EX(symbol_table) != NULL)) {
453                zend_clean_and_cache_symbol_table(EX(symbol_table) TSRMLS_CC);
454            }
455            zend_vm_stack_free_extra_args(execute_data TSRMLS_CC);
456            EG(current_execute_data) = EX(prev_execute_data);
457            if ((EX(func)->op_array.fn_flags & ZEND_ACC_CLOSURE) && EX(func)->op_array.prototype) {
458                OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
459            }
460        } else /* if (frame_kind == VM_FRAME_TOP_CODE) */ {
461            zend_array *symbol_table = EX(symbol_table);
462            zend_execute_data *old_execute_data;
463
464            zend_detach_symbol_table(execute_data);
465            old_execute_data = EX(prev_execute_data);
466            while (old_execute_data) {
467                if (old_execute_data->func && ZEND_USER_CODE(old_execute_data->func->op_array.type)) {
468                    if (old_execute_data->symbol_table == symbol_table) {
469                        zend_attach_symbol_table(old_execute_data);
470                    }
471                    break;
472                }
473                old_execute_data = old_execute_data->prev_execute_data;
474            }
475            EG(current_execute_data) = EX(prev_execute_data);
476        }
477        zend_vm_stack_free_call_frame(execute_data TSRMLS_CC);
478
479        ZEND_VM_RETURN();
480    }
481}
482
483static int ZEND_FASTCALL  ZEND_JMP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
484{
485    USE_OPLINE
486
487    ZEND_VM_SET_OPCODE(opline->op1.jmp_addr);
488    ZEND_VM_CONTINUE();
489}
490
491static int ZEND_FASTCALL  ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
492{
493    USE_OPLINE
494    zend_execute_data *call = EX(call);
495    zend_function *fbc = call->func;
496
497    SAVE_OPLINE();
498    EX(call) = call->prev_execute_data;
499    if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
500        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
501            zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name->val, fbc->common.function_name->val);
502        }
503        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
504            zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
505                fbc->common.scope ? fbc->common.scope->name->val : "",
506                fbc->common.scope ? "::" : "",
507                fbc->common.function_name->val);
508            if (UNEXPECTED(EG(exception) != NULL)) {
509                HANDLE_EXCEPTION();
510            }
511        }
512    }
513    if (fbc->common.scope &&
514        !(fbc->common.fn_flags & ZEND_ACC_STATIC) &&
515        !call->object) {
516
517        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
518            /* FIXME: output identifiers properly */
519            zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
520            if (UNEXPECTED(EG(exception) != NULL)) {
521                HANDLE_EXCEPTION();
522            }
523        } else {
524            /* FIXME: output identifiers properly */
525            /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
526            zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
527        }
528    }
529
530    LOAD_OPLINE();
531
532    if (UNEXPECTED(fbc->type == ZEND_INTERNAL_FUNCTION)) {
533        int should_change_scope = 0;
534        zval *ret;
535
536        if (fbc->common.scope) {
537            should_change_scope = 1;
538            Z_OBJ(EG(This)) = call->object;
539            /* TODO: we don't set scope if we call an object method ??? */
540            /* See: ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt */
541#if 1
542            EG(scope) = (call->object) ? NULL : fbc->common.scope;
543#else
544            EG(scope) = fbc->common.scope;
545#endif
546        } else {
547            call->called_scope = EX(called_scope);
548        }
549
550        call->prev_execute_data = execute_data;
551        EG(current_execute_data) = call;
552
553        if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
554            uint32_t i;
555            zval *p = ZEND_CALL_ARG(call, 1);
556
557            for (i = 0; i < call->num_args; ++i) {
558                zend_verify_arg_type(fbc, i + 1, p, 0 TSRMLS_CC);
559                p++;
560            }
561            if (UNEXPECTED(EG(exception) != NULL)) {
562                EG(current_execute_data) = call->prev_execute_data;
563                zend_vm_stack_free_args(call TSRMLS_CC);
564                zend_vm_stack_free_call_frame(call TSRMLS_CC);
565                if (RETURN_VALUE_USED(opline)) {
566                    ZVAL_UNDEF(EX_VAR(opline->result.var));
567                }
568                if (UNEXPECTED(should_change_scope)) {
569                    goto fcall_end_change_scope;
570                } else {
571                    goto fcall_end;
572                }
573            }
574        }
575
576        ret = EX_VAR(opline->result.var);
577        ZVAL_NULL(ret);
578        Z_VAR_FLAGS_P(ret) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
579
580        if (!zend_execute_internal) {
581            /* saves one function call if zend_execute_internal is not used */
582            fbc->internal_function.handler(call->num_args, ret TSRMLS_CC);
583        } else {
584            zend_execute_internal(call, ret TSRMLS_CC);
585        }
586        EG(current_execute_data) = call->prev_execute_data;
587        zend_vm_stack_free_args(call TSRMLS_CC);
588        zend_vm_stack_free_call_frame(call TSRMLS_CC);
589
590        if (!RETURN_VALUE_USED(opline)) {
591            zval_ptr_dtor(ret);
592        }
593
594        if (UNEXPECTED(should_change_scope)) {
595            goto fcall_end_change_scope;
596        } else {
597            goto fcall_end;
598        }
599    } else if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
600        zval *return_value = NULL;
601
602        Z_OBJ(EG(This)) = call->object;
603        EG(scope) = fbc->common.scope;
604        call->symbol_table = NULL;
605        if (RETURN_VALUE_USED(opline)) {
606            return_value = EX_VAR(opline->result.var);
607
608            ZVAL_NULL(return_value);
609            Z_VAR_FLAGS_P(return_value) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
610        }
611
612        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
613            if (RETURN_VALUE_USED(opline)) {
614                zend_generator_create_zval(call, &fbc->op_array, EX_VAR(opline->result.var) TSRMLS_CC);
615            } else {
616                zend_vm_stack_free_args(call TSRMLS_CC);
617            }
618
619            zend_vm_stack_free_call_frame(call TSRMLS_CC);
620        } else {
621            call->prev_execute_data = execute_data;
622            i_init_func_execute_data(call, &fbc->op_array, return_value, EXPECTED(zend_execute_ex == execute_ex) ? VM_FRAME_NESTED_FUNCTION : VM_FRAME_TOP_FUNCTION TSRMLS_CC);
623
624            if (EXPECTED(zend_execute_ex == execute_ex)) {
625                ZEND_VM_ENTER();
626            } else {
627                zend_execute_ex(call TSRMLS_CC);
628            }
629        }
630    } else { /* ZEND_OVERLOADED_FUNCTION */
631        Z_OBJ(EG(This)) = call->object;
632        EG(scope) = fbc->common.scope;
633
634        ZVAL_NULL(EX_VAR(opline->result.var));
635
636        /* Not sure what should be done here if it's a static method */
637        if (EXPECTED(call->object != NULL)) {
638            call->prev_execute_data = execute_data;
639            EG(current_execute_data) = call;
640            call->object->handlers->call_method(fbc->common.function_name, call->object, call->num_args, EX_VAR(opline->result.var) TSRMLS_CC);
641            EG(current_execute_data) = call->prev_execute_data;
642        } else {
643            zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
644        }
645
646        zend_vm_stack_free_args(call TSRMLS_CC);
647
648        zend_vm_stack_free_call_frame(call TSRMLS_CC);
649
650        if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
651            zend_string_release(fbc->common.function_name);
652        }
653        efree(fbc);
654
655        if (!RETURN_VALUE_USED(opline)) {
656            zval_ptr_dtor(EX_VAR(opline->result.var));
657        } else {
658//???           Z_UNSET_ISREF_P(EX_T(opline->result.var).var.ptr);
659//???           Z_SET_REFCOUNT_P(EX_T(opline->result.var).var.ptr, 1);
660            Z_VAR_FLAGS_P(EX_VAR(opline->result.var)) = 0;
661        }
662    }
663
664fcall_end_change_scope:
665    if (Z_OBJ(EG(This))) {
666        if (UNEXPECTED(EG(exception) != NULL) && (opline->op1.num & ZEND_CALL_CTOR)) {
667            if (!(opline->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
668                Z_DELREF(EG(This));
669            }
670            if (Z_REFCOUNT(EG(This)) == 1) {
671                zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC);
672            }
673        }
674        OBJ_RELEASE(Z_OBJ(EG(This)));
675    }
676    Z_OBJ(EG(This)) = EX(object);
677    EG(scope) = EX(scope);
678
679fcall_end:
680    if (UNEXPECTED(EG(exception) != NULL)) {
681        zend_throw_exception_internal(NULL TSRMLS_CC);
682        if (RETURN_VALUE_USED(opline)) {
683            zval_ptr_dtor(EX_VAR(opline->result.var));
684        }
685        HANDLE_EXCEPTION();
686    }
687
688    ZEND_VM_NEXT_OPCODE();
689}
690
691static int ZEND_FASTCALL  ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
692{
693    /* The generator object is stored in EX(return_value) */
694    zend_generator *generator = (zend_generator *) EX(return_value);
695
696    /* Close the generator to free up resources */
697    zend_generator_close(generator, 1 TSRMLS_CC);
698
699    /* Pass execution back to handling code */
700    ZEND_VM_RETURN();
701}
702
703static int ZEND_FASTCALL  ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
704{
705    USE_OPLINE
706    zend_free_op free_op1;
707    zval *args;
708    int arg_num;
709    SAVE_OPLINE();
710
711    args = get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, BP_VAR_R);
712    arg_num = EX(call)->num_args + 1;
713
714send_again:
715    switch (Z_TYPE_P(args)) {
716        case IS_ARRAY: {
717            HashTable *ht = Z_ARRVAL_P(args);
718            zval *arg, *top;
719            zend_string *name;
720
721            zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, zend_hash_num_elements(ht) TSRMLS_CC);
722
723            if (opline->op1_type != IS_CONST && opline->op1_type != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
724                uint32_t i;
725                int separate = 0;
726
727                /* check if any of arguments are going to be passed by reference */
728                for (i = 0; i < zend_hash_num_elements(ht); i++) {
729                    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
730                        separate = 1;
731                        break;
732                    }
733                }
734                if (separate) {
735                    zval_copy_ctor(args);
736                    ht = Z_ARRVAL_P(args);
737                }
738            }
739
740            ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
741                if (name) {
742                    zend_error(E_RECOVERABLE_ERROR, "Cannot unpack array with string keys");
743                    FREE_OP(free_op1);
744                    CHECK_EXCEPTION();
745                    ZEND_VM_NEXT_OPCODE();
746                }
747
748                top = ZEND_CALL_ARG(EX(call), arg_num);
749                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
750                    if (!Z_IMMUTABLE_P(args)) {
751                        ZVAL_MAKE_REF(arg);
752                        Z_ADDREF_P(arg);
753                        ZVAL_REF(top, Z_REF_P(arg));
754                    } else {
755                        ZVAL_DUP(top, arg);
756                    }
757                } else if (Z_ISREF_P(arg)) {
758                    ZVAL_COPY(top, Z_REFVAL_P(arg));
759                } else {
760                    ZVAL_COPY(top, arg);
761                }
762
763                EX(call)->num_args++;
764                arg_num++;
765            } ZEND_HASH_FOREACH_END();
766
767            break;
768        }
769        case IS_OBJECT: {
770            zend_class_entry *ce = Z_OBJCE_P(args);
771            zend_object_iterator *iter;
772
773            if (!ce || !ce->get_iterator) {
774                zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
775                break;
776            }
777
778            iter = ce->get_iterator(ce, args, 0 TSRMLS_CC);
779            if (UNEXPECTED(!iter)) {
780                FREE_OP(free_op1);
781                if (!EG(exception)) {
782                    zend_throw_exception_ex(
783                        NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val
784                    );
785                }
786                HANDLE_EXCEPTION();
787            }
788
789            if (iter->funcs->rewind) {
790                iter->funcs->rewind(iter TSRMLS_CC);
791                if (UNEXPECTED(EG(exception) != NULL)) {
792                    goto unpack_iter_dtor;
793                }
794            }
795
796            for (; iter->funcs->valid(iter TSRMLS_CC) == SUCCESS; ++arg_num) {
797                zval *arg, *top;
798
799                if (UNEXPECTED(EG(exception) != NULL)) {
800                    goto unpack_iter_dtor;
801                }
802
803                arg = iter->funcs->get_current_data(iter TSRMLS_CC);
804                if (UNEXPECTED(EG(exception) != NULL)) {
805                    goto unpack_iter_dtor;
806                }
807
808                if (iter->funcs->get_current_key) {
809                    zval key;
810                    iter->funcs->get_current_key(iter, &key TSRMLS_CC);
811                    if (UNEXPECTED(EG(exception) != NULL)) {
812                        goto unpack_iter_dtor;
813                    }
814
815                    if (Z_TYPE(key) == IS_STRING) {
816                        zend_error(E_RECOVERABLE_ERROR,
817                            "Cannot unpack Traversable with string keys");
818                        zval_dtor(&key);
819                        goto unpack_iter_dtor;
820                    }
821
822                    zval_dtor(&key);
823                }
824
825                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
826                    zend_error(
827                        E_WARNING, "Cannot pass by-reference argument %d of %s%s%s()"
828                        " by unpacking a Traversable, passing by-value instead", arg_num,
829                        EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
830                        EX(call)->func->common.scope ? "::" : "",
831                        EX(call)->func->common.function_name->val
832                    );
833                }
834
835                if (Z_ISREF_P(arg)) {
836                    ZVAL_DUP(arg, Z_REFVAL_P(arg));
837                } else {
838                    if (Z_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
839                }
840
841                zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1 TSRMLS_CC);
842                top = ZEND_CALL_ARG(EX(call), arg_num);
843                ZVAL_COPY_VALUE(top, arg);
844                EX(call)->num_args++;
845
846                iter->funcs->move_forward(iter TSRMLS_CC);
847                if (UNEXPECTED(EG(exception) != NULL)) {
848                    goto unpack_iter_dtor;
849                }
850            }
851
852unpack_iter_dtor:
853            zend_iterator_dtor(iter TSRMLS_CC);
854            break;
855        }
856        case IS_REFERENCE:
857            args = Z_REFVAL_P(args);
858            goto send_again;
859            break;
860        default:
861            zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
862    }
863
864    FREE_OP(free_op1);
865    CHECK_EXCEPTION();
866    ZEND_VM_NEXT_OPCODE();
867}
868
869static int ZEND_FASTCALL  ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
870{
871    USE_OPLINE
872    zend_free_op free_op1;
873    zval *args;
874    SAVE_OPLINE();
875
876    args = get_zval_ptr_deref(opline->op1_type, &opline->op1, execute_data, &free_op1, BP_VAR_R);
877
878    if (Z_TYPE_P(args) != IS_ARRAY) {
879        zend_error(E_WARNING, "call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
880        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
881            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
882        }
883        if (EX(call)->object) {
884            OBJ_RELEASE(EX(call)->object);
885        }
886        EX(call)->func = (zend_function*)&zend_pass_function;
887        EX(call)->called_scope = NULL;
888        EX(call)->object = NULL;
889    } else {
890        uint32_t arg_num = 1;
891
892        HashTable *ht = Z_ARRVAL_P(args);
893        zval *arg, *param, tmp;
894
895        zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht) TSRMLS_CC);
896
897        if (opline->op1_type != IS_CONST && opline->op1_type != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
898            uint32_t i;
899            int separate = 0;
900
901            /* check if any of arguments are going to be passed by reference */
902            for (i = 0; i < zend_hash_num_elements(ht); i++) {
903                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
904                    separate = 1;
905                    break;
906                }
907            }
908            if (separate) {
909                zval_copy_ctor(args);
910                ht = Z_ARRVAL_P(args);
911            }
912        }
913
914        param = ZEND_CALL_ARG(EX(call), arg_num);
915        ZEND_HASH_FOREACH_VAL(ht, arg) {
916            if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
917                // TODO: Scalar values don't have reference counters anymore.
918                // They are assumed to be 1, and they may be easily passed by
919                // reference now. However, previously scalars with refcount==1
920                // might be passed and with refcount>1 might not. We can support
921                // only single behavior ???
922#if 0
923                if (Z_REFCOUNTED_P(arg) &&
924                    // This solution breaks the following test (omit warning message) ???
925                    // Zend/tests/bug61273.phpt
926                    // ext/reflection/tests/bug42976.phpt
927                    // ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt
928#else
929                if (!Z_REFCOUNTED_P(arg) ||
930                    // This solution breaks the following test (emit warning message) ???
931                    // ext/pdo_sqlite/tests/pdo_005.phpt
932#endif
933                    (!Z_ISREF_P(arg) && Z_REFCOUNT_P(arg) > 1)) {
934
935                    if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
936
937                        zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
938                            arg_num,
939                            EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
940                            EX(call)->func->common.scope ? "::" : "",
941                            EX(call)->func->common.function_name->val);
942
943                        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
944                            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
945                        }
946                        if (EX(call)->object) {
947                            OBJ_RELEASE(EX(call)->object);
948                        }
949                        EX(call)->func = (zend_function*)&zend_pass_function;
950                        EX(call)->called_scope = NULL;
951                        EX(call)->object = NULL;
952
953                        break;
954                    }
955
956                    if (Z_REFCOUNTED_P(arg)) {
957                        Z_DELREF_P(arg);
958                    }
959                    ZVAL_DUP(&tmp, arg);
960                    ZVAL_NEW_REF(arg, &tmp);
961                    Z_ADDREF_P(arg);
962                } else if (!Z_ISREF_P(arg)) {
963                    ZVAL_NEW_REF(arg, arg);
964                    Z_ADDREF_P(arg);
965                } else if (Z_REFCOUNTED_P(arg)) {
966                    Z_ADDREF_P(arg);
967                }
968                ZVAL_COPY_VALUE(param, arg);
969            } else if (Z_ISREF_P(arg) &&
970                   /* don't separate references for __call */
971                   (EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
972                ZVAL_DUP(param, Z_REFVAL_P(arg));
973            } else {
974                ZVAL_COPY(param, arg);
975            }
976            EX(call)->num_args++;
977            arg_num++;
978            param++;
979        } ZEND_HASH_FOREACH_END();
980    }
981    FREE_OP(free_op1);
982    CHECK_EXCEPTION();
983    ZEND_VM_NEXT_OPCODE();
984}
985
986static int ZEND_FASTCALL  ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
987{
988    USE_OPLINE
989    uint32_t arg_num = opline->op1.num;
990
991    SAVE_OPLINE();
992    if (UNEXPECTED(arg_num > EX(num_args))) {
993        zend_verify_missing_arg(execute_data, arg_num TSRMLS_CC);
994        CHECK_EXCEPTION();
995    } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
996        zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
997
998        zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
999        CHECK_EXCEPTION();
1000    }
1001
1002    ZEND_VM_NEXT_OPCODE();
1003}
1004
1005static int ZEND_FASTCALL  ZEND_RECV_VARIADIC_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1006{
1007    USE_OPLINE
1008    uint32_t arg_num = opline->op1.num;
1009    uint32_t arg_count = EX(num_args);
1010    zval *params;
1011
1012    SAVE_OPLINE();
1013
1014    params = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
1015
1016    if (arg_num <= arg_count) {
1017        zval *param;
1018
1019        array_init_size(params, arg_count - arg_num + 1);
1020        param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
1021        if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
1022            do {
1023                zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
1024                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
1025                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
1026                param++;
1027            } while (++arg_num <= arg_count);
1028        } else {
1029            do {
1030                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
1031                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
1032                param++;
1033            } while (++arg_num <= arg_count);
1034        }
1035    } else {
1036        array_init(params);
1037    }
1038
1039    CHECK_EXCEPTION();
1040    ZEND_VM_NEXT_OPCODE();
1041}
1042
1043static int ZEND_FASTCALL  ZEND_NEW_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1044{
1045    USE_OPLINE
1046    zval object_zval;
1047    zend_function *constructor;
1048
1049    SAVE_OPLINE();
1050    if (UNEXPECTED((Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) != 0)) {
1051        if (Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_INTERFACE) {
1052            zend_error_noreturn(E_ERROR, "Cannot instantiate interface %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
1053        } else if ((Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
1054            zend_error_noreturn(E_ERROR, "Cannot instantiate trait %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
1055        } else {
1056            zend_error_noreturn(E_ERROR, "Cannot instantiate abstract class %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
1057        }
1058    }
1059    object_init_ex(&object_zval, Z_CE_P(EX_VAR(opline->op1.var)));
1060    constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC);
1061
1062    if (constructor == NULL) {
1063        if (RETURN_VALUE_USED(opline)) {
1064            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
1065        } else {
1066            zval_ptr_dtor(&object_zval);
1067        }
1068        ZEND_VM_JMP(opline->op2.jmp_addr);
1069    } else {
1070        /* We are not handling overloaded classes right now */
1071        EX(call) = zend_vm_stack_push_call_frame(
1072            constructor, opline->extended_value,
1073            RETURN_VALUE_USED(opline) ?
1074                ZEND_CALL_CTOR : (ZEND_CALL_CTOR | ZEND_CALL_CTOR_RESULT_UNUSED),
1075            Z_CE_P(EX_VAR(opline->op1.var)),
1076            Z_OBJ(object_zval),
1077            EX(call) TSRMLS_CC);
1078
1079        if (RETURN_VALUE_USED(opline)) {
1080            ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
1081            EX(call)->return_value = EX_VAR(opline->result.var);
1082        } else {
1083            EX(call)->return_value = NULL;
1084        }
1085
1086        CHECK_EXCEPTION();
1087        ZEND_VM_NEXT_OPCODE();
1088    }
1089}
1090
1091static int ZEND_FASTCALL  ZEND_BEGIN_SILENCE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1092{
1093    USE_OPLINE
1094
1095    SAVE_OPLINE();
1096    ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));
1097    if (Z_TYPE(EX(old_error_reporting)) == IS_UNDEF) {
1098        ZVAL_LONG(&EX(old_error_reporting), EG(error_reporting));
1099        EX(old_error_reporting).u2.silence_num = opline->op2.num;
1100    }
1101
1102    if (EG(error_reporting)) {
1103        do {
1104            EG(error_reporting) = 0;
1105            if (!EG(error_reporting_ini_entry)) {
1106                zend_ini_entry *p = zend_hash_str_find_ptr(EG(ini_directives), "error_reporting", sizeof("error_reporting")-1);
1107                if (p) {
1108                    EG(error_reporting_ini_entry) = p;
1109                } else {
1110                    break;
1111                }
1112            }
1113            if (!EG(error_reporting_ini_entry)->modified) {
1114                if (!EG(modified_ini_directives)) {
1115                    ALLOC_HASHTABLE(EG(modified_ini_directives));
1116                    zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
1117                }
1118                if (EXPECTED(zend_hash_str_add_ptr(EG(modified_ini_directives), "error_reporting", sizeof("error_reporting")-1, EG(error_reporting_ini_entry)) != NULL)) {
1119                    EG(error_reporting_ini_entry)->orig_value = EG(error_reporting_ini_entry)->value;
1120                    EG(error_reporting_ini_entry)->orig_modifiable = EG(error_reporting_ini_entry)->modifiable;
1121                    EG(error_reporting_ini_entry)->modified = 1;
1122                }
1123            }
1124        } while (0);
1125    }
1126    CHECK_EXCEPTION();
1127    ZEND_VM_NEXT_OPCODE();
1128}
1129
1130static int ZEND_FASTCALL  ZEND_EXT_STMT_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1131{
1132    SAVE_OPLINE();
1133    if (!EG(no_extensions)) {
1134        zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, EX(func) TSRMLS_CC);
1135    }
1136    CHECK_EXCEPTION();
1137    ZEND_VM_NEXT_OPCODE();
1138}
1139
1140static int ZEND_FASTCALL  ZEND_EXT_FCALL_BEGIN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1141{
1142    SAVE_OPLINE();
1143    if (!EG(no_extensions)) {
1144        zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, EX(func) TSRMLS_CC);
1145    }
1146    CHECK_EXCEPTION();
1147    ZEND_VM_NEXT_OPCODE();
1148}
1149
1150static int ZEND_FASTCALL  ZEND_EXT_FCALL_END_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1151{
1152    SAVE_OPLINE();
1153    if (!EG(no_extensions)) {
1154        zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, EX(func) TSRMLS_CC);
1155    }
1156    CHECK_EXCEPTION();
1157    ZEND_VM_NEXT_OPCODE();
1158}
1159
1160static int ZEND_FASTCALL  ZEND_DECLARE_CLASS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1161{
1162    USE_OPLINE
1163
1164    SAVE_OPLINE();
1165    Z_CE_P(EX_VAR(opline->result.var)) = do_bind_class(&EX(func)->op_array, opline, EG(class_table), 0 TSRMLS_CC);
1166    CHECK_EXCEPTION();
1167    ZEND_VM_NEXT_OPCODE();
1168}
1169
1170static int ZEND_FASTCALL  ZEND_DECLARE_INHERITED_CLASS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1171{
1172    USE_OPLINE
1173
1174    SAVE_OPLINE();
1175    Z_CE_P(EX_VAR(opline->result.var)) = do_bind_inherited_class(&EX(func)->op_array, opline, EG(class_table), Z_CE_P(EX_VAR(opline->extended_value)), 0 TSRMLS_CC);
1176    CHECK_EXCEPTION();
1177    ZEND_VM_NEXT_OPCODE();
1178}
1179
1180static int ZEND_FASTCALL  ZEND_DECLARE_INHERITED_CLASS_DELAYED_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1181{
1182    USE_OPLINE
1183    zval *zce, *orig_zce;
1184
1185    SAVE_OPLINE();
1186    if ((zce = zend_hash_find(EG(class_table), Z_STR_P(opline->op2.zv))) == NULL ||
1187        ((orig_zce = zend_hash_find(EG(class_table), Z_STR_P(opline->op1.zv))) != NULL &&
1188         Z_CE_P(zce) != Z_CE_P(orig_zce))) {
1189        do_bind_inherited_class(&EX(func)->op_array, opline, EG(class_table), Z_CE_P(EX_VAR(opline->extended_value)), 0 TSRMLS_CC);
1190    }
1191    CHECK_EXCEPTION();
1192    ZEND_VM_NEXT_OPCODE();
1193}
1194
1195static int ZEND_FASTCALL  ZEND_DECLARE_FUNCTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1196{
1197    USE_OPLINE
1198
1199    SAVE_OPLINE();
1200    do_bind_function(&EX(func)->op_array, opline, EG(function_table), 0 TSRMLS_CC);
1201    CHECK_EXCEPTION();
1202    ZEND_VM_NEXT_OPCODE();
1203}
1204
1205static int ZEND_FASTCALL  ZEND_TICKS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1206{
1207    USE_OPLINE
1208
1209    SAVE_OPLINE();
1210    if (++EG(ticks_count)>=opline->extended_value) {
1211        EG(ticks_count)=0;
1212        if (zend_ticks_function) {
1213            zend_ticks_function(opline->extended_value TSRMLS_CC);
1214        }
1215    }
1216    CHECK_EXCEPTION();
1217    ZEND_VM_NEXT_OPCODE();
1218}
1219
1220static int ZEND_FASTCALL  ZEND_EXT_NOP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1221{
1222    ZEND_VM_NEXT_OPCODE();
1223}
1224
1225static int ZEND_FASTCALL  ZEND_NOP_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1226{
1227    ZEND_VM_NEXT_OPCODE();
1228}
1229
1230static int ZEND_FASTCALL  ZEND_ADD_TRAIT_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1231{
1232    USE_OPLINE
1233    zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
1234    zend_class_entry *trait;
1235
1236    SAVE_OPLINE();
1237    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
1238        trait = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
1239    } else {
1240        trait = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv),
1241                                         opline->op2.zv + 1,
1242                                         opline->extended_value TSRMLS_CC);
1243        if (UNEXPECTED(trait == NULL)) {
1244            CHECK_EXCEPTION();
1245            ZEND_VM_NEXT_OPCODE();
1246        }
1247        if (!((trait->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT)) {
1248            zend_error_noreturn(E_ERROR, "%s cannot use %s - it is not a trait", ce->name->val, trait->name->val);
1249        }
1250        CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), trait);
1251    }
1252
1253    zend_do_implement_trait(ce, trait TSRMLS_CC);
1254
1255    CHECK_EXCEPTION();
1256    ZEND_VM_NEXT_OPCODE();
1257}
1258
1259static int ZEND_FASTCALL  ZEND_BIND_TRAITS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1260{
1261    USE_OPLINE
1262    zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
1263
1264    SAVE_OPLINE();
1265    zend_do_bind_traits(ce TSRMLS_CC);
1266    CHECK_EXCEPTION();
1267    ZEND_VM_NEXT_OPCODE();
1268}
1269
1270static int ZEND_FASTCALL  ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1271{
1272    uint32_t op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
1273    int i;
1274    uint32_t catch_op_num = 0, finally_op_num = 0, finally_op_end = 0;
1275
1276    for (i = 0; i < EX(func)->op_array.last_try_catch; i++) {
1277        if (EX(func)->op_array.try_catch_array[i].try_op > op_num) {
1278            /* further blocks will not be relevant... */
1279            break;
1280        }
1281        if (op_num < EX(func)->op_array.try_catch_array[i].catch_op) {
1282            catch_op_num = EX(func)->op_array.try_catch_array[i].catch_op;
1283        }
1284        if (op_num < EX(func)->op_array.try_catch_array[i].finally_op) {
1285            finally_op_num = EX(func)->op_array.try_catch_array[i].finally_op;
1286        }
1287        if (op_num >= EX(func)->op_array.try_catch_array[i].finally_op &&
1288                op_num < EX(func)->op_array.try_catch_array[i].finally_end) {
1289            finally_op_end = EX(func)->op_array.try_catch_array[i].finally_end;
1290        }
1291    }
1292
1293    if (EX(call)) {
1294        zend_execute_data *call = EX(call);
1295        do {
1296            /* If the exception was thrown during a function call there might be
1297             * arguments pushed to the stack that have to be dtor'ed. */
1298            zend_vm_stack_free_args(EX(call) TSRMLS_CC);
1299
1300            if (call->object) {
1301                if (call->flags & ZEND_CALL_CTOR) {
1302                    if (!(call->flags & ZEND_CALL_CTOR_RESULT_UNUSED)) {
1303                        GC_REFCOUNT(call->object)--;
1304                    }
1305                    if (GC_REFCOUNT(call->object) == 1) {
1306                        zend_object_store_ctor_failed(call->object TSRMLS_CC);
1307                    }
1308                }
1309                OBJ_RELEASE(call->object);
1310            }
1311            EX(call) = call->prev_execute_data;
1312            zend_vm_stack_free_call_frame(call TSRMLS_CC);
1313            call = EX(call);
1314        } while (call);
1315    }
1316
1317    for (i = 0; i < EX(func)->op_array.last_brk_cont; i++) {
1318        if (EX(func)->op_array.brk_cont_array[i].start < 0) {
1319            continue;
1320        } else if (EX(func)->op_array.brk_cont_array[i].start > op_num) {
1321            /* further blocks will not be relevant... */
1322            break;
1323        } else if (op_num < EX(func)->op_array.brk_cont_array[i].brk) {
1324            if (!catch_op_num ||
1325                catch_op_num >= EX(func)->op_array.brk_cont_array[i].brk) {
1326                zend_op *brk_opline = &EX(func)->op_array.opcodes[EX(func)->op_array.brk_cont_array[i].brk];
1327
1328                if (brk_opline->opcode == ZEND_FREE) {
1329                    if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
1330                        zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
1331                    }
1332                }
1333            }
1334        }
1335    }
1336
1337    /* restore previous error_reporting value */
1338    if (!EG(error_reporting) && Z_TYPE(EX(old_error_reporting)) != IS_UNDEF && Z_LVAL(EX(old_error_reporting)) != 0) {
1339        EG(error_reporting) = Z_LVAL(EX(old_error_reporting));
1340    }
1341    ZVAL_UNDEF(&EX(old_error_reporting));
1342
1343    if (finally_op_num && (!catch_op_num || catch_op_num >= finally_op_num)) {
1344        if (EX(delayed_exception)) {
1345            zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
1346        }
1347        EX(delayed_exception) = EG(exception);
1348        EG(exception) = NULL;
1349        EX(fast_ret) = NULL;
1350        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[finally_op_num]);
1351        ZEND_VM_CONTINUE();
1352    } else if (catch_op_num) {
1353        if (finally_op_end && catch_op_num > finally_op_end) {
1354            /* we are going out of current finally scope */
1355            if (EX(delayed_exception)) {
1356                zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
1357                EX(delayed_exception) = NULL;
1358            }
1359        }
1360        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[catch_op_num]);
1361        ZEND_VM_CONTINUE();
1362    } else {
1363        if (EX(delayed_exception)) {
1364            zend_exception_set_previous(EG(exception), EX(delayed_exception) TSRMLS_CC);
1365            EX(delayed_exception) = NULL;
1366        }
1367        if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
1368            return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1369        } else {
1370            return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1371        }
1372    }
1373}
1374
1375static int ZEND_FASTCALL  ZEND_VERIFY_ABSTRACT_CLASS_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1376{
1377    USE_OPLINE
1378
1379    SAVE_OPLINE();
1380    zend_verify_abstract_class(Z_CE_P(EX_VAR(opline->op1.var)) TSRMLS_CC);
1381    CHECK_EXCEPTION();
1382    ZEND_VM_NEXT_OPCODE();
1383}
1384
1385static int ZEND_FASTCALL  ZEND_USER_OPCODE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1386{
1387    USE_OPLINE
1388    int ret;
1389
1390    SAVE_OPLINE();
1391    ret = zend_user_opcode_handlers[opline->opcode](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL);
1392    LOAD_OPLINE();
1393
1394    switch (ret) {
1395        case ZEND_USER_OPCODE_CONTINUE:
1396            ZEND_VM_CONTINUE();
1397        case ZEND_USER_OPCODE_RETURN:
1398            if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
1399                return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1400            } else {
1401                return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1402            }
1403        case ZEND_USER_OPCODE_ENTER:
1404            ZEND_VM_ENTER();
1405        case ZEND_USER_OPCODE_LEAVE:
1406            ZEND_VM_LEAVE();
1407        case ZEND_USER_OPCODE_DISPATCH:
1408            ZEND_VM_DISPATCH(opline->opcode, opline);
1409        default:
1410            ZEND_VM_DISPATCH((zend_uchar)(ret & 0xff), opline);
1411    }
1412}
1413
1414static int ZEND_FASTCALL  ZEND_DISCARD_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1415{
1416    if (EX(delayed_exception) != NULL) {
1417        /* discard the previously thrown exception */
1418        OBJ_RELEASE(EX(delayed_exception));
1419        EX(delayed_exception) = NULL;
1420    }
1421
1422    ZEND_VM_NEXT_OPCODE();
1423}
1424
1425static int ZEND_FASTCALL  ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1426{
1427    USE_OPLINE
1428
1429    if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) &&
1430        UNEXPECTED(EG(prev_exception) != NULL)) {
1431        /* in case of unhandled exception jump to catch block instead of finally */
1432        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
1433        ZEND_VM_CONTINUE();
1434    }
1435    EX(fast_ret) = opline;
1436    EX(delayed_exception) = NULL;
1437    ZEND_VM_SET_OPCODE(opline->op1.jmp_addr);
1438    ZEND_VM_CONTINUE();
1439}
1440
1441static int ZEND_FASTCALL  ZEND_FAST_RET_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1442{
1443    if (EX(fast_ret)) {
1444        ZEND_VM_SET_OPCODE(EX(fast_ret) + 1);
1445        if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) {
1446            EX(fast_ret) = &EX(func)->op_array.opcodes[EX(fast_ret)->op2.opline_num];
1447        }
1448        ZEND_VM_CONTINUE();
1449    } else {
1450        /* special case for unhandled exceptions */
1451        USE_OPLINE
1452
1453        if (opline->extended_value == ZEND_FAST_RET_TO_FINALLY) {
1454            ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
1455            ZEND_VM_CONTINUE();
1456        } else {
1457            EG(exception) = EX(delayed_exception);
1458            EX(delayed_exception) = NULL;
1459            if (opline->extended_value == ZEND_FAST_RET_TO_CATCH) {
1460                ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->op2.opline_num]);
1461                ZEND_VM_CONTINUE();
1462            } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
1463                return ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1464            } else {
1465                return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
1466            }
1467        }
1468    }
1469}
1470
1471static int ZEND_FASTCALL  ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1472{
1473    USE_OPLINE
1474
1475    SAVE_OPLINE();
1476    if (EG(exception)) {
1477        zend_exception_save(TSRMLS_C);
1478    }
1479    if (IS_CONST == IS_UNUSED) {
1480        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
1481        CHECK_EXCEPTION();
1482        ZEND_VM_NEXT_OPCODE();
1483    } else {
1484
1485        zval *class_name = opline->op2.zv;
1486
1487        if (IS_CONST == IS_CONST) {
1488            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
1489                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
1490            } else {
1491                Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
1492                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
1493            }
1494        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
1495            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
1496        } else if (Z_TYPE_P(class_name) == IS_STRING) {
1497            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
1498        } else {
1499            if (UNEXPECTED(EG(exception) != NULL)) {
1500                HANDLE_EXCEPTION();
1501            }
1502            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
1503        }
1504
1505        CHECK_EXCEPTION();
1506        ZEND_VM_NEXT_OPCODE();
1507    }
1508}
1509
1510static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1511{
1512    USE_OPLINE
1513    zend_function *fbc;
1514    zval *function_name, *func;
1515
1516    if (IS_CONST == IS_CONST && Z_TYPE_P(opline->op2.zv) == IS_STRING) {
1517        function_name = (zval*)(opline->op2.zv+1);
1518        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
1519            fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
1520        } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
1521            SAVE_OPLINE();
1522            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
1523        } else {
1524            fbc = Z_FUNC_P(func);
1525            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
1526        }
1527
1528        EX(call) = zend_vm_stack_push_call_frame(
1529            fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
1530
1531        /*CHECK_EXCEPTION();*/
1532        ZEND_VM_NEXT_OPCODE();
1533    } else {
1534        zend_string *lcname;
1535
1536        zend_class_entry *called_scope;
1537        zend_object *object;
1538        zval *function_name_ptr;
1539
1540        SAVE_OPLINE();
1541        function_name_ptr = function_name = opline->op2.zv;
1542
1543        ZVAL_DEREF(function_name);
1544        if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
1545            if (Z_STRVAL_P(function_name)[0] == '\\') {
1546                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
1547                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
1548            } else {
1549                lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
1550                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
1551            }
1552            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
1553                zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
1554            }
1555            zend_string_free(lcname);
1556
1557            fbc = Z_FUNC_P(func);
1558            called_scope = NULL;
1559            object = NULL;
1560        } else if (IS_CONST != IS_CONST &&
1561            EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
1562            Z_OBJ_HANDLER_P(function_name, get_closure) &&
1563            Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object TSRMLS_CC) == SUCCESS) {
1564            if (object) {
1565                GC_REFCOUNT(object)++;
1566            }
1567            if (IS_CONST == IS_VAR && 0 && Z_REFCOUNT_P(function_name) == 1 &&
1568                fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
1569                /* Delay closure destruction until its invocation */
1570                fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
1571            } else if (IS_CONST == IS_CV) {
1572
1573            }
1574        } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
1575                zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
1576            zval *obj;
1577            zval *method;
1578
1579            obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
1580            method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
1581
1582            if (!obj || !method) {
1583                zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1");
1584            }
1585
1586            ZVAL_DEREF(obj);
1587            if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
1588                zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
1589            }
1590
1591            ZVAL_DEREF(method);
1592            if (Z_TYPE_P(method) != IS_STRING) {
1593                zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
1594            }
1595
1596            if (Z_TYPE_P(obj) == IS_STRING) {
1597                object = NULL;
1598                called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC);
1599                if (UNEXPECTED(called_scope == NULL)) {
1600                    CHECK_EXCEPTION();
1601                    ZEND_VM_NEXT_OPCODE();
1602                }
1603
1604                if (called_scope->get_static_method) {
1605                    fbc = called_scope->get_static_method(called_scope, Z_STR_P(method) TSRMLS_CC);
1606                } else {
1607                    fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL TSRMLS_CC);
1608                }
1609                if (UNEXPECTED(fbc == NULL)) {
1610                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
1611                }
1612            } else {
1613                called_scope = Z_OBJCE_P(obj);
1614                object = Z_OBJ_P(obj);
1615
1616                fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL TSRMLS_CC);
1617                if (UNEXPECTED(fbc == NULL)) {
1618                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(object), Z_STRVAL_P(method));
1619                }
1620
1621                if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
1622                    object = NULL;
1623                } else {
1624                    GC_REFCOUNT(object)++; /* For $this pointer */
1625                }
1626            }
1627
1628        } else {
1629            if (UNEXPECTED(EG(exception) != NULL)) {
1630                HANDLE_EXCEPTION();
1631            }
1632            zend_error_noreturn(E_ERROR, "Function name must be a string");
1633            ZEND_VM_CONTINUE(); /* Never reached */
1634        }
1635        EX(call) = zend_vm_stack_push_call_frame(
1636            fbc, opline->extended_value, 0, called_scope, object, EX(call) TSRMLS_CC);
1637
1638        CHECK_EXCEPTION();
1639        ZEND_VM_NEXT_OPCODE();
1640    }
1641}
1642
1643static int ZEND_FASTCALL  ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1644{
1645    USE_OPLINE
1646    zval *func_name;
1647    zval *func;
1648    zend_function *fbc;
1649
1650    func_name = opline->op2.zv + 1;
1651    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
1652        fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
1653    } else if ((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL) {
1654        func_name++;
1655        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL)) {
1656            SAVE_OPLINE();
1657            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
1658        } else {
1659            fbc = Z_FUNC_P(func);
1660            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
1661        }
1662    } else {
1663        fbc = Z_FUNC_P(func);
1664        CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
1665    }
1666
1667    EX(call) = zend_vm_stack_push_call_frame(
1668        fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
1669
1670    ZEND_VM_NEXT_OPCODE();
1671}
1672
1673static int ZEND_FASTCALL  ZEND_INIT_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1674{
1675    USE_OPLINE
1676
1677    zval *fname = opline->op2.zv;
1678    zval *func;
1679    zend_function *fbc;
1680
1681    if (CACHED_PTR(Z_CACHE_SLOT_P(fname))) {
1682        fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname));
1683    } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(fname))) == NULL)) {
1684        SAVE_OPLINE();
1685        zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(fname));
1686    } else {
1687        fbc = Z_FUNC_P(func);
1688        CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
1689    }
1690
1691    EX(call) = zend_vm_stack_push_call_frame(
1692        fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
1693
1694    ZEND_VM_NEXT_OPCODE();
1695}
1696
1697static int ZEND_FASTCALL  ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1698{
1699    USE_OPLINE
1700    uint32_t arg_num = opline->op1.num;
1701    zval *param;
1702
1703    SAVE_OPLINE();
1704    param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
1705    if (arg_num > EX(num_args)) {
1706        ZVAL_COPY_VALUE(param, opline->op2.zv);
1707        if (Z_OPT_CONSTANT_P(param)) {
1708            zval_update_constant(param, 0 TSRMLS_CC);
1709        } else {
1710            /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
1711            if (UNEXPECTED(Z_OPT_COPYABLE_P(param))) {
1712                zval_copy_ctor_func(param);
1713            }
1714        }
1715    }
1716
1717    if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
1718        zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
1719    }
1720
1721    CHECK_EXCEPTION();
1722    ZEND_VM_NEXT_OPCODE();
1723}
1724
1725static int ZEND_FASTCALL  ZEND_BRK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1726{
1727    USE_OPLINE
1728    zend_brk_cont_element *el;
1729
1730    SAVE_OPLINE();
1731    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
1732                       &EX(func)->op_array, execute_data TSRMLS_CC);
1733    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->brk);
1734}
1735
1736static int ZEND_FASTCALL  ZEND_CONT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1737{
1738    USE_OPLINE
1739    zend_brk_cont_element *el;
1740
1741    SAVE_OPLINE();
1742    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
1743                       &EX(func)->op_array, execute_data TSRMLS_CC);
1744    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->cont);
1745}
1746
1747static int ZEND_FASTCALL  ZEND_GOTO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1748{
1749    zend_op *brk_opline;
1750    USE_OPLINE
1751    zend_brk_cont_element *el;
1752
1753    SAVE_OPLINE();
1754    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value,
1755                       &EX(func)->op_array, execute_data TSRMLS_CC);
1756
1757    brk_opline = EX(func)->op_array.opcodes + el->brk;
1758
1759    if (brk_opline->opcode == ZEND_FREE) {
1760        if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
1761            zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
1762        }
1763    }
1764    ZEND_VM_JMP(opline->op1.jmp_addr);
1765}
1766
1767static int ZEND_FASTCALL  ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1768{
1769    USE_OPLINE
1770    zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
1771    zend_class_entry *iface;
1772
1773    SAVE_OPLINE();
1774    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
1775        iface = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
1776    } else {
1777        iface = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
1778        if (UNEXPECTED(iface == NULL)) {
1779            CHECK_EXCEPTION();
1780            ZEND_VM_NEXT_OPCODE();
1781        }
1782        CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), iface);
1783    }
1784
1785    if (UNEXPECTED((iface->ce_flags & ZEND_ACC_INTERFACE) == 0)) {
1786        zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name->val, iface->name->val);
1787    }
1788    zend_do_implement_interface(ce, iface TSRMLS_CC);
1789
1790    CHECK_EXCEPTION();
1791    ZEND_VM_NEXT_OPCODE();
1792}
1793
1794static int ZEND_FASTCALL  ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1795{
1796    USE_OPLINE
1797
1798    SAVE_OPLINE();
1799    if (EG(exception)) {
1800        zend_exception_save(TSRMLS_C);
1801    }
1802    if (IS_TMP_VAR == IS_UNUSED) {
1803        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
1804        CHECK_EXCEPTION();
1805        ZEND_VM_NEXT_OPCODE();
1806    } else {
1807        zend_free_op free_op2;
1808        zval *class_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
1809
1810        if (IS_TMP_VAR == IS_CONST) {
1811            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
1812                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
1813            } else {
1814                Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
1815                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
1816            }
1817        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
1818            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
1819        } else if (Z_TYPE_P(class_name) == IS_STRING) {
1820            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
1821        } else {
1822            if (UNEXPECTED(EG(exception) != NULL)) {
1823                HANDLE_EXCEPTION();
1824            }
1825            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
1826        }
1827
1828        zval_ptr_dtor_nogc(free_op2.var);
1829        CHECK_EXCEPTION();
1830        ZEND_VM_NEXT_OPCODE();
1831    }
1832}
1833
1834static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1835{
1836    USE_OPLINE
1837    zend_function *fbc;
1838    zval *function_name, *func;
1839
1840    if (IS_TMP_VAR == IS_CONST && Z_TYPE_P(opline->op2.zv) == IS_STRING) {
1841        function_name = (zval*)(opline->op2.zv+1);
1842        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
1843            fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
1844        } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
1845            SAVE_OPLINE();
1846            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
1847        } else {
1848            fbc = Z_FUNC_P(func);
1849            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
1850        }
1851
1852        EX(call) = zend_vm_stack_push_call_frame(
1853            fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
1854
1855        /*CHECK_EXCEPTION();*/
1856        ZEND_VM_NEXT_OPCODE();
1857    } else {
1858        zend_string *lcname;
1859        zend_free_op free_op2;
1860        zend_class_entry *called_scope;
1861        zend_object *object;
1862        zval *function_name_ptr;
1863
1864        SAVE_OPLINE();
1865        function_name_ptr = function_name = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
1866
1867        ZVAL_DEREF(function_name);
1868        if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
1869            if (Z_STRVAL_P(function_name)[0] == '\\') {
1870                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
1871                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
1872            } else {
1873                lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
1874                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
1875            }
1876            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
1877                zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
1878            }
1879            zend_string_free(lcname);
1880            zval_ptr_dtor_nogc(free_op2.var);
1881
1882            fbc = Z_FUNC_P(func);
1883            called_scope = NULL;
1884            object = NULL;
1885        } else if (IS_TMP_VAR != IS_CONST &&
1886            EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
1887            Z_OBJ_HANDLER_P(function_name, get_closure) &&
1888            Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object TSRMLS_CC) == SUCCESS) {
1889            if (object) {
1890                GC_REFCOUNT(object)++;
1891            }
1892            if (IS_TMP_VAR == IS_VAR && 1 && Z_REFCOUNT_P(function_name) == 1 &&
1893                fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
1894                /* Delay closure destruction until its invocation */
1895                fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
1896            } else if (IS_TMP_VAR == IS_CV) {
1897                zval_ptr_dtor_nogc(free_op2.var);
1898            }
1899        } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
1900                zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
1901            zval *obj;
1902            zval *method;
1903
1904            obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
1905            method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
1906
1907            if (!obj || !method) {
1908                zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1");
1909            }
1910
1911            ZVAL_DEREF(obj);
1912            if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
1913                zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
1914            }
1915
1916            ZVAL_DEREF(method);
1917            if (Z_TYPE_P(method) != IS_STRING) {
1918                zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
1919            }
1920
1921            if (Z_TYPE_P(obj) == IS_STRING) {
1922                object = NULL;
1923                called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC);
1924                if (UNEXPECTED(called_scope == NULL)) {
1925                    CHECK_EXCEPTION();
1926                    ZEND_VM_NEXT_OPCODE();
1927                }
1928
1929                if (called_scope->get_static_method) {
1930                    fbc = called_scope->get_static_method(called_scope, Z_STR_P(method) TSRMLS_CC);
1931                } else {
1932                    fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL TSRMLS_CC);
1933                }
1934                if (UNEXPECTED(fbc == NULL)) {
1935                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
1936                }
1937            } else {
1938                called_scope = Z_OBJCE_P(obj);
1939                object = Z_OBJ_P(obj);
1940
1941                fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL TSRMLS_CC);
1942                if (UNEXPECTED(fbc == NULL)) {
1943                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(object), Z_STRVAL_P(method));
1944                }
1945
1946                if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
1947                    object = NULL;
1948                } else {
1949                    GC_REFCOUNT(object)++; /* For $this pointer */
1950                }
1951            }
1952            zval_ptr_dtor_nogc(free_op2.var);
1953        } else {
1954            if (UNEXPECTED(EG(exception) != NULL)) {
1955                HANDLE_EXCEPTION();
1956            }
1957            zend_error_noreturn(E_ERROR, "Function name must be a string");
1958            ZEND_VM_CONTINUE(); /* Never reached */
1959        }
1960        EX(call) = zend_vm_stack_push_call_frame(
1961            fbc, opline->extended_value, 0, called_scope, object, EX(call) TSRMLS_CC);
1962
1963        CHECK_EXCEPTION();
1964        ZEND_VM_NEXT_OPCODE();
1965    }
1966}
1967
1968static int ZEND_FASTCALL  ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1969{
1970    USE_OPLINE
1971
1972    SAVE_OPLINE();
1973    if (EG(exception)) {
1974        zend_exception_save(TSRMLS_C);
1975    }
1976    if (IS_VAR == IS_UNUSED) {
1977        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
1978        CHECK_EXCEPTION();
1979        ZEND_VM_NEXT_OPCODE();
1980    } else {
1981        zend_free_op free_op2;
1982        zval *class_name = _get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
1983
1984        if (IS_VAR == IS_CONST) {
1985            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
1986                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
1987            } else {
1988                Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
1989                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
1990            }
1991        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
1992            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
1993        } else if (Z_TYPE_P(class_name) == IS_STRING) {
1994            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
1995        } else {
1996            if (UNEXPECTED(EG(exception) != NULL)) {
1997                HANDLE_EXCEPTION();
1998            }
1999            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
2000        }
2001
2002        zval_ptr_dtor_nogc(free_op2.var);
2003        CHECK_EXCEPTION();
2004        ZEND_VM_NEXT_OPCODE();
2005    }
2006}
2007
2008static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2009{
2010    USE_OPLINE
2011    zend_function *fbc;
2012    zval *function_name, *func;
2013
2014    if (IS_VAR == IS_CONST && Z_TYPE_P(opline->op2.zv) == IS_STRING) {
2015        function_name = (zval*)(opline->op2.zv+1);
2016        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
2017            fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
2018        } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
2019            SAVE_OPLINE();
2020            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
2021        } else {
2022            fbc = Z_FUNC_P(func);
2023            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
2024        }
2025
2026        EX(call) = zend_vm_stack_push_call_frame(
2027            fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
2028
2029        /*CHECK_EXCEPTION();*/
2030        ZEND_VM_NEXT_OPCODE();
2031    } else {
2032        zend_string *lcname;
2033        zend_free_op free_op2;
2034        zend_class_entry *called_scope;
2035        zend_object *object;
2036        zval *function_name_ptr;
2037
2038        SAVE_OPLINE();
2039        function_name_ptr = function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC);
2040
2041        ZVAL_DEREF(function_name);
2042        if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2043            if (Z_STRVAL_P(function_name)[0] == '\\') {
2044                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
2045                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
2046            } else {
2047                lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
2048                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
2049            }
2050            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
2051                zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
2052            }
2053            zend_string_free(lcname);
2054            zval_ptr_dtor_nogc(free_op2.var);
2055
2056            fbc = Z_FUNC_P(func);
2057            called_scope = NULL;
2058            object = NULL;
2059        } else if (IS_VAR != IS_CONST &&
2060            EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2061            Z_OBJ_HANDLER_P(function_name, get_closure) &&
2062            Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object TSRMLS_CC) == SUCCESS) {
2063            if (object) {
2064                GC_REFCOUNT(object)++;
2065            }
2066            if (IS_VAR == IS_VAR && (free_op2.var != NULL) && Z_REFCOUNT_P(function_name) == 1 &&
2067                fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2068                /* Delay closure destruction until its invocation */
2069                fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
2070            } else if (IS_VAR == IS_CV) {
2071                zval_ptr_dtor_nogc(free_op2.var);
2072            }
2073        } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2074                zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2075            zval *obj;
2076            zval *method;
2077
2078            obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2079            method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2080
2081            if (!obj || !method) {
2082                zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1");
2083            }
2084
2085            ZVAL_DEREF(obj);
2086            if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2087                zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
2088            }
2089
2090            ZVAL_DEREF(method);
2091            if (Z_TYPE_P(method) != IS_STRING) {
2092                zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
2093            }
2094
2095            if (Z_TYPE_P(obj) == IS_STRING) {
2096                object = NULL;
2097                called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC);
2098                if (UNEXPECTED(called_scope == NULL)) {
2099                    CHECK_EXCEPTION();
2100                    ZEND_VM_NEXT_OPCODE();
2101                }
2102
2103                if (called_scope->get_static_method) {
2104                    fbc = called_scope->get_static_method(called_scope, Z_STR_P(method) TSRMLS_CC);
2105                } else {
2106                    fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL TSRMLS_CC);
2107                }
2108                if (UNEXPECTED(fbc == NULL)) {
2109                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
2110                }
2111            } else {
2112                called_scope = Z_OBJCE_P(obj);
2113                object = Z_OBJ_P(obj);
2114
2115                fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL TSRMLS_CC);
2116                if (UNEXPECTED(fbc == NULL)) {
2117                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(object), Z_STRVAL_P(method));
2118                }
2119
2120                if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2121                    object = NULL;
2122                } else {
2123                    GC_REFCOUNT(object)++; /* For $this pointer */
2124                }
2125            }
2126            zval_ptr_dtor_nogc(free_op2.var);
2127        } else {
2128            if (UNEXPECTED(EG(exception) != NULL)) {
2129                HANDLE_EXCEPTION();
2130            }
2131            zend_error_noreturn(E_ERROR, "Function name must be a string");
2132            ZEND_VM_CONTINUE(); /* Never reached */
2133        }
2134        EX(call) = zend_vm_stack_push_call_frame(
2135            fbc, opline->extended_value, 0, called_scope, object, EX(call) TSRMLS_CC);
2136
2137        CHECK_EXCEPTION();
2138        ZEND_VM_NEXT_OPCODE();
2139    }
2140}
2141
2142static int ZEND_FASTCALL  ZEND_FETCH_CLASS_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2143{
2144    USE_OPLINE
2145
2146    SAVE_OPLINE();
2147    if (EG(exception)) {
2148        zend_exception_save(TSRMLS_C);
2149    }
2150    if (IS_UNUSED == IS_UNUSED) {
2151        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
2152        CHECK_EXCEPTION();
2153        ZEND_VM_NEXT_OPCODE();
2154    } else {
2155
2156        zval *class_name = NULL;
2157
2158        if (IS_UNUSED == IS_CONST) {
2159            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2160                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2161            } else {
2162                Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
2163                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2164            }
2165        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2166            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2167        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2168            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
2169        } else {
2170            if (UNEXPECTED(EG(exception) != NULL)) {
2171                HANDLE_EXCEPTION();
2172            }
2173            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
2174        }
2175
2176        CHECK_EXCEPTION();
2177        ZEND_VM_NEXT_OPCODE();
2178    }
2179}
2180
2181static int ZEND_FASTCALL  ZEND_FETCH_CLASS_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2182{
2183    USE_OPLINE
2184
2185    SAVE_OPLINE();
2186    if (EG(exception)) {
2187        zend_exception_save(TSRMLS_C);
2188    }
2189    if (IS_CV == IS_UNUSED) {
2190        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
2191        CHECK_EXCEPTION();
2192        ZEND_VM_NEXT_OPCODE();
2193    } else {
2194
2195        zval *class_name = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
2196
2197        if (IS_CV == IS_CONST) {
2198            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2199                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2200            } else {
2201                Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC);
2202                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2203            }
2204        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2205            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2206        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2207            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
2208        } else {
2209            if (UNEXPECTED(EG(exception) != NULL)) {
2210                HANDLE_EXCEPTION();
2211            }
2212            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
2213        }
2214
2215        CHECK_EXCEPTION();
2216        ZEND_VM_NEXT_OPCODE();
2217    }
2218}
2219
2220static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2221{
2222    USE_OPLINE
2223    zend_function *fbc;
2224    zval *function_name, *func;
2225
2226    if (IS_CV == IS_CONST && Z_TYPE_P(opline->op2.zv) == IS_STRING) {
2227        function_name = (zval*)(opline->op2.zv+1);
2228        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
2229            fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
2230        } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
2231            SAVE_OPLINE();
2232            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
2233        } else {
2234            fbc = Z_FUNC_P(func);
2235            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
2236        }
2237
2238        EX(call) = zend_vm_stack_push_call_frame(
2239            fbc, opline->extended_value, 0, NULL, NULL, EX(call) TSRMLS_CC);
2240
2241        /*CHECK_EXCEPTION();*/
2242        ZEND_VM_NEXT_OPCODE();
2243    } else {
2244        zend_string *lcname;
2245
2246        zend_class_entry *called_scope;
2247        zend_object *object;
2248        zval *function_name_ptr;
2249
2250        SAVE_OPLINE();
2251        function_name_ptr = function_name = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC);
2252
2253        ZVAL_DEREF(function_name);
2254        if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2255            if (Z_STRVAL_P(function_name)[0] == '\\') {
2256                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
2257                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
2258            } else {
2259                lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
2260                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
2261            }
2262            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
2263                zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
2264            }
2265            zend_string_free(lcname);
2266
2267            fbc = Z_FUNC_P(func);
2268            called_scope = NULL;
2269            object = NULL;
2270        } else if (IS_CV != IS_CONST &&
2271            EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2272            Z_OBJ_HANDLER_P(function_name, get_closure) &&
2273            Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object TSRMLS_CC) == SUCCESS) {
2274            if (object) {
2275                GC_REFCOUNT(object)++;
2276            }
2277            if (IS_CV == IS_VAR && 0 && Z_REFCOUNT_P(function_name) == 1 &&
2278                fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2279                /* Delay closure destruction until its invocation */
2280                fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
2281            } else if (IS_CV == IS_CV) {
2282
2283            }
2284        } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2285                zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2286            zval *obj;
2287            zval *method;
2288
2289            obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2290            method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2291
2292            if (!obj || !method) {
2293                zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1");
2294            }
2295
2296            ZVAL_DEREF(obj);
2297            if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2298                zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
2299            }
2300
2301            ZVAL_DEREF(method);
2302            if (Z_TYPE_P(method) != IS_STRING) {
2303                zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
2304            }
2305
2306            if (Z_TYPE_P(obj) == IS_STRING) {
2307                object = NULL;
2308                called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC);
2309                if (UNEXPECTED(called_scope == NULL)) {
2310                    CHECK_EXCEPTION();
2311                    ZEND_VM_NEXT_OPCODE();
2312                }
2313
2314                if (called_scope->get_static_method) {
2315                    fbc = called_scope->get_static_method(called_scope, Z_STR_P(method) TSRMLS_CC);
2316                } else {
2317                    fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL TSRMLS_CC);
2318                }
2319                if (UNEXPECTED(fbc == NULL)) {
2320                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
2321                }
2322            } else {
2323                called_scope = Z_OBJCE_P(obj);
2324                object = Z_OBJ_P(obj);
2325
2326                fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL TSRMLS_CC);
2327                if (UNEXPECTED(fbc == NULL)) {
2328                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(object), Z_STRVAL_P(method));
2329                }
2330
2331                if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2332                    object = NULL;
2333                } else {
2334                    GC_REFCOUNT(object)++; /* For $this pointer */
2335                }
2336            }
2337
2338        } else {
2339            if (UNEXPECTED(EG(exception) != NULL)) {
2340                HANDLE_EXCEPTION();
2341            }
2342            zend_error_noreturn(E_ERROR, "Function name must be a string");
2343            ZEND_VM_CONTINUE(); /* Never reached */
2344        }
2345        EX(call) = zend_vm_stack_push_call_frame(
2346            fbc, opline->extended_value, 0, called_scope, object, EX(call) TSRMLS_CC);
2347
2348        CHECK_EXCEPTION();
2349        ZEND_VM_NEXT_OPCODE();
2350    }
2351}
2352
2353static int ZEND_FASTCALL  ZEND_BW_NOT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2354{
2355    USE_OPLINE
2356
2357
2358    SAVE_OPLINE();
2359    bitwise_not_function(EX_VAR(opline->result.var),
2360        opline->op1.zv TSRMLS_CC);
2361
2362    CHECK_EXCEPTION();
2363    ZEND_VM_NEXT_OPCODE();
2364}
2365
2366static int ZEND_FASTCALL  ZEND_BOOL_NOT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2367{
2368    USE_OPLINE
2369
2370
2371    SAVE_OPLINE();
2372    boolean_not_function(EX_VAR(opline->result.var),
2373        opline->op1.zv TSRMLS_CC);
2374
2375    CHECK_EXCEPTION();
2376    ZEND_VM_NEXT_OPCODE();
2377}
2378
2379static int ZEND_FASTCALL  ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2380{
2381    USE_OPLINE
2382
2383    zval *z;
2384
2385    SAVE_OPLINE();
2386    z = opline->op1.zv;
2387
2388    zend_print_variable(z TSRMLS_CC);
2389
2390    CHECK_EXCEPTION();
2391    ZEND_VM_NEXT_OPCODE();
2392}
2393
2394static int ZEND_FASTCALL  ZEND_PRINT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2395{
2396    USE_OPLINE
2397
2398    ZVAL_LONG(EX_VAR(opline->result.var), 1);
2399    return ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
2400}
2401
2402static int ZEND_FASTCALL  ZEND_JMPZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2403{
2404    USE_OPLINE
2405
2406    zval *val;
2407
2408    SAVE_OPLINE();
2409    val = opline->op1.zv;
2410
2411    if (IS_CONST == IS_TMP_VAR) {
2412        if (Z_TYPE_P(val) == IS_TRUE) {
2413            ZEND_VM_SET_OPCODE(opline + 1);
2414            ZEND_VM_CONTINUE();
2415        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
2416            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
2417            ZEND_VM_CONTINUE();
2418        }
2419    }
2420
2421    if (i_zend_is_true(val TSRMLS_CC)) {
2422        opline++;
2423    } else {
2424        opline = opline->op2.jmp_addr;
2425    }
2426
2427    if (UNEXPECTED(EG(exception) != NULL)) {
2428        HANDLE_EXCEPTION();
2429    }
2430    ZEND_VM_JMP(opline);
2431}
2432
2433static int ZEND_FASTCALL  ZEND_JMPNZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2434{
2435    USE_OPLINE
2436
2437    zval *val;
2438
2439    SAVE_OPLINE();
2440    val = opline->op1.zv;
2441
2442    if (IS_CONST == IS_TMP_VAR) {
2443        if (Z_TYPE_P(val) == IS_TRUE) {
2444            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
2445            ZEND_VM_CONTINUE();
2446        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
2447            ZEND_VM_SET_OPCODE(opline + 1);
2448            ZEND_VM_CONTINUE();
2449        }
2450    }
2451
2452    if (i_zend_is_true(val TSRMLS_CC)) {
2453        opline = opline->op2.jmp_addr;
2454    } else {
2455        opline++;
2456    }
2457
2458    if (UNEXPECTED(EG(exception) != NULL)) {
2459        HANDLE_EXCEPTION();
2460    }
2461    ZEND_VM_JMP(opline);
2462}
2463
2464static int ZEND_FASTCALL  ZEND_JMPZNZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2465{
2466    USE_OPLINE
2467
2468    zval *val;
2469
2470    SAVE_OPLINE();
2471    val = opline->op1.zv;
2472
2473    if (IS_CONST == IS_TMP_VAR) {
2474        if (EXPECTED(Z_TYPE_P(val) == IS_TRUE)) {
2475            ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
2476            ZEND_VM_CONTINUE();
2477        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
2478            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
2479            ZEND_VM_CONTINUE();
2480        }
2481    }
2482
2483    if (i_zend_is_true(val TSRMLS_CC)) {
2484        opline = (zend_op*)(((char*)opline) + opline->extended_value);
2485    } else {
2486        opline = opline->op2.jmp_addr;
2487    }
2488
2489    if (UNEXPECTED(EG(exception) != NULL)) {
2490        HANDLE_EXCEPTION();
2491    }
2492    ZEND_VM_JMP(opline);
2493}
2494
2495static int ZEND_FASTCALL  ZEND_JMPZ_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2496{
2497    USE_OPLINE
2498
2499    zval *val;
2500
2501    SAVE_OPLINE();
2502    val = opline->op1.zv;
2503
2504    if (IS_CONST == IS_TMP_VAR) {
2505        if (Z_TYPE_P(val) == IS_TRUE) {
2506            ZVAL_TRUE(EX_VAR(opline->result.var));
2507            ZEND_VM_SET_OPCODE(opline + 1);
2508            ZEND_VM_CONTINUE();
2509        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
2510            ZVAL_FALSE(EX_VAR(opline->result.var));
2511            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
2512            ZEND_VM_CONTINUE();
2513        }
2514    }
2515
2516    if (i_zend_is_true(val TSRMLS_CC)) {
2517        ZVAL_TRUE(EX_VAR(opline->result.var));
2518        opline++;
2519    } else {
2520        ZVAL_FALSE(EX_VAR(opline->result.var));
2521        opline = opline->op2.jmp_addr;
2522    }
2523
2524    if (UNEXPECTED(EG(exception) != NULL)) {
2525        HANDLE_EXCEPTION();
2526    }
2527    ZEND_VM_JMP(opline);
2528}
2529
2530static int ZEND_FASTCALL  ZEND_JMPNZ_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2531{
2532    USE_OPLINE
2533
2534    zval *val;
2535
2536    SAVE_OPLINE();
2537    val = opline->op1.zv;
2538
2539    if (IS_CONST == IS_TMP_VAR) {
2540        if (Z_TYPE_P(val) == IS_TRUE) {
2541            ZVAL_TRUE(EX_VAR(opline->result.var));
2542            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
2543            ZEND_VM_CONTINUE();
2544        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
2545            ZVAL_FALSE(EX_VAR(opline->result.var));
2546            ZEND_VM_SET_OPCODE(opline + 1);
2547            ZEND_VM_CONTINUE();
2548        }
2549    }
2550    if (i_zend_is_true(val TSRMLS_CC)) {
2551        ZVAL_TRUE(EX_VAR(opline->result.var));
2552        opline = opline->op2.jmp_addr;
2553    } else {
2554        ZVAL_FALSE(EX_VAR(opline->result.var));
2555        opline++;
2556    }
2557
2558    if (UNEXPECTED(EG(exception) != NULL)) {
2559        HANDLE_EXCEPTION();
2560    }
2561    ZEND_VM_JMP(opline);
2562}
2563
2564static int ZEND_FASTCALL  ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2565{
2566    USE_OPLINE
2567    zval *retval_ptr;
2568
2569
2570    SAVE_OPLINE();
2571    retval_ptr = opline->op1.zv;
2572
2573    if (!EX(return_value)) {
2574
2575    } else {
2576        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
2577            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2578            if (IS_CONST == IS_CONST) {
2579                if (UNEXPECTED(Z_OPT_COPYABLE_P(EX(return_value)))) {
2580                    zval_copy_ctor_func(EX(return_value));
2581                }
2582            }
2583        } else if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) && Z_ISREF_P(retval_ptr)) {
2584            ZVAL_COPY(EX(return_value), Z_REFVAL_P(retval_ptr));
2585
2586        } else {
2587            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2588            if (IS_CONST == IS_CV) {
2589                if (Z_OPT_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2590            }
2591        }
2592    }
2593    return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
2594}
2595
2596static int ZEND_FASTCALL  ZEND_RETURN_BY_REF_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2597{
2598    USE_OPLINE
2599    zval *retval_ptr;
2600
2601
2602    SAVE_OPLINE();
2603
2604    do {
2605        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR ||
2606            (IS_CONST == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
2607            /* Not supposed to happen, but we'll allow it */
2608            zend_error(E_NOTICE, "Only variable references should be returned by reference");
2609
2610            retval_ptr = opline->op1.zv;
2611            if (!EX(return_value)) {
2612                if (IS_CONST == IS_TMP_VAR) {
2613
2614                }
2615            } else {
2616                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2617                if (IS_CONST != IS_TMP_VAR) {
2618                    zval_opt_copy_ctor_no_imm(EX(return_value));
2619                }
2620            }
2621            break;
2622        }
2623
2624        retval_ptr = NULL;
2625
2626        if (IS_CONST == IS_VAR && UNEXPECTED(retval_ptr == NULL)) {
2627            zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");
2628        }
2629
2630        if (IS_CONST == IS_VAR && !Z_ISREF_P(retval_ptr)) {
2631            if (opline->extended_value == ZEND_RETURNS_FUNCTION &&
2632                (Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF)) {
2633            } else {
2634                zend_error(E_NOTICE, "Only variable references should be returned by reference");
2635                if (EX(return_value)) {
2636                    ZVAL_NEW_REF(EX(return_value), retval_ptr);
2637                    if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2638                }
2639                break;
2640            }
2641        }
2642
2643        if (EX(return_value)) {
2644            ZVAL_MAKE_REF(retval_ptr);
2645            Z_ADDREF_P(retval_ptr);
2646            ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
2647        }
2648    } while (0);
2649
2650    return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
2651}
2652
2653static int ZEND_FASTCALL  ZEND_THROW_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2654{
2655    USE_OPLINE
2656    zval *value;
2657
2658
2659    SAVE_OPLINE();
2660    value = opline->op1.zv;
2661
2662    if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
2663        if (UNEXPECTED(EG(exception) != NULL)) {
2664            HANDLE_EXCEPTION();
2665        }
2666        zend_error_noreturn(E_ERROR, "Can only throw objects");
2667    }
2668
2669    zend_exception_save(TSRMLS_C);
2670    if (IS_CONST != IS_TMP_VAR) {
2671        if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
2672    }
2673
2674    zend_throw_exception_object(value TSRMLS_CC);
2675    zend_exception_restore(TSRMLS_C);
2676
2677    HANDLE_EXCEPTION();
2678}
2679
2680static int ZEND_FASTCALL  ZEND_SEND_VAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2681{
2682    USE_OPLINE
2683    zval *value, *arg;
2684
2685
2686    SAVE_OPLINE();
2687    value = opline->op1.zv;
2688    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2689    EX(call)->num_args = opline->op2.num;
2690    ZVAL_COPY_VALUE(arg, value);
2691    if (IS_CONST == IS_CONST) {
2692        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2693            zval_copy_ctor_func(arg);
2694        }
2695    }
2696    ZEND_VM_NEXT_OPCODE();
2697}
2698
2699static int ZEND_FASTCALL  ZEND_SEND_VAL_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2700{
2701    USE_OPLINE
2702    zval *value, *arg;
2703
2704
2705    SAVE_OPLINE();
2706    if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
2707        zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
2708    }
2709    value = opline->op1.zv;
2710    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2711    EX(call)->num_args = opline->op2.num;
2712    ZVAL_COPY_VALUE(arg, value);
2713    if (IS_CONST == IS_CONST) {
2714        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2715            zval_copy_ctor_func(arg);
2716        }
2717    }
2718    ZEND_VM_NEXT_OPCODE();
2719}
2720
2721static int ZEND_FASTCALL  ZEND_BOOL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2722{
2723    USE_OPLINE
2724
2725    zval *retval = EX_VAR(opline->result.var);
2726
2727    SAVE_OPLINE();
2728    /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */
2729    ZVAL_BOOL(retval, i_zend_is_true(opline->op1.zv TSRMLS_CC));
2730
2731    CHECK_EXCEPTION();
2732    ZEND_VM_NEXT_OPCODE();
2733}
2734
2735static int ZEND_FASTCALL  ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2736{
2737    USE_OPLINE
2738
2739    zval *obj;
2740    zend_class_entry *ce;
2741    zend_function *clone;
2742    zend_object_clone_obj_t clone_call;
2743
2744    SAVE_OPLINE();
2745    obj = opline->op1.zv;
2746
2747    if (IS_CONST == IS_CONST ||
2748        UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT)) {
2749        if (UNEXPECTED(EG(exception) != NULL)) {
2750            HANDLE_EXCEPTION();
2751        }
2752        zend_error_noreturn(E_ERROR, "__clone method called on non-object");
2753    }
2754
2755    ce = Z_OBJCE_P(obj);
2756    clone = ce ? ce->clone : NULL;
2757    clone_call =  Z_OBJ_HT_P(obj)->clone_obj;
2758    if (UNEXPECTED(clone_call == NULL)) {
2759        if (ce) {
2760            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name->val);
2761        } else {
2762            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");
2763        }
2764    }
2765
2766    if (ce && clone) {
2767        if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
2768            /* Ensure that if we're calling a private function, we're allowed to do so.
2769             */
2770            if (UNEXPECTED(ce != EX(scope))) {
2771                zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
2772            }
2773        } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
2774            /* Ensure that if we're calling a protected function, we're allowed to do so.
2775             */
2776            if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EX(scope)))) {
2777                zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
2778            }
2779        }
2780    }
2781
2782    if (EXPECTED(EG(exception) == NULL)) {
2783        ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj TSRMLS_CC));
2784        if (!RETURN_VALUE_USED(opline) || UNEXPECTED(EG(exception) != NULL)) {
2785            zval_ptr_dtor(EX_VAR(opline->result.var));
2786        }
2787    }
2788
2789    CHECK_EXCEPTION();
2790    ZEND_VM_NEXT_OPCODE();
2791}
2792
2793static int ZEND_FASTCALL  ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2794{
2795    USE_OPLINE
2796
2797    zval *expr;
2798    zval *result = EX_VAR(opline->result.var);
2799
2800    SAVE_OPLINE();
2801    expr = opline->op1.zv;
2802
2803    switch (opline->extended_value) {
2804        case IS_NULL:
2805            /* This code is taken from convert_to_null. However, it does not seems very useful,
2806             * because a conversion to null always results in the same value. This could only
2807             * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
2808#if 0
2809            if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
2810                ZVAL_DEREF(expr);
2811            }
2812            if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
2813                if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
2814                    break;
2815                }
2816            }
2817#endif
2818
2819            ZVAL_NULL(result);
2820            break;
2821        case _IS_BOOL:
2822            ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
2823            break;
2824        case IS_LONG:
2825            ZVAL_LONG(result, zval_get_long(expr));
2826            break;
2827        case IS_DOUBLE:
2828            ZVAL_DOUBLE(result, zval_get_double(expr));
2829            break;
2830        case IS_STRING:
2831            ZVAL_STR(result, zval_get_string(expr));
2832            break;
2833        default:
2834            /* If value is already of correct type, return it directly */
2835            if (Z_TYPE_P(expr) == opline->extended_value) {
2836                ZVAL_COPY_VALUE(result, expr);
2837                if (IS_CONST == IS_CONST) {
2838                    if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
2839                        zval_copy_ctor_func(result);
2840                    }
2841                } else if (IS_CONST != IS_TMP_VAR) {
2842                    if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
2843                }
2844
2845                CHECK_EXCEPTION();
2846                ZEND_VM_NEXT_OPCODE();
2847            }
2848
2849            if (opline->extended_value == IS_ARRAY) {
2850                if (Z_TYPE_P(expr) != IS_OBJECT) {
2851                    ZVAL_NEW_ARR(result);
2852                    zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
2853                    if (Z_TYPE_P(expr) != IS_NULL) {
2854                        expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
2855                        if (IS_CONST == IS_CONST) {
2856                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
2857                                zval_copy_ctor_func(expr);
2858                            }
2859                        } else if (IS_CONST != IS_TMP_VAR) {
2860                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
2861                        }
2862                    }
2863                } else {
2864                    ZVAL_COPY_VALUE(result, expr);
2865                    if (IS_CONST != IS_TMP_VAR) {
2866                        zval_opt_copy_ctor(result);
2867                    }
2868                    convert_to_array(result);
2869                }
2870            } else {
2871                if (Z_TYPE_P(expr) != IS_ARRAY) {
2872                    object_init(result);
2873                    if (Z_TYPE_P(expr) != IS_NULL) {
2874                        expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
2875                        if (IS_CONST == IS_CONST) {
2876                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
2877                                zval_copy_ctor_func(expr);
2878                            }
2879                        } else if (IS_CONST != IS_TMP_VAR) {
2880                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
2881                        }
2882                    }
2883                } else {
2884                    ZVAL_COPY_VALUE(result, expr);
2885                    if (IS_CONST != IS_TMP_VAR) {
2886                        zval_opt_copy_ctor(result);
2887                    }
2888                    convert_to_object(result);
2889                }
2890            }
2891
2892            CHECK_EXCEPTION();
2893            ZEND_VM_NEXT_OPCODE();
2894    }
2895
2896    CHECK_EXCEPTION();
2897    ZEND_VM_NEXT_OPCODE();
2898}
2899
2900static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2901{
2902    USE_OPLINE
2903    zend_op_array *new_op_array=NULL;
2904
2905    zval *inc_filename;
2906    zval tmp_inc_filename;
2907    zend_bool failure_retval=0;
2908
2909    SAVE_OPLINE();
2910    inc_filename = opline->op1.zv;
2911
2912    ZVAL_UNDEF(&tmp_inc_filename);
2913    if (Z_TYPE_P(inc_filename) != IS_STRING) {
2914        ZVAL_DUP(&tmp_inc_filename, inc_filename);
2915        convert_to_string(&tmp_inc_filename);
2916        inc_filename = &tmp_inc_filename;
2917    }
2918
2919    if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
2920        if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
2921            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
2922        } else {
2923            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
2924        }
2925    } else {
2926        switch (opline->extended_value) {
2927            case ZEND_INCLUDE_ONCE:
2928            case ZEND_REQUIRE_ONCE: {
2929                    zend_file_handle file_handle;
2930                    char *resolved_path;
2931
2932                    resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename) TSRMLS_CC);
2933                    if (resolved_path) {
2934                        failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, (int)strlen(resolved_path));
2935                    } else {
2936                        resolved_path = Z_STRVAL_P(inc_filename);
2937                    }
2938
2939                    if (failure_retval) {
2940                        /* do nothing, file already included */
2941                    } else if (SUCCESS == zend_stream_open(resolved_path, &file_handle TSRMLS_CC)) {
2942
2943                        if (!file_handle.opened_path) {
2944                            file_handle.opened_path = estrdup(resolved_path);
2945                        }
2946
2947                        if (zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, (int)strlen(file_handle.opened_path))) {
2948                            new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
2949                            zend_destroy_file_handle(&file_handle TSRMLS_CC);
2950                        } else {
2951                            zend_file_handle_dtor(&file_handle TSRMLS_CC);
2952                            failure_retval=1;
2953                        }
2954                    } else {
2955                        if (opline->extended_value == ZEND_INCLUDE_ONCE) {
2956                            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
2957                        } else {
2958                            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
2959                        }
2960                    }
2961                    if (resolved_path != Z_STRVAL_P(inc_filename)) {
2962                        efree(resolved_path);
2963                    }
2964                }
2965                break;
2966            case ZEND_INCLUDE:
2967            case ZEND_REQUIRE:
2968                new_op_array = compile_filename(opline->extended_value, inc_filename TSRMLS_CC);
2969                break;
2970            case ZEND_EVAL: {
2971                    char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
2972
2973                    new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
2974                    efree(eval_desc);
2975                }
2976                break;
2977            EMPTY_SWITCH_DEFAULT_CASE()
2978        }
2979    }
2980    if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
2981        zval_ptr_dtor(&tmp_inc_filename);
2982    }
2983
2984    if (UNEXPECTED(EG(exception) != NULL)) {
2985        HANDLE_EXCEPTION();
2986    } else if (EXPECTED(new_op_array != NULL)) {
2987        zval *return_value = NULL;
2988        zend_execute_data *call;
2989
2990        if (RETURN_VALUE_USED(opline)) {
2991            return_value = EX_VAR(opline->result.var);
2992        }
2993
2994        call = zend_vm_stack_push_call_frame(
2995            (zend_function*)new_op_array, 0, 0, EX(called_scope), EX(object), NULL TSRMLS_CC);
2996
2997        if (EX(symbol_table)) {
2998            call->symbol_table = EX(symbol_table);
2999        } else {
3000            call->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
3001        }
3002
3003        call->prev_execute_data = execute_data;
3004        i_init_code_execute_data(call, new_op_array, return_value, EXPECTED(zend_execute_ex == execute_ex) ? VM_FRAME_NESTED_CODE : VM_FRAME_TOP_CODE TSRMLS_CC);
3005        if (EXPECTED(zend_execute_ex == execute_ex)) {
3006            ZEND_VM_ENTER();
3007        } else {
3008            zend_execute_ex(call TSRMLS_CC);
3009        }
3010
3011        destroy_op_array(new_op_array TSRMLS_CC);
3012        efree_size(new_op_array, sizeof(zend_op_array));
3013        if (UNEXPECTED(EG(exception) != NULL)) {
3014            zend_throw_exception_internal(NULL TSRMLS_CC);
3015            HANDLE_EXCEPTION();
3016        }
3017
3018    } else if (RETURN_VALUE_USED(opline)) {
3019        ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
3020    }
3021    ZEND_VM_NEXT_OPCODE();
3022}
3023
3024static int ZEND_FASTCALL  ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3025{
3026    USE_OPLINE
3027
3028    zval *array_ptr, *array_ref, iterator, tmp;
3029    HashTable *fe_ht;
3030    zend_object_iterator *iter = NULL;
3031    zend_class_entry *ce = NULL;
3032    zend_bool is_empty = 0;
3033
3034    SAVE_OPLINE();
3035
3036    if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) &&
3037        (opline->extended_value & ZEND_FE_FETCH_BYREF)) {
3038        array_ptr = array_ref = NULL;
3039        ZVAL_DEREF(array_ptr);
3040        if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
3041            SEPARATE_ARRAY(array_ptr);
3042            if (!Z_ISREF_P(array_ref)) {
3043                ZVAL_NEW_REF(array_ref, array_ref);
3044                array_ptr = Z_REFVAL_P(array_ref);
3045            }
3046            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
3047        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
3048            if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
3049                zend_error(E_WARNING, "foreach() cannot iterate over objects without PHP class");
3050                ZEND_VM_JMP(opline->op2.jmp_addr);
3051            }
3052
3053            ce = Z_OBJCE_P(array_ptr);
3054            if (!ce || ce->get_iterator == NULL) {
3055                Z_ADDREF_P(array_ptr);
3056            }
3057            array_ref = array_ptr;
3058        } else {
3059            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
3060        }
3061    } else {
3062        array_ptr = array_ref = opline->op1.zv;
3063        ZVAL_DEREF(array_ptr);
3064        if (IS_CONST == IS_TMP_VAR) {
3065            ZVAL_COPY_VALUE(&tmp, array_ptr);
3066            if (Z_OPT_IMMUTABLE_P(&tmp)) {
3067                zval_copy_ctor_func(&tmp);
3068            }
3069            array_ref = array_ptr = &tmp;
3070            if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
3071                ce = Z_OBJCE_P(array_ptr);
3072                if (ce && ce->get_iterator) {
3073                    Z_DELREF_P(array_ref);
3074                }
3075            }
3076        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
3077            ce = Z_OBJCE_P(array_ptr);
3078            if (!ce || !ce->get_iterator) {
3079                if (IS_CONST == IS_CV) {
3080                    Z_ADDREF_P(array_ref);
3081                }
3082            }
3083        } else if (Z_IMMUTABLE_P(array_ref)) {
3084            if (IS_CONST == IS_CV) {
3085                zval_copy_ctor_func(array_ref);
3086                Z_ADDREF_P(array_ref);
3087            } else {
3088                ZVAL_COPY_VALUE(&tmp, array_ref);
3089                zval_copy_ctor_func(&tmp);
3090                array_ptr = array_ref = &tmp;
3091            }
3092        } else if (Z_REFCOUNTED_P(array_ref)) {
3093            if (IS_CONST == IS_CONST ||
3094                       (IS_CONST == IS_CV &&
3095                        !Z_ISREF_P(array_ref) &&
3096                        Z_REFCOUNT_P(array_ref) > 1) ||
3097                       (IS_CONST == IS_VAR &&
3098                        !Z_ISREF_P(array_ref) &&
3099                        Z_REFCOUNT_P(array_ref) > 2)) {
3100                if (IS_CONST == IS_VAR) {
3101                    Z_DELREF_P(array_ref);
3102                }
3103                ZVAL_DUP(&tmp, array_ref);
3104                array_ptr = array_ref = &tmp;
3105            } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
3106                if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
3107                    ZVAL_UNREF(array_ref);
3108                    array_ptr = array_ref;
3109                }
3110                if (Z_IMMUTABLE_P(array_ptr)) {
3111                    zval_copy_ctor_func(array_ptr);
3112                } else if (Z_ISREF_P(array_ref) &&
3113                           Z_COPYABLE_P(array_ptr) &&
3114                           Z_REFCOUNT_P(array_ptr) > 1) {
3115                    Z_DELREF_P(array_ptr);
3116                    zval_copy_ctor_func(array_ptr);
3117                }
3118                if (IS_CONST == IS_CV) {
3119                    Z_ADDREF_P(array_ref);
3120                }
3121            }
3122        }
3123    }
3124
3125    if (ce && ce->get_iterator) {
3126        iter = ce->get_iterator(ce, array_ptr, opline->extended_value & ZEND_FE_FETCH_BYREF TSRMLS_CC);
3127
3128        if (IS_CONST == IS_VAR && !(opline->extended_value & ZEND_FE_FETCH_BYREF)) {
3129
3130        }
3131        if (iter && EXPECTED(EG(exception) == NULL)) {
3132            ZVAL_OBJ(&iterator, &iter->std);
3133            array_ptr = array_ref = &iterator;
3134        } else {
3135            if (IS_CONST == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
3136
3137            }
3138            if (!EG(exception)) {
3139                zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val);
3140            }
3141            zend_throw_exception_internal(NULL TSRMLS_CC);
3142            HANDLE_EXCEPTION();
3143        }
3144    }
3145
3146    ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
3147
3148    if (iter) {
3149        iter->index = 0;
3150        if (iter->funcs->rewind) {
3151            iter->funcs->rewind(iter TSRMLS_CC);
3152            if (UNEXPECTED(EG(exception) != NULL)) {
3153                zval_ptr_dtor(array_ref);
3154                if (IS_CONST == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
3155
3156                }
3157                HANDLE_EXCEPTION();
3158            }
3159        }
3160        is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;
3161        if (UNEXPECTED(EG(exception) != NULL)) {
3162            zval_ptr_dtor(array_ref);
3163            if (IS_CONST == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
3164
3165            }
3166            HANDLE_EXCEPTION();
3167        }
3168        iter->index = -1; /* will be set to 0 before using next handler */
3169    } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
3170        HashPointer *ptr = (HashPointer*)EX_VAR((opline+2)->op1.var);
3171        HashPosition pos = 0;
3172        Bucket *p;
3173
3174        while (1) {
3175            if (pos >= fe_ht->nNumUsed) {
3176                is_empty = 1;
3177                if (IS_CONST == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
3178
3179                }
3180                ZEND_VM_JMP(opline->op2.jmp_addr);
3181            }
3182            p = fe_ht->arData + pos;
3183            if (Z_TYPE(p->val) == IS_UNDEF ||
3184                (Z_TYPE(p->val) == IS_INDIRECT &&
3185                 Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)) {
3186                pos++;
3187                continue;
3188            }
3189            if (!ce ||
3190                !p->key ||
3191                zend_check_property_access(Z_OBJ_P(array_ptr), p->key TSRMLS_CC) == SUCCESS) {
3192                break;
3193            }
3194            pos++;
3195        }
3196        fe_ht->nInternalPointer = pos;
3197        ptr->pos = pos;
3198        ptr->ht = fe_ht;
3199        ptr->h = fe_ht->arData[pos].h;
3200        is_empty = 0;
3201    } else {
3202        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
3203        is_empty = 1;
3204    }
3205
3206    if (IS_CONST == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
3207
3208    }
3209    if (is_empty) {
3210        ZEND_VM_JMP(opline->op2.jmp_addr);
3211    } else {
3212        CHECK_EXCEPTION();
3213        ZEND_VM_NEXT_OPCODE();
3214    }
3215}
3216
3217static int ZEND_FASTCALL  ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3218{
3219#if 0 || (IS_CONST != IS_UNUSED)
3220    USE_OPLINE
3221
3222    SAVE_OPLINE();
3223    if (IS_CONST != IS_UNUSED) {
3224
3225        zval *ptr = opline->op1.zv;
3226
3227        if (Z_TYPE_P(ptr) == IS_LONG) {
3228            EG(exit_status) = Z_LVAL_P(ptr);
3229        } else {
3230            zend_print_variable(ptr TSRMLS_CC);
3231        }
3232
3233    }
3234#endif
3235    zend_bailout();
3236    ZEND_VM_NEXT_OPCODE(); /* Never reached */
3237}
3238
3239static int ZEND_FASTCALL  ZEND_JMP_SET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3240{
3241    USE_OPLINE
3242
3243    zval *value;
3244    int is_ref = 0;
3245
3246    SAVE_OPLINE();
3247    value = opline->op1.zv;
3248
3249    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
3250        is_ref = 1;
3251        value = Z_REFVAL_P(value);
3252    }
3253    if (i_zend_is_true(value TSRMLS_CC)) {
3254        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
3255        if (IS_CONST == IS_CONST) {
3256            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
3257                zval_copy_ctor_func(EX_VAR(opline->result.var));
3258            }
3259        } else if (IS_CONST == IS_CV) {
3260            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3261        } else if (IS_CONST == IS_VAR && is_ref) {
3262            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3263
3264        }
3265        ZEND_VM_JMP(opline->op2.jmp_addr);
3266    }
3267
3268    CHECK_EXCEPTION();
3269    ZEND_VM_NEXT_OPCODE();
3270}
3271
3272static int ZEND_FASTCALL  ZEND_COALESCE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3273{
3274    USE_OPLINE
3275
3276    zval *value;
3277    int is_ref = 0;
3278
3279    SAVE_OPLINE();
3280    value = opline->op1.zv;
3281
3282    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
3283        is_ref = 1;
3284        value = Z_REFVAL_P(value);
3285    }
3286
3287    if (Z_TYPE_P(value) > IS_NULL) {
3288        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
3289        if (IS_CONST == IS_CONST) {
3290            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
3291                zval_copy_ctor_func(EX_VAR(opline->result.var));
3292            }
3293        } else if (IS_CONST == IS_CV) {
3294            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3295        } else if (IS_CONST == IS_VAR && is_ref) {
3296            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3297
3298        }
3299        ZEND_VM_JMP(opline->op2.jmp_addr);
3300    }
3301
3302    CHECK_EXCEPTION();
3303    ZEND_VM_NEXT_OPCODE();
3304}
3305
3306static int ZEND_FASTCALL  ZEND_QM_ASSIGN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3307{
3308    USE_OPLINE
3309
3310    zval *value;
3311
3312    SAVE_OPLINE();
3313    value = opline->op1.zv;
3314
3315    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
3316        ZVAL_COPY(EX_VAR(opline->result.var), Z_REFVAL_P(value));
3317
3318    } else {
3319        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
3320        if (IS_CONST == IS_CONST) {
3321            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
3322                zval_copy_ctor_func(EX_VAR(opline->result.var));
3323            }
3324        } else if (IS_CONST == IS_CV) {
3325            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3326        }
3327    }
3328    ZEND_VM_NEXT_OPCODE();
3329}
3330
3331static int ZEND_FASTCALL  ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3332{
3333    USE_OPLINE
3334    zval *value;
3335
3336
3337    SAVE_OPLINE();
3338    value = opline->op1.zv;
3339    if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) {
3340        ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value));
3341    } else {
3342        if (Z_TYPE_P(value) < IS_TRUE) {
3343            ZVAL_LONG(EX_VAR(opline->result.var), 0);
3344        } else if (Z_TYPE_P(value) == IS_TRUE) {
3345            ZVAL_LONG(EX_VAR(opline->result.var), 1);
3346        } else if (Z_TYPE_P(value) <= IS_DOUBLE) {
3347            zend_string *str = zval_get_string(value);
3348            ZVAL_LONG(EX_VAR(opline->result.var), str->len);
3349            zend_string_release(str);
3350        } else if (Z_TYPE_P(value) == IS_OBJECT) {
3351            zend_string *str;
3352            zval tmp;
3353
3354            ZVAL_COPY(&tmp, value);
3355            if (parse_arg_object_to_str(&tmp, &str, IS_STRING TSRMLS_CC) == FAILURE) {
3356                goto strlen_error;
3357            }
3358            ZVAL_LONG(EX_VAR(opline->result.var), str->len);
3359            zval_dtor(&tmp);
3360        } else {
3361strlen_error:
3362            zend_error(E_WARNING, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
3363            ZVAL_NULL(EX_VAR(opline->result.var));
3364        }
3365    }
3366
3367    CHECK_EXCEPTION();
3368    ZEND_VM_NEXT_OPCODE();
3369}
3370
3371static int ZEND_FASTCALL  ZEND_TYPE_CHECK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3372{
3373    USE_OPLINE
3374    zval *value;
3375
3376
3377    SAVE_OPLINE();
3378    value = opline->op1.zv;
3379    switch (opline->extended_value) {
3380        case IS_NULL:
3381        case IS_LONG:
3382        case IS_DOUBLE:
3383        case IS_STRING:
3384        case IS_ARRAY:
3385            ZVAL_BOOL(EX_VAR(opline->result.var), Z_TYPE_P(value) == opline->extended_value);
3386            break;
3387        case _IS_BOOL:
3388            ZVAL_BOOL(EX_VAR(opline->result.var), Z_TYPE_P(value) == IS_TRUE || Z_TYPE_P(value) == IS_FALSE);
3389            break;
3390        case IS_OBJECT:
3391            if (Z_TYPE_P(value) == opline->extended_value) {
3392                if (Z_OBJ_HT_P(value)->get_class_entry == NULL) {
3393                    ZVAL_TRUE(EX_VAR(opline->result.var));
3394                } else {
3395                    zend_class_entry *ce = Z_OBJCE_P(value);
3396                    if (ce->name->len == sizeof("__PHP_Incomplete_Class") - 1
3397                            && !strncmp(ce->name->val, "__PHP_Incomplete_Class", ce->name->len)) {
3398                        ZVAL_FALSE(EX_VAR(opline->result.var));
3399                    } else {
3400                        ZVAL_TRUE(EX_VAR(opline->result.var));
3401                    }
3402                }
3403            } else {
3404                ZVAL_FALSE(EX_VAR(opline->result.var));
3405            }
3406            break;
3407        case IS_RESOURCE:
3408            if (Z_TYPE_P(value) == opline->extended_value) {
3409                const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value) TSRMLS_CC);
3410                ZVAL_BOOL(EX_VAR(opline->result.var), type_name != NULL);
3411            } else {
3412                ZVAL_FALSE(EX_VAR(opline->result.var));
3413            }
3414            break;
3415        EMPTY_SWITCH_DEFAULT_CASE()
3416    }
3417
3418    CHECK_EXCEPTION();
3419    ZEND_VM_NEXT_OPCODE();
3420}
3421
3422static int ZEND_FASTCALL  ZEND_DEFINED_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3423{
3424    USE_OPLINE
3425    zend_constant *c;
3426
3427    SAVE_OPLINE();
3428    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
3429        ZVAL_TRUE(EX_VAR(opline->result.var));
3430    } else if ((c = zend_quick_get_constant(opline->op1.zv, 0 TSRMLS_CC)) == NULL) {
3431        ZVAL_FALSE(EX_VAR(opline->result.var));
3432    } else {
3433        CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), c);
3434        ZVAL_TRUE(EX_VAR(opline->result.var));
3435    }
3436    CHECK_EXCEPTION();
3437    ZEND_VM_NEXT_OPCODE();
3438}
3439
3440static int ZEND_FASTCALL  ZEND_ADD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3441{
3442    USE_OPLINE
3443
3444
3445    SAVE_OPLINE();
3446    fast_add_function(EX_VAR(opline->result.var),
3447        opline->op1.zv,
3448        opline->op2.zv TSRMLS_CC);
3449
3450
3451    CHECK_EXCEPTION();
3452    ZEND_VM_NEXT_OPCODE();
3453}
3454
3455static int ZEND_FASTCALL  ZEND_SUB_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3456{
3457    USE_OPLINE
3458
3459
3460    SAVE_OPLINE();
3461    fast_sub_function(EX_VAR(opline->result.var),
3462        opline->op1.zv,
3463        opline->op2.zv TSRMLS_CC);
3464
3465
3466    CHECK_EXCEPTION();
3467    ZEND_VM_NEXT_OPCODE();
3468}
3469
3470static int ZEND_FASTCALL  ZEND_MUL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3471{
3472    USE_OPLINE
3473
3474
3475    SAVE_OPLINE();
3476    fast_mul_function(EX_VAR(opline->result.var),
3477        opline->op1.zv,
3478        opline->op2.zv TSRMLS_CC);
3479
3480
3481    CHECK_EXCEPTION();
3482    ZEND_VM_NEXT_OPCODE();
3483}
3484
3485static int ZEND_FASTCALL  ZEND_DIV_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3486{
3487    USE_OPLINE
3488
3489
3490    SAVE_OPLINE();
3491    fast_div_function(EX_VAR(opline->result.var),
3492        opline->op1.zv,
3493        opline->op2.zv TSRMLS_CC);
3494
3495
3496    CHECK_EXCEPTION();
3497    ZEND_VM_NEXT_OPCODE();
3498}
3499
3500static int ZEND_FASTCALL  ZEND_MOD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3501{
3502    USE_OPLINE
3503
3504
3505    SAVE_OPLINE();
3506    fast_mod_function(EX_VAR(opline->result.var),
3507        opline->op1.zv,
3508        opline->op2.zv TSRMLS_CC);
3509
3510
3511    CHECK_EXCEPTION();
3512    ZEND_VM_NEXT_OPCODE();
3513}
3514
3515static int ZEND_FASTCALL  ZEND_SL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3516{
3517    USE_OPLINE
3518
3519
3520    SAVE_OPLINE();
3521    shift_left_function(EX_VAR(opline->result.var),
3522        opline->op1.zv,
3523        opline->op2.zv TSRMLS_CC);
3524
3525
3526    CHECK_EXCEPTION();
3527    ZEND_VM_NEXT_OPCODE();
3528}
3529
3530static int ZEND_FASTCALL  ZEND_SR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3531{
3532    USE_OPLINE
3533
3534
3535    SAVE_OPLINE();
3536    shift_right_function(EX_VAR(opline->result.var),
3537        opline->op1.zv,
3538        opline->op2.zv TSRMLS_CC);
3539
3540
3541    CHECK_EXCEPTION();
3542    ZEND_VM_NEXT_OPCODE();
3543}
3544
3545static int ZEND_FASTCALL  ZEND_CONCAT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3546{
3547    USE_OPLINE
3548
3549
3550    SAVE_OPLINE();
3551    concat_function(EX_VAR(opline->result.var),
3552        opline->op1.zv,
3553        opline->op2.zv TSRMLS_CC);
3554
3555
3556    CHECK_EXCEPTION();
3557    ZEND_VM_NEXT_OPCODE();
3558}
3559
3560static int ZEND_FASTCALL  ZEND_IS_IDENTICAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3561{
3562    USE_OPLINE
3563
3564
3565    SAVE_OPLINE();
3566    fast_is_identical_function(EX_VAR(opline->result.var),
3567        opline->op1.zv,
3568        opline->op2.zv TSRMLS_CC);
3569
3570
3571    CHECK_EXCEPTION();
3572    ZEND_VM_NEXT_OPCODE();
3573}
3574
3575static int ZEND_FASTCALL  ZEND_IS_NOT_IDENTICAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3576{
3577    USE_OPLINE
3578
3579    zval *result = EX_VAR(opline->result.var);
3580
3581    SAVE_OPLINE();
3582    fast_is_not_identical_function(result,
3583        opline->op1.zv,
3584        opline->op2.zv TSRMLS_CC);
3585
3586
3587    CHECK_EXCEPTION();
3588    ZEND_VM_NEXT_OPCODE();
3589}
3590
3591static int ZEND_FASTCALL  ZEND_IS_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3592{
3593    USE_OPLINE
3594
3595    zval *result = EX_VAR(opline->result.var);
3596
3597    SAVE_OPLINE();
3598    fast_equal_function(result,
3599        opline->op1.zv,
3600        opline->op2.zv TSRMLS_CC);
3601
3602
3603    CHECK_EXCEPTION();
3604    ZEND_VM_NEXT_OPCODE();
3605}
3606
3607static int ZEND_FASTCALL  ZEND_IS_NOT_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3608{
3609    USE_OPLINE
3610
3611    zval *result = EX_VAR(opline->result.var);
3612
3613    SAVE_OPLINE();
3614    fast_not_equal_function(result,
3615        opline->op1.zv,
3616        opline->op2.zv TSRMLS_CC);
3617
3618
3619    CHECK_EXCEPTION();
3620    ZEND_VM_NEXT_OPCODE();
3621}
3622
3623static int ZEND_FASTCALL  ZEND_IS_SMALLER_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3624{
3625    USE_OPLINE
3626
3627    zval *result = EX_VAR(opline->result.var);
3628
3629    SAVE_OPLINE();
3630    fast_is_smaller_function(result,
3631        opline->op1.zv,
3632        opline->op2.zv TSRMLS_CC);
3633
3634
3635    CHECK_EXCEPTION();
3636    ZEND_VM_NEXT_OPCODE();
3637}
3638
3639static int ZEND_FASTCALL  ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3640{
3641    USE_OPLINE
3642
3643    zval *result = EX_VAR(opline->result.var);
3644
3645    SAVE_OPLINE();
3646    fast_is_smaller_or_equal_function(result,
3647        opline->op1.zv,
3648        opline->op2.zv TSRMLS_CC);
3649
3650
3651    CHECK_EXCEPTION();
3652    ZEND_VM_NEXT_OPCODE();
3653}
3654
3655static int ZEND_FASTCALL  ZEND_BW_OR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3656{
3657    USE_OPLINE
3658
3659
3660    SAVE_OPLINE();
3661    bitwise_or_function(EX_VAR(opline->result.var),
3662        opline->op1.zv,
3663        opline->op2.zv TSRMLS_CC);
3664
3665
3666    CHECK_EXCEPTION();
3667    ZEND_VM_NEXT_OPCODE();
3668}
3669
3670static int ZEND_FASTCALL  ZEND_BW_AND_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3671{
3672    USE_OPLINE
3673
3674
3675    SAVE_OPLINE();
3676    bitwise_and_function(EX_VAR(opline->result.var),
3677        opline->op1.zv,
3678        opline->op2.zv TSRMLS_CC);
3679
3680
3681    CHECK_EXCEPTION();
3682    ZEND_VM_NEXT_OPCODE();
3683}
3684
3685static int ZEND_FASTCALL  ZEND_BW_XOR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3686{
3687    USE_OPLINE
3688
3689
3690    SAVE_OPLINE();
3691    bitwise_xor_function(EX_VAR(opline->result.var),
3692        opline->op1.zv,
3693        opline->op2.zv TSRMLS_CC);
3694
3695
3696    CHECK_EXCEPTION();
3697    ZEND_VM_NEXT_OPCODE();
3698}
3699
3700static int ZEND_FASTCALL  ZEND_BOOL_XOR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3701{
3702    USE_OPLINE
3703
3704
3705    SAVE_OPLINE();
3706    boolean_xor_function(EX_VAR(opline->result.var),
3707        opline->op1.zv,
3708        opline->op2.zv TSRMLS_CC);
3709
3710
3711    CHECK_EXCEPTION();
3712    ZEND_VM_NEXT_OPCODE();
3713}
3714
3715static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type, ZEND_OPCODE_HANDLER_ARGS)
3716{
3717    USE_OPLINE
3718
3719    zval *varname;
3720    zval *retval;
3721    zend_string *name;
3722    HashTable *target_symbol_table;
3723
3724    SAVE_OPLINE();
3725    varname = opline->op1.zv;
3726
3727    if (IS_CONST == IS_CONST) {
3728        name = Z_STR_P(varname);
3729    } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
3730        name = Z_STR_P(varname);
3731        zend_string_addref(name);
3732    } else {
3733        name = zval_get_string(varname);
3734    }
3735
3736    if (IS_CONST != IS_UNUSED) {
3737        zend_class_entry *ce;
3738
3739        if (IS_CONST == IS_CONST) {
3740            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
3741                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
3742            } else {
3743                ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
3744                if (UNEXPECTED(ce == NULL)) {
3745                    if (IS_CONST != IS_CONST) {
3746                        zend_string_release(name);
3747                    }
3748
3749                    CHECK_EXCEPTION();
3750                    ZEND_VM_NEXT_OPCODE();
3751                }
3752                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
3753            }
3754        } else {
3755            ce = Z_CE_P(EX_VAR(opline->op2.var));
3756        }
3757        retval = zend_std_get_static_property(ce, name, 0, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC);
3758
3759    } else {
3760        target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
3761        retval = zend_hash_find(target_symbol_table, name);
3762        if (retval == NULL) {
3763            switch (type) {
3764                case BP_VAR_R:
3765                case BP_VAR_UNSET:
3766                    zend_error(E_NOTICE,"Undefined variable: %s", name->val);
3767                    /* break missing intentionally */
3768                case BP_VAR_IS:
3769                    retval = &EG(uninitialized_zval);
3770                    break;
3771                case BP_VAR_RW:
3772                    zend_error(E_NOTICE,"Undefined variable: %s", name->val);
3773                    /* break missing intentionally */
3774                case BP_VAR_W:
3775                    retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
3776                    break;
3777                EMPTY_SWITCH_DEFAULT_CASE()
3778            }
3779        /* GLOBAL or $$name variable may be an INDIRECT pointer to CV */
3780        } else if (Z_TYPE_P(retval) == IS_INDIRECT) {
3781            retval = Z_INDIRECT_P(retval);
3782            if (Z_TYPE_P(retval) == IS_UNDEF) {
3783                switch (type) {
3784                    case BP_VAR_R:
3785                    case BP_VAR_UNSET:
3786                        zend_error(E_NOTICE,"Undefined variable: %s", name->val);
3787                        /* break missing intentionally */
3788                    case BP_VAR_IS:
3789                        retval = &EG(uninitialized_zval);
3790                        break;
3791                    case BP_VAR_RW:
3792                        zend_error(E_NOTICE,"Undefined variable: %s", name->val);
3793                        /* break missing intentionally */
3794                    case BP_VAR_W:
3795                        ZVAL_NULL(retval);
3796                        break;
3797                    EMPTY_SWITCH_DEFAULT_CASE()
3798                }
3799            }
3800        }
3801        if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) == ZEND_FETCH_STATIC) {
3802            if (Z_CONSTANT_P(retval)) {
3803                zval_update_constant(retval, 1 TSRMLS_CC);
3804            }
3805        } else if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) {
3806
3807        }
3808    }
3809
3810    if (IS_CONST != IS_CONST) {
3811        zend_string_release(name);
3812    }
3813
3814    ZEND_ASSERT(retval != NULL);
3815    if (type == BP_VAR_R || type == BP_VAR_IS) {
3816        if (/*type == BP_VAR_R &&*/ Z_ISREF_P(retval) && Z_REFCOUNT_P(retval) == 1) {
3817            ZVAL_UNREF(retval);
3818        }
3819        ZVAL_COPY(EX_VAR(opline->result.var), retval);
3820    } else {
3821        if (/*type == BP_VAR_W &&*/ (opline->extended_value & ZEND_FETCH_MAKE_REF)) {
3822            ZVAL_MAKE_REF(retval);
3823        }
3824        ZVAL_INDIRECT(EX_VAR(opline->result.var), retval);
3825    }
3826    CHECK_EXCEPTION();
3827    ZEND_VM_NEXT_OPCODE();
3828}
3829
3830static int ZEND_FASTCALL  ZEND_FETCH_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3831{
3832    return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3833}
3834
3835static int ZEND_FASTCALL  ZEND_FETCH_W_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3836{
3837    return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_W, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3838}
3839
3840static int ZEND_FASTCALL  ZEND_FETCH_RW_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3841{
3842    return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_RW, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3843}
3844
3845static int ZEND_FASTCALL  ZEND_FETCH_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3846{
3847    USE_OPLINE
3848
3849    if (zend_is_by_ref_func_arg_fetch(opline, EX(call) TSRMLS_CC)) {
3850        return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_W, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3851    } else {
3852        return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3853    }
3854}
3855
3856static int ZEND_FASTCALL  ZEND_FETCH_UNSET_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3857{
3858    return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_UNSET, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3859}
3860
3861static int ZEND_FASTCALL  ZEND_FETCH_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3862{
3863    return zend_fetch_var_address_helper_SPEC_CONST_CONST(BP_VAR_IS, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
3864}
3865
3866static int ZEND_FASTCALL  ZEND_FETCH_DIM_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3867{
3868    USE_OPLINE
3869
3870    zval *container;
3871
3872    SAVE_OPLINE();
3873    container = opline->op1.zv;
3874    zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC);
3875
3876    if (IS_CONST != IS_VAR || !(opline->extended_value & ZEND_FETCH_ADD_LOCK)) {
3877
3878    }
3879    CHECK_EXCEPTION();
3880    ZEND_VM_NEXT_OPCODE();
3881}
3882
3883static int ZEND_FASTCALL  ZEND_FETCH_DIM_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3884{
3885    USE_OPLINE
3886
3887    zval *container;
3888
3889    SAVE_OPLINE();
3890    container = opline->op1.zv;
3891    zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC);
3892
3893
3894    CHECK_EXCEPTION();
3895    ZEND_VM_NEXT_OPCODE();
3896}
3897
3898static int ZEND_FASTCALL  ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3899{
3900    USE_OPLINE
3901    zval *container;
3902    zend_free_op free_op1;
3903
3904    SAVE_OPLINE();
3905
3906    if (zend_is_by_ref_func_arg_fetch(opline, EX(call) TSRMLS_CC)) {
3907        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
3908            zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context");
3909        }
3910        container = NULL;
3911        if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) {
3912            zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
3913        }
3914        zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC);
3915        if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
3916            EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
3917        }
3918
3919
3920    } else {
3921        if (IS_CONST == IS_UNUSED) {
3922            zend_error_noreturn(E_ERROR, "Cannot use [] for reading");
3923        }
3924        container = opline->op1.zv;
3925        zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, opline->op2.zv, IS_CONST TSRMLS_CC);
3926
3927
3928    }
3929    CHECK_EXCEPTION();
3930    ZEND_VM_NEXT_OPCODE();
3931}
3932
3933static int ZEND_FASTCALL  ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3934{
3935    USE_OPLINE
3936
3937    zval *container;
3938
3939    zval *offset;
3940
3941    SAVE_OPLINE();
3942    container = opline->op1.zv;
3943    offset  = opline->op2.zv;
3944
3945    if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) ||
3946        UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) {
3947        zend_error(E_NOTICE, "Trying to get property of non-object");
3948        ZVAL_NULL(EX_VAR(opline->result.var));
3949    } else {
3950        zval *retval;
3951
3952        /* here we are sure we are dealing with an object */
3953        retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC);
3954
3955        if (retval != EX_VAR(opline->result.var)) {
3956            ZVAL_COPY(EX_VAR(opline->result.var), retval);
3957        }
3958    }
3959
3960
3961    CHECK_EXCEPTION();
3962    ZEND_VM_NEXT_OPCODE();
3963}
3964
3965static int ZEND_FASTCALL  ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3966{
3967    USE_OPLINE
3968
3969    zval *container;
3970
3971    zval *offset;
3972
3973    SAVE_OPLINE();
3974    container = opline->op1.zv;
3975    offset  = opline->op2.zv;
3976
3977    if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT) ||
3978        UNEXPECTED(Z_OBJ_HT_P(container)->read_property == NULL)) {
3979        ZVAL_NULL(EX_VAR(opline->result.var));
3980    } else {
3981        zval *retval;
3982
3983        /* here we are sure we are dealing with an object */
3984        retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC);
3985
3986        if (retval != EX_VAR(opline->result.var)) {
3987            ZVAL_COPY(EX_VAR(opline->result.var), retval);
3988        }
3989    }
3990
3991
3992    CHECK_EXCEPTION();
3993    ZEND_VM_NEXT_OPCODE();
3994}
3995
3996static int ZEND_FASTCALL  ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3997{
3998    USE_OPLINE
3999    zval *container;
4000
4001    if (zend_is_by_ref_func_arg_fetch(opline, EX(call) TSRMLS_CC)) {
4002        /* Behave like FETCH_OBJ_W */
4003        zend_free_op free_op1;
4004        zval *property;
4005
4006        SAVE_OPLINE();
4007        property = opline->op2.zv;
4008        container = NULL;
4009
4010        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
4011            zend_error_noreturn(E_ERROR, "Cannot use temporary expression in write context");
4012        }
4013        if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) {
4014            zend_error_noreturn(E_ERROR, "Cannot use string offset as an object");
4015        }
4016        zend_fetch_property_address(EX_VAR(opline->result.var), container, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W, 0 TSRMLS_CC);
4017
4018        if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) {
4019            EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
4020        }
4021
4022        CHECK_EXCEPTION();
4023        ZEND_VM_NEXT_OPCODE();
4024    } else {
4025        return ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
4026    }
4027}
4028
4029static int ZEND_FASTCALL  ZEND_FETCH_DIM_TMP_VAR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4030{
4031    USE_OPLINE
4032
4033    zval *container;
4034
4035    SAVE_OPLINE();
4036    container = opline->op1.zv;
4037
4038    if (UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
4039        ZVAL_NULL(EX_VAR(opline->result.var));
4040    } else {
4041
4042        zval *value = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), opline->op2.zv, IS_CONST, BP_VAR_R TSRMLS_CC);
4043
4044        ZVAL_COPY(EX_VAR(opline->result.var), value);
4045
4046    }
4047    CHECK_EXCEPTION();
4048    ZEND_VM_NEXT_OPCODE();
4049}
4050
4051static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4052{
4053    USE_OPLINE
4054    zval *function_name;
4055    zend_class_entry *ce;
4056    zend_object *object;
4057    zend_function *fbc;
4058
4059    SAVE_OPLINE();
4060
4061    if (IS_CONST == IS_CONST) {
4062        /* no function found. try a static method in class */
4063        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
4064            ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
4065        } else {
4066            ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
4067            if (UNEXPECTED(EG(exception) != NULL)) {
4068                HANDLE_EXCEPTION();
4069            }
4070            if (UNEXPECTED(ce == NULL)) {
4071                zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
4072            }
4073            CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
4074        }
4075    } else {
4076        ce = Z_CE_P(EX_VAR(opline->op1.var));
4077    }
4078
4079    if (IS_CONST == IS_CONST &&
4080        IS_CONST == IS_CONST &&
4081        CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4082        fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4083    } else if (IS_CONST != IS_CONST &&
4084               IS_CONST == IS_CONST &&
4085               (fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce))) {
4086        /* do nothing */
4087    } else if (IS_CONST != IS_UNUSED) {
4088
4089
4090        function_name = opline->op2.zv;
4091        if (IS_CONST != IS_CONST) {
4092            if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
4093                if (UNEXPECTED(EG(exception) != NULL)) {
4094                    HANDLE_EXCEPTION();
4095                }
4096                zend_error_noreturn(E_ERROR, "Function name must be a string");
4097            }
4098        }
4099
4100        if (ce->get_static_method) {
4101            fbc = ce->get_static_method(ce, Z_STR_P(function_name) TSRMLS_CC);
4102        } else {
4103            fbc = zend_std_get_static_method(ce, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.zv + 1) : NULL) TSRMLS_CC);
4104        }
4105        if (UNEXPECTED(fbc == NULL)) {
4106            zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name->val, Z_STRVAL_P(function_name));
4107        }
4108        if (IS_CONST == IS_CONST &&
4109            EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
4110            EXPECTED((fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) {
4111            if (IS_CONST == IS_CONST) {
4112                CACHE_PTR(Z_CACHE_SLOT_P(function_name), fbc);
4113            } else {
4114                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), ce, fbc);
4115            }
4116        }
4117        if (IS_CONST != IS_CONST) {
4118
4119        }
4120    } else {
4121        if (UNEXPECTED(ce->constructor == NULL)) {
4122            zend_error_noreturn(E_ERROR, "Cannot call constructor");
4123        }
4124        if (EX(object) && zend_get_class_entry(EX(object) TSRMLS_CC) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
4125            zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val);
4126        }
4127        fbc = ce->constructor;
4128    }
4129
4130    object = NULL;
4131    if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
4132        if (EX(object)) {
4133            object = EX(object);
4134            GC_REFCOUNT(object)++;
4135            if (object->handlers->get_class_entry &&
4136                !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
4137                /* We are calling method of the other (incompatible) class,
4138                   but passing $this. This is done for compatibility with php-4. */
4139                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
4140                    zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
4141                } else {
4142                    /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
4143                    zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
4144                }
4145            }
4146        }
4147    }
4148
4149    if (IS_CONST != IS_CONST) {
4150        /* previous opcode is ZEND_FETCH_CLASS */
4151        if ((opline-1)->extended_value == ZEND_FETCH_CLASS_PARENT || (opline-1)->extended_value == ZEND_FETCH_CLASS_SELF) {
4152            ce = EX(called_scope);
4153        }
4154    }
4155
4156    EX(call) = zend_vm_stack_push_call_frame(
4157        fbc, opline->extended_value, 0, ce, object, EX(call) TSRMLS_CC);
4158
4159    if (IS_CONST == IS_UNUSED) {
4160        EX(call)->return_value = NULL;
4161    }
4162
4163    CHECK_EXCEPTION();
4164    ZEND_VM_NEXT_OPCODE();
4165}
4166
4167static int ZEND_FASTCALL  ZEND_INIT_USER_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4168{
4169    USE_OPLINE
4170
4171    zval *function_name = opline->op2.zv;
4172    zend_fcall_info_cache fcc;
4173    char *error = NULL;
4174    zend_function *func;
4175    zend_class_entry *called_scope;
4176    zend_object *object;
4177
4178    if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error TSRMLS_CC)) {
4179        if (error) {
4180            efree(error);
4181        }
4182        func = fcc.function_handler;
4183        if (func->common.fn_flags & ZEND_ACC_CLOSURE) {
4184            /* Delay closure destruction until its invocation */
4185            func->common.prototype = (zend_function*)Z_OBJ_P(function_name);
4186            Z_ADDREF_P(function_name);
4187        }
4188        called_scope = fcc.called_scope;
4189        object = fcc.object;
4190        if (object) {
4191            GC_REFCOUNT(object)++; /* For $this pointer */
4192        }
4193    } else {
4194        zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
4195        efree(error);
4196        func = (zend_function*)&zend_pass_function;
4197        called_scope = NULL;
4198        object = NULL;
4199    }
4200
4201    EX(call) = zend_vm_stack_push_call_frame(
4202        func, opline->extended_value, 0, called_scope, object, EX(call) TSRMLS_CC);
4203
4204    CHECK_EXCEPTION();
4205    ZEND_VM_NEXT_OPCODE();
4206}
4207
4208static int ZEND_FASTCALL  ZEND_CASE_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4209{
4210    USE_OPLINE
4211
4212    zval *result = EX_VAR(opline->result.var);
4213
4214    SAVE_OPLINE();
4215    fast_equal_function(result,
4216         opline->op1.zv,
4217         opline->op2.zv TSRMLS_CC);
4218
4219    CHECK_EXCEPTION();
4220    ZEND_VM_NEXT_OPCODE();
4221}
4222
4223static int ZEND_FASTCALL  ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4224{
4225    USE_OPLINE
4226
4227    SAVE_OPLINE();
4228    if (IS_CONST == IS_UNUSED) {
4229        zend_constant *c;
4230        zval *retval;
4231
4232        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4233            c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4234        } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) {
4235            if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
4236                char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv));
4237                if(!actual) {
4238                    actual = Z_STRVAL_P(opline->op2.zv);
4239                } else {
4240                    actual++;
4241                }
4242                /* non-qualified constant - allow text substitution */
4243                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
4244                ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv)));
4245                CHECK_EXCEPTION();
4246                ZEND_VM_NEXT_OPCODE();
4247            } else {
4248                zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL_P(opline->op2.zv));
4249            }
4250        } else {
4251            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), c);
4252        }
4253        retval = EX_VAR(opline->result.var);
4254        ZVAL_COPY_VALUE(retval, &c->value);
4255        if (Z_OPT_COPYABLE_P(retval) || Z_OPT_REFCOUNTED_P(retval)) {
4256            if (Z_OPT_COPYABLE_P(retval)) {
4257                zval_copy_ctor_func(retval);
4258            } else {
4259                Z_ADDREF_P(retval);
4260            }
4261        }
4262    } else {
4263        /* class constant */
4264        zend_class_entry *ce;
4265        zval *value;
4266
4267        if (IS_CONST == IS_CONST) {
4268            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4269                value = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4270                ZVAL_DEREF(value);
4271                ZVAL_DUP(EX_VAR(opline->result.var), value);
4272                goto constant_fetch_end;
4273            } else if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
4274                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
4275            } else {
4276                ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, opline->extended_value TSRMLS_CC);
4277                if (UNEXPECTED(EG(exception) != NULL)) {
4278                    HANDLE_EXCEPTION();
4279                }
4280                if (UNEXPECTED(ce == NULL)) {
4281                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
4282                }
4283                CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
4284            }
4285        } else {
4286            ce = Z_CE_P(EX_VAR(opline->op1.var));
4287            if ((value = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce)) != NULL) {
4288                ZVAL_DEREF(value);
4289                ZVAL_DUP(EX_VAR(opline->result.var), value);
4290                goto constant_fetch_end;
4291            }
4292        }
4293
4294        if (EXPECTED((value = zend_hash_find(&ce->constants_table, Z_STR_P(opline->op2.zv))) != NULL)) {
4295            ZVAL_DEREF(value);
4296            if (Z_CONSTANT_P(value)) {
4297                EG(scope) = ce;
4298                zval_update_constant(value, 1 TSRMLS_CC);
4299                EG(scope) = EX(scope);
4300            }
4301            if (IS_CONST == IS_CONST) {
4302                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), value);
4303            } else {
4304                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value);
4305            }
4306            ZVAL_DUP(EX_VAR(opline->result.var), value);
4307        } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
4308            /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
4309            ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
4310        } else {
4311            zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
4312        }
4313    }
4314constant_fetch_end:
4315    CHECK_EXCEPTION();
4316    ZEND_VM_NEXT_OPCODE();
4317}
4318
4319static int ZEND_FASTCALL  ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4320{
4321    USE_OPLINE
4322
4323    zval *expr_ptr, new_expr;
4324
4325    SAVE_OPLINE();
4326    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) &&
4327        (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) {
4328        expr_ptr = NULL;
4329        if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr == NULL)) {
4330            zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
4331        }
4332        ZVAL_MAKE_REF(expr_ptr);
4333        Z_ADDREF_P(expr_ptr);
4334
4335    } else {
4336        expr_ptr = opline->op1.zv;
4337        if (IS_CONST == IS_TMP_VAR) {
4338            ZVAL_COPY_VALUE(&new_expr, expr_ptr);
4339            expr_ptr = &new_expr;
4340        } else if (IS_CONST == IS_CONST) {
4341            if (!Z_IMMUTABLE_P(expr_ptr)) {
4342                ZVAL_DUP(&new_expr, expr_ptr);
4343                expr_ptr = &new_expr;
4344            }
4345        } else if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) && Z_ISREF_P(expr_ptr)) {
4346            expr_ptr = Z_REFVAL_P(expr_ptr);
4347            if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr);
4348
4349        } else if (IS_CONST == IS_CV && Z_REFCOUNTED_P(expr_ptr)) {
4350            Z_ADDREF_P(expr_ptr);
4351        }
4352    }
4353
4354    if (IS_CONST != IS_UNUSED) {
4355
4356        zval *offset = opline->op2.zv;
4357        zend_string *str;
4358        zend_ulong hval;
4359
4360add_again:
4361        switch (Z_TYPE_P(offset)) {
4362            case IS_DOUBLE:
4363                hval = zend_dval_to_lval(Z_DVAL_P(offset));
4364                goto num_index;
4365            case IS_LONG:
4366                hval = Z_LVAL_P(offset);
4367num_index:
4368                zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr);
4369                break;
4370            case IS_STRING:
4371                str = Z_STR_P(offset);
4372                if (IS_CONST != IS_CONST) {
4373                    if (ZEND_HANDLE_NUMERIC(str, hval)) {
4374                        goto num_index;
4375                    }
4376                }
4377str_index:
4378                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
4379                break;
4380            case IS_NULL:
4381                str = STR_EMPTY_ALLOC();
4382                goto str_index;
4383            case IS_FALSE:
4384                hval = 0;
4385                goto num_index;
4386            case IS_TRUE:
4387                hval = 1;
4388                goto num_index;
4389            case IS_REFERENCE:
4390                offset = Z_REFVAL_P(offset);
4391                goto add_again;
4392                break;
4393            default:
4394                zend_error(E_WARNING, "Illegal offset type");
4395                zval_ptr_dtor(expr_ptr);
4396                /* do nothing */
4397                break;
4398        }
4399
4400    } else {
4401        zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
4402    }
4403    CHECK_EXCEPTION();
4404    ZEND_VM_NEXT_OPCODE();
4405}
4406
4407static int ZEND_FASTCALL  ZEND_INIT_ARRAY_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4408{
4409    zval *array;
4410    uint32_t size;
4411    USE_OPLINE
4412
4413    array = EX_VAR(opline->result.var);
4414    if (IS_CONST != IS_UNUSED) {
4415        size = opline->extended_value >> ZEND_ARRAY_SIZE_SHIFT;
4416    } else {
4417        size = 0;
4418    }
4419    ZVAL_NEW_ARR(array);
4420    zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0);
4421
4422    if (IS_CONST != IS_UNUSED) {
4423        /* Explicitly initialize array as not-packed if flag is set */
4424        if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
4425            zend_hash_real_init(Z_ARRVAL_P(array), 0);
4426        }
4427    }
4428
4429    if (IS_CONST == IS_UNUSED) {
4430        ZEND_VM_NEXT_OPCODE();
4431#if 0 || IS_CONST != IS_UNUSED
4432    } else {
4433        return ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
4434#endif
4435    }
4436}
4437
4438static int ZEND_FASTCALL  ZEND_UNSET_VAR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4439{
4440    USE_OPLINE
4441    zval tmp, *varname;
4442    HashTable *target_symbol_table;
4443
4444
4445    SAVE_OPLINE();
4446    if (IS_CONST == IS_CV &&
4447        IS_CONST == IS_UNUSED &&
4448        (opline->extended_value & ZEND_QUICK_SET)) {
4449        zval *var = EX_VAR(opline->op1.var);
4450
4451        if (Z_REFCOUNTED_P(var)) {
4452            zend_refcounted *garbage = Z_COUNTED_P(var);
4453
4454            if (!--GC_REFCOUNT(garbage)) {
4455                ZVAL_UNDEF(var);
4456                _zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
4457            } else {
4458                GC_ZVAL_CHECK_POSSIBLE_ROOT(var);
4459                ZVAL_UNDEF(var);
4460            }
4461        } else {
4462            ZVAL_UNDEF(var);
4463        }
4464        CHECK_EXCEPTION();
4465        ZEND_VM_NEXT_OPCODE();
4466    }
4467
4468    varname = opline->op1.zv;
4469
4470    ZVAL_UNDEF(&tmp);
4471    if (IS_CONST != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4472        ZVAL_DUP(&tmp, varname);
4473        convert_to_string(&tmp);
4474        varname = &tmp;
4475    }
4476
4477    if (IS_CONST != IS_UNUSED) {
4478        zend_class_entry *ce;
4479
4480        if (IS_CONST == IS_CONST) {
4481            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4482                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4483            } else {
4484                ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4485                if (UNEXPECTED(EG(exception) != NULL)) {
4486                    if (IS_CONST != IS_CONST) {
4487                        zval_dtor(&tmp);
4488                    }
4489
4490                    HANDLE_EXCEPTION();
4491                }
4492                if (UNEXPECTED(ce == NULL)) {
4493                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op2.zv));
4494                }
4495                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4496            }
4497        } else {
4498            ce = Z_CE_P(EX_VAR(opline->op2.var));
4499        }
4500        zend_std_unset_static_property(ce, Z_STR_P(varname), ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC);
4501    } else {
4502        target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4503        zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
4504    }
4505
4506    if (IS_CONST != IS_CONST) {
4507        zval_dtor(&tmp);
4508    }
4509
4510    CHECK_EXCEPTION();
4511    ZEND_VM_NEXT_OPCODE();
4512}
4513
4514static int ZEND_FASTCALL  ZEND_ISSET_ISEMPTY_VAR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4515{
4516    USE_OPLINE
4517    zval *value;
4518    zend_bool isset = 1;
4519
4520    SAVE_OPLINE();
4521    if (IS_CONST == IS_CV &&
4522        IS_CONST == IS_UNUSED &&
4523        (opline->extended_value & ZEND_QUICK_SET)) {
4524        if (Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_UNDEF) {
4525            value = EX_VAR(opline->op1.var);
4526            ZVAL_DEREF(value);
4527        } else {
4528            isset = 0;
4529        }
4530    } else {
4531        HashTable *target_symbol_table;
4532
4533        zval tmp, *varname = opline->op1.zv;
4534
4535        if (IS_CONST != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4536            ZVAL_DUP(&tmp, varname);
4537            convert_to_string(&tmp);
4538            varname = &tmp;
4539        }
4540
4541        if (IS_CONST != IS_UNUSED) {
4542            zend_class_entry *ce;
4543
4544            if (IS_CONST == IS_CONST) {
4545                if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4546                    ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4547                } else {
4548                    ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4549                    if (UNEXPECTED(ce == NULL)) {
4550                        CHECK_EXCEPTION();
4551                        ZEND_VM_NEXT_OPCODE();
4552                    }
4553                    CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4554                }
4555            } else {
4556                ce = Z_CE_P(EX_VAR(opline->op2.var));
4557            }
4558            value = zend_std_get_static_property(ce, Z_STR_P(varname), 1, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(varname)) : NULL) TSRMLS_CC);
4559            if (!value) {
4560                isset = 0;
4561            }
4562        } else {
4563            target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4564            if ((value = zend_hash_find(target_symbol_table, Z_STR_P(varname))) == NULL) {
4565                isset = 0;
4566            }
4567        }
4568
4569        if (IS_CONST != IS_CONST && varname == &tmp) {
4570            zval_dtor(&tmp);
4571        }
4572
4573    }
4574
4575    if (opline->extended_value & ZEND_ISSET) {
4576        if (isset && Z_TYPE_P(value) != IS_NULL &&
4577            (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL)) {
4578            ZVAL_BOOL(EX_VAR(opline->result.var), 1);
4579        } else {
4580            ZVAL_BOOL(EX_VAR(opline->result.var), 0);
4581        }
4582    } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4583        if (!isset || !i_zend_is_true(value TSRMLS_CC)) {
4584            ZVAL_BOOL(EX_VAR(opline->result.var), 1);
4585        } else {
4586            ZVAL_BOOL(EX_VAR(opline->result.var), 0);
4587        }
4588    }
4589
4590    CHECK_EXCEPTION();
4591    ZEND_VM_NEXT_OPCODE();
4592}
4593
4594static int ZEND_FASTCALL  ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4595{
4596    USE_OPLINE
4597
4598    zval *container;
4599    int result;
4600    zend_ulong hval;
4601    zval *offset;
4602
4603    SAVE_OPLINE();
4604    container = opline->op1.zv;
4605    offset = opline->op2.zv;
4606
4607    if (Z_TYPE_P(container) == IS_ARRAY) {
4608        HashTable *ht = Z_ARRVAL_P(container);
4609        zval *value;
4610        zend_string *str;
4611
4612isset_again:
4613        if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
4614            str = Z_STR_P(offset);
4615            if (IS_CONST != IS_CONST) {
4616                if (ZEND_HANDLE_NUMERIC(str, hval)) {
4617                    goto num_index_prop;
4618                }
4619            }
4620str_index_prop:
4621            value = zend_hash_find_ind(ht, str);
4622        } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4623            hval = Z_LVAL_P(offset);
4624num_index_prop:
4625            value = zend_hash_index_find(ht, hval);
4626        } else {
4627            switch (Z_TYPE_P(offset)) {
4628                case IS_DOUBLE:
4629                    hval = zend_dval_to_lval(Z_DVAL_P(offset));
4630                    goto num_index_prop;
4631                case IS_NULL:
4632                    str = STR_EMPTY_ALLOC();
4633                    goto str_index_prop;
4634                case IS_FALSE:
4635                    hval = 0;
4636                    goto num_index_prop;
4637                case IS_TRUE:
4638                    hval = 1;
4639                    goto num_index_prop;
4640                case IS_RESOURCE:
4641                    hval = Z_RES_HANDLE_P(offset);
4642                    goto num_index_prop;
4643                case IS_REFERENCE:
4644                    offset = Z_REFVAL_P(offset);
4645                    goto isset_again;
4646                default:
4647                    zend_error(E_WARNING, "Illegal offset type in isset or empty");
4648                    value = NULL;
4649                    break;
4650            }
4651        }
4652
4653        if (opline->extended_value & ZEND_ISSET) {
4654            /* > IS_NULL means not IS_UNDEF and not IS_NULL */
4655            result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
4656                (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
4657        } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4658            result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
4659        }
4660    } else if (Z_TYPE_P(container) == IS_OBJECT) {
4661        if (Z_OBJ_HT_P(container)->has_dimension) {
4662            result = Z_OBJ_HT_P(container)->has_dimension(container, offset, (opline->extended_value & ZEND_ISSET) == 0 TSRMLS_CC);
4663        } else {
4664            zend_error(E_NOTICE, "Trying to check element of non-array");
4665            result = 0;
4666        }
4667        if ((opline->extended_value & ZEND_ISSET) == 0) {
4668            result = !result;
4669        }
4670    } else if (Z_TYPE_P(container) == IS_STRING) { /* string offsets */
4671        zval tmp;
4672
4673        result = 0;
4674        if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
4675            if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
4676                ZVAL_DEREF(offset);
4677            }
4678            if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
4679                    || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
4680                        && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
4681                ZVAL_DUP(&tmp, offset);
4682                convert_to_long(&tmp);
4683                offset = &tmp;
4684            }
4685        }
4686        if (Z_TYPE_P(offset) == IS_LONG) {
4687            if (offset->value.lval >= 0 && (size_t)offset->value.lval < Z_STRLEN_P(container)) {
4688                if ((opline->extended_value & ZEND_ISSET) ||
4689                    Z_STRVAL_P(container)[offset->value.lval] != '0') {
4690                    result = 1;
4691                }
4692            }
4693        }
4694        if ((opline->extended_value & ZEND_ISSET) == 0) {
4695            result = !result;
4696        }
4697    } else {
4698        result = ((opline->extended_value & ZEND_ISSET) == 0);
4699    }
4700
4701    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4702
4703    CHECK_EXCEPTION();
4704    ZEND_VM_NEXT_OPCODE();
4705}
4706
4707static int ZEND_FASTCALL  ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4708{
4709    USE_OPLINE
4710
4711    zval *container;
4712    int result;
4713    zval *offset;
4714
4715    SAVE_OPLINE();
4716    container = opline->op1.zv;
4717    offset = opline->op2.zv;
4718
4719    if (Z_TYPE_P(container) == IS_OBJECT) {
4720        if (Z_OBJ_HT_P(container)->has_property) {
4721            result = Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISSET) == 0, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL) TSRMLS_CC);
4722        } else {
4723            zend_error(E_NOTICE, "Trying to check property of non-object");
4724            result = 0;
4725        }
4726        if ((opline->extended_value & ZEND_ISSET) == 0) {
4727            result = !result;
4728        }
4729    } else {
4730        result = ((opline->extended_value & ZEND_ISSET) == 0);
4731    }
4732
4733    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4734
4735    CHECK_EXCEPTION();
4736    ZEND_VM_NEXT_OPCODE();
4737}
4738
4739static int ZEND_FASTCALL  ZEND_DECLARE_CONST_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4740{
4741    USE_OPLINE
4742
4743    zval *name;
4744    zval *val;
4745    zend_constant c;
4746
4747    SAVE_OPLINE();
4748    name  = opline->op1.zv;
4749    val   = opline->op2.zv;
4750
4751    ZVAL_COPY_VALUE(&c.value, val);
4752    if (Z_OPT_CONSTANT(c.value)) {
4753        zval_update_constant(&c.value, 0 TSRMLS_CC);
4754    } else {
4755        /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
4756        if (UNEXPECTED(Z_OPT_COPYABLE(c.value))) {
4757            zval_copy_ctor_func(&c.value);
4758        }
4759    }
4760    c.flags = CONST_CS; /* non persistent, case sensetive */
4761    c.name = zend_string_dup(Z_STR_P(name), 0);
4762    c.module_number = PHP_USER_CONSTANT;
4763
4764    if (zend_register_constant(&c TSRMLS_CC) == FAILURE) {
4765    }
4766
4767
4768    CHECK_EXCEPTION();
4769    ZEND_VM_NEXT_OPCODE();
4770}
4771
4772static int ZEND_FASTCALL  ZEND_YIELD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4773{
4774    USE_OPLINE
4775
4776    /* The generator object is stored in EX(return_value) */
4777    zend_generator *generator = (zend_generator *) EX(return_value);
4778
4779    if (generator->flags & ZEND_GENERATOR_FORCED_CLOSE) {
4780        zend_error_noreturn(E_ERROR, "Cannot yield from finally in a force-closed generator");
4781    }
4782
4783    /* Destroy the previously yielded value */
4784    zval_ptr_dtor(&generator->value);
4785
4786    /* Destroy the previously yielded key */
4787    zval_ptr_dtor(&generator->key);
4788
4789    /* Set the new yielded value */
4790    if (IS_CONST != IS_UNUSED) {
4791
4792
4793        if (EX(func)->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
4794            /* Constants and temporary variables aren't yieldable by reference,
4795             * but we still allow them with a notice. */
4796            if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
4797                zval *value;
4798
4799                zend_error(E_NOTICE, "Only variable references should be yielded by reference");
4800
4801                value = opline->op1.zv;
4802                ZVAL_COPY_VALUE(&generator->value, value);
4803                if (Z_OPT_REFCOUNTED(generator->value)) Z_SET_REFCOUNT(generator->value, 1);
4804
4805                /* Temporary variables don't need ctor copying */
4806                if (IS_CONST != IS_TMP_VAR) {
4807                    zval_opt_copy_ctor(&generator->value);
4808                }
4809            } else {
4810                zval *value_ptr = NULL;
4811
4812                if (IS_CONST == IS_VAR && UNEXPECTED(value_ptr == NULL)) {
4813                    zend_error_noreturn(E_ERROR, "Cannot yield string offsets by reference");
4814                }
4815
4816                /* If a function call result is yielded and the function did
4817                 * not return by reference we throw a notice. */
4818                if (IS_CONST == IS_VAR && !Z_ISREF_P(value_ptr)
4819                    && !(opline->extended_value == ZEND_RETURNS_FUNCTION
4820                         && (Z_VAR_FLAGS_P(value_ptr) & IS_VAR_RET_REF))) {
4821                    zend_error(E_NOTICE, "Only variable references should be yielded by reference");
4822                } else {
4823                    ZVAL_MAKE_REF(value_ptr);
4824                }
4825                ZVAL_COPY(&generator->value, value_ptr);
4826
4827            }
4828        } else {
4829            zval *value = opline->op1.zv;
4830
4831            /* Consts, temporary variables and references need copying */
4832            if (IS_CONST == IS_CONST) {
4833                ZVAL_DUP(&generator->value, value);
4834            } else if (IS_CONST == IS_TMP_VAR) {
4835                ZVAL_COPY_VALUE(&generator->value, value);
4836            } else if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) && Z_ISREF_P(value)) {
4837                ZVAL_DUP(&generator->value, Z_REFVAL_P(value));
4838
4839            } else {
4840                ZVAL_COPY_VALUE(&generator->value, value);
4841                if (IS_CONST == IS_CV) {
4842                    if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4843                }
4844            }
4845        }
4846    } else {
4847        /* If no value was specified yield null */
4848        ZVAL_NULL(&generator->value);
4849    }
4850
4851    /* Set the new yielded key */
4852    if (IS_CONST != IS_UNUSED) {
4853
4854        zval *key = opline->op2.zv;
4855
4856        /* Consts, temporary variables and references need copying */
4857        if (IS_CONST == IS_CONST) {
4858            ZVAL_DUP(&generator->key, key);
4859        } else if (IS_CONST == IS_TMP_VAR) {
4860            ZVAL_COPY_VALUE(&generator->key, key);
4861        } else if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(key)) {
4862            ZVAL_DUP(&generator->key, Z_REFVAL_P(key));
4863
4864        } else {
4865            ZVAL_COPY_VALUE(&generator->key, key);
4866            if (IS_CONST == IS_CV) {
4867                if (Z_OPT_REFCOUNTED_P(key)) Z_ADDREF_P(key);
4868            }
4869        }
4870
4871        if (Z_TYPE(generator->key) == IS_LONG
4872            && Z_LVAL(generator->key) > generator->largest_used_integer_key
4873        ) {
4874            generator->largest_used_integer_key = Z_LVAL(generator->key);
4875        }
4876    } else {
4877        /* If no key was specified we use auto-increment keys */
4878        generator->largest_used_integer_key++;
4879        ZVAL_LONG(&generator->key, generator->largest_used_integer_key);
4880    }
4881
4882    if (RETURN_VALUE_USED(opline)) {
4883        /* If the return value of yield is used set the send
4884         * target and initialize it to NULL */
4885        generator->send_target = EX_VAR(opline->result.var);
4886        ZVAL_NULL(generator->send_target);
4887    } else {
4888        generator->send_target = NULL;
4889    }
4890
4891    /* We increment to the next op, so we are at the correct position when the
4892     * generator is resumed. */
4893    ZEND_VM_INC_OPCODE();
4894
4895    /* The GOTO VM uses a local opline variable. We need to set the opline
4896     * variable in execute_data so we don't resume at an old position. */
4897    SAVE_OPLINE();
4898
4899    ZEND_VM_RETURN();
4900}
4901
4902static int ZEND_FASTCALL  ZEND_POW_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4903{
4904    USE_OPLINE
4905
4906
4907    SAVE_OPLINE();
4908    pow_function(EX_VAR(opline->result.var),
4909        opline->op1.zv,
4910        opline->op2.zv TSRMLS_CC);
4911
4912
4913    CHECK_EXCEPTION();
4914    ZEND_VM_NEXT_OPCODE();
4915}
4916
4917static int ZEND_FASTCALL  ZEND_ADD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4918{
4919    USE_OPLINE
4920    zend_free_op free_op2;
4921
4922    SAVE_OPLINE();
4923    fast_add_function(EX_VAR(opline->result.var),
4924        opline->op1.zv,
4925        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
4926
4927    zval_ptr_dtor_nogc(free_op2.var);
4928    CHECK_EXCEPTION();
4929    ZEND_VM_NEXT_OPCODE();
4930}
4931
4932static int ZEND_FASTCALL  ZEND_SUB_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4933{
4934    USE_OPLINE
4935    zend_free_op free_op2;
4936
4937    SAVE_OPLINE();
4938    fast_sub_function(EX_VAR(opline->result.var),
4939        opline->op1.zv,
4940        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
4941
4942    zval_ptr_dtor_nogc(free_op2.var);
4943    CHECK_EXCEPTION();
4944    ZEND_VM_NEXT_OPCODE();
4945}
4946
4947static int ZEND_FASTCALL  ZEND_MUL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4948{
4949    USE_OPLINE
4950    zend_free_op free_op2;
4951
4952    SAVE_OPLINE();
4953    fast_mul_function(EX_VAR(opline->result.var),
4954        opline->op1.zv,
4955        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
4956
4957    zval_ptr_dtor_nogc(free_op2.var);
4958    CHECK_EXCEPTION();
4959    ZEND_VM_NEXT_OPCODE();
4960}
4961
4962static int ZEND_FASTCALL  ZEND_DIV_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4963{
4964    USE_OPLINE
4965    zend_free_op free_op2;
4966
4967    SAVE_OPLINE();
4968    fast_div_function(EX_VAR(opline->result.var),
4969        opline->op1.zv,
4970        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
4971
4972    zval_ptr_dtor_nogc(free_op2.var);
4973    CHECK_EXCEPTION();
4974    ZEND_VM_NEXT_OPCODE();
4975}
4976
4977static int ZEND_FASTCALL  ZEND_MOD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4978{
4979    USE_OPLINE
4980    zend_free_op free_op2;
4981
4982    SAVE_OPLINE();
4983    fast_mod_function(EX_VAR(opline->result.var),
4984        opline->op1.zv,
4985        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
4986
4987    zval_ptr_dtor_nogc(free_op2.var);
4988    CHECK_EXCEPTION();
4989    ZEND_VM_NEXT_OPCODE();
4990}
4991
4992static int ZEND_FASTCALL  ZEND_SL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4993{
4994    USE_OPLINE
4995    zend_free_op free_op2;
4996
4997    SAVE_OPLINE();
4998    shift_left_function(EX_VAR(opline->result.var),
4999        opline->op1.zv,
5000        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5001
5002    zval_ptr_dtor_nogc(free_op2.var);
5003    CHECK_EXCEPTION();
5004    ZEND_VM_NEXT_OPCODE();
5005}
5006
5007static int ZEND_FASTCALL  ZEND_SR_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5008{
5009    USE_OPLINE
5010    zend_free_op free_op2;
5011
5012    SAVE_OPLINE();
5013    shift_right_function(EX_VAR(opline->result.var),
5014        opline->op1.zv,
5015        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5016
5017    zval_ptr_dtor_nogc(free_op2.var);
5018    CHECK_EXCEPTION();
5019    ZEND_VM_NEXT_OPCODE();
5020}
5021
5022static int ZEND_FASTCALL  ZEND_CONCAT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5023{
5024    USE_OPLINE
5025    zend_free_op free_op2;
5026
5027    SAVE_OPLINE();
5028    concat_function(EX_VAR(opline->result.var),
5029        opline->op1.zv,
5030        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5031
5032    zval_ptr_dtor_nogc(free_op2.var);
5033    CHECK_EXCEPTION();
5034    ZEND_VM_NEXT_OPCODE();
5035}
5036
5037static int ZEND_FASTCALL  ZEND_IS_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5038{
5039    USE_OPLINE
5040    zend_free_op free_op2;
5041
5042    SAVE_OPLINE();
5043    fast_is_identical_function(EX_VAR(opline->result.var),
5044        opline->op1.zv,
5045        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5046
5047    zval_ptr_dtor_nogc(free_op2.var);
5048    CHECK_EXCEPTION();
5049    ZEND_VM_NEXT_OPCODE();
5050}
5051
5052static int ZEND_FASTCALL  ZEND_IS_NOT_IDENTICAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5053{
5054    USE_OPLINE
5055    zend_free_op free_op2;
5056    zval *result = EX_VAR(opline->result.var);
5057
5058    SAVE_OPLINE();
5059    fast_is_not_identical_function(result,
5060        opline->op1.zv,
5061        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5062
5063    zval_ptr_dtor_nogc(free_op2.var);
5064    CHECK_EXCEPTION();
5065    ZEND_VM_NEXT_OPCODE();
5066}
5067
5068static int ZEND_FASTCALL  ZEND_IS_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5069{
5070    USE_OPLINE
5071    zend_free_op free_op2;
5072    zval *result = EX_VAR(opline->result.var);
5073
5074    SAVE_OPLINE();
5075    fast_equal_function(result,
5076        opline->op1.zv,
5077        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5078
5079    zval_ptr_dtor_nogc(free_op2.var);
5080    CHECK_EXCEPTION();
5081    ZEND_VM_NEXT_OPCODE();
5082}
5083
5084static int ZEND_FASTCALL  ZEND_IS_NOT_EQUAL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5085{
5086    USE_OPLINE
5087    zend_free_op free_op2;
5088    zval *result = EX_VAR(opline->result.var);
5089
5090    SAVE_OPLINE();
5091    fast_not_equal_function(result,
5092        opline->op1.zv,
5093        _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC) TSRMLS_CC);
5094
5095    zval_ptr_dtor_nogc(free_op2.var);
5096    CHECK_EXCEPTION();
5097    ZEND_VM_NEXT_OPCODE();
5098}
5099
5100static int ZEND_FASTCALL  ZEND_IS_SMALLER_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
5101{
5102    USE_OPLINE
5103    zend_free_op free_op2;
5104<