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