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