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