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