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