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