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