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