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