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