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