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