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