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