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