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_error(E_EXCEPTION | E_ERROR, "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_error(E_EXCEPTION | E_ERROR, "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_error(E_EXCEPTION | E_ERROR, "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_error(E_EXCEPTION | E_ERROR,
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
1661        if (RETURN_VALUE_USED(target-1)) {
1662            ZVAL_TRUE(EX_VAR((target-1)->result.var));
1663        }
1664        ZEND_VM_JMP(target);
1665    } else {
1666        ZEND_VM_NEXT_OPCODE();
1667    }
1668}
1669
1670static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_NAME_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1671{
1672    uint32_t fetch_type;
1673    USE_OPLINE
1674
1675    SAVE_OPLINE();
1676    fetch_type = opline->extended_value;
1677
1678    if (UNEXPECTED(EG(scope) == NULL)) {
1679        zend_error(E_EXCEPTION | E_ERROR, "Cannot use \"%s\" when no class scope is active",
1680            fetch_type == ZEND_FETCH_CLASS_SELF ? "self" :
1681            fetch_type == ZEND_FETCH_CLASS_PARENT ? "parent" : "static");
1682        HANDLE_EXCEPTION();
1683    }
1684
1685    switch (fetch_type) {
1686        case ZEND_FETCH_CLASS_SELF:
1687            ZVAL_STR_COPY(EX_VAR(opline->result.var), EG(scope)->name);
1688            break;
1689        case ZEND_FETCH_CLASS_PARENT:
1690            if (UNEXPECTED(EG(scope)->parent == NULL)) {
1691                zend_error(E_EXCEPTION | E_ERROR,
1692                    "Cannot use \"parent\" when current class scope has no parent");
1693                HANDLE_EXCEPTION();
1694            }
1695            ZVAL_STR_COPY(EX_VAR(opline->result.var), EG(scope)->parent->name);
1696            break;
1697        case ZEND_FETCH_CLASS_STATIC:
1698            ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(called_scope)->name);
1699            break;
1700        EMPTY_SWITCH_DEFAULT_CASE()
1701    }
1702    ZEND_VM_NEXT_OPCODE();
1703}
1704
1705static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1706{
1707    zend_array *args;
1708    zend_function *fbc = EX(func);
1709    zend_object *object = Z_OBJ(EX(This));
1710    zval *ret = EX(return_value);
1711    uint32_t call_info = EX_CALL_INFO() & (ZEND_CALL_NESTED | ZEND_CALL_TOP | ZEND_CALL_RELEASE_THIS);
1712    zend_class_entry *scope = EX(called_scope);
1713    uint32_t num_args = EX_NUM_ARGS();
1714    zend_execute_data *call;
1715    USE_OPLINE
1716
1717    args = emalloc(sizeof(zend_array));
1718    zend_hash_init(args, num_args, NULL, ZVAL_PTR_DTOR, 0);
1719    if (num_args) {
1720        zval *p = ZEND_CALL_ARG(execute_data, 1);
1721        zval *end = p + num_args;
1722
1723        zend_hash_real_init(args, 1);
1724        ZEND_HASH_FILL_PACKED(args) {
1725            do {
1726                ZEND_HASH_FILL_ADD(p);
1727                p++;
1728            } while (p != end);
1729        } ZEND_HASH_FILL_END();
1730    }
1731
1732    SAVE_OPLINE();
1733    call = execute_data;
1734    execute_data = EG(current_execute_data) = EX(prev_execute_data);
1735    zend_vm_stack_free_call_frame(call);
1736    call = zend_vm_stack_push_call_frame(call_info, fbc->common.prototype, 2, scope, object);
1737    call->prev_execute_data = execute_data;
1738
1739    ZVAL_STR(ZEND_CALL_ARG(call, 1), fbc->common.function_name);
1740    ZVAL_ARR(ZEND_CALL_ARG(call, 2), args);
1741    zend_free_trampoline(fbc);
1742    fbc = call->func;
1743
1744    if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
1745
1746        ZEND_ASSERT(!(fbc->common.fn_flags & ZEND_ACC_GENERATOR));
1747
1748        call->symbol_table = NULL;
1749        i_init_func_execute_data(call, &fbc->op_array,
1750                ret, (fbc->common.fn_flags & ZEND_ACC_STATIC) == 0);
1751
1752        if (EXPECTED(zend_execute_ex == execute_ex)) {
1753            ZEND_VM_ENTER();
1754        } else {
1755            ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
1756            zend_execute_ex(call);
1757        }
1758    } else {
1759        zval retval;
1760
1761        ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
1762
1763        EG(current_execute_data) = call;
1764
1765        if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
1766            uint32_t i;
1767            uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
1768            zval *p = ZEND_CALL_ARG(call, 1);
1769
1770            EG(current_execute_data) = call;
1771
1772            for (i = 0; i < num_args; ++i) {
1773                zend_verify_internal_arg_type(fbc, i + 1, p);
1774                if (UNEXPECTED(EG(exception) != NULL)) {
1775                    EG(current_execute_data) = call->prev_execute_data;
1776                    zend_vm_stack_free_args(call);
1777                    zend_vm_stack_free_call_frame(call);
1778                    if (ret) {
1779                        ZVAL_UNDEF(ret);
1780                    }
1781                    goto call_trampoline_end;
1782                }
1783                p++;
1784            }
1785        }
1786
1787        if (ret == NULL) {
1788            ZVAL_NULL(&retval);
1789            ret = &retval;
1790        }
1791        Z_VAR_FLAGS_P(ret) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
1792
1793        if (!zend_execute_internal) {
1794            /* saves one function call if zend_execute_internal is not used */
1795            fbc->internal_function.handler(call, ret);
1796        } else {
1797            zend_execute_internal(call, ret);
1798        }
1799
1800#if ZEND_DEBUG
1801        ZEND_ASSERT(
1802            !call->func ||
1803            !(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
1804            zend_verify_internal_return_type(call->func, EX_VAR(opline->result.var)));
1805#endif
1806
1807        EG(current_execute_data) = call->prev_execute_data;
1808
1809        zend_vm_stack_free_args(call);
1810
1811        if (ret == &retval) {
1812            zval_ptr_dtor(ret);
1813        }
1814    }
1815
1816call_trampoline_end:
1817    execute_data = EG(current_execute_data);
1818
1819    if (!EX(func) || !ZEND_USER_CODE(EX(func)->type) || (call_info & ZEND_CALL_TOP)) {
1820        ZEND_VM_RETURN();
1821    }
1822
1823    opline = EX(opline);
1824
1825    if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
1826        object = Z_OBJ(call->This);
1827        OBJ_RELEASE(object);
1828    }
1829    EG(scope) = EX(func)->op_array.scope;
1830    zend_vm_stack_free_call_frame(call);
1831
1832    if (UNEXPECTED(EG(exception) != NULL)) {
1833        zend_throw_exception_internal(NULL);
1834        if (RETURN_VALUE_USED(opline)) {
1835            zval_ptr_dtor(EX_VAR(opline->result.var));
1836        }
1837        HANDLE_EXCEPTION_LEAVE();
1838    }
1839
1840    ZEND_VM_INC_OPCODE();
1841    ZEND_VM_LEAVE();
1842}
1843
1844static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1845{
1846    USE_OPLINE
1847
1848    SAVE_OPLINE();
1849    if (EG(exception)) {
1850        zend_exception_save();
1851    }
1852    if (IS_CONST == IS_UNUSED) {
1853        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
1854        CHECK_EXCEPTION();
1855        ZEND_VM_NEXT_OPCODE();
1856    } else {
1857
1858        zval *class_name = EX_CONSTANT(opline->op2);
1859
1860try_class_name:
1861        if (IS_CONST == IS_CONST) {
1862            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
1863                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
1864            } else {
1865                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);
1866                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
1867            }
1868        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
1869            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
1870        } else if (Z_TYPE_P(class_name) == IS_STRING) {
1871            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
1872        } else if ((IS_CONST & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
1873            class_name = Z_REFVAL_P(class_name);
1874            goto try_class_name;
1875        } else {
1876            if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
1877                GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
1878            }
1879            if (UNEXPECTED(EG(exception) != NULL)) {
1880                HANDLE_EXCEPTION();
1881            }
1882            zend_error(E_EXCEPTION | E_ERROR, "Class name must be a valid object or a string");
1883        }
1884
1885        CHECK_EXCEPTION();
1886        ZEND_VM_NEXT_OPCODE();
1887    }
1888}
1889
1890static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1891{
1892    USE_OPLINE
1893    zend_function *fbc;
1894    zval *function_name, *func;
1895    zend_execute_data *call;
1896
1897    if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2))))) {
1898        fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
1899    } else {
1900        function_name = (zval*)(EX_CONSTANT(opline->op2)+1);
1901        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
1902            SAVE_OPLINE();
1903            zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
1904            HANDLE_EXCEPTION();
1905        } else {
1906            fbc = Z_FUNC_P(func);
1907            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
1908        }
1909    }
1910    call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
1911        fbc, opline->extended_value, NULL, NULL);
1912    call->prev_execute_data = EX(call);
1913    EX(call) = call;
1914
1915    ZEND_VM_NEXT_OPCODE();
1916}
1917
1918static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
1919{
1920    USE_OPLINE
1921    zend_function *fbc;
1922    zval *function_name, *func;
1923    zend_string *lcname;
1924
1925    zend_class_entry *called_scope;
1926    zend_object *object;
1927    zend_execute_data *call;
1928    uint32_t call_info = ZEND_CALL_NESTED_FUNCTION;
1929
1930    SAVE_OPLINE();
1931    function_name = EX_CONSTANT(opline->op2);
1932
1933try_function_name:
1934    if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
1935        const char *colon;
1936
1937        if ((colon = zend_memrchr(Z_STRVAL_P(function_name), ':', Z_STRLEN_P(function_name))) != NULL &&
1938            colon > Z_STRVAL_P(function_name) &&
1939            *(colon-1) == ':'
1940        ) {
1941            zend_string *mname;
1942            size_t cname_length = colon - Z_STRVAL_P(function_name) - 1;
1943            size_t mname_length = Z_STRLEN_P(function_name) - cname_length - (sizeof("::") - 1);
1944
1945            lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
1946
1947            object = NULL;
1948            called_scope = zend_fetch_class_by_name(lcname, NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
1949            if (UNEXPECTED(called_scope == NULL)) {
1950                zend_string_release(lcname);
1951                CHECK_EXCEPTION();
1952                ZEND_VM_NEXT_OPCODE();
1953            }
1954
1955            mname = zend_string_init(Z_STRVAL_P(function_name) + (cname_length + sizeof("::") - 1), mname_length, 0);
1956
1957            if (called_scope->get_static_method) {
1958                fbc = called_scope->get_static_method(called_scope, mname);
1959            } else {
1960                fbc = zend_std_get_static_method(called_scope, mname, NULL);
1961            }
1962            if (UNEXPECTED(fbc == NULL)) {
1963                if (EXPECTED(!EG(exception))) {
1964                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), ZSTR_VAL(mname));
1965                }
1966                zend_string_release(lcname);
1967                zend_string_release(mname);
1968
1969                HANDLE_EXCEPTION();
1970            }
1971
1972            zend_string_release(lcname);
1973            zend_string_release(mname);
1974
1975            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
1976                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
1977                    zend_error(E_DEPRECATED,
1978                        "Non-static method %s::%s() should not be called statically",
1979                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
1980                } else {
1981                    zend_error(
1982                        E_EXCEPTION | E_ERROR,
1983                        "Non-static method %s::%s() cannot be called statically",
1984                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
1985
1986                    HANDLE_EXCEPTION();
1987                }
1988            }
1989        } else {
1990            if (Z_STRVAL_P(function_name)[0] == '\\') {
1991                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
1992                zend_str_tolower_copy(ZSTR_VAL(lcname), Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
1993            } else {
1994                lcname = zend_string_tolower(Z_STR_P(function_name));
1995            }
1996            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
1997                zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
1998                zend_string_release(lcname);
1999
2000                HANDLE_EXCEPTION();
2001            }
2002            zend_string_release(lcname);
2003
2004            fbc = Z_FUNC_P(func);
2005            called_scope = NULL;
2006            object = NULL;
2007        }
2008
2009    } else if (IS_CONST != IS_CONST &&
2010        EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2011        Z_OBJ_HANDLER_P(function_name, get_closure) &&
2012        Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
2013        if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2014            /* Delay closure destruction until its invocation */
2015            ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
2016            GC_REFCOUNT(fbc->common.prototype)++;
2017            call_info |= ZEND_CALL_CLOSURE;
2018        }
2019
2020    } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2021            zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2022        zval *obj;
2023        zval *method;
2024        obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2025        method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2026
2027        if (!obj || !method) {
2028            zend_error(E_EXCEPTION | E_ERROR, "Array callback has to contain indices 0 and 1");
2029
2030            HANDLE_EXCEPTION();
2031        }
2032
2033        ZVAL_DEREF(obj);
2034        if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2035            zend_error(E_EXCEPTION | E_ERROR, "First array member is not a valid class name or object");
2036
2037            HANDLE_EXCEPTION();
2038        }
2039
2040        ZVAL_DEREF(method);
2041        if (Z_TYPE_P(method) != IS_STRING) {
2042            zend_error(E_EXCEPTION | E_ERROR, "Second array member is not a valid method");
2043
2044            HANDLE_EXCEPTION();
2045        }
2046
2047        if (Z_TYPE_P(obj) == IS_STRING) {
2048            object = NULL;
2049            called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
2050            if (UNEXPECTED(called_scope == NULL)) {
2051                CHECK_EXCEPTION();
2052                ZEND_VM_NEXT_OPCODE();
2053            }
2054
2055            if (called_scope->get_static_method) {
2056                fbc = called_scope->get_static_method(called_scope, Z_STR_P(method));
2057            } else {
2058                fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL);
2059            }
2060            if (UNEXPECTED(fbc == NULL)) {
2061                if (EXPECTED(!EG(exception))) {
2062                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), Z_STRVAL_P(method));
2063                }
2064
2065                HANDLE_EXCEPTION();
2066            }
2067            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2068                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2069                    zend_error(E_DEPRECATED,
2070                        "Non-static method %s::%s() should not be called statically",
2071                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2072                } else {
2073                    zend_error(
2074                        E_EXCEPTION | E_ERROR,
2075                        "Non-static method %s::%s() cannot be called statically",
2076                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2077
2078                    HANDLE_EXCEPTION();
2079                }
2080            }
2081        } else {
2082            called_scope = Z_OBJCE_P(obj);
2083            object = Z_OBJ_P(obj);
2084
2085            fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL);
2086            if (UNEXPECTED(fbc == NULL)) {
2087                if (EXPECTED(!EG(exception))) {
2088                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(object->ce->name), Z_STRVAL_P(method));
2089                }
2090
2091                HANDLE_EXCEPTION();
2092            }
2093
2094            if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2095                object = NULL;
2096            } else {
2097                call_info |= ZEND_CALL_RELEASE_THIS;
2098                GC_REFCOUNT(object)++; /* For $this pointer */
2099            }
2100        }
2101
2102    } else if ((IS_CONST & (IS_VAR|IS_CV)) && Z_TYPE_P(function_name) == IS_REFERENCE) {
2103        function_name = Z_REFVAL_P(function_name);
2104        goto try_function_name;
2105    } else {
2106        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
2107            GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
2108        }
2109        if (UNEXPECTED(EG(exception) != NULL)) {
2110            HANDLE_EXCEPTION();
2111        }
2112        zend_error(E_EXCEPTION | E_ERROR, "Function name must be a string");
2113
2114        HANDLE_EXCEPTION();
2115    }
2116    call = zend_vm_stack_push_call_frame(call_info,
2117        fbc, opline->extended_value, called_scope, object);
2118    call->prev_execute_data = EX(call);
2119    EX(call) = call;
2120
2121    CHECK_EXCEPTION();
2122    ZEND_VM_NEXT_OPCODE();
2123}
2124
2125static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2126{
2127    USE_OPLINE
2128    zval *func_name;
2129    zval *func;
2130    zend_function *fbc;
2131    zend_execute_data *call;
2132
2133    func_name = EX_CONSTANT(opline->op2) + 1;
2134    if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
2135        fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
2136    } else if ((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL) {
2137        func_name++;
2138        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL)) {
2139            SAVE_OPLINE();
2140            zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
2141            HANDLE_EXCEPTION();
2142        } else {
2143            fbc = Z_FUNC_P(func);
2144            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
2145        }
2146    } else {
2147        fbc = Z_FUNC_P(func);
2148        CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
2149    }
2150
2151    call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
2152        fbc, opline->extended_value, NULL, NULL);
2153    call->prev_execute_data = EX(call);
2154    EX(call) = call;
2155
2156    ZEND_VM_NEXT_OPCODE();
2157}
2158
2159static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2160{
2161    USE_OPLINE
2162
2163    zval *fname = EX_CONSTANT(opline->op2);
2164    zval *func;
2165    zend_function *fbc;
2166    zend_execute_data *call;
2167
2168    if (CACHED_PTR(Z_CACHE_SLOT_P(fname))) {
2169        fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname));
2170    } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(fname))) == NULL)) {
2171        SAVE_OPLINE();
2172        zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(fname));
2173        HANDLE_EXCEPTION();
2174    } else {
2175        fbc = Z_FUNC_P(func);
2176        CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
2177    }
2178
2179    call = zend_vm_stack_push_call_frame_ex(
2180        opline->op1.num, ZEND_CALL_NESTED_FUNCTION,
2181        fbc, opline->extended_value, NULL, NULL);
2182    call->prev_execute_data = EX(call);
2183    EX(call) = call;
2184
2185    ZEND_VM_NEXT_OPCODE();
2186}
2187
2188static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2189{
2190    USE_OPLINE
2191    uint32_t arg_num;
2192    zval *param;
2193
2194    ZEND_VM_REPEATABLE_OPCODE
2195
2196    arg_num = opline->op1.num;
2197    param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
2198    if (arg_num > EX_NUM_ARGS()) {
2199        ZVAL_COPY_VALUE(param, EX_CONSTANT(opline->op2));
2200        if (Z_OPT_CONSTANT_P(param)) {
2201            SAVE_OPLINE();
2202            if (UNEXPECTED(zval_update_constant_ex(param, 0, NULL) != SUCCESS)) {
2203                ZVAL_UNDEF(param);
2204                HANDLE_EXCEPTION();
2205            }
2206        } else {
2207            /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
2208            if (UNEXPECTED(Z_OPT_COPYABLE_P(param))) {
2209                zval_copy_ctor_func(param);
2210            }
2211        }
2212    }
2213
2214    if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
2215        zval *default_value = EX_CONSTANT(opline->op2);
2216
2217        SAVE_OPLINE();
2218        if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))))) {
2219            HANDLE_EXCEPTION();
2220        }
2221    }
2222
2223    ZEND_VM_REPEAT_OPCODE(ZEND_RECV_INIT);
2224    ZEND_VM_NEXT_OPCODE();
2225}
2226
2227static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GOTO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2228{
2229    USE_OPLINE
2230    zend_brk_cont_element *el;
2231
2232    SAVE_OPLINE();
2233    el = zend_brk_cont(Z_LVAL_P(EX_CONSTANT(opline->op2)), opline->extended_value,
2234                       &EX(func)->op_array, execute_data);
2235
2236    if (el->start >= 0) {
2237        zend_op *brk_opline = EX(func)->op_array.opcodes + el->brk;
2238
2239        if (brk_opline->opcode == ZEND_FREE) {
2240            zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
2241        } else if (brk_opline->opcode == ZEND_FE_FREE) {
2242            zval *var = EX_VAR(brk_opline->op1.var);
2243            if (Z_TYPE_P(var) != IS_ARRAY && Z_FE_ITER_P(var) != (uint32_t)-1) {
2244                zend_hash_iterator_del(Z_FE_ITER_P(var));
2245            }
2246            zval_ptr_dtor_nogc(var);
2247        }
2248    }
2249    ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op1));
2250}
2251
2252static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2253{
2254    USE_OPLINE
2255    zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
2256    zend_class_entry *iface;
2257
2258    SAVE_OPLINE();
2259    if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
2260        iface = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
2261    } else {
2262        iface = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_INTERFACE);
2263        if (UNEXPECTED(iface == NULL)) {
2264            CHECK_EXCEPTION();
2265            ZEND_VM_NEXT_OPCODE();
2266        }
2267        CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), iface);
2268    }
2269
2270    if (UNEXPECTED((iface->ce_flags & ZEND_ACC_INTERFACE) == 0)) {
2271        zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ZSTR_VAL(ce->name), ZSTR_VAL(iface->name));
2272    }
2273    zend_do_implement_interface(ce, iface);
2274
2275    CHECK_EXCEPTION();
2276    ZEND_VM_NEXT_OPCODE();
2277}
2278
2279static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2280{
2281    USE_OPLINE
2282
2283    SAVE_OPLINE();
2284    if (EG(exception)) {
2285        zend_exception_save();
2286    }
2287    if (IS_UNUSED == IS_UNUSED) {
2288        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
2289        CHECK_EXCEPTION();
2290        ZEND_VM_NEXT_OPCODE();
2291    } else {
2292
2293        zval *class_name = NULL;
2294
2295try_class_name:
2296        if (IS_UNUSED == IS_CONST) {
2297            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2298                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2299            } else {
2300                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);
2301                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2302            }
2303        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2304            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2305        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2306            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
2307        } else if ((IS_UNUSED & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
2308            class_name = Z_REFVAL_P(class_name);
2309            goto try_class_name;
2310        } else {
2311            if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
2312                GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
2313            }
2314            if (UNEXPECTED(EG(exception) != NULL)) {
2315                HANDLE_EXCEPTION();
2316            }
2317            zend_error(E_EXCEPTION | E_ERROR, "Class name must be a valid object or a string");
2318        }
2319
2320        CHECK_EXCEPTION();
2321        ZEND_VM_NEXT_OPCODE();
2322    }
2323}
2324
2325static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2326{
2327    USE_OPLINE
2328
2329    SAVE_OPLINE();
2330    if (EG(exception)) {
2331        zend_exception_save();
2332    }
2333    if (IS_CV == IS_UNUSED) {
2334        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
2335        CHECK_EXCEPTION();
2336        ZEND_VM_NEXT_OPCODE();
2337    } else {
2338
2339        zval *class_name = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
2340
2341try_class_name:
2342        if (IS_CV == IS_CONST) {
2343            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2344                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2345            } else {
2346                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);
2347                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2348            }
2349        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2350            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2351        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2352            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
2353        } else if ((IS_CV & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
2354            class_name = Z_REFVAL_P(class_name);
2355            goto try_class_name;
2356        } else {
2357            if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
2358                GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
2359            }
2360            if (UNEXPECTED(EG(exception) != NULL)) {
2361                HANDLE_EXCEPTION();
2362            }
2363            zend_error(E_EXCEPTION | E_ERROR, "Class name must be a valid object or a string");
2364        }
2365
2366        CHECK_EXCEPTION();
2367        ZEND_VM_NEXT_OPCODE();
2368    }
2369}
2370
2371static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2372{
2373    USE_OPLINE
2374    zend_function *fbc;
2375    zval *function_name, *func;
2376    zend_string *lcname;
2377
2378    zend_class_entry *called_scope;
2379    zend_object *object;
2380    zend_execute_data *call;
2381    uint32_t call_info = ZEND_CALL_NESTED_FUNCTION;
2382
2383    SAVE_OPLINE();
2384    function_name = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
2385
2386try_function_name:
2387    if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2388        const char *colon;
2389
2390        if ((colon = zend_memrchr(Z_STRVAL_P(function_name), ':', Z_STRLEN_P(function_name))) != NULL &&
2391            colon > Z_STRVAL_P(function_name) &&
2392            *(colon-1) == ':'
2393        ) {
2394            zend_string *mname;
2395            size_t cname_length = colon - Z_STRVAL_P(function_name) - 1;
2396            size_t mname_length = Z_STRLEN_P(function_name) - cname_length - (sizeof("::") - 1);
2397
2398            lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
2399
2400            object = NULL;
2401            called_scope = zend_fetch_class_by_name(lcname, NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
2402            if (UNEXPECTED(called_scope == NULL)) {
2403                zend_string_release(lcname);
2404                CHECK_EXCEPTION();
2405                ZEND_VM_NEXT_OPCODE();
2406            }
2407
2408            mname = zend_string_init(Z_STRVAL_P(function_name) + (cname_length + sizeof("::") - 1), mname_length, 0);
2409
2410            if (called_scope->get_static_method) {
2411                fbc = called_scope->get_static_method(called_scope, mname);
2412            } else {
2413                fbc = zend_std_get_static_method(called_scope, mname, NULL);
2414            }
2415            if (UNEXPECTED(fbc == NULL)) {
2416                if (EXPECTED(!EG(exception))) {
2417                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), ZSTR_VAL(mname));
2418                }
2419                zend_string_release(lcname);
2420                zend_string_release(mname);
2421
2422                HANDLE_EXCEPTION();
2423            }
2424
2425            zend_string_release(lcname);
2426            zend_string_release(mname);
2427
2428            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2429                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2430                    zend_error(E_DEPRECATED,
2431                        "Non-static method %s::%s() should not be called statically",
2432                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2433                } else {
2434                    zend_error(
2435                        E_EXCEPTION | E_ERROR,
2436                        "Non-static method %s::%s() cannot be called statically",
2437                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2438
2439                    HANDLE_EXCEPTION();
2440                }
2441            }
2442        } else {
2443            if (Z_STRVAL_P(function_name)[0] == '\\') {
2444                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
2445                zend_str_tolower_copy(ZSTR_VAL(lcname), Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
2446            } else {
2447                lcname = zend_string_tolower(Z_STR_P(function_name));
2448            }
2449            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
2450                zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
2451                zend_string_release(lcname);
2452
2453                HANDLE_EXCEPTION();
2454            }
2455            zend_string_release(lcname);
2456
2457            fbc = Z_FUNC_P(func);
2458            called_scope = NULL;
2459            object = NULL;
2460        }
2461
2462    } else if (IS_CV != IS_CONST &&
2463        EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2464        Z_OBJ_HANDLER_P(function_name, get_closure) &&
2465        Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
2466        if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2467            /* Delay closure destruction until its invocation */
2468            ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
2469            GC_REFCOUNT(fbc->common.prototype)++;
2470            call_info |= ZEND_CALL_CLOSURE;
2471        }
2472
2473    } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2474            zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2475        zval *obj;
2476        zval *method;
2477        obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2478        method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2479
2480        if (!obj || !method) {
2481            zend_error(E_EXCEPTION | E_ERROR, "Array callback has to contain indices 0 and 1");
2482
2483            HANDLE_EXCEPTION();
2484        }
2485
2486        ZVAL_DEREF(obj);
2487        if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2488            zend_error(E_EXCEPTION | E_ERROR, "First array member is not a valid class name or object");
2489
2490            HANDLE_EXCEPTION();
2491        }
2492
2493        ZVAL_DEREF(method);
2494        if (Z_TYPE_P(method) != IS_STRING) {
2495            zend_error(E_EXCEPTION | E_ERROR, "Second array member is not a valid method");
2496
2497            HANDLE_EXCEPTION();
2498        }
2499
2500        if (Z_TYPE_P(obj) == IS_STRING) {
2501            object = NULL;
2502            called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
2503            if (UNEXPECTED(called_scope == NULL)) {
2504                CHECK_EXCEPTION();
2505                ZEND_VM_NEXT_OPCODE();
2506            }
2507
2508            if (called_scope->get_static_method) {
2509                fbc = called_scope->get_static_method(called_scope, Z_STR_P(method));
2510            } else {
2511                fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL);
2512            }
2513            if (UNEXPECTED(fbc == NULL)) {
2514                if (EXPECTED(!EG(exception))) {
2515                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), Z_STRVAL_P(method));
2516                }
2517
2518                HANDLE_EXCEPTION();
2519            }
2520            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2521                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2522                    zend_error(E_DEPRECATED,
2523                        "Non-static method %s::%s() should not be called statically",
2524                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2525                } else {
2526                    zend_error(
2527                        E_EXCEPTION | E_ERROR,
2528                        "Non-static method %s::%s() cannot be called statically",
2529                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2530
2531                    HANDLE_EXCEPTION();
2532                }
2533            }
2534        } else {
2535            called_scope = Z_OBJCE_P(obj);
2536            object = Z_OBJ_P(obj);
2537
2538            fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL);
2539            if (UNEXPECTED(fbc == NULL)) {
2540                if (EXPECTED(!EG(exception))) {
2541                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(object->ce->name), Z_STRVAL_P(method));
2542                }
2543
2544                HANDLE_EXCEPTION();
2545            }
2546
2547            if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2548                object = NULL;
2549            } else {
2550                call_info |= ZEND_CALL_RELEASE_THIS;
2551                GC_REFCOUNT(object)++; /* For $this pointer */
2552            }
2553        }
2554
2555    } else if ((IS_CV & (IS_VAR|IS_CV)) && Z_TYPE_P(function_name) == IS_REFERENCE) {
2556        function_name = Z_REFVAL_P(function_name);
2557        goto try_function_name;
2558    } else {
2559        if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
2560            GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
2561        }
2562        if (UNEXPECTED(EG(exception) != NULL)) {
2563            HANDLE_EXCEPTION();
2564        }
2565        zend_error(E_EXCEPTION | E_ERROR, "Function name must be a string");
2566
2567        HANDLE_EXCEPTION();
2568    }
2569    call = zend_vm_stack_push_call_frame(call_info,
2570        fbc, opline->extended_value, called_scope, object);
2571    call->prev_execute_data = EX(call);
2572    EX(call) = call;
2573
2574    CHECK_EXCEPTION();
2575    ZEND_VM_NEXT_OPCODE();
2576}
2577
2578static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2579{
2580    USE_OPLINE
2581
2582    SAVE_OPLINE();
2583    if (EG(exception)) {
2584        zend_exception_save();
2585    }
2586    if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
2587        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
2588        CHECK_EXCEPTION();
2589        ZEND_VM_NEXT_OPCODE();
2590    } else {
2591        zend_free_op free_op2;
2592        zval *class_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
2593
2594try_class_name:
2595        if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
2596            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2597                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2598            } else {
2599                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);
2600                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2601            }
2602        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2603            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2604        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2605            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
2606        } else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
2607            class_name = Z_REFVAL_P(class_name);
2608            goto try_class_name;
2609        } else {
2610            if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
2611                GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
2612            }
2613            if (UNEXPECTED(EG(exception) != NULL)) {
2614                HANDLE_EXCEPTION();
2615            }
2616            zend_error(E_EXCEPTION | E_ERROR, "Class name must be a valid object or a string");
2617        }
2618
2619        zval_ptr_dtor_nogc(free_op2);
2620        CHECK_EXCEPTION();
2621        ZEND_VM_NEXT_OPCODE();
2622    }
2623}
2624
2625static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_DYNAMIC_CALL_SPEC_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2626{
2627    USE_OPLINE
2628    zend_function *fbc;
2629    zval *function_name, *func;
2630    zend_string *lcname;
2631    zend_free_op free_op2;
2632    zend_class_entry *called_scope;
2633    zend_object *object;
2634    zend_execute_data *call;
2635    uint32_t call_info = ZEND_CALL_NESTED_FUNCTION;
2636
2637    SAVE_OPLINE();
2638    function_name = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
2639
2640try_function_name:
2641    if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2642        const char *colon;
2643
2644        if ((colon = zend_memrchr(Z_STRVAL_P(function_name), ':', Z_STRLEN_P(function_name))) != NULL &&
2645            colon > Z_STRVAL_P(function_name) &&
2646            *(colon-1) == ':'
2647        ) {
2648            zend_string *mname;
2649            size_t cname_length = colon - Z_STRVAL_P(function_name) - 1;
2650            size_t mname_length = Z_STRLEN_P(function_name) - cname_length - (sizeof("::") - 1);
2651
2652            lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
2653
2654            object = NULL;
2655            called_scope = zend_fetch_class_by_name(lcname, NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
2656            if (UNEXPECTED(called_scope == NULL)) {
2657                zend_string_release(lcname);
2658                CHECK_EXCEPTION();
2659                ZEND_VM_NEXT_OPCODE();
2660            }
2661
2662            mname = zend_string_init(Z_STRVAL_P(function_name) + (cname_length + sizeof("::") - 1), mname_length, 0);
2663
2664            if (called_scope->get_static_method) {
2665                fbc = called_scope->get_static_method(called_scope, mname);
2666            } else {
2667                fbc = zend_std_get_static_method(called_scope, mname, NULL);
2668            }
2669            if (UNEXPECTED(fbc == NULL)) {
2670                if (EXPECTED(!EG(exception))) {
2671                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), ZSTR_VAL(mname));
2672                }
2673                zend_string_release(lcname);
2674                zend_string_release(mname);
2675                zval_ptr_dtor_nogc(free_op2);
2676                HANDLE_EXCEPTION();
2677            }
2678
2679            zend_string_release(lcname);
2680            zend_string_release(mname);
2681
2682            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2683                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2684                    zend_error(E_DEPRECATED,
2685                        "Non-static method %s::%s() should not be called statically",
2686                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2687                } else {
2688                    zend_error(
2689                        E_EXCEPTION | E_ERROR,
2690                        "Non-static method %s::%s() cannot be called statically",
2691                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2692                    zval_ptr_dtor_nogc(free_op2);
2693                    HANDLE_EXCEPTION();
2694                }
2695            }
2696        } else {
2697            if (Z_STRVAL_P(function_name)[0] == '\\') {
2698                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
2699                zend_str_tolower_copy(ZSTR_VAL(lcname), Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
2700            } else {
2701                lcname = zend_string_tolower(Z_STR_P(function_name));
2702            }
2703            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
2704                zend_error(E_EXCEPTION | E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
2705                zend_string_release(lcname);
2706                zval_ptr_dtor_nogc(free_op2);
2707                HANDLE_EXCEPTION();
2708            }
2709            zend_string_release(lcname);
2710
2711            fbc = Z_FUNC_P(func);
2712            called_scope = NULL;
2713            object = NULL;
2714        }
2715        zval_ptr_dtor_nogc(free_op2);
2716    } else if ((IS_TMP_VAR|IS_VAR) != IS_CONST &&
2717        EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2718        Z_OBJ_HANDLER_P(function_name, get_closure) &&
2719        Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
2720        if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2721            /* Delay closure destruction until its invocation */
2722            ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
2723            GC_REFCOUNT(fbc->common.prototype)++;
2724            call_info |= ZEND_CALL_CLOSURE;
2725        }
2726        zval_ptr_dtor_nogc(free_op2);
2727    } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2728            zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2729        zval *obj;
2730        zval *method;
2731        obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2732        method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2733
2734        if (!obj || !method) {
2735            zend_error(E_EXCEPTION | E_ERROR, "Array callback has to contain indices 0 and 1");
2736            zval_ptr_dtor_nogc(free_op2);
2737            HANDLE_EXCEPTION();
2738        }
2739
2740        ZVAL_DEREF(obj);
2741        if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2742            zend_error(E_EXCEPTION | E_ERROR, "First array member is not a valid class name or object");
2743            zval_ptr_dtor_nogc(free_op2);
2744            HANDLE_EXCEPTION();
2745        }
2746
2747        ZVAL_DEREF(method);
2748        if (Z_TYPE_P(method) != IS_STRING) {
2749            zend_error(E_EXCEPTION | E_ERROR, "Second array member is not a valid method");
2750            zval_ptr_dtor_nogc(free_op2);
2751            HANDLE_EXCEPTION();
2752        }
2753
2754        if (Z_TYPE_P(obj) == IS_STRING) {
2755            object = NULL;
2756            called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
2757            if (UNEXPECTED(called_scope == NULL)) {
2758                CHECK_EXCEPTION();
2759                ZEND_VM_NEXT_OPCODE();
2760            }
2761
2762            if (called_scope->get_static_method) {
2763                fbc = called_scope->get_static_method(called_scope, Z_STR_P(method));
2764            } else {
2765                fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL);
2766            }
2767            if (UNEXPECTED(fbc == NULL)) {
2768                if (EXPECTED(!EG(exception))) {
2769                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), Z_STRVAL_P(method));
2770                }
2771                zval_ptr_dtor_nogc(free_op2);
2772                HANDLE_EXCEPTION();
2773            }
2774            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2775                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2776                    zend_error(E_DEPRECATED,
2777                        "Non-static method %s::%s() should not be called statically",
2778                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2779                } else {
2780                    zend_error(
2781                        E_EXCEPTION | E_ERROR,
2782                        "Non-static method %s::%s() cannot be called statically",
2783                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
2784                    zval_ptr_dtor_nogc(free_op2);
2785                    HANDLE_EXCEPTION();
2786                }
2787            }
2788        } else {
2789            called_scope = Z_OBJCE_P(obj);
2790            object = Z_OBJ_P(obj);
2791
2792            fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL);
2793            if (UNEXPECTED(fbc == NULL)) {
2794                if (EXPECTED(!EG(exception))) {
2795                    zend_error(E_EXCEPTION | E_ERROR, "Call to undefined method %s::%s()", ZSTR_VAL(object->ce->name), Z_STRVAL_P(method));
2796                }
2797                zval_ptr_dtor_nogc(free_op2);
2798                HANDLE_EXCEPTION();
2799            }
2800
2801            if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2802                object = NULL;
2803            } else {
2804                call_info |= ZEND_CALL_RELEASE_THIS;
2805                GC_REFCOUNT(object)++; /* For $this pointer */
2806            }
2807        }
2808        zval_ptr_dtor_nogc(free_op2);
2809    } else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && Z_TYPE_P(function_name) == IS_REFERENCE) {
2810        function_name = Z_REFVAL_P(function_name);
2811        goto try_function_name;
2812    } else {
2813        if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
2814            GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
2815        }
2816        if (UNEXPECTED(EG(exception) != NULL)) {
2817            HANDLE_EXCEPTION();
2818        }
2819        zend_error(E_EXCEPTION | E_ERROR, "Function name must be a string");
2820        zval_ptr_dtor_nogc(free_op2);
2821        HANDLE_EXCEPTION();
2822    }
2823    call = zend_vm_stack_push_call_frame(call_info,
2824        fbc, opline->extended_value, called_scope, object);
2825    call->prev_execute_data = EX(call);
2826    EX(call) = call;
2827
2828    CHECK_EXCEPTION();
2829    ZEND_VM_NEXT_OPCODE();
2830}
2831
2832static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BW_NOT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2833{
2834    USE_OPLINE
2835
2836
2837    SAVE_OPLINE();
2838    bitwise_not_function(EX_VAR(opline->result.var),
2839        EX_CONSTANT(opline->op1));
2840
2841    CHECK_EXCEPTION();
2842    ZEND_VM_NEXT_OPCODE();
2843}
2844
2845static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BOOL_NOT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2846{
2847    USE_OPLINE
2848    zval *val;
2849
2850
2851    val = EX_CONSTANT(opline->op1);
2852    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2853        ZVAL_FALSE(EX_VAR(opline->result.var));
2854    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2855        if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2856            SAVE_OPLINE();
2857            GET_OP1_UNDEF_CV(val, BP_VAR_R);
2858            CHECK_EXCEPTION();
2859        }
2860        ZVAL_TRUE(EX_VAR(opline->result.var));
2861    } else {
2862        SAVE_OPLINE();
2863        ZVAL_BOOL(EX_VAR(opline->result.var), !i_zend_is_true(val));
2864
2865        CHECK_EXCEPTION();
2866    }
2867    ZEND_VM_NEXT_OPCODE();
2868}
2869
2870static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2871{
2872    USE_OPLINE
2873
2874    zval *z;
2875
2876    SAVE_OPLINE();
2877    z = EX_CONSTANT(opline->op1);
2878
2879    if (Z_TYPE_P(z) == IS_STRING) {
2880        zend_string *str = Z_STR_P(z);
2881
2882        if (ZSTR_LEN(str) != 0) {
2883            zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
2884        }
2885    } else {
2886        zend_string *str = _zval_get_string_func(z);
2887
2888        if (ZSTR_LEN(str) != 0) {
2889            zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
2890        } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(z) == IS_UNDEF)) {
2891            GET_OP1_UNDEF_CV(z, BP_VAR_R);
2892        }
2893        zend_string_release(str);
2894    }
2895
2896    CHECK_EXCEPTION();
2897    ZEND_VM_NEXT_OPCODE();
2898}
2899
2900static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2901{
2902    USE_OPLINE
2903
2904    zval *val;
2905
2906    val = EX_CONSTANT(opline->op1);
2907
2908    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2909        ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2910        ZEND_VM_CONTINUE();
2911    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2912        if (IS_CONST == IS_CV) {
2913            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2914                SAVE_OPLINE();
2915                GET_OP1_UNDEF_CV(val, BP_VAR_R);
2916            }
2917            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2918        } else {
2919            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2920            ZEND_VM_CONTINUE();
2921        }
2922    }
2923
2924    SAVE_OPLINE();
2925    if (i_zend_is_true(val)) {
2926        opline++;
2927    } else {
2928        opline = OP_JMP_ADDR(opline, opline->op2);
2929    }
2930
2931    if (UNEXPECTED(EG(exception) != NULL)) {
2932        HANDLE_EXCEPTION();
2933    }
2934    ZEND_VM_JMP(opline);
2935}
2936
2937static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2938{
2939    USE_OPLINE
2940
2941    zval *val;
2942
2943    val = EX_CONSTANT(opline->op1);
2944
2945    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2946        ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2947        ZEND_VM_CONTINUE();
2948    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2949        if (IS_CONST == IS_CV) {
2950            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2951                SAVE_OPLINE();
2952                GET_OP1_UNDEF_CV(val, BP_VAR_R);
2953                CHECK_EXCEPTION();
2954            }
2955            ZEND_VM_NEXT_OPCODE();
2956        } else {
2957            ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2958            ZEND_VM_CONTINUE();
2959        }
2960    }
2961
2962    SAVE_OPLINE();
2963    if (i_zend_is_true(val)) {
2964        opline = OP_JMP_ADDR(opline, opline->op2);
2965    } else {
2966        opline++;
2967    }
2968
2969    if (UNEXPECTED(EG(exception) != NULL)) {
2970        HANDLE_EXCEPTION();
2971    }
2972    ZEND_VM_JMP(opline);
2973}
2974
2975static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZNZ_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
2976{
2977    USE_OPLINE
2978
2979    zval *val;
2980
2981    val = EX_CONSTANT(opline->op1);
2982
2983    if (EXPECTED(Z_TYPE_INFO_P(val) == IS_TRUE)) {
2984        ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
2985        ZEND_VM_CONTINUE();
2986    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2987        if (IS_CONST == IS_CV) {
2988            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2989                SAVE_OPLINE();
2990                GET_OP1_UNDEF_CV(val, BP_VAR_R);
2991            }
2992            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2993        } else {
2994            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2995            ZEND_VM_CONTINUE();
2996        }
2997    }
2998
2999    SAVE_OPLINE();
3000    if (i_zend_is_true(val)) {
3001        opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
3002    } else {
3003        opline = OP_JMP_ADDR(opline, opline->op2);
3004    }
3005
3006    if (UNEXPECTED(EG(exception) != NULL)) {
3007        HANDLE_EXCEPTION();
3008    }
3009    ZEND_VM_JMP(opline);
3010}
3011
3012static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3013{
3014    USE_OPLINE
3015
3016    zval *val;
3017    int ret;
3018
3019    val = EX_CONSTANT(opline->op1);
3020
3021    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
3022        ZVAL_TRUE(EX_VAR(opline->result.var));
3023        ZEND_VM_SET_NEXT_OPCODE(opline + 1);
3024        ZEND_VM_CONTINUE();
3025    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
3026        ZVAL_FALSE(EX_VAR(opline->result.var));
3027        if (IS_CONST == IS_CV) {
3028            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
3029                SAVE_OPLINE();
3030                GET_OP1_UNDEF_CV(val, BP_VAR_R);
3031            }
3032            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3033        } else {
3034            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
3035            ZEND_VM_CONTINUE();
3036        }
3037    }
3038
3039    SAVE_OPLINE();
3040    ret = i_zend_is_true(val);
3041
3042    if (ret) {
3043        ZVAL_TRUE(EX_VAR(opline->result.var));
3044        opline++;
3045    } else {
3046        ZVAL_FALSE(EX_VAR(opline->result.var));
3047        opline = OP_JMP_ADDR(opline, opline->op2);
3048    }
3049    if (UNEXPECTED(EG(exception) != NULL)) {
3050        HANDLE_EXCEPTION();
3051    }
3052    ZEND_VM_JMP(opline);
3053}
3054
3055static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3056{
3057    USE_OPLINE
3058
3059    zval *val;
3060    int ret;
3061
3062    val = EX_CONSTANT(opline->op1);
3063
3064    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
3065        ZVAL_TRUE(EX_VAR(opline->result.var));
3066        ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
3067        ZEND_VM_CONTINUE();
3068    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
3069        ZVAL_FALSE(EX_VAR(opline->result.var));
3070        if (IS_CONST == IS_CV) {
3071            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
3072                SAVE_OPLINE();
3073                GET_OP1_UNDEF_CV(val, BP_VAR_R);
3074                CHECK_EXCEPTION();
3075            }
3076            ZEND_VM_NEXT_OPCODE();
3077        } else {
3078            ZEND_VM_SET_NEXT_OPCODE(opline + 1);
3079            ZEND_VM_CONTINUE();
3080        }
3081    }
3082
3083    SAVE_OPLINE();
3084    ret = i_zend_is_true(val);
3085
3086    if (ret) {
3087        ZVAL_TRUE(EX_VAR(opline->result.var));
3088        opline = OP_JMP_ADDR(opline, opline->op2);
3089    } else {
3090        ZVAL_FALSE(EX_VAR(opline->result.var));
3091        opline++;
3092    }
3093    if (UNEXPECTED(EG(exception) != NULL)) {
3094        HANDLE_EXCEPTION();
3095    }
3096    ZEND_VM_JMP(opline);
3097}
3098
3099static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3100{
3101    USE_OPLINE
3102    zval *retval_ptr;
3103    zend_free_op free_op1;
3104
3105    retval_ptr = EX_CONSTANT(opline->op1);
3106    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(retval_ptr) == IS_UNDEF)) {
3107        SAVE_OPLINE();
3108        retval_ptr = GET_OP1_UNDEF_CV(retval_ptr, BP_VAR_R);
3109        if (EX(return_value)) {
3110            ZVAL_NULL(EX(return_value));
3111        }
3112    } else if (!EX(return_value)) {
3113        if (IS_CONST == IS_VAR || IS_CONST == IS_TMP_VAR ) {
3114            if (Z_REFCOUNTED_P(free_op1) && !Z_DELREF_P(free_op1)) {
3115                SAVE_OPLINE();
3116                zval_dtor_func_for_ptr(Z_COUNTED_P(free_op1));
3117            }
3118        }
3119    } else {
3120        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
3121            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3122            if (IS_CONST == IS_CONST) {
3123                if (UNEXPECTED(Z_OPT_COPYABLE_P(EX(return_value)))) {
3124                    zval_copy_ctor_func(EX(return_value));
3125                }
3126            }
3127        } else if (IS_CONST == IS_CV) {
3128            ZVAL_DEREF(retval_ptr);
3129            ZVAL_COPY(EX(return_value), retval_ptr);
3130        } else /* if (IS_CONST == IS_VAR) */ {
3131            if (UNEXPECTED(Z_ISREF_P(retval_ptr))) {
3132                zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
3133
3134                retval_ptr = Z_REFVAL_P(retval_ptr);
3135                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3136                if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
3137                    efree_size(ref, sizeof(zend_reference));
3138                } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
3139                    Z_ADDREF_P(retval_ptr);
3140                }
3141            } else {
3142                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3143            }
3144        }
3145    }
3146    ZEND_VM_TAIL_CALL(zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
3147}
3148
3149static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RETURN_BY_REF_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3150{
3151    USE_OPLINE
3152    zval *retval_ptr;
3153
3154
3155    SAVE_OPLINE();
3156
3157    do {
3158        if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR ||
3159            (IS_CONST == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
3160            /* Not supposed to happen, but we'll allow it */
3161            zend_error(E_NOTICE, "Only variable references should be returned by reference");
3162
3163            retval_ptr = EX_CONSTANT(opline->op1);
3164            if (!EX(return_value)) {
3165                if (IS_CONST == IS_TMP_VAR) {
3166
3167                }
3168            } else {
3169                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3170                Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
3171                if (IS_CONST != IS_TMP_VAR) {
3172                    zval_opt_copy_ctor_no_imm(EX(return_value));
3173                }
3174            }
3175            break;
3176        }
3177
3178        retval_ptr = NULL;
3179
3180        if (IS_CONST == IS_VAR && UNEXPECTED(retval_ptr == NULL)) {
3181            zend_error(E_EXCEPTION | E_ERROR, "Cannot return string offsets by reference");
3182            HANDLE_EXCEPTION();
3183        }
3184
3185        if (IS_CONST == IS_VAR) {
3186            if (retval_ptr == &EG(uninitialized_zval) ||
3187                (opline->extended_value == ZEND_RETURNS_FUNCTION &&
3188                 !(Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF))) {
3189                zend_error(E_NOTICE, "Only variable references should be returned by reference");
3190                if (EX(return_value)) {
3191                    ZVAL_NEW_REF(EX(return_value), retval_ptr);
3192                    Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
3193                    if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
3194                }
3195                break;
3196            }
3197        }
3198
3199        if (EX(return_value)) {
3200            ZVAL_MAKE_REF(retval_ptr);
3201            Z_ADDREF_P(retval_ptr);
3202            ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
3203            Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
3204        }
3205    } while (0);
3206
3207    ZEND_VM_TAIL_CALL(zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
3208}
3209
3210static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3211{
3212    USE_OPLINE
3213    zval *retval;
3214
3215
3216    zend_generator *generator = zend_get_running_generator(execute_data);
3217
3218    SAVE_OPLINE();
3219    retval = EX_CONSTANT(opline->op1);
3220
3221    /* Copy return value into generator->retval */
3222    if (IS_CONST == IS_CONST || IS_CONST == IS_TMP_VAR) {
3223        ZVAL_COPY_VALUE(&generator->retval, retval);
3224        if (IS_CONST == IS_CONST) {
3225            if (UNEXPECTED(Z_OPT_COPYABLE(generator->retval))) {
3226                zval_copy_ctor_func(&generator->retval);
3227            }
3228        }
3229    } else if (IS_CONST == IS_CV) {
3230        ZVAL_DEREF(retval);
3231        ZVAL_COPY(&generator->retval, retval);
3232    } else /* if (IS_CONST == IS_VAR) */ {
3233        if (UNEXPECTED(Z_ISREF_P(retval))) {
3234            zend_refcounted *ref = Z_COUNTED_P(retval);
3235
3236            retval = Z_REFVAL_P(retval);
3237            ZVAL_COPY_VALUE(&generator->retval, retval);
3238            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
3239                efree_size(ref, sizeof(zend_reference));
3240            } else if (Z_OPT_REFCOUNTED_P(retval)) {
3241                Z_ADDREF_P(retval);
3242            }
3243        } else {
3244            ZVAL_COPY_VALUE(&generator->retval, retval);
3245        }
3246    }
3247
3248    /* Close the generator to free up resources */
3249    zend_generator_close(generator, 1);
3250
3251    /* Pass execution back to handling code */
3252    ZEND_VM_RETURN();
3253}
3254
3255static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_THROW_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3256{
3257    USE_OPLINE
3258    zval *value;
3259
3260
3261    SAVE_OPLINE();
3262    value = EX_CONSTANT(opline->op1);
3263
3264    do {
3265        if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
3266            if ((IS_CONST & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
3267                value = Z_REFVAL_P(value);
3268                if (EXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
3269                    break;
3270                }
3271            }
3272            if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
3273                GET_OP1_UNDEF_CV(value, BP_VAR_R);
3274            }
3275            if (UNEXPECTED(EG(exception) != NULL)) {
3276                HANDLE_EXCEPTION();
3277            }
3278            zend_error(E_EXCEPTION | E_ERROR, "Can only throw objects");
3279
3280            HANDLE_EXCEPTION();
3281        }
3282    } while (0);
3283
3284    zend_exception_save();
3285    if (IS_CONST != IS_TMP_VAR) {
3286        if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
3287    }
3288
3289    zend_throw_exception_object(value);
3290    zend_exception_restore();
3291
3292    HANDLE_EXCEPTION();
3293}
3294
3295static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3296{
3297    USE_OPLINE
3298    zval *value, *arg;
3299
3300
3301    value = EX_CONSTANT(opline->op1);
3302    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
3303    ZVAL_COPY_VALUE(arg, value);
3304    if (IS_CONST == IS_CONST) {
3305        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
3306            zval_copy_ctor_func(arg);
3307        }
3308    }
3309    ZEND_VM_NEXT_OPCODE();
3310}
3311
3312static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3313{
3314    USE_OPLINE
3315    zval *value, *arg;
3316
3317
3318    if (EXPECTED(opline->op2.num <= MAX_ARG_FLAG_NUM)) {
3319        if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3320            goto send_val_by_ref;
3321        }
3322    } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3323send_val_by_ref:
3324        SAVE_OPLINE();
3325        zend_error(E_EXCEPTION | E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
3326
3327        arg = ZEND_CALL_VAR(EX(call), opline->result.var);
3328        ZVAL_UNDEF(arg);
3329        HANDLE_EXCEPTION();
3330    }
3331    value = EX_CONSTANT(opline->op1);
3332    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
3333    ZVAL_COPY_VALUE(arg, value);
3334    if (IS_CONST == IS_CONST) {
3335        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
3336            zval_copy_ctor_func(arg);
3337        }
3338    }
3339    ZEND_VM_NEXT_OPCODE();
3340}
3341
3342static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BOOL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3343{
3344    USE_OPLINE
3345    zval *val;
3346
3347
3348    val = EX_CONSTANT(opline->op1);
3349    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
3350        ZVAL_TRUE(EX_VAR(opline->result.var));
3351    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
3352        if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
3353            SAVE_OPLINE();
3354            GET_OP1_UNDEF_CV(val, BP_VAR_R);
3355            CHECK_EXCEPTION();
3356        }
3357        ZVAL_FALSE(EX_VAR(opline->result.var));
3358    } else {
3359        SAVE_OPLINE();
3360        ZVAL_BOOL(EX_VAR(opline->result.var), i_zend_is_true(val));
3361
3362        CHECK_EXCEPTION();
3363    }
3364    ZEND_VM_NEXT_OPCODE();
3365}
3366
3367static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3368{
3369    USE_OPLINE
3370    zval object_zval;
3371    zend_function *constructor;
3372    zend_class_entry *ce;
3373
3374    SAVE_OPLINE();
3375    if (IS_CONST == IS_CONST) {
3376        if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
3377            ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
3378        } else {
3379            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);
3380            if (UNEXPECTED(ce == NULL)) {
3381                CHECK_EXCEPTION();
3382                ZEND_VM_NEXT_OPCODE();
3383            }
3384            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
3385        }
3386    } else {
3387        ce = Z_CE_P(EX_VAR(opline->op1.var));
3388    }
3389    if (UNEXPECTED(object_init_ex(&object_zval, ce) != SUCCESS)) {
3390        HANDLE_EXCEPTION();
3391    }
3392    constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval));
3393
3394    if (constructor == NULL) {
3395        if (EXPECTED(RETURN_VALUE_USED(opline))) {
3396            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
3397        } else {
3398            OBJ_RELEASE(Z_OBJ(object_zval));
3399        }
3400        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3401    } else {
3402        /* We are not handling overloaded classes right now */
3403        zend_execute_data *call = zend_vm_stack_push_call_frame(
3404                ZEND_CALL_FUNCTION | ZEND_CALL_RELEASE_THIS | ZEND_CALL_CTOR |
3405                (EXPECTED(RETURN_VALUE_USED(opline)) ? 0 : ZEND_CALL_CTOR_RESULT_UNUSED),
3406            constructor,
3407            opline->extended_value,
3408            ce,
3409            Z_OBJ(object_zval));
3410        call->prev_execute_data = EX(call);
3411        EX(call) = call;
3412
3413        if (EXPECTED(RETURN_VALUE_USED(opline))) {
3414            ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
3415        }
3416
3417        CHECK_EXCEPTION();
3418        ZEND_VM_NEXT_OPCODE();
3419    }
3420}
3421
3422static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3423{
3424    USE_OPLINE
3425
3426    zval *obj;
3427    zend_class_entry *ce;
3428    zend_function *clone;
3429    zend_object_clone_obj_t clone_call;
3430
3431    SAVE_OPLINE();
3432    obj = EX_CONSTANT(opline->op1);
3433
3434    if (IS_CONST == IS_UNUSED && UNEXPECTED(Z_OBJ_P(obj) == NULL)) {
3435        zend_error(E_EXCEPTION | E_ERROR, "Using $this when not in object context");
3436        HANDLE_EXCEPTION();
3437    }
3438
3439    do {
3440        if (IS_CONST == IS_CONST ||
3441            (IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) {
3442            if ((IS_CONST & (IS_VAR|IS_CV)) && Z_ISREF_P(obj)) {
3443                obj = Z_REFVAL_P(obj);
3444                if (EXPECTED(Z_TYPE_P(obj) == IS_OBJECT)) {
3445                    break;
3446                }
3447            }
3448            if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(obj) == IS_UNDEF)) {
3449                GET_OP1_UNDEF_CV(obj, BP_VAR_R);
3450            }
3451            if (UNEXPECTED(EG(exception) != NULL)) {
3452                HANDLE_EXCEPTION();
3453            }
3454            zend_error(E_EXCEPTION | E_ERROR, "__clone method called on non-object");
3455
3456            HANDLE_EXCEPTION();
3457        }
3458    } while (0);
3459
3460    ce = Z_OBJCE_P(obj);
3461    clone = ce ? ce->clone : NULL;
3462    clone_call =  Z_OBJ_HT_P(obj)->clone_obj;
3463    if (UNEXPECTED(clone_call == NULL)) {
3464        if (ce) {
3465            zend_error(E_EXCEPTION | E_ERROR, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name));
3466        } else {
3467            zend_error(E_EXCEPTION | E_ERROR, "Trying to clone an uncloneable object");
3468        }
3469
3470        HANDLE_EXCEPTION();
3471    }
3472
3473    if (ce && clone) {
3474        if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
3475            /* Ensure that if we're calling a private function, we're allowed to do so.
3476             */
3477            if (UNEXPECTED(ce != EG(scope))) {
3478                zend_error(E_EXCEPTION | E_ERROR, "Call to private %s::__clone() from context '%s'", ZSTR_VAL(ce->name), EG(scope) ? ZSTR_VAL(EG(scope)->name) : "");
3479
3480                HANDLE_EXCEPTION();
3481            }
3482        } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
3483            /* Ensure that if we're calling a protected function, we're allowed to do so.
3484             */
3485            if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EG(scope)))) {
3486                zend_error(E_EXCEPTION | E_ERROR, "Call to protected %s::__clone() from context '%s'", ZSTR_VAL(ce->name), EG(scope) ? ZSTR_VAL(EG(scope)->name) : "");
3487
3488                HANDLE_EXCEPTION();
3489            }
3490        }
3491    }
3492
3493    if (EXPECTED(EG(exception) == NULL)) {
3494        ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj));
3495        if (UNEXPECTED(!RETURN_VALUE_USED(opline)) || UNEXPECTED(EG(exception) != NULL)) {
3496            OBJ_RELEASE(Z_OBJ_P(EX_VAR(opline->result.var)));
3497        }
3498    }
3499
3500    CHECK_EXCEPTION();
3501    ZEND_VM_NEXT_OPCODE();
3502}
3503
3504static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3505{
3506    USE_OPLINE
3507
3508    zval *expr;
3509    zval *result = EX_VAR(opline->result.var);
3510
3511    SAVE_OPLINE();
3512    expr = EX_CONSTANT(opline->op1);
3513
3514    switch (opline->extended_value) {
3515        case IS_NULL:
3516            /* This code is taken from convert_to_null. However, it does not seems very useful,
3517             * because a conversion to null always results in the same value. This could only
3518             * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
3519#if 0
3520            if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
3521                ZVAL_DEREF(expr);
3522            }
3523            if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
3524                if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
3525                    break;
3526                }
3527            }
3528#endif
3529
3530            ZVAL_NULL(result);
3531            break;
3532        case _IS_BOOL:
3533            ZVAL_BOOL(result, zend_is_true(expr));
3534            break;
3535        case IS_LONG:
3536            ZVAL_LONG(result, zval_get_long(expr));
3537            break;
3538        case IS_DOUBLE:
3539            ZVAL_DOUBLE(result, zval_get_double(expr));
3540            break;
3541        case IS_STRING:
3542            ZVAL_STR(result, zval_get_string(expr));
3543            break;
3544        default:
3545            if (IS_CONST & (IS_VAR|IS_CV)) {
3546                ZVAL_DEREF(expr);
3547            }
3548            /* If value is already of correct type, return it directly */
3549            if (Z_TYPE_P(expr) == opline->extended_value) {
3550                ZVAL_COPY_VALUE(result, expr);
3551                if (IS_CONST == IS_CONST) {
3552                    if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
3553                        zval_copy_ctor_func(result);
3554                    }
3555                } else if (IS_CONST != IS_TMP_VAR) {
3556                    if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
3557                }
3558
3559                CHECK_EXCEPTION();
3560                ZEND_VM_NEXT_OPCODE();
3561            }
3562
3563            if (opline->extended_value == IS_ARRAY) {
3564                if (Z_TYPE_P(expr) != IS_OBJECT) {
3565                    ZVAL_NEW_ARR(result);
3566                    zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
3567                    if (Z_TYPE_P(expr) != IS_NULL) {
3568                        expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
3569                        if (IS_CONST == IS_CONST) {
3570                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
3571                                zval_copy_ctor_func(expr);
3572                            }
3573                        } else {
3574                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
3575                        }
3576                    }
3577                } else {
3578                    ZVAL_COPY_VALUE(result, expr);
3579                    Z_ADDREF_P(result);
3580                    convert_to_array(result);
3581                }
3582            } else {
3583                if (Z_TYPE_P(expr) != IS_ARRAY) {
3584                    object_init(result);
3585                    if (Z_TYPE_P(expr) != IS_NULL) {
3586                        expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
3587                        if (IS_CONST == IS_CONST) {
3588                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
3589                                zval_copy_ctor_func(expr);
3590                            }
3591                        } else {
3592                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
3593                        }
3594                    }
3595                } else {
3596                    ZVAL_COPY(result, expr);
3597                    convert_to_object(result);
3598                }
3599            }
3600    }
3601
3602    CHECK_EXCEPTION();
3603    ZEND_VM_NEXT_OPCODE();
3604}
3605
3606static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3607{
3608    USE_OPLINE
3609    zend_op_array *new_op_array=NULL;
3610
3611    zval *inc_filename;
3612    zval tmp_inc_filename;
3613    zend_bool failure_retval=0;
3614
3615    SAVE_OPLINE();
3616    inc_filename = EX_CONSTANT(opline->op1);
3617
3618    ZVAL_UNDEF(&tmp_inc_filename);
3619    if (Z_TYPE_P(inc_filename) != IS_STRING) {
3620        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(inc_filename) == IS_UNDEF)) {
3621            inc_filename = GET_OP1_UNDEF_CV(inc_filename, BP_VAR_R);
3622        }
3623        ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
3624        inc_filename = &tmp_inc_filename;
3625    }
3626
3627    if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
3628        if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
3629            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
3630        } else {
3631            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
3632        }
3633    } else {
3634        switch (opline->extended_value) {
3635            case ZEND_INCLUDE_ONCE:
3636            case ZEND_REQUIRE_ONCE: {
3637                    zend_file_handle file_handle;
3638                    zend_string *resolved_path;
3639
3640                    resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
3641                    if (resolved_path) {
3642                        failure_retval = zend_hash_exists(&EG(included_files), resolved_path);
3643                    } else {
3644                        resolved_path = zend_string_copy(Z_STR_P(inc_filename));
3645                    }
3646
3647                    if (failure_retval) {
3648                        /* do nothing, file already included */
3649                    } else if (SUCCESS == zend_stream_open(ZSTR_VAL(resolved_path), &file_handle)) {
3650
3651                        if (!file_handle.opened_path) {
3652                            file_handle.opened_path = zend_string_copy(resolved_path);
3653                        }
3654
3655                        if (zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path)) {
3656                            new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE));
3657                            zend_destroy_file_handle(&file_handle);
3658                        } else {
3659                            zend_file_handle_dtor(&file_handle);
3660                            failure_retval=1;
3661                        }
3662                    } else {
3663                        if (opline->extended_value == ZEND_INCLUDE_ONCE) {
3664                            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename));
3665                        } else {
3666                            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename));
3667                        }
3668                    }
3669                    zend_string_release(resolved_path);
3670                }
3671                break;
3672            case ZEND_INCLUDE:
3673            case ZEND_REQUIRE:
3674                new_op_array = compile_filename(opline->extended_value, inc_filename);
3675                break;
3676            case ZEND_EVAL: {
3677                    char *eval_desc = zend_make_compiled_string_description("eval()'d code");
3678
3679                    new_op_array = zend_compile_string(inc_filename, eval_desc);
3680                    efree(eval_desc);
3681                }
3682                break;
3683            EMPTY_SWITCH_DEFAULT_CASE()
3684        }
3685    }
3686    if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
3687        zend_string_release(Z_STR(tmp_inc_filename));
3688    }
3689
3690    if (UNEXPECTED(EG(exception) != NULL)) {
3691        HANDLE_EXCEPTION();
3692    } else if (EXPECTED(new_op_array != NULL)) {
3693        zval *return_value = NULL;
3694        zend_execute_data *call;
3695
3696        if (RETURN_VALUE_USED(opline)) {
3697            return_value = EX_VAR(opline->result.var);
3698        }
3699
3700        new_op_array->scope = EG(scope);
3701
3702        call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_CODE,
3703            (zend_function*)new_op_array, 0, EX(called_scope), Z_OBJ(EX(This)));
3704
3705        if (EX(symbol_table)) {
3706            call->symbol_table = EX(symbol_table);
3707        } else {
3708            call->symbol_table = zend_rebuild_symbol_table();
3709        }
3710
3711        call->prev_execute_data = execute_data;
3712        i_init_code_execute_data(call, new_op_array, return_value);
3713        if (EXPECTED(zend_execute_ex == execute_ex)) {
3714            ZEND_VM_ENTER();
3715        } else {
3716            ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
3717            zend_execute_ex(call);
3718            zend_vm_stack_free_call_frame(call);
3719        }
3720
3721        destroy_op_array(new_op_array);
3722        efree_size(new_op_array, sizeof(zend_op_array));
3723        if (UNEXPECTED(EG(exception) != NULL)) {
3724            zend_throw_exception_internal(NULL);
3725            HANDLE_EXCEPTION();
3726        }
3727
3728    } else if (RETURN_VALUE_USED(opline)) {
3729        ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
3730    }
3731    ZEND_VM_INTERRUPT_CHECK();
3732    ZEND_VM_NEXT_OPCODE();
3733}
3734
3735static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3736{
3737    USE_OPLINE
3738
3739    zval *array_ptr, *result;
3740    HashTable *fe_ht;
3741
3742    SAVE_OPLINE();
3743
3744    array_ptr = EX_CONSTANT(opline->op1);
3745    if (EXPECTED(Z_TYPE_P(array_ptr) == IS_ARRAY)) {
3746        result = EX_VAR(opline->result.var);
3747        ZVAL_COPY_VALUE(result, array_ptr);
3748        if (IS_CONST != IS_TMP_VAR && Z_OPT_REFCOUNTED_P(result)) {
3749            Z_ADDREF_P(array_ptr);
3750        }
3751        Z_FE_POS_P(result) = 0;
3752
3753        CHECK_EXCEPTION();
3754        ZEND_VM_NEXT_OPCODE();
3755    } else if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) {
3756        if (!Z_OBJCE_P(array_ptr)->get_iterator) {
3757            HashPosition pos = 0;
3758            Bucket *p;
3759
3760            result = EX_VAR(opline->result.var);
3761            ZVAL_COPY_VALUE(result, array_ptr);
3762            if (IS_CONST != IS_TMP_VAR) {
3763                Z_ADDREF_P(array_ptr);
3764            }
3765            fe_ht = Z_OBJPROP_P(array_ptr);
3766            pos = 0;
3767            p = fe_ht->arData;
3768            while (1) {
3769                if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
3770
3771                    Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3772                    ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3773                }
3774                if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
3775                     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
3776                      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
3777                    (UNEXPECTED(!p->key) ||
3778                     EXPECTED(zend_check_property_access(Z_OBJ_P(array_ptr), p->key) == SUCCESS))) {
3779                    break;
3780                }
3781                pos++;
3782                p++;
3783            }
3784            Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
3785
3786            CHECK_EXCEPTION();
3787            ZEND_VM_NEXT_OPCODE();
3788        } else {
3789            zend_class_entry *ce = Z_OBJCE_P(array_ptr);
3790            zend_object_iterator *iter = ce->get_iterator(ce, array_ptr, 0);
3791            zend_bool is_empty;
3792
3793            if (UNEXPECTED(!iter) || UNEXPECTED(EG(exception))) {
3794
3795                if (!EG(exception)) {
3796                    zend_throw_exception_ex(NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name));
3797                }
3798                zend_throw_exception_internal(NULL);
3799                HANDLE_EXCEPTION();
3800            }
3801
3802            iter->index = 0;
3803            if (iter->funcs->rewind) {
3804                iter->funcs->rewind(iter);
3805                if (UNEXPECTED(EG(exception) != NULL)) {
3806                    OBJ_RELEASE(&iter->std);
3807
3808                    HANDLE_EXCEPTION();
3809                }
3810            }
3811
3812            is_empty = iter->funcs->valid(iter) != SUCCESS;
3813
3814            if (UNEXPECTED(EG(exception) != NULL)) {
3815                OBJ_RELEASE(&iter->std);
3816
3817                HANDLE_EXCEPTION();
3818            }
3819            iter->index = -1; /* will be set to 0 before using next handler */
3820
3821            ZVAL_OBJ(EX_VAR(opline->result.var), &iter->std);
3822            Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3823
3824            if (is_empty) {
3825                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3826            } else {
3827                CHECK_EXCEPTION();
3828                ZEND_VM_NEXT_OPCODE();
3829            }
3830        }
3831    } else {
3832        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
3833        ZVAL_UNDEF(EX_VAR(opline->result.var));
3834        Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3835
3836        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3837    }
3838}
3839
3840static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
3841{
3842    USE_OPLINE
3843
3844    zval *array_ptr, *array_ref;
3845    HashTable *fe_ht;
3846    HashPosition pos = 0;
3847    Bucket *p;
3848
3849    SAVE_OPLINE();
3850
3851    if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
3852        array_ref = array_ptr = NULL;
3853        if (Z_ISREF_P(array_ref)) {
3854            array_ptr = Z_REFVAL_P(array_ref);
3855        }
3856    } else {
3857        array_ref = array_ptr = EX_CONSTANT(opline->op1);
3858    }
3859
3860    if (EXPECTED(Z_TYPE_P(array_ptr) == IS_ARRAY)) {
3861        if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
3862            if (array_ptr == array_ref) {
3863                ZVAL_NEW_REF(array_ref, array_ref);
3864                array_ptr = Z_REFVAL_P(array_ref);
3865            }
3866            Z_ADDREF_P(array_ref);
3867            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
3868        } else {
3869            array_ptr = EX_VAR(opline->result.var);
3870            ZVAL_COPY_VALUE(array_ptr, array_ref);
3871        }
3872        if (IS_CONST == IS_CONST) {
3873            zval_copy_ctor_func(array_ptr);
3874        } else {
3875            SEPARATE_ARRAY(array_ptr);
3876        }
3877        fe_ht = Z_ARRVAL_P(array_ptr);
3878        p = fe_ht->arData;
3879        while (1) {
3880            if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
3881
3882                Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3883                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3884            }
3885            if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
3886                (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
3887                 EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) {
3888                break;
3889            }
3890            pos++;
3891            p++;
3892        }
3893        Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
3894
3895        CHECK_EXCEPTION();
3896        ZEND_VM_NEXT_OPCODE();
3897    } else if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) {
3898        if (!Z_OBJCE_P(array_ptr)->get_iterator) {
3899            if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
3900                if (array_ptr == array_ref) {
3901                    ZVAL_NEW_REF(array_ref, array_ref);
3902                    array_ptr = Z_REFVAL_P(array_ref);
3903                }
3904                Z_ADDREF_P(array_ref);
3905                ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
3906            } else {
3907                array_ptr = EX_VAR(opline->result.var);
3908                ZVAL_COPY_VALUE(array_ptr, array_ref);
3909            }
3910            fe_ht = Z_OBJPROP_P(array_ptr);
3911            p = fe_ht->arData;
3912            while (1) {
3913                if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
3914
3915                    Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3916                    ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3917                }
3918                if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
3919                     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
3920                      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
3921                    (UNEXPECTED(!p->key) ||
3922                     EXPECTED(zend_check_property_access(Z_OBJ_P(array_ptr), p->key) == SUCCESS))) {
3923                    break;
3924                }
3925                pos++;
3926                p++;
3927            }
3928            Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
3929
3930            CHECK_EXCEPTION();
3931            ZEND_VM_NEXT_OPCODE();
3932        } else {
3933            zend_class_entry *ce = Z_OBJCE_P(array_ptr);
3934            zend_object_iterator *iter = ce->get_iterator(ce, array_ptr, 1);
3935            zend_bool is_empty;
3936
3937            if (UNEXPECTED(!iter) || UNEXPECTED(EG(exception))) {
3938                if (IS_CONST == IS_VAR) {
3939
3940                } else {
3941
3942                }
3943                if (!EG(exception)) {
3944                    zend_throw_exception_ex(NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name));
3945                }
3946                zend_throw_exception_internal(NULL);
3947                HANDLE_EXCEPTION();
3948            }
3949
3950            iter->index = 0;
3951            if (iter->funcs->rewind) {
3952                iter->funcs->rewind(iter);
3953                if (UNEXPECTED(EG(exception) != NULL)) {
3954                    OBJ_RELEASE(&iter->std);
3955                    if (IS_CONST == IS_VAR) {
3956
3957                    } else {
3958
3959                    }
3960                    HANDLE_EXCEPTION();
3961                }
3962            }
3963
3964            is_empty = iter->funcs->valid(iter) != SUCCESS;
3965
3966            if (UNEXPECTED(EG(exception) != NULL)) {
3967                OBJ_RELEASE(&iter->std);
3968                if (IS_CONST == IS_VAR) {
3969
3970                } else {
3971
3972                }
3973                HANDLE_EXCEPTION();
3974            }
3975            iter->index = -1; /* will be set to 0 before using next handler */
3976
3977            ZVAL_OBJ(EX_VAR(opline->result.var), &iter->std);
3978            Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3979
3980            if (IS_CONST == IS_VAR) {
3981
3982            } else {
3983
3984            }
3985            if (is_empty) {
3986                ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
3987            } else {
3988                CHECK_EXCEPTION();
3989                ZEND_VM_NEXT_OPCODE();
3990            }
3991        }
3992    } else {
3993        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
3994        ZVAL_UNDEF(EX_VAR(opline->result.var));
3995        Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
3996        if (IS_CONST == IS_VAR) {
3997
3998        } else {
3999
4000        }
4001        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
4002    }
4003}
4004
4005static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4006{
4007#if 0 || (IS_CONST != IS_UNUSED)
4008    USE_OPLINE
4009
4010    SAVE_OPLINE();
4011    if (IS_CONST != IS_UNUSED) {
4012
4013        zval *ptr = EX_CONSTANT(opline->op1);
4014
4015        do {
4016            if (Z_TYPE_P(ptr) == IS_LONG) {
4017                EG(exit_status) = Z_LVAL_P(ptr);
4018            } else {
4019                if ((IS_CONST & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
4020                    ptr = Z_REFVAL_P(ptr);
4021                    if (Z_TYPE_P(ptr) == IS_LONG) {
4022                        EG(exit_status) = Z_LVAL_P(ptr);
4023                        break;
4024                    }
4025                }
4026                zend_print_variable(ptr);
4027            }
4028        } while (0);
4029
4030    }
4031#endif
4032    zend_bailout();
4033    ZEND_VM_NEXT_OPCODE(); /* Never reached */
4034}
4035
4036static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4037{
4038    USE_OPLINE
4039
4040    zval *value;
4041    zval *ref = NULL;
4042
4043    SAVE_OPLINE();
4044    value = EX_CONSTANT(opline->op1);
4045
4046    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
4047        if (IS_CONST == IS_VAR) {
4048            ref = value;
4049        }
4050        value = Z_REFVAL_P(value);
4051    }
4052    if (i_zend_is_true(value)) {
4053        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
4054        if (IS_CONST == IS_CONST) {
4055            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
4056                zval_copy_ctor_func(EX_VAR(opline->result.var));
4057            }
4058        } else if (IS_CONST == IS_CV) {
4059            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4060        } else if (IS_CONST == IS_VAR && ref) {
4061            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4062            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4063                efree_size(ref, sizeof(zend_reference));
4064            }
4065        }
4066        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
4067    }
4068
4069    CHECK_EXCEPTION();
4070    ZEND_VM_NEXT_OPCODE();
4071}
4072
4073static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COALESCE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4074{
4075    USE_OPLINE
4076
4077    zval *value;
4078    zval *ref = NULL;
4079
4080    SAVE_OPLINE();
4081    value = EX_CONSTANT(opline->op1);
4082
4083    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
4084        if (IS_CONST == IS_VAR) {
4085            ref = value;
4086        }
4087        value = Z_REFVAL_P(value);
4088    }
4089
4090    if (Z_TYPE_P(value) > IS_NULL) {
4091        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
4092        if (IS_CONST == IS_CONST) {
4093            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
4094                zval_copy_ctor_func(EX_VAR(opline->result.var));
4095            }
4096        } else if (IS_CONST == IS_CV) {
4097            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4098        } else if (IS_CONST == IS_VAR && ref) {
4099            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4100            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4101                efree_size(ref, sizeof(zend_reference));
4102            }
4103        }
4104        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
4105    }
4106
4107    CHECK_EXCEPTION();
4108    ZEND_VM_NEXT_OPCODE();
4109}
4110
4111static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4112{
4113    USE_OPLINE
4114
4115    zval *value;
4116
4117    value = EX_CONSTANT(opline->op1);
4118    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4119        SAVE_OPLINE();
4120        value = GET_OP1_UNDEF_CV(value, BP_VAR_R);
4121        CHECK_EXCEPTION();
4122    }
4123
4124    if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && Z_ISREF_P(value)) {
4125        ZVAL_COPY(EX_VAR(opline->result.var), Z_REFVAL_P(value));
4126        if (IS_CONST == IS_VAR) {
4127            if (UNEXPECTED(Z_DELREF_P(value) == 0)) {
4128                efree_size(Z_REF_P(value), sizeof(zend_reference));
4129            }
4130        }
4131    } else {
4132        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
4133        if (IS_CONST == IS_CONST) {
4134            if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
4135                zval_copy_ctor_func(EX_VAR(opline->result.var));
4136            }
4137        } else if (IS_CONST == IS_CV) {
4138            if (Z_OPT_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4139        }
4140    }
4141    ZEND_VM_NEXT_OPCODE();
4142}
4143
4144static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4145{
4146    USE_OPLINE
4147
4148    zend_generator *generator = zend_get_running_generator(execute_data);
4149
4150    zval *val;
4151
4152
4153    SAVE_OPLINE();
4154    val = EX_CONSTANT(opline->op1);
4155
4156    if (Z_TYPE_P(val) == IS_ARRAY) {
4157        ZVAL_COPY_VALUE(&generator->values, val);
4158        if (IS_CONST != IS_TMP_VAR && Z_OPT_REFCOUNTED_P(val)) {
4159            Z_ADDREF_P(val);
4160        }
4161        Z_FE_POS(generator->values) = 0;
4162
4163    } else if (IS_CONST != IS_CONST && Z_TYPE_P(val) == IS_OBJECT && Z_OBJCE_P(val)->get_iterator) {
4164        zend_class_entry *ce = Z_OBJCE_P(val);
4165        if (ce == zend_ce_generator) {
4166            zend_generator *new_gen = (zend_generator *) Z_OBJ_P(val);
4167
4168            if (IS_CONST != IS_TMP_VAR) {
4169                Z_ADDREF_P(val);
4170            }
4171
4172            if (Z_ISUNDEF(new_gen->retval)) {
4173                if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
4174                    zend_error(E_ERROR | E_EXCEPTION, "Impossible to yield from the Generator being currently run");
4175                    HANDLE_EXCEPTION();
4176                } else {
4177                    zend_generator_yield_from(generator, new_gen);
4178                }
4179            } else if (UNEXPECTED(new_gen->execute_data == NULL)) {
4180                zend_error(E_ERROR | E_EXCEPTION, "Generator passed to yield from was aborted without proper return and is unable to continue");
4181                HANDLE_EXCEPTION();
4182            } else {
4183                if (RETURN_VALUE_USED(opline)) {
4184                    ZVAL_COPY(EX_VAR(opline->result.var), &new_gen->retval);
4185                }
4186                ZEND_VM_NEXT_OPCODE();
4187            }
4188        } else {
4189            zend_object_iterator *iter = ce->get_iterator(ce, val, 0);
4190
4191            if (UNEXPECTED(!iter) || UNEXPECTED(EG(exception))) {
4192                if (!EG(exception)) {
4193                    zend_error(E_ERROR | E_EXCEPTION, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name));
4194                }
4195                HANDLE_EXCEPTION();
4196            }
4197
4198            iter->index = 0;
4199            if (iter->funcs->rewind) {
4200                iter->funcs->rewind(iter);
4201                if (UNEXPECTED(EG(exception) != NULL)) {
4202                    OBJ_RELEASE(&iter->std);
4203                    HANDLE_EXCEPTION();
4204                }
4205            }
4206
4207            ZVAL_OBJ(&generator->values, &iter->std);
4208        }
4209    } else {
4210        zend_error(E_ERROR | E_EXCEPTION, "Can use \"yield from\" only with arrays and Traversables", 0);
4211        HANDLE_EXCEPTION();
4212    }
4213
4214    /* This is the default return value
4215     * when the expression is a Generator, it will be overwritten in zend_generator_resume() */
4216    if (RETURN_VALUE_USED(opline)) {
4217        ZVAL_NULL(EX_VAR(opline->result.var));
4218    }
4219
4220    /* We increment to the next op, so we are at the correct position when the
4221     * generator is resumed. */
4222    ZEND_VM_INC_OPCODE();
4223
4224    /* The GOTO VM uses a local opline variable. We need to set the opline
4225     * variable in execute_data so we don't resume at an old position. */
4226    SAVE_OPLINE();
4227
4228    ZEND_VM_RETURN();
4229}
4230
4231static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4232{
4233    USE_OPLINE
4234    zval *value;
4235
4236
4237    SAVE_OPLINE();
4238    value = EX_CONSTANT(opline->op1);
4239try_strlen:
4240    if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) {
4241        ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value));
4242    } else {
4243        zend_bool strict;
4244
4245        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4246            value = GET_OP1_UNDEF_CV(value, BP_VAR_R);
4247        }
4248        if ((IS_CONST & (IS_VAR|IS_CV)) && Z_TYPE_P(value) == IS_REFERENCE) {
4249            value = Z_REFVAL_P(value);
4250            goto try_strlen;
4251        }
4252        strict = EX_USES_STRICT_TYPES();
4253        do {
4254            if (EXPECTED(!strict)) {
4255                zend_string *str;
4256                zval tmp;
4257
4258                ZVAL_COPY(&tmp, value);
4259                if (zend_parse_arg_str_weak(&tmp, &str)) {
4260                    ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
4261                    zval_ptr_dtor(&tmp);
4262                    break;
4263                }
4264                zval_ptr_dtor(&tmp);
4265            }
4266            zend_internal_type_error(strict, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
4267            ZVAL_NULL(EX_VAR(opline->result.var));
4268        } while (0);
4269    }
4270
4271    CHECK_EXCEPTION();
4272    ZEND_VM_NEXT_OPCODE();
4273}
4274
4275static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4276{
4277    USE_OPLINE
4278    zval *value;
4279    int result = 0;
4280
4281
4282    SAVE_OPLINE();
4283    value = EX_CONSTANT(opline->op1);
4284    if (EXPECTED(Z_TYPE_P(value) == opline->extended_value)) {
4285        if (IS_CONST != IS_CONST && UNEXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
4286            zend_class_entry *ce = Z_OBJCE_P(value);
4287
4288            if (UNEXPECTED(ZSTR_LEN(ce->name) != sizeof("__PHP_Incomplete_Class") - 1) ||
4289                EXPECTED(memcmp(ZSTR_VAL(ce->name), "__PHP_Incomplete_Class", sizeof("__PHP_Incomplete_Class") - 1) != 0)) {
4290                result = 1;
4291            }
4292        } else if (UNEXPECTED(Z_TYPE_P(value) == IS_RESOURCE)) {
4293            const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(value));
4294
4295            if (EXPECTED(type_name != NULL)) {
4296                result = 1;
4297            }
4298        } else {
4299            result = 1;
4300        }
4301    } else if (UNEXPECTED(opline->extended_value == _IS_BOOL) &&
4302               EXPECTED(Z_TYPE_P(value) == IS_TRUE || Z_TYPE_P(value) == IS_FALSE)) {
4303        result = 1;
4304    }
4305
4306    ZEND_VM_SMART_BRANCH(result, 1);
4307    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4308    CHECK_EXCEPTION();
4309    ZEND_VM_NEXT_OPCODE();
4310}
4311
4312static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DEFINED_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4313{
4314    USE_OPLINE
4315    zend_constant *c;
4316    int result;
4317
4318    if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
4319        result = 1;
4320    } else if ((c = zend_quick_get_constant(EX_CONSTANT(opline->op1), 0)) == NULL) {
4321        result = 0;
4322        ZVAL_FALSE(EX_VAR(opline->result.var));
4323    } else {
4324        CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), c);
4325        result = 1;
4326    }
4327    ZEND_VM_SMART_BRANCH(result, 0);
4328    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4329    ZEND_VM_NEXT_OPCODE();
4330}
4331
4332static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4333{
4334    USE_OPLINE
4335
4336    zval *op1, *op2, *result;
4337
4338    op1 = EX_CONSTANT(opline->op1);
4339    op2 = EX_CONSTANT(opline->op2);
4340    if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4341        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4342            result = EX_VAR(opline->result.var);
4343            fast_long_add_function(result, op1, op2);
4344            ZEND_VM_NEXT_OPCODE();
4345        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4346            result = EX_VAR(opline->result.var);
4347            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2));
4348            ZEND_VM_NEXT_OPCODE();
4349        }
4350    } else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
4351        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4352            result = EX_VAR(opline->result.var);
4353            ZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2));
4354            ZEND_VM_NEXT_OPCODE();
4355        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4356            result = EX_VAR(opline->result.var);
4357            ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2)));
4358            ZEND_VM_NEXT_OPCODE();
4359        }
4360    }
4361
4362    SAVE_OPLINE();
4363    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4364        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4365    }
4366    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4367        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4368    }
4369    add_function(EX_VAR(opline->result.var), op1, op2);
4370
4371
4372    CHECK_EXCEPTION();
4373    ZEND_VM_NEXT_OPCODE();
4374}
4375
4376static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SUB_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4377{
4378    USE_OPLINE
4379
4380    zval *op1, *op2, *result;
4381
4382    op1 = EX_CONSTANT(opline->op1);
4383    op2 = EX_CONSTANT(opline->op2);
4384    if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4385        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4386            result = EX_VAR(opline->result.var);
4387            fast_long_sub_function(result, op1, op2);
4388            ZEND_VM_NEXT_OPCODE();
4389        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4390            result = EX_VAR(opline->result.var);
4391            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2));
4392            ZEND_VM_NEXT_OPCODE();
4393        }
4394    } else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
4395        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4396            result = EX_VAR(opline->result.var);
4397            ZVAL_DOUBLE(result, Z_DVAL_P(op1) - Z_DVAL_P(op2));
4398            ZEND_VM_NEXT_OPCODE();
4399        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4400            result = EX_VAR(opline->result.var);
4401            ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2)));
4402            ZEND_VM_NEXT_OPCODE();
4403        }
4404    }
4405
4406    SAVE_OPLINE();
4407    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4408        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4409    }
4410    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4411        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4412    }
4413    sub_function(EX_VAR(opline->result.var), op1, op2);
4414
4415
4416    CHECK_EXCEPTION();
4417    ZEND_VM_NEXT_OPCODE();
4418}
4419
4420static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MUL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4421{
4422    USE_OPLINE
4423
4424    zval *op1, *op2, *result;
4425
4426    op1 = EX_CONSTANT(opline->op1);
4427    op2 = EX_CONSTANT(opline->op2);
4428    if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4429        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4430            zend_long overflow;
4431
4432            result = EX_VAR(opline->result.var);
4433            ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow);
4434            Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG;
4435            ZEND_VM_NEXT_OPCODE();
4436        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4437            result = EX_VAR(opline->result.var);
4438            ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2));
4439            ZEND_VM_NEXT_OPCODE();
4440        }
4441    } else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
4442        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4443            result = EX_VAR(opline->result.var);
4444            ZVAL_DOUBLE(result, Z_DVAL_P(op1) * Z_DVAL_P(op2));
4445            ZEND_VM_NEXT_OPCODE();
4446        } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4447            result = EX_VAR(opline->result.var);
4448            ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2)));
4449            ZEND_VM_NEXT_OPCODE();
4450        }
4451    }
4452
4453    SAVE_OPLINE();
4454    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4455        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4456    }
4457    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4458        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4459    }
4460    mul_function(EX_VAR(opline->result.var), op1, op2);
4461
4462
4463    CHECK_EXCEPTION();
4464    ZEND_VM_NEXT_OPCODE();
4465}
4466
4467static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DIV_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4468{
4469    USE_OPLINE
4470
4471    zval *op1, *op2;
4472
4473    SAVE_OPLINE();
4474    op1 = EX_CONSTANT(opline->op1);
4475    op2 = EX_CONSTANT(opline->op2);
4476    fast_div_function(EX_VAR(opline->result.var), op1, op2);
4477
4478
4479    CHECK_EXCEPTION();
4480    ZEND_VM_NEXT_OPCODE();
4481}
4482
4483static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4484{
4485    USE_OPLINE
4486
4487    zval *op1, *op2, *result;
4488
4489    op1 = EX_CONSTANT(opline->op1);
4490    op2 = EX_CONSTANT(opline->op2);
4491    if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4492        if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4493            result = EX_VAR(opline->result.var);
4494            if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
4495                SAVE_OPLINE();
4496                zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
4497                HANDLE_EXCEPTION();
4498            } else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
4499                /* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
4500                ZVAL_LONG(result, 0);
4501            } else {
4502                ZVAL_LONG(result, Z_LVAL_P(op1) % Z_LVAL_P(op2));
4503            }
4504            ZEND_VM_NEXT_OPCODE();
4505        }
4506    }
4507
4508    SAVE_OPLINE();
4509    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4510        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4511    }
4512    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4513        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4514    }
4515    mod_function(EX_VAR(opline->result.var), op1, op2);
4516
4517
4518    CHECK_EXCEPTION();
4519    ZEND_VM_NEXT_OPCODE();
4520}
4521
4522static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4523{
4524    USE_OPLINE
4525
4526    zval *op1, *op2;
4527
4528    SAVE_OPLINE();
4529    op1 = EX_CONSTANT(opline->op1);
4530    op2 = EX_CONSTANT(opline->op2);
4531    shift_left_function(EX_VAR(opline->result.var), op1, op2);
4532
4533
4534    CHECK_EXCEPTION();
4535    ZEND_VM_NEXT_OPCODE();
4536}
4537
4538static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4539{
4540    USE_OPLINE
4541
4542    zval *op1, *op2;
4543
4544    SAVE_OPLINE();
4545    op1 = EX_CONSTANT(opline->op1);
4546    op2 = EX_CONSTANT(opline->op2);
4547    shift_right_function(EX_VAR(opline->result.var), op1, op2);
4548
4549
4550    CHECK_EXCEPTION();
4551    ZEND_VM_NEXT_OPCODE();
4552}
4553
4554static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CONCAT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4555{
4556    USE_OPLINE
4557
4558    zval *op1, *op2;
4559
4560    SAVE_OPLINE();
4561    op1 = EX_CONSTANT(opline->op1);
4562    op2 = EX_CONSTANT(opline->op2);
4563
4564    do {
4565        if ((IS_CONST == IS_CONST || EXPECTED(Z_TYPE_P(op1) == IS_STRING)) &&
4566            (IS_CONST == IS_CONST || EXPECTED(Z_TYPE_P(op2) == IS_STRING))) {
4567            zend_string *op1_str = Z_STR_P(op1);
4568            zend_string *op2_str = Z_STR_P(op2);
4569            zend_string *str;
4570
4571            if (IS_CONST != IS_CONST) {
4572                if (UNEXPECTED(ZSTR_LEN(op1_str) == 0)) {
4573                    ZVAL_STR_COPY(EX_VAR(opline->result.var), op2_str);
4574
4575                    break;
4576                }
4577            }
4578            if (IS_CONST != IS_CONST) {
4579                if (UNEXPECTED(ZSTR_LEN(op2_str) == 0)) {
4580                    ZVAL_STR_COPY(EX_VAR(opline->result.var), op1_str);
4581
4582                    break;
4583                }
4584            }
4585            if (IS_CONST != IS_CONST && IS_CONST != IS_CV &&
4586                !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
4587                size_t len = ZSTR_LEN(op1_str);
4588
4589                str = zend_string_realloc(op1_str, len + ZSTR_LEN(op2_str), 0);
4590                memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
4591                ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
4592                break;
4593            } else {
4594                str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
4595                memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
4596                memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
4597                ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
4598            }
4599        } else {
4600            if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
4601                op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4602            }
4603            if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
4604                op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4605            }
4606            concat_function(EX_VAR(opline->result.var), op1, op2);
4607        }
4608
4609    } while (0);
4610
4611    CHECK_EXCEPTION();
4612    ZEND_VM_NEXT_OPCODE();
4613}
4614
4615static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_IDENTICAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4616{
4617    USE_OPLINE
4618
4619    zval *op1, *op2;
4620    int result;
4621
4622    SAVE_OPLINE();
4623    op1 = EX_CONSTANT(opline->op1);
4624    op2 = EX_CONSTANT(opline->op2);
4625    result = fast_is_identical_function(op1, op2);
4626
4627
4628    ZEND_VM_SMART_BRANCH(result, (IS_CONST|IS_CONST) & (IS_VAR|IS_TMP_VAR));
4629    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4630    if ((IS_CONST|IS_CONST) & (IS_VAR|IS_TMP_VAR)) {
4631        CHECK_EXCEPTION();
4632    }
4633    ZEND_VM_NEXT_OPCODE();
4634}
4635
4636static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4637{
4638    USE_OPLINE
4639
4640    zval *op1, *op2;
4641    int result;
4642
4643    SAVE_OPLINE();
4644    op1 = EX_CONSTANT(opline->op1);
4645    op2 = EX_CONSTANT(opline->op2);
4646    result = fast_is_not_identical_function(op1, op2);
4647
4648
4649    ZEND_VM_SMART_BRANCH(result, (IS_CONST|IS_CONST) & (IS_VAR|IS_TMP_VAR));
4650    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4651    if ((IS_CONST|IS_CONST) & (IS_VAR|IS_TMP_VAR)) {
4652        CHECK_EXCEPTION();
4653    }
4654    ZEND_VM_NEXT_OPCODE();
4655}
4656
4657static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4658{
4659    USE_OPLINE
4660
4661    zval *op1, *op2, *result;
4662
4663    op1 = EX_CONSTANT(opline->op1);
4664    op2 = EX_CONSTANT(opline->op2);
4665    do {
4666        int result;
4667
4668        if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
4669            if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4670                result = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
4671            } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4672                result = ((double)Z_LVAL_P(op1) == Z_DVAL_P(op2));
4673            } else {
4674                break;
4675            }
4676        } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
4677            if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4678                result = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
4679            } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4680                result = (Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)));
4681            } else {
4682                break;
4683            }
4684        } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
4685            if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
4686                if (Z_STR_P(op1) == Z_STR_P(op2)) {
4687                    result = 1;
4688                } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
4689                    if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
4690                        result = 0;
4691                    } else {
4692                        result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0);
4693                    }
4694                } else {
4695                    result = (zendi_smart_strcmp(op1, op2) == 0);
4696                }
4697
4698
4699            } else {
4700                break;
4701            }
4702        } else {
4703            break;
4704        }
4705        ZEND_VM_SMART_BRANCH(result, 0);
4706        ZVAL_BOOL(EX_VAR(opline->result.var), result);
4707        ZEND_VM_NEXT_OPCODE();
4708    } while (0);
4709
4710    SAVE_OPLINE();
4711    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
4712        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4713    }
4714    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
4715        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4716    }
4717    result = EX_VAR(opline->result.var);
4718    compare_function(result, op1, op2);
4719    ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
4720
4721
4722    CHECK_EXCEPTION();
4723    ZEND_VM_NEXT_OPCODE();
4724}
4725
4726static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4727{
4728    USE_OPLINE
4729
4730    zval *op1, *op2, *result;
4731
4732    op1 = EX_CONSTANT(opline->op1);
4733    op2 = EX_CONSTANT(opline->op2);
4734    do {
4735        int result;
4736
4737        if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
4738            if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4739                result = (Z_LVAL_P(op1) != Z_LVAL_P(op2));
4740            } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4741                result = ((double)Z_LVAL_P(op1) != Z_DVAL_P(op2));
4742            } else {
4743                break;
4744            }
4745        } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
4746            if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4747                result = (Z_DVAL_P(op1) != Z_DVAL_P(op2));
4748            } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4749                result = (Z_DVAL_P(op1) != ((double)Z_LVAL_P(op2)));
4750            } else {
4751                break;
4752            }
4753        } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
4754            if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
4755                if (Z_STR_P(op1) == Z_STR_P(op2)) {
4756                    result = 0;
4757                } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
4758                    if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
4759                        result = 1;
4760                    } else {
4761                        result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) != 0);
4762                    }
4763                } else {
4764                    result = (zendi_smart_strcmp(op1, op2) != 0);
4765                }
4766
4767
4768            } else {
4769                break;
4770            }
4771        } else {
4772            break;
4773        }
4774        ZEND_VM_SMART_BRANCH(result, 0);
4775        ZVAL_BOOL(EX_VAR(opline->result.var), result);
4776        ZEND_VM_NEXT_OPCODE();
4777    } while (0);
4778
4779    SAVE_OPLINE();
4780    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
4781        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4782    }
4783    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
4784        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4785    }
4786    result = EX_VAR(opline->result.var);
4787    compare_function(result, op1, op2);
4788    ZVAL_BOOL(result, Z_LVAL_P(result) != 0);
4789
4790
4791    CHECK_EXCEPTION();
4792    ZEND_VM_NEXT_OPCODE();
4793}
4794
4795static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4796{
4797    USE_OPLINE
4798
4799    zval *op1, *op2, *result;
4800
4801    op1 = EX_CONSTANT(opline->op1);
4802    op2 = EX_CONSTANT(opline->op2);
4803    do {
4804        int result;
4805
4806        if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4807            if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4808                result = (Z_LVAL_P(op1) < Z_LVAL_P(op2));
4809            } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4810                result = ((double)Z_LVAL_P(op1) < Z_DVAL_P(op2));
4811            } else {
4812                break;
4813            }
4814        } else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
4815            if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4816                result = (Z_DVAL_P(op1) < Z_DVAL_P(op2));
4817            } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4818                result = (Z_DVAL_P(op1) < ((double)Z_LVAL_P(op2)));
4819            } else {
4820                break;
4821            }
4822        } else {
4823            break;
4824        }
4825        ZEND_VM_SMART_BRANCH(result, 0);
4826        ZVAL_BOOL(EX_VAR(opline->result.var), result);
4827        ZEND_VM_NEXT_OPCODE();
4828    } while (0);
4829
4830    SAVE_OPLINE();
4831    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4832        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4833    }
4834    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4835        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4836    }
4837    result = EX_VAR(opline->result.var);
4838    compare_function(result, op1, op2);
4839    ZVAL_BOOL(result, Z_LVAL_P(result) < 0);
4840
4841
4842    CHECK_EXCEPTION();
4843    ZEND_VM_NEXT_OPCODE();
4844}
4845
4846static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4847{
4848    USE_OPLINE
4849
4850    zval *op1, *op2, *result;
4851
4852    op1 = EX_CONSTANT(opline->op1);
4853    op2 = EX_CONSTANT(opline->op2);
4854    do {
4855        int result;
4856
4857        if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
4858            if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4859                result = (Z_LVAL_P(op1) <= Z_LVAL_P(op2));
4860            } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4861                result = ((double)Z_LVAL_P(op1) <= Z_DVAL_P(op2));
4862            } else {
4863                break;
4864            }
4865        } else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
4866            if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
4867                result = (Z_DVAL_P(op1) <= Z_DVAL_P(op2));
4868            } else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
4869                result = (Z_DVAL_P(op1) <= ((double)Z_LVAL_P(op2)));
4870            } else {
4871                break;
4872            }
4873        } else {
4874            break;
4875        }
4876        ZEND_VM_SMART_BRANCH(result, 0);
4877        ZVAL_BOOL(EX_VAR(opline->result.var), result);
4878        ZEND_VM_NEXT_OPCODE();
4879    } while (0);
4880
4881    SAVE_OPLINE();
4882    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
4883        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4884    }
4885    if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
4886        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4887    }
4888    result = EX_VAR(opline->result.var);
4889    compare_function(result, op1, op2);
4890    ZVAL_BOOL(result, Z_LVAL_P(result) <= 0);
4891
4892
4893    CHECK_EXCEPTION();
4894    ZEND_VM_NEXT_OPCODE();
4895}
4896
4897static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SPACESHIP_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4898{
4899    USE_OPLINE
4900
4901    zval *op1, *op2;
4902
4903    SAVE_OPLINE();
4904    op1 = EX_CONSTANT(opline->op1);
4905    op2 = EX_CONSTANT(opline->op2);
4906    compare_function(EX_VAR(opline->result.var), op1, op2);
4907
4908
4909    CHECK_EXCEPTION();
4910    ZEND_VM_NEXT_OPCODE();
4911}
4912
4913static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BW_OR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4914{
4915    USE_OPLINE
4916
4917    zval *op1, *op2;
4918
4919    SAVE_OPLINE();
4920    op1 = EX_CONSTANT(opline->op1);
4921    op2 = EX_CONSTANT(opline->op2);
4922    bitwise_or_function(EX_VAR(opline->result.var), op1, op2);
4923
4924
4925    CHECK_EXCEPTION();
4926    ZEND_VM_NEXT_OPCODE();
4927}
4928
4929static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BW_AND_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4930{
4931    USE_OPLINE
4932
4933    zval *op1, *op2;
4934
4935    SAVE_OPLINE();
4936    op1 = EX_CONSTANT(opline->op1);
4937    op2 = EX_CONSTANT(opline->op2);
4938    bitwise_and_function(EX_VAR(opline->result.var), op1, op2);
4939
4940
4941    CHECK_EXCEPTION();
4942    ZEND_VM_NEXT_OPCODE();
4943}
4944
4945static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BW_XOR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4946{
4947    USE_OPLINE
4948
4949    zval *op1, *op2;
4950
4951    SAVE_OPLINE();
4952    op1 = EX_CONSTANT(opline->op1);
4953    op2 = EX_CONSTANT(opline->op2);
4954    bitwise_xor_function(EX_VAR(opline->result.var), op1, op2);
4955
4956
4957    CHECK_EXCEPTION();
4958    ZEND_VM_NEXT_OPCODE();
4959}
4960
4961static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BOOL_XOR_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
4962{
4963    USE_OPLINE
4964
4965    zval *op1, *op2;
4966
4967    SAVE_OPLINE();
4968    op1 = EX_CONSTANT(opline->op1);
4969    op2 = EX_CONSTANT(opline->op2);
4970    boolean_xor_function(EX_VAR(opline->result.var), op1, op2);
4971
4972
4973    CHECK_EXCEPTION();
4974    ZEND_VM_NEXT_OPCODE();
4975}
4976
4977static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type ZEND_OPCODE_HANDLER_ARGS_DC)
4978{
4979    USE_OPLINE
4980
4981    zval *varname;
4982    zval *retval;
4983    zend_string *name;
4984    HashTable *target_symbol_table;
4985
4986    SAVE_OPLINE();
4987    varname = EX_CONSTANT(opline->op1);
4988
4989    if (IS_CONST == IS_CONST) {
4990        name = Z_STR_P(varname);
4991    } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
4992        name = Z_STR_P(varname);
4993        zend_string_addref(name);
4994    } else {
4995        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
4996            GET_OP1_UNDEF_CV(varname, BP_VAR_R);
4997        }
4998        name = zval_get_string(varname);
4999    }
5000
5001    if (IS_CONST != IS_UNUSED) {
5002        zend_class_entry *ce;
5003
5004        if (IS_CONST == IS_CONST) {
5005            if (IS_CONST == IS_CONST && CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
5006
5007                ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
5008                retval = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)) + sizeof(void*));
5009
5010                /* check if static properties were destoyed */
5011                if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
5012                    zend_error(E_EXCEPTION | E_ERROR, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
5013
5014                    HANDLE_EXCEPTION();
5015                }
5016
5017                goto fetch_var_return;
5018            } else if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
5019                ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5020            } else {
5021                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);
5022                if (UNEXPECTED(ce == NULL)) {
5023                    if (IS_CONST != IS_CONST) {
5024                        zend_string_release(name);
5025                    }
5026
5027                    CHECK_EXCEPTION();
5028                    ZEND_VM_NEXT_OPCODE();
5029                }
5030                CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce);
5031            }
5032        } else {
5033            ce = Z_CE_P(EX_VAR(opline->op2.var));
5034            if (IS_CONST == IS_CONST &&
5035                (retval = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce)) != NULL) {
5036
5037                /* check if static properties were destoyed */
5038                if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
5039                    zend_error(E_EXCEPTION | E_ERROR, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
5040
5041                    HANDLE_EXCEPTION();
5042                }
5043
5044                goto fetch_var_return;
5045            }
5046        }
5047        retval = zend_std_get_static_property(ce, name, 0);
5048        if (UNEXPECTED(EG(exception))) {
5049
5050            HANDLE_EXCEPTION();
5051        }
5052        if (IS_CONST == IS_CONST && retval) {
5053            CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce, retval);
5054        }
5055
5056    } else {
5057        target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK);
5058        retval = zend_hash_find(target_symbol_table, name);
5059        if (retval == NULL) {
5060            switch (type) {
5061                case BP_VAR_R:
5062                case BP_VAR_UNSET:
5063                    zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name));
5064                    /* break missing intentionally */
5065                case BP_VAR_IS:
5066                    retval = &EG(uninitialized_zval);
5067                    break;