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