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