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