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