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