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