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        FREE_OP1();
1914        ZVAL_TRUE(EX_VAR(opline->result.var));
1915        opline++;
1916    } else {
1917        FREE_OP1();
1918        ZVAL_FALSE(EX_VAR(opline->result.var));
1919        opline = opline->op2.jmp_addr;
1920    }
1921    if (UNEXPECTED(EG(exception) != NULL)) {
1922        HANDLE_EXCEPTION();
1923    }
1924    ZEND_VM_JMP(opline);
1925}
1926
1927ZEND_VM_HANDLER(47, ZEND_JMPNZ_EX, CONST|TMP|VAR|CV, ANY)
1928{
1929    USE_OPLINE
1930    zend_free_op free_op1;
1931    zval *val;
1932
1933    SAVE_OPLINE();
1934    val = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
1935
1936    if (OP1_TYPE == IS_TMP_VAR) {
1937        if (Z_TYPE_P(val) == IS_TRUE) {
1938            ZVAL_TRUE(EX_VAR(opline->result.var));
1939            ZEND_VM_SET_OPCODE(opline->op2.jmp_addr);
1940            ZEND_VM_CONTINUE();
1941        } else if (EXPECTED(Z_TYPE_P(val) <= IS_TRUE)) {
1942            ZVAL_FALSE(EX_VAR(opline->result.var));
1943            ZEND_VM_SET_OPCODE(opline + 1);
1944            ZEND_VM_CONTINUE();
1945        }
1946    }
1947    if (i_zend_is_true(val TSRMLS_CC)) {
1948        ZVAL_TRUE(EX_VAR(opline->result.var));
1949        opline = opline->op2.jmp_addr;
1950    } else {
1951        ZVAL_FALSE(EX_VAR(opline->result.var));
1952        opline++;
1953    }
1954    FREE_OP1();
1955    if (UNEXPECTED(EG(exception) != NULL)) {
1956        HANDLE_EXCEPTION();
1957    }
1958    ZEND_VM_JMP(opline);
1959}
1960
1961ZEND_VM_HANDLER(70, ZEND_FREE, TMP|VAR, ANY)
1962{
1963    USE_OPLINE
1964
1965    SAVE_OPLINE();
1966    zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
1967    CHECK_EXCEPTION();
1968    ZEND_VM_NEXT_OPCODE();
1969}
1970
1971ZEND_VM_HANDLER(54, ZEND_ADD_CHAR, TMP|UNUSED, CONST)
1972{
1973    USE_OPLINE
1974    zval *str = EX_VAR(opline->result.var);
1975
1976    SAVE_OPLINE();
1977
1978    if (OP1_TYPE == IS_UNUSED) {
1979        /* Initialize for erealloc in add_char_to_string */
1980        ZVAL_EMPTY_STRING(str);
1981    }
1982
1983    add_char_to_string(str, str, opline->op2.zv);
1984
1985    /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */
1986    /*CHECK_EXCEPTION();*/
1987    ZEND_VM_NEXT_OPCODE();
1988}
1989
1990ZEND_VM_HANDLER(55, ZEND_ADD_STRING, TMP|UNUSED, CONST)
1991{
1992    USE_OPLINE
1993    zval *str = EX_VAR(opline->result.var);
1994
1995    SAVE_OPLINE();
1996
1997    if (OP1_TYPE == IS_UNUSED) {
1998        /* Initialize for erealloc in add_string_to_string */
1999        ZVAL_EMPTY_STRING(str);
2000    }
2001
2002    add_string_to_string(str, str, opline->op2.zv);
2003
2004    /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */
2005    /*CHECK_EXCEPTION();*/
2006    ZEND_VM_NEXT_OPCODE();
2007}
2008
2009ZEND_VM_HANDLER(56, ZEND_ADD_VAR, TMP|UNUSED, TMP|VAR|CV)
2010{
2011    USE_OPLINE
2012    zend_free_op free_op2;
2013    zval *str = EX_VAR(opline->result.var);
2014    zval *var;
2015    zval var_copy;
2016    int use_copy = 0;
2017
2018    SAVE_OPLINE();
2019    var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2020
2021    if (OP1_TYPE == IS_UNUSED) {
2022        /* Initialize for erealloc in add_string_to_string */
2023        ZVAL_EMPTY_STRING(str);
2024    }
2025
2026    if (Z_TYPE_P(var) != IS_STRING) {
2027        ZVAL_DEREF(var);
2028        if (Z_TYPE_P(var) != IS_STRING) {
2029            use_copy = zend_make_printable_zval(var, &var_copy TSRMLS_CC);
2030
2031            if (use_copy) {
2032                var = &var_copy;
2033            }
2034        }
2035    }
2036    add_string_to_string(str, str, var);
2037
2038    if (use_copy) {
2039        zval_dtor(var);
2040    }
2041    /* original comment, possibly problematic:
2042     * FREE_OP is missing intentionally here - we're always working on the same temporary variable
2043     * (Zeev):  I don't think it's problematic, we only use variables
2044     * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're
2045     * string offsets or overloaded objects
2046     */
2047    FREE_OP2();
2048
2049    CHECK_EXCEPTION();
2050    ZEND_VM_NEXT_OPCODE();
2051}
2052
2053ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMP|VAR|UNUSED|CV)
2054{
2055    USE_OPLINE
2056
2057    SAVE_OPLINE();
2058    if (EG(exception)) {
2059        zend_exception_save(TSRMLS_C);
2060    }
2061    if (OP2_TYPE == IS_UNUSED) {
2062        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value TSRMLS_CC);
2063        CHECK_EXCEPTION();
2064        ZEND_VM_NEXT_OPCODE();
2065    } else {
2066        zend_free_op free_op2;
2067        zval *class_name = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
2068
2069        if (OP2_TYPE == IS_CONST) {
2070            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2071                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2072            } else {
2073                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);
2074                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2075            }
2076        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2077            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2078        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2079            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value TSRMLS_CC);
2080        } else {
2081            if (UNEXPECTED(EG(exception) != NULL)) {
2082                HANDLE_EXCEPTION();
2083            }
2084            zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string");
2085        }
2086
2087        FREE_OP2();
2088        CHECK_EXCEPTION();
2089        ZEND_VM_NEXT_OPCODE();
2090    }
2091}
2092
2093ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
2094{
2095    USE_OPLINE
2096    zval *function_name;
2097    zend_free_op free_op1, free_op2;
2098    zval *object;
2099    zend_function *fbc;
2100    zend_class_entry *called_scope;
2101    zend_object *obj;
2102
2103    SAVE_OPLINE();
2104
2105    function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
2106
2107    if (OP2_TYPE != IS_CONST &&
2108        UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
2109        if (UNEXPECTED(EG(exception) != NULL)) {
2110            HANDLE_EXCEPTION();
2111        }
2112        zend_error_noreturn(E_ERROR, "Method name must be a string");
2113    }
2114
2115    object = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_R);
2116
2117    if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
2118        uint32_t nesting = 1;
2119
2120        if (UNEXPECTED(EG(exception) != NULL)) {
2121            FREE_OP2();
2122            HANDLE_EXCEPTION();
2123        }
2124
2125        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)));
2126        FREE_OP2();
2127        FREE_OP1_IF_VAR();
2128
2129        if (EG(exception) != NULL) {
2130            HANDLE_EXCEPTION();
2131        }
2132
2133        /* No exception raised: Skip over arguments until fcall opcode with correct
2134         * nesting level. Return NULL (except when return value unused) */
2135        do {
2136            opline++;
2137            if (opline->opcode == ZEND_INIT_FCALL ||
2138                opline->opcode == ZEND_INIT_FCALL_BY_NAME ||
2139                opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME ||
2140                opline->opcode == ZEND_INIT_METHOD_CALL ||
2141                opline->opcode == ZEND_INIT_STATIC_METHOD_CALL ||
2142                opline->opcode == ZEND_INIT_USER_CALL ||
2143                opline->opcode == ZEND_NEW
2144            ) {
2145                nesting++;
2146            } else if (opline->opcode == ZEND_DO_FCALL) {
2147                nesting--;
2148            }
2149        } while (nesting);
2150
2151        if (RETURN_VALUE_USED(opline)) {
2152            ZVAL_NULL(EX_VAR(opline->result.var));
2153        }
2154
2155        /* We've skipped EXT_FCALL_BEGIND, so also skip the ending opcode */
2156        if ((opline + 1)->opcode == ZEND_EXT_FCALL_END) {
2157            opline++;
2158        }
2159        ZEND_VM_JMP(++opline);
2160    }
2161
2162    obj = Z_OBJ_P(object);
2163    called_scope = obj->ce;
2164
2165    if (OP2_TYPE != IS_CONST ||
2166        EXPECTED((fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope)) == NULL)) {
2167        zend_object *orig_obj = obj;
2168
2169        if (UNEXPECTED(obj->handlers->get_method == NULL)) {
2170            zend_error_noreturn(E_ERROR, "Object does not support method calls");
2171        }
2172
2173        /* First, locate the function. */
2174        fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (opline->op2.zv + 1) : NULL) TSRMLS_CC);
2175        if (UNEXPECTED(fbc == NULL)) {
2176            zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", obj->ce->name->val, Z_STRVAL_P(function_name));
2177        }
2178        if (OP2_TYPE == IS_CONST &&
2179            EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
2180            EXPECTED((fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) &&
2181            EXPECTED(obj == orig_obj)) {
2182            CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope, fbc);
2183        }
2184    }
2185
2186    if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) {
2187        obj = NULL;
2188    } else {
2189        GC_REFCOUNT(obj)++; /* For $this pointer */
2190    }
2191
2192    EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2193        fbc, opline->extended_value, called_scope, obj, EX(call) TSRMLS_CC);
2194
2195    FREE_OP2();
2196    FREE_OP1_IF_VAR();
2197
2198    CHECK_EXCEPTION();
2199    ZEND_VM_NEXT_OPCODE();
2200}
2201
2202ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUSED|CV)
2203{
2204    USE_OPLINE
2205    zval *function_name;
2206    zend_class_entry *ce;
2207    zend_object *object;
2208    zend_function *fbc;
2209
2210    SAVE_OPLINE();
2211
2212    if (OP1_TYPE == IS_CONST) {
2213        /* no function found. try a static method in class */
2214        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
2215            ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
2216        } else {
2217            ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
2218            if (UNEXPECTED(EG(exception) != NULL)) {
2219                HANDLE_EXCEPTION();
2220            }
2221            if (UNEXPECTED(ce == NULL)) {
2222                zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
2223            }
2224            CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
2225        }
2226    } else {
2227        ce = Z_CE_P(EX_VAR(opline->op1.var));
2228    }
2229
2230    if (OP1_TYPE == IS_CONST &&
2231        OP2_TYPE == IS_CONST &&
2232        CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
2233        fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
2234    } else if (OP1_TYPE != IS_CONST &&
2235               OP2_TYPE == IS_CONST &&
2236               (fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce))) {
2237        /* do nothing */
2238    } else if (OP2_TYPE != IS_UNUSED) {
2239        zend_free_op free_op2;
2240
2241        function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
2242        if (OP2_TYPE != IS_CONST) {
2243            if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
2244                if (UNEXPECTED(EG(exception) != NULL)) {
2245                    HANDLE_EXCEPTION();
2246                }
2247                zend_error_noreturn(E_ERROR, "Function name must be a string");
2248            }
2249        }
2250
2251        if (ce->get_static_method) {
2252            fbc = ce->get_static_method(ce, Z_STR_P(function_name) TSRMLS_CC);
2253        } else {
2254            fbc = zend_std_get_static_method(ce, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (opline->op2.zv + 1) : NULL) TSRMLS_CC);
2255        }
2256        if (UNEXPECTED(fbc == NULL)) {
2257            zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", ce->name->val, Z_STRVAL_P(function_name));
2258        }
2259        if (OP2_TYPE == IS_CONST &&
2260            EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
2261            EXPECTED((fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0)) {
2262            if (OP1_TYPE == IS_CONST) {
2263                CACHE_PTR(Z_CACHE_SLOT_P(function_name), fbc);
2264            } else {
2265                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), ce, fbc);
2266            }
2267        }
2268        if (OP2_TYPE != IS_CONST) {
2269            FREE_OP2();
2270        }
2271    } else {
2272        if (UNEXPECTED(ce->constructor == NULL)) {
2273            zend_error_noreturn(E_ERROR, "Cannot call constructor");
2274        }
2275        if (Z_OBJ(EX(This)) && Z_OBJ(EX(This))->ce != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
2276            zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val);
2277        }
2278        fbc = ce->constructor;
2279    }
2280
2281    object = NULL;
2282    if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2283        if (Z_OBJ(EX(This))) {
2284            object = Z_OBJ(EX(This));
2285            GC_REFCOUNT(object)++;
2286        }
2287        if (!object ||
2288            !instanceof_function(object->ce, ce TSRMLS_CC)) {
2289            /* We are calling method of the other (incompatible) class,
2290               but passing $this. This is done for compatibility with php-4. */
2291            if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2292                zend_error(
2293                    object ? E_DEPRECATED : E_STRICT,
2294                    "Non-static method %s::%s() should not be called statically%s",
2295                    fbc->common.scope->name->val, fbc->common.function_name->val,
2296                    object ? ", assuming $this from incompatible context" : "");
2297            } else {
2298                /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
2299                zend_error_noreturn(
2300                    E_ERROR,
2301                    "Non-static method %s::%s() cannot be called statically%s",
2302                    fbc->common.scope->name->val, fbc->common.function_name->val,
2303                    object ? ", assuming $this from incompatible context" : "");
2304            }
2305        }
2306    }
2307
2308    if (OP1_TYPE != IS_CONST) {
2309        /* previous opcode is ZEND_FETCH_CLASS */
2310        if ((opline-1)->extended_value == ZEND_FETCH_CLASS_PARENT || (opline-1)->extended_value == ZEND_FETCH_CLASS_SELF) {
2311            ce = EX(called_scope);
2312        }
2313    }
2314
2315    EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2316        fbc, opline->extended_value, ce, object, EX(call) TSRMLS_CC);
2317
2318    if (OP2_TYPE == IS_UNUSED) {
2319        EX(call)->return_value = NULL;
2320    }
2321
2322    CHECK_EXCEPTION();
2323    ZEND_VM_NEXT_OPCODE();
2324}
2325
2326ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
2327{
2328    USE_OPLINE
2329    zend_function *fbc;
2330    zval *function_name, *func;
2331
2332    if (OP2_TYPE == IS_CONST && Z_TYPE_P(opline->op2.zv) == IS_STRING) {
2333        function_name = (zval*)(opline->op2.zv+1);
2334        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
2335            fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
2336        } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
2337            SAVE_OPLINE();
2338            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
2339        } else {
2340            fbc = Z_FUNC_P(func);
2341            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
2342        }
2343
2344        EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2345            fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
2346
2347        /*CHECK_EXCEPTION();*/
2348        ZEND_VM_NEXT_OPCODE();
2349    } else {
2350        zend_string *lcname;
2351        zend_free_op free_op2;
2352        zend_class_entry *called_scope;
2353        zend_object *object;
2354        zval *function_name_ptr;
2355
2356        SAVE_OPLINE();
2357        function_name_ptr = function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
2358
2359        ZVAL_DEREF(function_name);
2360        if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2361            if (Z_STRVAL_P(function_name)[0] == '\\') {
2362                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
2363                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
2364            } else {
2365                lcname = zend_string_alloc(Z_STRLEN_P(function_name), 0);
2366                zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name));
2367            }
2368            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
2369                zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name));
2370            }
2371            zend_string_free(lcname);
2372            FREE_OP2();
2373
2374            fbc = Z_FUNC_P(func);
2375            called_scope = NULL;
2376            object = NULL;
2377        } else if (OP2_TYPE != IS_CONST &&
2378            EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
2379            Z_OBJ_HANDLER_P(function_name, get_closure) &&
2380            Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object TSRMLS_CC) == SUCCESS) {
2381            if (object) {
2382                GC_REFCOUNT(object)++;
2383            }
2384            if (OP2_TYPE == IS_VAR && OP2_FREE && Z_REFCOUNT_P(function_name) == 1 &&
2385                fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
2386                /* Delay closure destruction until its invocation */
2387                fbc->common.prototype = (zend_function*)Z_OBJ_P(function_name_ptr);
2388            } else if (OP2_TYPE == IS_CV) {
2389                FREE_OP2();
2390            }
2391        } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
2392                zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
2393            zval *obj;
2394            zval *method;
2395
2396            obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
2397            method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
2398
2399            if (!obj || !method) {
2400                zend_error_noreturn(E_ERROR, "Array callback has to contain indices 0 and 1");
2401            }
2402
2403            ZVAL_DEREF(obj);
2404            if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
2405                zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
2406            }
2407
2408            ZVAL_DEREF(method);
2409            if (Z_TYPE_P(method) != IS_STRING) {
2410                zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
2411            }
2412
2413            if (Z_TYPE_P(obj) == IS_STRING) {
2414                object = NULL;
2415                called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC);
2416                if (UNEXPECTED(called_scope == NULL)) {
2417                    CHECK_EXCEPTION();
2418                    ZEND_VM_NEXT_OPCODE();
2419                }
2420
2421                if (called_scope->get_static_method) {
2422                    fbc = called_scope->get_static_method(called_scope, Z_STR_P(method) TSRMLS_CC);
2423                } else {
2424                    fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL TSRMLS_CC);
2425                }
2426                if (UNEXPECTED(fbc == NULL)) {
2427                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
2428                }
2429                if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
2430                    if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2431                        zend_error(E_STRICT,
2432                        "Non-static method %s::%s() should not be called statically",
2433                        fbc->common.scope->name->val, fbc->common.function_name->val);
2434                    } else {
2435                        zend_error_noreturn(
2436                            E_ERROR,
2437                            "Non-static method %s::%s() cannot be called statically",
2438                            fbc->common.scope->name->val, fbc->common.function_name->val);
2439                    }
2440                }
2441            } else {
2442                called_scope = Z_OBJCE_P(obj);
2443                object = Z_OBJ_P(obj);
2444
2445                fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL TSRMLS_CC);
2446                if (UNEXPECTED(fbc == NULL)) {
2447                    zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", object->ce->name->val, Z_STRVAL_P(method));
2448                }
2449
2450                if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
2451                    object = NULL;
2452                } else {
2453                    GC_REFCOUNT(object)++; /* For $this pointer */
2454                }
2455            }
2456            FREE_OP2();
2457        } else {
2458            if (UNEXPECTED(EG(exception) != NULL)) {
2459                HANDLE_EXCEPTION();
2460            }
2461            zend_error_noreturn(E_ERROR, "Function name must be a string");
2462            ZEND_VM_CONTINUE(); /* Never reached */
2463        }
2464        EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2465            fbc, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC);
2466
2467        CHECK_EXCEPTION();
2468        ZEND_VM_NEXT_OPCODE();
2469    }
2470}
2471
2472ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMP|VAR|CV)
2473{
2474    USE_OPLINE
2475    zend_free_op free_op2;
2476    zval *function_name = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
2477    zend_fcall_info_cache fcc;
2478    char *error = NULL;
2479    zend_function *func;
2480    zend_class_entry *called_scope;
2481    zend_object *object;
2482
2483    if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error TSRMLS_CC)) {
2484        if (error) {
2485            efree(error);
2486        }
2487        func = fcc.function_handler;
2488        if (func->common.fn_flags & ZEND_ACC_CLOSURE) {
2489            /* Delay closure destruction until its invocation */
2490            func->common.prototype = (zend_function*)Z_OBJ_P(function_name);
2491            Z_ADDREF_P(function_name);
2492        }
2493        called_scope = fcc.called_scope;
2494        object = fcc.object;
2495        if (object) {
2496            GC_REFCOUNT(object)++; /* For $this pointer */
2497        } else if (func->common.scope &&
2498                   !(func->common.fn_flags & ZEND_ACC_STATIC)) {
2499            if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
2500                zend_error(E_STRICT,
2501                "Non-static method %s::%s() should not be called statically",
2502                func->common.scope->name->val, func->common.function_name->val);
2503            } else {
2504                zend_error_noreturn(
2505                    E_ERROR,
2506                    "Non-static method %s::%s() cannot be called statically",
2507                    func->common.scope->name->val, func->common.function_name->val);
2508            }
2509        }
2510    } else {
2511        zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
2512        efree(error);
2513        func = (zend_function*)&zend_pass_function;
2514        called_scope = NULL;
2515        object = NULL;
2516    }
2517
2518    EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2519        func, opline->extended_value, called_scope, object, EX(call) TSRMLS_CC);
2520
2521    FREE_OP2();
2522    CHECK_EXCEPTION();
2523    ZEND_VM_NEXT_OPCODE();
2524}
2525
2526ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST)
2527{
2528    USE_OPLINE
2529    zval *func_name;
2530    zval *func;
2531    zend_function *fbc;
2532
2533    func_name = opline->op2.zv + 1;
2534    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
2535        fbc = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
2536    } else if ((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL) {
2537        func_name++;
2538        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL)) {
2539            SAVE_OPLINE();
2540            zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(opline->op2.zv));
2541        } else {
2542            fbc = Z_FUNC_P(func);
2543            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
2544        }
2545    } else {
2546        fbc = Z_FUNC_P(func);
2547        CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), fbc);
2548    }
2549
2550    EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2551        fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
2552
2553    ZEND_VM_NEXT_OPCODE();
2554}
2555
2556ZEND_VM_HANDLER(61, ZEND_INIT_FCALL, ANY, CONST)
2557{
2558    USE_OPLINE
2559    zend_free_op free_op2;
2560    zval *fname = GET_OP2_ZVAL_PTR(BP_VAR_R);
2561    zval *func;
2562    zend_function *fbc;
2563
2564    if (CACHED_PTR(Z_CACHE_SLOT_P(fname))) {
2565        fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname));
2566    } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(fname))) == NULL)) {
2567        SAVE_OPLINE();
2568        zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(fname));
2569    } else {
2570        fbc = Z_FUNC_P(func);
2571        CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
2572    }
2573
2574    EX(call) = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_FUNCTION,
2575        fbc, opline->extended_value, NULL, NULL, EX(call) TSRMLS_CC);
2576
2577    FREE_OP2();
2578
2579    ZEND_VM_NEXT_OPCODE();
2580}
2581
2582ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
2583{
2584    USE_OPLINE
2585    zend_execute_data *call = EX(call);
2586    zend_function *fbc = call->func;
2587    zend_object *object = Z_OBJ(call->This);
2588
2589    SAVE_OPLINE();
2590    EX(call) = call->prev_execute_data;
2591    if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
2592        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
2593            zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name->val, fbc->common.function_name->val);
2594        }
2595        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
2596            zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
2597                fbc->common.scope ? fbc->common.scope->name->val : "",
2598                fbc->common.scope ? "::" : "",
2599                fbc->common.function_name->val);
2600            if (UNEXPECTED(EG(exception) != NULL)) {
2601                HANDLE_EXCEPTION();
2602            }
2603        }
2604    }
2605
2606    LOAD_OPLINE();
2607
2608    if (UNEXPECTED(fbc->type == ZEND_INTERNAL_FUNCTION)) {
2609        int should_change_scope = 0;
2610        zval *ret;
2611
2612        if (fbc->common.scope) {
2613            should_change_scope = 1;
2614            /* TODO: we don't set scope if we call an object method ??? */
2615            /* See: ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt */
2616#if 1
2617            EG(scope) = object ? NULL : fbc->common.scope;
2618#else
2619            EG(scope) = fbc->common.scope;
2620#endif
2621        } else {
2622            call->called_scope = EX(called_scope);
2623            Z_OBJ(call->This) = Z_OBJ(EX(This));
2624        }
2625
2626        call->prev_execute_data = execute_data;
2627        EG(current_execute_data) = call;
2628
2629        if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
2630            uint32_t i;
2631            zval *p = ZEND_CALL_ARG(call, 1);
2632
2633            for (i = 0; i < call->num_args; ++i) {
2634                zend_verify_arg_type(fbc, i + 1, p TSRMLS_CC);
2635                p++;
2636            }
2637            if (UNEXPECTED(EG(exception) != NULL)) {
2638                EG(current_execute_data) = call->prev_execute_data;
2639                zend_vm_stack_free_args(call TSRMLS_CC);
2640                zend_vm_stack_free_call_frame(call TSRMLS_CC);
2641                if (RETURN_VALUE_USED(opline)) {
2642                    ZVAL_UNDEF(EX_VAR(opline->result.var));
2643                }
2644                if (UNEXPECTED(should_change_scope)) {
2645                    ZEND_VM_C_GOTO(fcall_end_change_scope);
2646                } else {
2647                    ZEND_VM_C_GOTO(fcall_end);
2648                }
2649            }
2650        }
2651
2652        ret = EX_VAR(opline->result.var);
2653        ZVAL_NULL(ret);
2654        Z_VAR_FLAGS_P(ret) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
2655
2656        if (!zend_execute_internal) {
2657            /* saves one function call if zend_execute_internal is not used */
2658            fbc->internal_function.handler(call, ret TSRMLS_CC);
2659        } else {
2660            zend_execute_internal(call, ret TSRMLS_CC);
2661        }
2662        EG(current_execute_data) = call->prev_execute_data;
2663        zend_vm_stack_free_args(call TSRMLS_CC);
2664        zend_vm_stack_free_call_frame(call TSRMLS_CC);
2665
2666        if (!RETURN_VALUE_USED(opline)) {
2667            zval_ptr_dtor(ret);
2668        }
2669
2670        if (UNEXPECTED(should_change_scope)) {
2671            ZEND_VM_C_GOTO(fcall_end_change_scope);
2672        } else {
2673            ZEND_VM_C_GOTO(fcall_end);
2674        }
2675    } else if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
2676        call->scope = EG(scope) = fbc->common.scope;
2677        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
2678            if (RETURN_VALUE_USED(opline)) {
2679                zend_generator_create_zval(call, &fbc->op_array, EX_VAR(opline->result.var) TSRMLS_CC);
2680            } else {
2681                zend_vm_stack_free_args(call TSRMLS_CC);
2682            }
2683
2684            zend_vm_stack_free_call_frame(call TSRMLS_CC);
2685        } else {
2686            zval *return_value = NULL;
2687
2688            call->symbol_table = NULL;
2689            if (RETURN_VALUE_USED(opline)) {
2690                return_value = EX_VAR(opline->result.var);
2691
2692                ZVAL_NULL(return_value);
2693                Z_VAR_FLAGS_P(return_value) = 0;
2694            }
2695
2696            call->prev_execute_data = execute_data;
2697            i_init_func_execute_data(call, &fbc->op_array, return_value TSRMLS_CC);
2698
2699            if (EXPECTED(zend_execute_ex == execute_ex)) {
2700                ZEND_VM_ENTER();
2701            } else {
2702                call->frame_info = VM_FRAME_INFO(
2703                    VM_FRAME_TOP_FUNCTION,
2704                    VM_FRAME_FLAGS(call->frame_info));
2705                zend_execute_ex(call TSRMLS_CC);
2706            }
2707        }
2708    } else { /* ZEND_OVERLOADED_FUNCTION */
2709        EG(scope) = fbc->common.scope;
2710
2711        ZVAL_NULL(EX_VAR(opline->result.var));
2712
2713        /* Not sure what should be done here if it's a static method */
2714        if (EXPECTED(object != NULL)) {
2715            call->prev_execute_data = execute_data;
2716            EG(current_execute_data) = call;
2717            object->handlers->call_method(fbc->common.function_name, object, call, EX_VAR(opline->result.var) TSRMLS_CC);
2718            EG(current_execute_data) = call->prev_execute_data;
2719        } else {
2720            zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
2721        }
2722
2723        zend_vm_stack_free_args(call TSRMLS_CC);
2724
2725        zend_vm_stack_free_call_frame(call TSRMLS_CC);
2726
2727        if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
2728            zend_string_release(fbc->common.function_name);
2729        }
2730        efree(fbc);
2731
2732        if (!RETURN_VALUE_USED(opline)) {
2733            zval_ptr_dtor(EX_VAR(opline->result.var));
2734        } else {
2735//???           Z_UNSET_ISREF_P(EX_T(opline->result.var).var.ptr);
2736//???           Z_SET_REFCOUNT_P(EX_T(opline->result.var).var.ptr, 1);
2737            Z_VAR_FLAGS_P(EX_VAR(opline->result.var)) = 0;
2738        }
2739    }
2740
2741ZEND_VM_C_LABEL(fcall_end_change_scope):
2742    if (object) {
2743        if (UNEXPECTED(EG(exception) != NULL) && (opline->op1.num & ZEND_CALL_CTOR)) {
2744            if (!(opline->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
2745                GC_REFCOUNT(object)--;
2746            }
2747            if (GC_REFCOUNT(object) == 1) {
2748                zend_object_store_ctor_failed(object TSRMLS_CC);
2749            }
2750        }
2751        OBJ_RELEASE(object);
2752    }
2753    EG(scope) = EX(scope);
2754
2755ZEND_VM_C_LABEL(fcall_end):
2756    if (UNEXPECTED(EG(exception) != NULL)) {
2757        zend_throw_exception_internal(NULL TSRMLS_CC);
2758        if (RETURN_VALUE_USED(opline)) {
2759            zval_ptr_dtor(EX_VAR(opline->result.var));
2760        }
2761        HANDLE_EXCEPTION();
2762    }
2763
2764    ZEND_VM_NEXT_OPCODE();
2765}
2766
2767ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
2768{
2769    USE_OPLINE
2770    zval *retval_ptr;
2771    zend_free_op free_op1;
2772
2773    SAVE_OPLINE();
2774    retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2775
2776    if (!EX(return_value)) {
2777        FREE_OP1();
2778    } else {
2779        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) {
2780            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2781            if (OP1_TYPE == IS_CONST) {
2782                if (UNEXPECTED(Z_OPT_COPYABLE_P(EX(return_value)))) {
2783                    zval_copy_ctor_func(EX(return_value));
2784                }
2785            }
2786        } else if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(retval_ptr)) {
2787            ZVAL_COPY(EX(return_value), Z_REFVAL_P(retval_ptr));
2788            FREE_OP1_IF_VAR();
2789        } else {
2790            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2791            if (OP1_TYPE == IS_CV) {
2792                if (Z_OPT_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2793            }
2794        }
2795    }
2796    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
2797}
2798
2799ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
2800{
2801    USE_OPLINE
2802    zval *retval_ptr;
2803    zend_free_op free_op1;
2804
2805    SAVE_OPLINE();
2806
2807    do {
2808        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR ||
2809            (OP1_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
2810            /* Not supposed to happen, but we'll allow it */
2811            zend_error(E_NOTICE, "Only variable references should be returned by reference");
2812
2813            retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2814            if (!EX(return_value)) {
2815                if (OP1_TYPE == IS_TMP_VAR) {
2816                    FREE_OP1();
2817                }
2818            } else {
2819                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2820                Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
2821                if (OP1_TYPE != IS_TMP_VAR) {
2822                    zval_opt_copy_ctor_no_imm(EX(return_value));
2823                }
2824            }
2825            break;
2826        }
2827
2828        retval_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
2829
2830        if (OP1_TYPE == IS_VAR && UNEXPECTED(retval_ptr == NULL)) {
2831            zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");
2832        }
2833
2834        if (OP1_TYPE == IS_VAR) {
2835            if (retval_ptr == &EG(uninitialized_zval) ||
2836                (opline->extended_value == ZEND_RETURNS_FUNCTION &&
2837                 !(Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF))) {
2838                zend_error(E_NOTICE, "Only variable references should be returned by reference");
2839                if (EX(return_value)) {
2840                    ZVAL_NEW_REF(EX(return_value), retval_ptr);
2841                    Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
2842                    if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2843                }
2844                break;
2845            }
2846        }
2847
2848        if (EX(return_value)) {
2849            ZVAL_MAKE_REF(retval_ptr);
2850            Z_ADDREF_P(retval_ptr);
2851            ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
2852            Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
2853        }
2854    } while (0);
2855
2856    FREE_OP1_VAR_PTR();
2857    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
2858}
2859
2860ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY)
2861{
2862    /* The generator object is stored in EX(return_value) */
2863    zend_generator *generator = (zend_generator *) EX(return_value);
2864
2865    /* Close the generator to free up resources */
2866    zend_generator_close(generator, 1 TSRMLS_CC);
2867
2868    /* Pass execution back to handling code */
2869    ZEND_VM_RETURN();
2870}
2871
2872ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
2873{
2874    USE_OPLINE
2875    zval *value;
2876    zend_free_op free_op1;
2877
2878    SAVE_OPLINE();
2879    value = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
2880
2881    if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
2882        if (UNEXPECTED(EG(exception) != NULL)) {
2883            HANDLE_EXCEPTION();
2884        }
2885        zend_error_noreturn(E_ERROR, "Can only throw objects");
2886    }
2887
2888    zend_exception_save(TSRMLS_C);
2889    if (OP1_TYPE != IS_TMP_VAR) {
2890        if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
2891    }
2892
2893    zend_throw_exception_object(value TSRMLS_CC);
2894    zend_exception_restore(TSRMLS_C);
2895    FREE_OP1_IF_VAR();
2896    HANDLE_EXCEPTION();
2897}
2898
2899ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
2900{
2901    USE_OPLINE
2902    zend_class_entry *ce, *catch_ce;
2903    zend_object *exception;
2904
2905    SAVE_OPLINE();
2906    /* Check whether an exception has been thrown, if not, jump over code */
2907    zend_exception_restore(TSRMLS_C);
2908    if (EG(exception) == NULL) {
2909        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
2910        ZEND_VM_CONTINUE(); /* CHECK_ME */
2911    }
2912    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
2913        catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
2914    } else {
2915        catch_ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC);
2916
2917        CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), catch_ce);
2918    }
2919    ce = EG(exception)->ce;
2920
2921#ifdef HAVE_DTRACE
2922    if (DTRACE_EXCEPTION_CAUGHT_ENABLED()) {
2923        DTRACE_EXCEPTION_CAUGHT((char *)ce->name);
2924    }
2925#endif /* HAVE_DTRACE */
2926
2927    if (ce != catch_ce) {
2928        if (!instanceof_function(ce, catch_ce TSRMLS_CC)) {
2929            if (opline->result.num) {
2930                zend_throw_exception_internal(NULL TSRMLS_CC);
2931                HANDLE_EXCEPTION();
2932            }
2933            ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
2934            ZEND_VM_CONTINUE(); /* CHECK_ME */
2935        }
2936    }
2937
2938    exception = EG(exception);
2939    if (Z_REFCOUNTED_P(EX_VAR(opline->op2.var))) {
2940        zval_ptr_dtor(EX_VAR(opline->op2.var));
2941    }
2942    ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
2943    if (UNEXPECTED(EG(exception) != exception)) {
2944        GC_REFCOUNT(EG(exception))++;
2945        HANDLE_EXCEPTION();
2946    } else {
2947        EG(exception) = NULL;
2948        ZEND_VM_NEXT_OPCODE();
2949    }
2950}
2951
2952ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY)
2953{
2954    USE_OPLINE
2955    zval *value, *arg;
2956    zend_free_op free_op1;
2957
2958    SAVE_OPLINE();
2959    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
2960    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2961    EX(call)->num_args = opline->op2.num;
2962    ZVAL_COPY_VALUE(arg, value);
2963    if (OP1_TYPE == IS_CONST) {
2964        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2965            zval_copy_ctor_func(arg);
2966        }
2967    }
2968    ZEND_VM_NEXT_OPCODE();
2969}
2970
2971ZEND_VM_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, ANY)
2972{
2973    USE_OPLINE
2974    zval *value, *arg;
2975    zend_free_op free_op1;
2976
2977    SAVE_OPLINE();
2978    if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
2979        zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
2980    }
2981    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
2982    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2983    EX(call)->num_args = opline->op2.num;
2984    ZVAL_COPY_VALUE(arg, value);
2985    if (OP1_TYPE == IS_CONST) {
2986        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2987            zval_copy_ctor_func(arg);
2988        }
2989    }
2990    ZEND_VM_NEXT_OPCODE();
2991}
2992
2993ZEND_VM_HANDLER(117, ZEND_SEND_VAR, VAR|CV, ANY)
2994{
2995    USE_OPLINE
2996    zval *varptr, *arg;
2997    zend_free_op free_op1;
2998
2999    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3000    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3001    EX(call)->num_args = opline->op2.num;
3002    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
3003        ZVAL_COPY(arg, Z_REFVAL_P(varptr));
3004        FREE_OP1();
3005    } else {
3006        ZVAL_COPY_VALUE(arg, varptr);
3007        if (OP1_TYPE == IS_CV) {
3008            if (Z_OPT_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
3009        }
3010    }
3011    ZEND_VM_NEXT_OPCODE();
3012}
3013
3014ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
3015{
3016    USE_OPLINE
3017    zend_free_op free_op1;
3018    zval *varptr, *arg;
3019
3020    SAVE_OPLINE();
3021    if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
3022        if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) {
3023            ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
3024        }
3025    } else {
3026        if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3027            ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
3028        }
3029    }
3030
3031    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3032    if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
3033         (Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
3034        (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
3035
3036        ZVAL_MAKE_REF(varptr);
3037        if (OP1_TYPE == IS_CV) {
3038            Z_ADDREF_P(varptr);
3039        }
3040        arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3041        EX(call)->num_args = opline->op2.num;
3042        ZVAL_COPY_VALUE(arg, varptr);
3043    } else {
3044        if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
3045            !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
3046            !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3047            zend_error(E_STRICT, "Only variables should be passed by reference");
3048        }
3049        arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3050        EX(call)->num_args = opline->op2.num;
3051        ZVAL_COPY(arg, varptr);
3052        FREE_OP1_IF_VAR();
3053    }
3054    CHECK_EXCEPTION();
3055    ZEND_VM_NEXT_OPCODE();
3056}
3057
3058ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
3059{
3060    USE_OPLINE
3061    zend_free_op free_op1;
3062    zval *varptr, *arg;
3063
3064    SAVE_OPLINE();
3065    varptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3066
3067    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == NULL)) {
3068        zend_error_noreturn(E_ERROR, "Only variables can be passed by reference");
3069    }
3070
3071    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3072    EX(call)->num_args = opline->op2.num;
3073    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == &EG(error_zval))) {
3074        ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
3075        ZEND_VM_NEXT_OPCODE();
3076    }
3077
3078    if (Z_ISREF_P(varptr)) {
3079        Z_ADDREF_P(varptr);
3080        ZVAL_COPY_VALUE(arg, varptr);
3081    } else if (OP1_TYPE == IS_VAR &&
3082        UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) {
3083        ZVAL_COPY_VALUE(arg, varptr);
3084        ZVAL_MAKE_REF(arg);
3085    } else {
3086        ZVAL_MAKE_REF(varptr);
3087        Z_ADDREF_P(varptr);
3088        ZVAL_REF(arg, Z_REF_P(varptr));
3089    }
3090
3091    FREE_OP1_VAR_PTR();
3092    ZEND_VM_NEXT_OPCODE();
3093}
3094
3095ZEND_VM_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, ANY)
3096{
3097    USE_OPLINE
3098    zval *varptr, *arg;
3099    zend_free_op free_op1;
3100
3101    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3102        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
3103    }
3104    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3105    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3106    EX(call)->num_args = opline->op2.num;
3107    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
3108        ZVAL_COPY(arg, Z_REFVAL_P(varptr));
3109        FREE_OP1();
3110    } else {
3111        ZVAL_COPY_VALUE(arg, varptr);
3112        if (OP1_TYPE == IS_CV) {
3113            if (Z_OPT_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
3114        }
3115    }
3116    ZEND_VM_NEXT_OPCODE();
3117}
3118
3119ZEND_VM_HANDLER(165, ZEND_SEND_UNPACK, ANY, ANY)
3120{
3121    USE_OPLINE
3122    zend_free_op free_op1;
3123    zval *args;
3124    int arg_num;
3125    SAVE_OPLINE();
3126
3127    args = GET_OP1_ZVAL_PTR(BP_VAR_R);
3128    arg_num = EX(call)->num_args + 1;
3129
3130ZEND_VM_C_LABEL(send_again):
3131    switch (Z_TYPE_P(args)) {
3132        case IS_ARRAY: {
3133            HashTable *ht = Z_ARRVAL_P(args);
3134            zval *arg, *top;
3135            zend_string *name;
3136
3137            zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, zend_hash_num_elements(ht) TSRMLS_CC);
3138
3139            if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
3140                uint32_t i;
3141                int separate = 0;
3142
3143                /* check if any of arguments are going to be passed by reference */
3144                for (i = 0; i < zend_hash_num_elements(ht); i++) {
3145                    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
3146                        separate = 1;
3147                        break;
3148                    }
3149                }
3150                if (separate) {
3151                    zval_copy_ctor(args);
3152                    ht = Z_ARRVAL_P(args);
3153                }
3154            }
3155
3156            ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
3157                if (name) {
3158                    zend_error(E_RECOVERABLE_ERROR, "Cannot unpack array with string keys");
3159                    FREE_OP1();
3160                    CHECK_EXCEPTION();
3161                    ZEND_VM_NEXT_OPCODE();
3162                }
3163
3164                top = ZEND_CALL_ARG(EX(call), arg_num);
3165                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3166                    if (!Z_IMMUTABLE_P(args)) {
3167                        ZVAL_MAKE_REF(arg);
3168                        Z_ADDREF_P(arg);
3169                        ZVAL_REF(top, Z_REF_P(arg));
3170                    } else {
3171                        ZVAL_DUP(top, arg);
3172                    }
3173                } else if (Z_ISREF_P(arg)) {
3174                    ZVAL_COPY(top, Z_REFVAL_P(arg));
3175                } else {
3176                    ZVAL_COPY(top, arg);
3177                }
3178
3179                EX(call)->num_args++;
3180                arg_num++;
3181            } ZEND_HASH_FOREACH_END();
3182
3183            break;
3184        }
3185        case IS_OBJECT: {
3186            zend_class_entry *ce = Z_OBJCE_P(args);
3187            zend_object_iterator *iter;
3188
3189            if (!ce || !ce->get_iterator) {
3190                zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
3191                break;
3192            }
3193
3194            iter = ce->get_iterator(ce, args, 0 TSRMLS_CC);
3195            if (UNEXPECTED(!iter)) {
3196                FREE_OP1();
3197                if (!EG(exception)) {
3198                    zend_throw_exception_ex(
3199                        NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val
3200                    );
3201                }
3202                HANDLE_EXCEPTION();
3203            }
3204
3205            if (iter->funcs->rewind) {
3206                iter->funcs->rewind(iter TSRMLS_CC);
3207                if (UNEXPECTED(EG(exception) != NULL)) {
3208                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3209                }
3210            }
3211
3212            for (; iter->funcs->valid(iter TSRMLS_CC) == SUCCESS; ++arg_num) {
3213                zval *arg, *top;
3214
3215                if (UNEXPECTED(EG(exception) != NULL)) {
3216                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3217                }
3218
3219                arg = iter->funcs->get_current_data(iter TSRMLS_CC);
3220                if (UNEXPECTED(EG(exception) != NULL)) {
3221                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3222                }
3223
3224                if (iter->funcs->get_current_key) {
3225                    zval key;
3226                    iter->funcs->get_current_key(iter, &key TSRMLS_CC);
3227                    if (UNEXPECTED(EG(exception) != NULL)) {
3228                        ZEND_VM_C_GOTO(unpack_iter_dtor);
3229                    }
3230
3231                    if (Z_TYPE(key) == IS_STRING) {
3232                        zend_error(E_RECOVERABLE_ERROR,
3233                            "Cannot unpack Traversable with string keys");
3234                        zval_dtor(&key);
3235                        ZEND_VM_C_GOTO(unpack_iter_dtor);
3236                    }
3237
3238                    zval_dtor(&key);
3239                }
3240
3241                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3242                    zend_error(
3243                        E_WARNING, "Cannot pass by-reference argument %d of %s%s%s()"
3244                        " by unpacking a Traversable, passing by-value instead", arg_num,
3245                        EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3246                        EX(call)->func->common.scope ? "::" : "",
3247                        EX(call)->func->common.function_name->val
3248                    );
3249                }
3250
3251                if (Z_ISREF_P(arg)) {
3252                    ZVAL_DUP(arg, Z_REFVAL_P(arg));
3253                } else {
3254                    if (Z_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
3255                }
3256
3257                zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1 TSRMLS_CC);
3258                top = ZEND_CALL_ARG(EX(call), arg_num);
3259                ZVAL_COPY_VALUE(top, arg);
3260                EX(call)->num_args++;
3261
3262                iter->funcs->move_forward(iter TSRMLS_CC);
3263                if (UNEXPECTED(EG(exception) != NULL)) {
3264                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3265                }
3266            }
3267
3268ZEND_VM_C_LABEL(unpack_iter_dtor):
3269            zend_iterator_dtor(iter TSRMLS_CC);
3270            break;
3271        }
3272        case IS_REFERENCE:
3273            args = Z_REFVAL_P(args);
3274            ZEND_VM_C_GOTO(send_again);
3275            break;
3276        default:
3277            zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
3278    }
3279
3280    FREE_OP1();
3281    CHECK_EXCEPTION();
3282    ZEND_VM_NEXT_OPCODE();
3283}
3284
3285ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
3286{
3287    USE_OPLINE
3288    zend_free_op free_op1;
3289    zval *args;
3290    SAVE_OPLINE();
3291
3292    args = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
3293
3294    if (Z_TYPE_P(args) != IS_ARRAY) {
3295        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)));
3296        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3297            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3298        }
3299        if (Z_OBJ(EX(call)->This)) {
3300            OBJ_RELEASE(Z_OBJ(EX(call)->This));
3301        }
3302        EX(call)->func = (zend_function*)&zend_pass_function;
3303        EX(call)->called_scope = NULL;
3304        Z_OBJ(EX(call)->This) = NULL;
3305    } else {
3306        uint32_t arg_num = 1;
3307
3308        HashTable *ht = Z_ARRVAL_P(args);
3309        zval *arg, *param, tmp;
3310
3311        zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht) TSRMLS_CC);
3312
3313        if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
3314            uint32_t i;
3315            int separate = 0;
3316
3317            /* check if any of arguments are going to be passed by reference */
3318            for (i = 0; i < zend_hash_num_elements(ht); i++) {
3319                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
3320                    separate = 1;
3321                    break;
3322                }
3323            }
3324            if (separate) {
3325                zval_copy_ctor(args);
3326                ht = Z_ARRVAL_P(args);
3327            }
3328        }
3329
3330        param = ZEND_CALL_ARG(EX(call), arg_num);
3331        ZEND_HASH_FOREACH_VAL(ht, arg) {
3332            if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3333                // TODO: Scalar values don't have reference counters anymore.
3334                // They are assumed to be 1, and they may be easily passed by
3335                // reference now. However, previously scalars with refcount==1
3336                // might be passed and with refcount>1 might not. We can support
3337                // only single behavior ???
3338#if 0
3339                if (Z_REFCOUNTED_P(arg) &&
3340                    // This solution breaks the following test (omit warning message) ???
3341                    // Zend/tests/bug61273.phpt
3342                    // ext/reflection/tests/bug42976.phpt
3343                    // ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt
3344#else
3345                if (!Z_REFCOUNTED_P(arg) ||
3346                    // This solution breaks the following test (emit warning message) ???
3347                    // ext/pdo_sqlite/tests/pdo_005.phpt
3348#endif
3349                    (!Z_ISREF_P(arg) && Z_REFCOUNT_P(arg) > 1)) {
3350
3351                    if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3352
3353                        zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
3354                            arg_num,
3355                            EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3356                            EX(call)->func->common.scope ? "::" : "",
3357                            EX(call)->func->common.function_name->val);
3358
3359                        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3360                            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3361                        }
3362                        if (Z_OBJ(EX(call)->This)) {
3363                            OBJ_RELEASE(Z_OBJ(EX(call)->This));
3364                        }
3365                        EX(call)->func = (zend_function*)&zend_pass_function;
3366                        EX(call)->called_scope = NULL;
3367                        Z_OBJ(EX(call)->This) = NULL;
3368
3369                        break;
3370                    }
3371
3372                    if (Z_REFCOUNTED_P(arg)) {
3373                        Z_DELREF_P(arg);
3374                    }
3375                    ZVAL_DUP(&tmp, arg);
3376                    ZVAL_NEW_REF(arg, &tmp);
3377                    Z_ADDREF_P(arg);
3378                } else if (!Z_ISREF_P(arg)) {
3379                    ZVAL_NEW_REF(arg, arg);
3380                    Z_ADDREF_P(arg);
3381                } else if (Z_REFCOUNTED_P(arg)) {
3382                    Z_ADDREF_P(arg);
3383                }
3384                ZVAL_COPY_VALUE(param, arg);
3385            } else if (Z_ISREF_P(arg) &&
3386                   /* don't separate references for __call */
3387                   (EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
3388                ZVAL_DUP(param, Z_REFVAL_P(arg));
3389            } else {
3390                ZVAL_COPY(param, arg);
3391            }
3392            EX(call)->num_args++;
3393            arg_num++;
3394            param++;
3395        } ZEND_HASH_FOREACH_END();
3396    }
3397    FREE_OP1();
3398    CHECK_EXCEPTION();
3399    ZEND_VM_NEXT_OPCODE();
3400}
3401
3402ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
3403{
3404    USE_OPLINE
3405    zval *arg, *param, tmp;
3406    zend_free_op free_op1;
3407
3408    arg = GET_OP1_ZVAL_PTR(BP_VAR_R);
3409    param = ZEND_CALL_ARG(EX(call), opline->op2.num);
3410
3411    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3412        // TODO: Scalar values don't have reference counters anymore.
3413        // They are assumed to be 1, and they may be easily passed by
3414        // reference now. However, previously scalars with refcount==1
3415        // might be passed and with refcount>1 might not. We can support
3416        // only single behavior ???
3417#if 0
3418        if (Z_REFCOUNTED_P(arg) &&
3419            // This solution breaks the following test (omit warning message) ???
3420            // Zend/tests/bug61273.phpt
3421            // ext/reflection/tests/bug42976.phpt
3422            // ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt
3423#else
3424        if (!Z_REFCOUNTED_P(arg) ||
3425            // This solution breaks the following test (emit warning message) ???
3426            // ext/pdo_sqlite/tests/pdo_005.phpt
3427#endif
3428            (!Z_ISREF_P(arg) /*&& Z_REFCOUNT_P(arg) > 1???*/)) {
3429
3430            if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3431
3432                zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
3433                    opline->op2.num,
3434                    EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3435                    EX(call)->func->common.scope ? "::" : "",
3436                    EX(call)->func->common.function_name->val);
3437
3438                if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3439                    OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3440                }
3441                if (Z_OBJ(EX(call)->This)) {
3442                    OBJ_RELEASE(Z_OBJ(EX(call)->This));
3443                }
3444                EX(call)->func = (zend_function*)&zend_pass_function;
3445                EX(call)->called_scope = NULL;
3446                Z_OBJ(EX(call)->This) = NULL;
3447
3448                FREE_OP1();
3449                CHECK_EXCEPTION();
3450                ZEND_VM_NEXT_OPCODE();
3451            }
3452
3453            if (Z_REFCOUNTED_P(arg)) {
3454                Z_DELREF_P(arg);
3455            }
3456            ZVAL_DUP(&tmp, arg);
3457            ZVAL_NEW_REF(arg, &tmp);
3458            Z_ADDREF_P(arg);
3459        } else if (!Z_ISREF_P(arg)) {
3460            ZVAL_NEW_REF(arg, arg);
3461            Z_ADDREF_P(arg);
3462        } else if (Z_REFCOUNTED_P(arg)) {
3463            Z_ADDREF_P(arg);
3464        }
3465        ZVAL_COPY_VALUE(param, arg);
3466    } else if (Z_ISREF_P(arg) &&
3467               /* don't separate references for __call */
3468               (EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
3469        ZVAL_DUP(param, Z_REFVAL_P(arg));
3470    } else {
3471        ZVAL_COPY(param, arg);
3472    }
3473
3474    EX(call)->num_args = opline->op2.num;
3475
3476    FREE_OP1();
3477    CHECK_EXCEPTION();
3478    ZEND_VM_NEXT_OPCODE();
3479}
3480
3481ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
3482{
3483    USE_OPLINE
3484    uint32_t arg_num = opline->op1.num;
3485
3486    SAVE_OPLINE();
3487    if (UNEXPECTED(arg_num > EX(num_args))) {
3488        zend_verify_missing_arg(execute_data, arg_num TSRMLS_CC);
3489        CHECK_EXCEPTION();
3490    } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3491        zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3492
3493        zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
3494        CHECK_EXCEPTION();
3495    }
3496
3497    ZEND_VM_NEXT_OPCODE();
3498}
3499
3500ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
3501{
3502    USE_OPLINE
3503    uint32_t arg_num = opline->op1.num;
3504    zval *param;
3505
3506    SAVE_OPLINE();
3507    param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3508    if (arg_num > EX(num_args)) {
3509        ZVAL_COPY_VALUE(param, opline->op2.zv);
3510        if (Z_OPT_CONSTANT_P(param)) {
3511            zval_update_constant(param, 0 TSRMLS_CC);
3512        } else {
3513            /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
3514            if (UNEXPECTED(Z_OPT_COPYABLE_P(param))) {
3515                zval_copy_ctor_func(param);
3516            }
3517        }
3518    }
3519
3520    if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3521        zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
3522    }
3523
3524    CHECK_EXCEPTION();
3525    ZEND_VM_NEXT_OPCODE();
3526}
3527
3528ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
3529{
3530    USE_OPLINE
3531    uint32_t arg_num = opline->op1.num;
3532    uint32_t arg_count = EX(num_args);
3533    zval *params;
3534
3535    SAVE_OPLINE();
3536
3537    params = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3538
3539    if (arg_num <= arg_count) {
3540        zval *param;
3541
3542        array_init_size(params, arg_count - arg_num + 1);
3543        param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
3544        if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3545            do {
3546                zend_verify_arg_type(EX(func), arg_num, param TSRMLS_CC);
3547                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
3548                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
3549                param++;
3550            } while (++arg_num <= arg_count);
3551        } else {
3552            do {
3553                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
3554                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
3555                param++;
3556            } while (++arg_num <= arg_count);
3557        }
3558    } else {
3559        array_init(params);
3560    }
3561
3562    CHECK_EXCEPTION();
3563    ZEND_VM_NEXT_OPCODE();
3564}
3565
3566ZEND_VM_HANDLER(52, ZEND_BOOL, CONST|TMP|VAR|CV, ANY)
3567{
3568    USE_OPLINE
3569    zend_free_op free_op1;
3570    zval *retval = EX_VAR(opline->result.var);
3571
3572    SAVE_OPLINE();
3573    /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */
3574    ZVAL_BOOL(retval, i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC));
3575    FREE_OP1();
3576
3577    CHECK_EXCEPTION();
3578    ZEND_VM_NEXT_OPCODE();
3579}
3580
3581ZEND_VM_HANDLER(50, ZEND_BRK, ANY, CONST)
3582{
3583    USE_OPLINE
3584    zend_brk_cont_element *el;
3585
3586    SAVE_OPLINE();
3587    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
3588                       &EX(func)->op_array, execute_data TSRMLS_CC);
3589    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->brk);
3590}
3591
3592ZEND_VM_HANDLER(51, ZEND_CONT, ANY, CONST)
3593{
3594    USE_OPLINE
3595    zend_brk_cont_element *el;
3596
3597    SAVE_OPLINE();
3598    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
3599                       &EX(func)->op_array, execute_data TSRMLS_CC);
3600    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->cont);
3601}
3602
3603ZEND_VM_HANDLER(100, ZEND_GOTO, ANY, CONST)
3604{
3605    zend_op *brk_opline;
3606    USE_OPLINE
3607    zend_brk_cont_element *el;
3608
3609    SAVE_OPLINE();
3610    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value,
3611                       &EX(func)->op_array, execute_data TSRMLS_CC);
3612
3613    brk_opline = EX(func)->op_array.opcodes + el->brk;
3614
3615    if (brk_opline->opcode == ZEND_FREE) {
3616        if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
3617            zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
3618        }
3619    }
3620    ZEND_VM_JMP(opline->op1.jmp_addr);
3621}
3622
3623ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)
3624{
3625    USE_OPLINE
3626    zend_free_op free_op1, free_op2;
3627    zval *result = EX_VAR(opline->result.var);
3628
3629    SAVE_OPLINE();
3630    fast_equal_function(result,
3631         GET_OP1_ZVAL_PTR(BP_VAR_R),
3632         GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC);
3633
3634    FREE_OP2();
3635    CHECK_EXCEPTION();
3636    ZEND_VM_NEXT_OPCODE();
3637}
3638
3639ZEND_VM_HANDLER(68, ZEND_NEW, CONST|VAR, ANY)
3640{
3641    USE_OPLINE
3642    zval object_zval;
3643    zend_function *constructor;
3644    zend_class_entry *ce;
3645
3646    SAVE_OPLINE();
3647    if (OP1_TYPE == IS_CONST) {
3648        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
3649            ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
3650        } else {
3651            ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, 0 TSRMLS_CC);
3652            if (UNEXPECTED(ce == NULL)) {
3653                CHECK_EXCEPTION();
3654                ZEND_VM_NEXT_OPCODE();
3655            }
3656            CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
3657        }
3658    } else {
3659        ce = Z_CE_P(EX_VAR(opline->op1.var));
3660    }
3661    if (UNEXPECTED((ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) != 0)) {
3662        if (ce->ce_flags & ZEND_ACC_INTERFACE) {
3663            zend_error_noreturn(E_ERROR, "Cannot instantiate interface %s", ce->name->val);
3664        } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
3665            zend_error_noreturn(E_ERROR, "Cannot instantiate trait %s", ce->name->val);
3666        } else {
3667            zend_error_noreturn(E_ERROR, "Cannot instantiate abstract class %s", ce->name->val);
3668        }
3669    }
3670    object_init_ex(&object_zval, ce);
3671    constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC);
3672
3673    if (constructor == NULL) {
3674        if (RETURN_VALUE_USED(opline)) {
3675            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
3676        } else {
3677            zval_ptr_dtor(&object_zval);
3678        }
3679        ZEND_VM_JMP(opline->op2.jmp_addr);
3680    } else {
3681        /* We are not handling overloaded classes right now */
3682        EX(call) = zend_vm_stack_push_call_frame(
3683            VM_FRAME_INFO(
3684                VM_FRAME_NESTED_FUNCTION,
3685                RETURN_VALUE_USED(opline) ?
3686                    ZEND_CALL_CTOR : (ZEND_CALL_CTOR | ZEND_CALL_CTOR_RESULT_UNUSED)),
3687            constructor,
3688            opline->extended_value,
3689            ce,
3690            Z_OBJ(object_zval),
3691            EX(call) TSRMLS_CC);
3692
3693        if (RETURN_VALUE_USED(opline)) {
3694            ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
3695            EX(call)->return_value = EX_VAR(opline->result.var);
3696        } else {
3697            EX(call)->return_value = NULL;
3698        }
3699
3700        CHECK_EXCEPTION();
3701        ZEND_VM_NEXT_OPCODE();
3702    }
3703}
3704
3705ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
3706{
3707    USE_OPLINE
3708    zend_free_op free_op1;
3709    zval *obj;
3710    zend_class_entry *ce;
3711    zend_function *clone;
3712    zend_object_clone_obj_t clone_call;
3713
3714    SAVE_OPLINE();
3715    obj = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_R);
3716
3717    if (OP1_TYPE == IS_CONST ||
3718        (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) {
3719        if (UNEXPECTED(EG(exception) != NULL)) {
3720            HANDLE_EXCEPTION();
3721        }
3722        zend_error_noreturn(E_ERROR, "__clone method called on non-object");
3723    }
3724
3725    ce = Z_OBJCE_P(obj);
3726    clone = ce ? ce->clone : NULL;
3727    clone_call =  Z_OBJ_HT_P(obj)->clone_obj;
3728    if (UNEXPECTED(clone_call == NULL)) {
3729        if (ce) {
3730            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name->val);
3731        } else {
3732            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");
3733        }
3734    }
3735
3736    if (ce && clone) {
3737        if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
3738            /* Ensure that if we're calling a private function, we're allowed to do so.
3739             */
3740            if (UNEXPECTED(ce != EX(scope))) {
3741                zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
3742            }
3743        } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
3744            /* Ensure that if we're calling a protected function, we're allowed to do so.
3745             */
3746            if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EX(scope)))) {
3747                zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
3748            }
3749        }
3750    }
3751
3752    if (EXPECTED(EG(exception) == NULL)) {
3753        ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj TSRMLS_CC));
3754        if (!RETURN_VALUE_USED(opline) || UNEXPECTED(EG(exception) != NULL)) {
3755            zval_ptr_dtor(EX_VAR(opline->result.var));
3756        }
3757    }
3758    FREE_OP1_IF_VAR();
3759    CHECK_EXCEPTION();
3760    ZEND_VM_NEXT_OPCODE();
3761}
3762
3763ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
3764{
3765    USE_OPLINE
3766
3767    SAVE_OPLINE();
3768    if (OP1_TYPE == IS_UNUSED) {
3769        zend_constant *c;
3770        zval *retval;
3771
3772        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
3773            c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
3774        } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) {
3775            if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
3776                char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv));
3777                if (!actual) {
3778                    ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv)));
3779                } else {
3780                    actual++;
3781                    ZVAL_STRINGL(EX_VAR(opline->result.var),
3782                            actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv)));
3783                }
3784                /* non-qualified constant - allow text substitution */
3785                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
3786                        Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var)));
3787                CHECK_EXCEPTION();
3788                ZEND_VM_NEXT_OPCODE();
3789            } else {
3790                zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL_P(opline->op2.zv));
3791            }
3792        } else {
3793            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), c);
3794        }
3795        retval = EX_VAR(opline->result.var);
3796        ZVAL_COPY_VALUE(retval, &c->value);
3797        if (Z_OPT_COPYABLE_P(retval) || Z_OPT_REFCOUNTED_P(retval)) {
3798            if (Z_OPT_COPYABLE_P(retval)) {
3799                zval_copy_ctor_func(retval);
3800            } else {
3801                Z_ADDREF_P(retval);
3802            }
3803        }
3804    } else {
3805        /* class constant */
3806        zend_class_entry *ce;
3807        zval *value;
3808
3809        if (OP1_TYPE == IS_CONST) {
3810            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
3811                value = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
3812                ZVAL_DEREF(value);
3813                ZVAL_DUP(EX_VAR(opline->result.var), value);
3814                ZEND_VM_C_GOTO(constant_fetch_end);
3815            } else if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
3816                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
3817            } else {
3818                ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, 0 TSRMLS_CC);
3819                if (UNEXPECTED(EG(exception) != NULL)) {
3820                    HANDLE_EXCEPTION();
3821                }
3822                if (UNEXPECTED(ce == NULL)) {
3823                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
3824                }
3825                CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
3826            }
3827        } else {
3828            ce = Z_CE_P(EX_VAR(opline->op1.var));
3829            if ((value = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce)) != NULL) {
3830                ZVAL_DEREF(value);
3831                ZVAL_DUP(EX_VAR(opline->result.var), value);
3832                ZEND_VM_C_GOTO(constant_fetch_end);
3833            }
3834        }
3835
3836        if (EXPECTED((value = zend_hash_find(&ce->constants_table, Z_STR_P(opline->op2.zv))) != NULL)) {
3837            ZVAL_DEREF(value);
3838            if (Z_CONSTANT_P(value)) {
3839                EG(scope) = ce;
3840                zval_update_constant(value, 1 TSRMLS_CC);
3841                EG(scope) = EX(scope);
3842            }
3843            if (OP1_TYPE == IS_CONST) {
3844                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), value);
3845            } else {
3846                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value);
3847            }
3848            ZVAL_DUP(EX_VAR(opline->result.var), value);
3849        } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
3850            /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
3851            ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
3852        } else {
3853            zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
3854        }
3855    }
3856ZEND_VM_C_LABEL(constant_fetch_end):
3857    CHECK_EXCEPTION();
3858    ZEND_VM_NEXT_OPCODE();
3859}
3860
3861ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUSED|CV)
3862{
3863    USE_OPLINE
3864    zend_free_op free_op1;
3865    zval *expr_ptr, new_expr;
3866
3867    SAVE_OPLINE();
3868    if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) &&
3869        (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) {
3870        expr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3871        if (OP1_TYPE == IS_VAR && UNEXPECTED(expr_ptr == NULL)) {
3872            zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
3873        }
3874        ZVAL_MAKE_REF(expr_ptr);
3875        Z_ADDREF_P(expr_ptr);
3876        FREE_OP1_VAR_PTR();
3877    } else {
3878        expr_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3879        if (OP1_TYPE == IS_TMP_VAR) {
3880            ZVAL_COPY_VALUE(&new_expr, expr_ptr);
3881            expr_ptr = &new_expr;
3882        } else if (OP1_TYPE == IS_CONST) {
3883            if (!Z_IMMUTABLE_P(expr_ptr)) {
3884                ZVAL_DUP(&new_expr, expr_ptr);
3885                expr_ptr = &new_expr;
3886            }
3887        } else if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(expr_ptr)) {
3888            expr_ptr = Z_REFVAL_P(expr_ptr);
3889            if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr);
3890            FREE_OP1_IF_VAR();
3891        } else if (OP1_TYPE == IS_CV && Z_REFCOUNTED_P(expr_ptr)) {
3892            Z_ADDREF_P(expr_ptr);
3893        }
3894    }
3895
3896    if (OP2_TYPE != IS_UNUSED) {
3897        zend_free_op free_op2;
3898        zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
3899        zend_string *str;
3900        zend_ulong hval;
3901
3902ZEND_VM_C_LABEL(add_again):
3903        switch (Z_TYPE_P(offset)) {
3904            case IS_DOUBLE:
3905                hval = zend_dval_to_lval(Z_DVAL_P(offset));
3906                ZEND_VM_C_GOTO(num_index);
3907            case IS_LONG:
3908                hval = Z_LVAL_P(offset);
3909ZEND_VM_C_LABEL(num_index):
3910                zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr);
3911                break;
3912            case IS_STRING:
3913                str = Z_STR_P(offset);
3914                if (OP2_TYPE != IS_CONST) {
3915                    if (ZEND_HANDLE_NUMERIC(str, hval)) {
3916                        ZEND_VM_C_GOTO(num_index);
3917                    }
3918                }
3919ZEND_VM_C_LABEL(str_index):
3920                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
3921                break;
3922            case IS_NULL:
3923                str = STR_EMPTY_ALLOC();
3924                ZEND_VM_C_GOTO(str_index);
3925            case IS_FALSE:
3926                hval = 0;
3927                ZEND_VM_C_GOTO(num_index);
3928            case IS_TRUE:
3929                hval = 1;
3930                ZEND_VM_C_GOTO(num_index);
3931            case IS_REFERENCE:
3932                offset = Z_REFVAL_P(offset);
3933                ZEND_VM_C_GOTO(add_again);
3934                break;
3935            default:
3936                zend_error(E_WARNING, "Illegal offset type");
3937                zval_ptr_dtor(expr_ptr);
3938                /* do nothing */
3939                break;
3940        }
3941        FREE_OP2();
3942    } else {
3943        zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
3944    }
3945    CHECK_EXCEPTION();
3946    ZEND_VM_NEXT_OPCODE();
3947}
3948
3949ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|UNUSED|CV)
3950{
3951    zval *array;
3952    uint32_t size;
3953    USE_OPLINE
3954
3955    array = EX_VAR(opline->result.var);
3956    if (OP1_TYPE != IS_UNUSED) {
3957        size = opline->extended_value >> ZEND_ARRAY_SIZE_SHIFT;
3958    } else {
3959        size = 0;
3960    }
3961    ZVAL_NEW_ARR(array);
3962    zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0);
3963
3964    if (OP1_TYPE != IS_UNUSED) {
3965        /* Explicitly initialize array as not-packed if flag is set */
3966        if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
3967            zend_hash_real_init(Z_ARRVAL_P(array), 0);
3968        }
3969    }
3970
3971    if (OP1_TYPE == IS_UNUSED) {
3972        ZEND_VM_NEXT_OPCODE();
3973#if !defined(ZEND_VM_SPEC) || OP1_TYPE != IS_UNUSED
3974    } else {
3975        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
3976#endif
3977    }
3978}
3979
3980ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY)
3981{
3982    USE_OPLINE
3983    zend_free_op free_op1;
3984    zval *expr;
3985    zval *result = EX_VAR(opline->result.var);
3986
3987    SAVE_OPLINE();
3988    expr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
3989
3990    switch (opline->extended_value) {
3991        case IS_NULL:
3992            /* This code is taken from convert_to_null. However, it does not seems very useful,
3993             * because a conversion to null always results in the same value. This could only
3994             * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
3995#if 0
3996            if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
3997                ZVAL_DEREF(expr);
3998            }
3999            if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
4000                if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
4001                    break;
4002                }
4003            }
4004#endif
4005
4006            ZVAL_NULL(result);
4007            break;
4008        case _IS_BOOL:
4009            ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
4010            break;
4011        case IS_LONG:
4012            ZVAL_LONG(result, zval_get_long(expr));
4013            break;
4014        case IS_DOUBLE:
4015            ZVAL_DOUBLE(result, zval_get_double(expr));
4016            break;
4017        case IS_STRING:
4018            ZVAL_STR(result, zval_get_string(expr));
4019            break;
4020        default:
4021            /* If value is already of correct type, return it directly */
4022            if (Z_TYPE_P(expr) == opline->extended_value) {
4023                ZVAL_COPY_VALUE(result, expr);
4024                if (OP1_TYPE == IS_CONST) {
4025                    if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
4026                        zval_copy_ctor_func(result);
4027                    }
4028                } else if (OP1_TYPE != IS_TMP_VAR) {
4029                    if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
4030                }
4031
4032                FREE_OP1_IF_VAR();
4033                CHECK_EXCEPTION();
4034                ZEND_VM_NEXT_OPCODE();
4035            }
4036
4037            if (opline->extended_value == IS_ARRAY) {
4038                if (Z_TYPE_P(expr) != IS_OBJECT) {
4039                    ZVAL_NEW_ARR(result);
4040                    zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
4041                    if (Z_TYPE_P(expr) != IS_NULL) {
4042                        expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
4043                        if (OP1_TYPE == IS_CONST) {
4044                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
4045                                zval_copy_ctor_func(expr);
4046                            }
4047                        } else {
4048                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
4049                        }
4050                    }
4051                } else {
4052                    ZVAL_COPY_VALUE(result, expr);
4053                    Z_ADDREF_P(result);
4054                    convert_to_array(result);
4055                }
4056            } else {
4057                if (Z_TYPE_P(expr) != IS_ARRAY) {
4058                    object_init(result);
4059                    if (Z_TYPE_P(expr) != IS_NULL) {
4060                        expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
4061                        if (OP1_TYPE == IS_CONST) {
4062                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
4063                                zval_copy_ctor_func(expr);
4064                            }
4065                        } else {
4066                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
4067                        }
4068                    }
4069                } else {
4070                    ZVAL_COPY_VALUE(result, expr);
4071                    zval_opt_copy_ctor(result);
4072                    convert_to_object(result);
4073                }
4074            }
4075    }
4076
4077    FREE_OP1();
4078    CHECK_EXCEPTION();
4079    ZEND_VM_NEXT_OPCODE();
4080}
4081
4082ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
4083{
4084    USE_OPLINE
4085    zend_op_array *new_op_array=NULL;
4086    zend_free_op free_op1;
4087    zval *inc_filename;
4088    zval tmp_inc_filename;
4089    zend_bool failure_retval=0;
4090
4091    SAVE_OPLINE();
4092    inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R);
4093
4094    ZVAL_UNDEF(&tmp_inc_filename);
4095    if (Z_TYPE_P(inc_filename) != IS_STRING) {
4096        ZVAL_STR(&tmp_inc_filename, zval_get_string(inc_filename));
4097        inc_filename = &tmp_inc_filename;
4098    }
4099
4100    if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
4101        if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
4102            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4103        } else {
4104            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4105        }
4106    } else {
4107        switch (opline->extended_value) {
4108            case ZEND_INCLUDE_ONCE:
4109            case ZEND_REQUIRE_ONCE: {
4110                    zend_file_handle file_handle;
4111                    char *resolved_path;
4112
4113                    resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename) TSRMLS_CC);
4114                    if (resolved_path) {
4115                        failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, (int)strlen(resolved_path));
4116                    } else {
4117                        resolved_path = Z_STRVAL_P(inc_filename);
4118                    }
4119
4120                    if (failure_retval) {
4121                        /* do nothing, file already included */
4122                    } else if (SUCCESS == zend_stream_open(resolved_path, &file_handle TSRMLS_CC)) {
4123
4124                        if (!file_handle.opened_path) {
4125                            file_handle.opened_path = estrdup(resolved_path);
4126                        }
4127
4128                        if (zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, (int)strlen(file_handle.opened_path))) {
4129                            new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
4130                            zend_destroy_file_handle(&file_handle TSRMLS_CC);
4131                        } else {
4132                            zend_file_handle_dtor(&file_handle TSRMLS_CC);
4133                            failure_retval=1;
4134                        }
4135                    } else {
4136                        if (opline->extended_value == ZEND_INCLUDE_ONCE) {
4137                            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4138                        } else {
4139                            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4140                        }
4141                    }
4142                    if (resolved_path != Z_STRVAL_P(inc_filename)) {
4143                        efree(resolved_path);
4144                    }
4145                }
4146                break;
4147            case ZEND_INCLUDE:
4148            case ZEND_REQUIRE:
4149                new_op_array = compile_filename(opline->extended_value, inc_filename TSRMLS_CC);
4150                break;
4151            case ZEND_EVAL: {
4152                    char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
4153
4154                    new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
4155                    efree(eval_desc);
4156                }
4157                break;
4158            EMPTY_SWITCH_DEFAULT_CASE()
4159        }
4160    }
4161    if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
4162        zval_ptr_dtor(&tmp_inc_filename);
4163    }
4164    FREE_OP1();
4165    if (UNEXPECTED(EG(exception) != NULL)) {
4166        HANDLE_EXCEPTION();
4167    } else if (EXPECTED(new_op_array != NULL)) {
4168        zval *return_value = NULL;
4169        zend_execute_data *call;
4170
4171        if (RETURN_VALUE_USED(opline)) {
4172            return_value = EX_VAR(opline->result.var);
4173        }
4174
4175        call = zend_vm_stack_push_call_frame(VM_FRAME_NESTED_CODE,
4176            (zend_function*)new_op_array, 0, EX(called_scope), Z_OBJ(EX(This)), NULL TSRMLS_CC);
4177
4178        if (EX(symbol_table)) {
4179            call->symbol_table = EX(symbol_table);
4180        } else {
4181            call->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
4182        }
4183
4184        call->prev_execute_data = execute_data;
4185        i_init_code_execute_data(call, new_op_array, return_value TSRMLS_CC);
4186        if (EXPECTED(zend_execute_ex == execute_ex)) {
4187            ZEND_VM_ENTER();
4188        } else {
4189            call->frame_info = VM_FRAME_TOP_CODE;
4190            zend_execute_ex(call TSRMLS_CC);
4191        }
4192
4193        destroy_op_array(new_op_array TSRMLS_CC);
4194        efree_size(new_op_array, sizeof(zend_op_array));
4195        if (UNEXPECTED(EG(exception) != NULL)) {
4196            zend_throw_exception_internal(NULL TSRMLS_CC);
4197            HANDLE_EXCEPTION();
4198        }
4199
4200    } else if (RETURN_VALUE_USED(opline)) {
4201        ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
4202    }
4203    ZEND_VM_NEXT_OPCODE();
4204}
4205
4206ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
4207{
4208    USE_OPLINE
4209    zval tmp, *varname;
4210    HashTable *target_symbol_table;
4211    zend_free_op free_op1;
4212
4213    SAVE_OPLINE();
4214    if (OP1_TYPE == IS_CV &&
4215        OP2_TYPE == IS_UNUSED &&
4216        (opline->extended_value & ZEND_QUICK_SET)) {
4217        zval *var = EX_VAR(opline->op1.var);
4218
4219        if (Z_REFCOUNTED_P(var)) {
4220            zend_refcounted *garbage = Z_COUNTED_P(var);
4221
4222            if (!--GC_REFCOUNT(garbage)) {
4223                ZVAL_UNDEF(var);
4224                _zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
4225            } else {
4226                GC_ZVAL_CHECK_POSSIBLE_ROOT(var);
4227                ZVAL_UNDEF(var);
4228            }
4229        } else {
4230            ZVAL_UNDEF(var);
4231        }
4232        CHECK_EXCEPTION();
4233        ZEND_VM_NEXT_OPCODE();
4234    }
4235
4236    varname = GET_OP1_ZVAL_PTR(BP_VAR_R);
4237
4238    ZVAL_UNDEF(&tmp);
4239    if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4240        ZVAL_STR(&tmp, zval_get_string(varname));
4241        varname = &tmp;
4242    }
4243
4244    if (OP2_TYPE != IS_UNUSED) {
4245        zend_class_entry *ce;
4246
4247        if (OP2_TYPE == IS_CONST) {
4248            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4249                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4250            } else {
4251                ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4252                if (UNEXPECTED(EG(exception) != NULL)) {
4253                    if (OP1_TYPE != IS_CONST) {
4254                        zval_dtor(&tmp);
4255                    }
4256                    FREE_OP1();
4257                    HANDLE_EXCEPTION();
4258                }
4259                if (UNEXPECTED(ce == NULL)) {
4260                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op2.zv));
4261                }
4262                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4263            }
4264        } else {
4265            ce = Z_CE_P(EX_VAR(opline->op2.var));
4266        }
4267        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);
4268    } else {
4269        target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4270        zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
4271    }
4272
4273    if (OP1_TYPE != IS_CONST) {
4274        zval_dtor(&tmp);
4275    }
4276    FREE_OP1();
4277    CHECK_EXCEPTION();
4278    ZEND_VM_NEXT_OPCODE();
4279}
4280
4281ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4282{
4283    USE_OPLINE
4284    zend_free_op free_op1, free_op2;
4285    zval *container;
4286    zval *offset;
4287    zend_ulong hval;
4288
4289    SAVE_OPLINE();
4290    container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
4291    if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
4292        zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4293    }
4294    if (OP1_TYPE != IS_UNUSED) {
4295        ZVAL_DEREF(container);
4296        SEPARATE_ZVAL_NOREF(container);
4297    }
4298    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4299
4300    if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
4301        HashTable *ht = Z_ARRVAL_P(container);
4302ZEND_VM_C_LABEL(offset_again):
4303        switch (Z_TYPE_P(offset)) {
4304            case IS_DOUBLE:
4305                hval = zend_dval_to_lval(Z_DVAL_P(offset));
4306                zend_hash_index_del(ht, hval);
4307                break;
4308            case IS_LONG:
4309                hval = Z_LVAL_P(offset);
4310ZEND_VM_C_LABEL(num_index_dim):
4311                zend_hash_index_del(ht, hval);
4312                break;
4313            case IS_STRING:
4314                if (OP2_TYPE != IS_CONST) {
4315                    if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
4316                        ZEND_VM_C_GOTO(num_index_dim);
4317                    }
4318                }
4319                if (ht == &EG(symbol_table).ht) {
4320                    zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
4321                } else {
4322                    zend_hash_del(ht, Z_STR_P(offset));
4323                }
4324                break;
4325            case IS_NULL:
4326                zend_hash_del(ht, STR_EMPTY_ALLOC());
4327                break;
4328            case IS_FALSE:
4329                hval = 0;
4330                ZEND_VM_C_GOTO(num_index_dim);
4331            case IS_TRUE:
4332                hval = 1;
4333                ZEND_VM_C_GOTO(num_index_dim);
4334            case IS_RESOURCE:
4335                hval = Z_RES_HANDLE_P(offset);
4336                ZEND_VM_C_GOTO(num_index_dim);
4337            case IS_REFERENCE:
4338                offset = Z_REFVAL_P(offset);
4339                ZEND_VM_C_GOTO(offset_again);
4340                break;
4341            default:
4342                zend_error(E_WARNING, "Illegal offset type in unset");
4343                break;
4344        }
4345        FREE_OP2();
4346    } else if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
4347        if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) {
4348            zend_error_noreturn(E_ERROR, "Cannot use object as array");
4349        }
4350//???       if (OP2_TYPE == IS_CONST) {
4351//???           zval_copy_ctor(offset);
4352//???       }
4353        Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC);
4354        FREE_OP2();
4355    } else if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
4356        zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4357        ZEND_VM_CONTINUE(); /* bailed out before */
4358    } else {
4359        FREE_OP2();
4360    }
4361    FREE_OP1_VAR_PTR();
4362    CHECK_EXCEPTION();
4363    ZEND_VM_NEXT_OPCODE();
4364}
4365
4366ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4367{
4368    USE_OPLINE
4369    zend_free_op free_op1, free_op2;
4370    zval *container;
4371    zval *offset;
4372
4373    SAVE_OPLINE();
4374    container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
4375    if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
4376        zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4377    }
4378    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4379
4380    ZVAL_DEREF(container);
4381    if (OP1_TYPE == IS_UNUSED || Z_TYPE_P(container) == IS_OBJECT) {
4382        if (Z_OBJ_HT_P(container)->unset_property) {
4383            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);
4384        } else {
4385            zend_error(E_NOTICE, "Trying to unset property of non-object");
4386        }
4387    }
4388    FREE_OP2();
4389    FREE_OP1_VAR_PTR();
4390    CHECK_EXCEPTION();
4391    ZEND_VM_NEXT_OPCODE();
4392}
4393
4394ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
4395{
4396    USE_OPLINE
4397    zend_free_op free_op1;
4398    zval *array_ptr, *array_ref, iterator, tmp;
4399    HashTable *fe_ht;
4400    zend_object_iterator *iter = NULL;
4401    zend_class_entry *ce = NULL;
4402    zend_bool is_empty = 0;
4403
4404    SAVE_OPLINE();
4405
4406    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) &&
4407        (opline->extended_value & ZEND_FE_FETCH_BYREF)) {
4408        array_ptr = array_ref = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R);
4409        ZVAL_DEREF(array_ptr);
4410        if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
4411            SEPARATE_ARRAY(array_ptr);
4412            if (!Z_ISREF_P(array_ref)) {
4413                ZVAL_NEW_REF(array_ref, array_ref);
4414                array_ptr = Z_REFVAL_P(array_ref);
4415            }
4416            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
4417        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4418            ce = Z_OBJCE_P(array_ptr);
4419            if (ce->get_iterator == NULL) {
4420                Z_ADDREF_P(array_ptr);
4421            }
4422            array_ref = array_ptr;
4423        } else {
4424            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
4425        }
4426    } else {
4427        array_ptr = array_ref = GET_OP1_ZVAL_PTR(BP_VAR_R);
4428        ZVAL_DEREF(array_ptr);
4429        if (OP1_TYPE == IS_TMP_VAR) {
4430            ZVAL_COPY_VALUE(&tmp, array_ptr);
4431            if (Z_OPT_IMMUTABLE_P(&tmp)) {
4432                zval_copy_ctor_func(&tmp);
4433            }
4434            array_ref = array_ptr = &tmp;
4435            if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4436                ce = Z_OBJCE_P(array_ptr);
4437                if (ce && ce->get_iterator) {
4438                    Z_DELREF_P(array_ref);
4439                }
4440            }
4441        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4442            ce = Z_OBJCE_P(array_ptr);
4443            if (!ce->get_iterator) {
4444                if (OP1_TYPE == IS_CV) {
4445                    Z_ADDREF_P(array_ref);
4446                }
4447            }
4448        } else if (Z_IMMUTABLE_P(array_ref)) {
4449            if (OP1_TYPE == IS_CV) {
4450                zval_copy_ctor_func(array_ref);
4451                Z_ADDREF_P(array_ref);
4452            } else {
4453                ZVAL_COPY_VALUE(&tmp, array_ref);
4454                zval_copy_ctor_func(&tmp);
4455                array_ptr = array_ref = &tmp;
4456            }
4457        } else if (Z_REFCOUNTED_P(array_ref)) {
4458            if (OP1_TYPE == IS_CONST ||
4459                       (OP1_TYPE == IS_CV &&
4460                        !Z_ISREF_P(array_ref) &&
4461                        Z_REFCOUNT_P(array_ref) > 1) ||
4462                       (OP1_TYPE == IS_VAR &&
4463                        !Z_ISREF_P(array_ref) &&
4464                        Z_REFCOUNT_P(array_ref) > 2)) {
4465                if (OP1_TYPE == IS_VAR) {
4466                    Z_DELREF_P(array_ref);
4467                }
4468                ZVAL_DUP(&tmp, array_ref);
4469                array_ptr = array_ref = &tmp;
4470            } else if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
4471                if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
4472                    ZVAL_UNREF(array_ref);
4473                    array_ptr = array_ref;
4474                }
4475                if (Z_IMMUTABLE_P(array_ptr)) {
4476                    zval_copy_ctor_func(array_ptr);
4477                } else if (Z_ISREF_P(array_ref) &&
4478                           Z_COPYABLE_P(array_ptr) &&
4479                           Z_REFCOUNT_P(array_ptr) > 1) {
4480                    Z_DELREF_P(array_ptr);
4481                    zval_copy_ctor_func(array_ptr);
4482                }
4483                if (OP1_TYPE == IS_CV) {
4484                    Z_ADDREF_P(array_ref);
4485                }
4486            }
4487        }
4488    }
4489
4490    if (ce && ce->get_iterator) {
4491        iter = ce->get_iterator(ce, array_ptr, opline->extended_value & ZEND_FE_FETCH_BYREF TSRMLS_CC);
4492
4493        if (OP1_TYPE == IS_VAR && !(opline->extended_value & ZEND_FE_FETCH_BYREF)) {
4494            FREE_OP1_IF_VAR();
4495        }
4496        if (iter && EXPECTED(EG(exception) == NULL)) {
4497            ZVAL_OBJ(&iterator, &iter->std);
4498            array_ptr = array_ref = &iterator;
4499        } else {
4500            if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4501                FREE_OP1_VAR_PTR();
4502            }
4503            if (!EG(exception)) {
4504                zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val);
4505            }
4506            zend_throw_exception_internal(NULL TSRMLS_CC);
4507            HANDLE_EXCEPTION();
4508        }
4509    }
4510
4511    ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
4512
4513    if (iter) {
4514        iter->index = 0;
4515        if (iter->funcs->rewind) {
4516            iter->funcs->rewind(iter TSRMLS_CC);
4517            if (UNEXPECTED(EG(exception) != NULL)) {
4518                zval_ptr_dtor(array_ref);
4519                if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4520                    FREE_OP1_VAR_PTR();
4521                }
4522                HANDLE_EXCEPTION();
4523            }
4524        }
4525        is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;
4526        if (UNEXPECTED(EG(exception) != NULL)) {
4527            zval_ptr_dtor(array_ref);
4528            if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4529                FREE_OP1_VAR_PTR();
4530            }
4531            HANDLE_EXCEPTION();
4532        }
4533        iter->index = -1; /* will be set to 0 before using next handler */
4534    } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
4535        HashPointer *ptr = (HashPointer*)EX_VAR((opline+2)->op1.var);
4536        HashPosition pos = 0;
4537        Bucket *p;
4538
4539        while (1) {
4540            if (pos >= fe_ht->nNumUsed) {
4541                is_empty = 1;
4542                if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4543                    FREE_OP1_VAR_PTR();
4544                }
4545                ZEND_VM_JMP(opline->op2.jmp_addr);
4546            }
4547            p = fe_ht->arData + pos;
4548            if (Z_TYPE(p->val) == IS_UNDEF ||
4549                (Z_TYPE(p->val) == IS_INDIRECT &&
4550                 Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)) {
4551                pos++;
4552                continue;
4553            }
4554            if (!ce ||
4555                !p->key ||
4556                zend_check_property_access(Z_OBJ_P(array_ptr), p->key TSRMLS_CC) == SUCCESS) {
4557                break;
4558            }
4559            pos++;
4560        }
4561        fe_ht->nInternalPointer = pos;
4562        ptr->pos = pos;
4563        ptr->ht = fe_ht;
4564        ptr->h = fe_ht->arData[pos].h;
4565        ptr->key = fe_ht->arData[pos].key;
4566        is_empty = 0;
4567    } else {
4568        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
4569        is_empty = 1;
4570    }
4571
4572    if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4573        FREE_OP1_VAR_PTR();
4574    }
4575    if (is_empty) {
4576        ZEND_VM_JMP(opline->op2.jmp_addr);
4577    } else {
4578        CHECK_EXCEPTION();
4579        ZEND_VM_NEXT_OPCODE();
4580    }
4581}
4582
4583ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
4584{
4585    USE_OPLINE
4586    zend_free_op free_op1;
4587    zval *array, *array_ref;
4588    zval *value;
4589    HashTable *fe_ht;
4590    HashPointer *ptr;
4591    HashPosition pos;
4592    Bucket *p;
4593
4594    array = array_ref = EX_VAR(opline->op1.var);
4595    if (Z_ISREF_P(array)) {
4596        array = Z_REFVAL_P(array);
4597        // TODO: referenced value might be changed to different array ???
4598        if (Z_IMMUTABLE_P(array)) {
4599            zval_copy_ctor_func(array);
4600        }
4601    }
4602
4603    SAVE_OPLINE();
4604
4605    if (EXPECTED(Z_TYPE_P(array) == IS_ARRAY)) {
4606        fe_ht = Z_ARRVAL_P(array);
4607        ptr = (HashPointer*)EX_VAR((opline+1)->op1.var);
4608        pos = ptr->pos;
4609        if (UNEXPECTED(pos == INVALID_IDX)) {
4610            /* reached end of iteration */
4611            ZEND_VM_JMP(opline->op2.jmp_addr);
4612        } else if (UNEXPECTED(ptr->ht != fe_ht)) {
4613            ptr->ht = fe_ht;
4614            pos = 0;
4615        } else if (UNEXPECTED(fe_ht->nInternalPointer != ptr->pos)) {
4616            if (fe_ht->u.flags & HASH_FLAG_PACKED) {
4617                pos = ptr->h;
4618            } else {
4619                pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask];
4620                while (1) {
4621                    if (pos == INVALID_IDX) {
4622                        pos = fe_ht->nInternalPointer;
4623                        break;
4624                    } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) {
4625                        break;
4626                    }
4627                    pos = Z_NEXT(fe_ht->arData[pos].val);
4628                }
4629            }
4630        }
4631        while (1) {
4632            if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
4633                /* reached end of iteration */
4634                ZEND_VM_JMP(opline->op2.jmp_addr);
4635            }
4636            p = fe_ht->arData + pos;
4637            value = &p->val;
4638            if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4639                pos++;
4640                continue;
4641            } else if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
4642                value = Z_INDIRECT_P(value);
4643                if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4644                    pos++;
4645                    continue;
4646                }
4647            }
4648            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4649                ZVAL_MAKE_REF(value);
4650                Z_ADDREF_P(value);
4651                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4652            } else {
4653                ZVAL_COPY(EX_VAR(opline->result.var), value);
4654            }
4655            if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4656                if (!p->key) {
4657                    ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
4658                } else {
4659                    ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
4660                }
4661            }
4662            break;
4663        }
4664        do {
4665            pos++;
4666            if (pos >= fe_ht->nNumUsed) {
4667                fe_ht->nInternalPointer = ptr->pos = INVALID_IDX;
4668                ZEND_VM_INC_OPCODE();
4669                ZEND_VM_NEXT_OPCODE();
4670            }
4671            p = fe_ht->arData + pos;
4672        } while (Z_TYPE(p->val) == IS_UNDEF ||
4673                 (Z_TYPE(p->val) == IS_INDIRECT &&
4674                  Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF));
4675        fe_ht->nInternalPointer = ptr->pos = pos;
4676        ptr->h = fe_ht->arData[pos].h;
4677        ptr->key = fe_ht->arData[pos].key;
4678        ZEND_VM_INC_OPCODE();
4679        ZEND_VM_NEXT_OPCODE();
4680    } else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) {
4681        zend_object_iterator *iter;
4682
4683        if ((iter = zend_iterator_unwrap(array TSRMLS_CC)) == NULL) {
4684            /* plain object */
4685            zend_object *zobj = Z_OBJ_P(array);
4686
4687            fe_ht = Z_OBJPROP_P(array);
4688            ptr = (HashPointer*)EX_VAR((opline+1)->op1.var);
4689            pos = ptr->pos;
4690            if (pos == INVALID_IDX) {
4691                /* reached end of iteration */
4692                ZEND_VM_JMP(opline->op2.jmp_addr);
4693            } else if (UNEXPECTED(ptr->ht != fe_ht)) {
4694                ptr->ht = fe_ht;
4695                pos = 0;
4696            } else if (UNEXPECTED(fe_ht->nInternalPointer != ptr->pos)) {
4697                if (fe_ht->u.flags & HASH_FLAG_PACKED) {
4698                    pos = ptr->h;
4699                } else {
4700                    pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask];
4701                    while (1) {
4702                        if (pos == INVALID_IDX) {
4703                            pos = fe_ht->nInternalPointer;
4704                            break;
4705                        } else if (fe_ht->arData[pos].h == ptr->h && fe_ht->arData[pos].key == ptr->key) {
4706                            break;
4707                        }
4708                        pos = Z_NEXT(fe_ht->arData[pos].val);
4709                    }
4710                }
4711            }
4712            while (1) {
4713                if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
4714                    /* reached end of iteration */
4715                    ZEND_VM_JMP(opline->op2.jmp_addr);
4716                }
4717
4718                p = fe_ht->arData + pos;
4719                value = &p->val;
4720                if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4721                    pos++;
4722                    continue;
4723                } else if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
4724                    value = Z_INDIRECT_P(value);
4725                    if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4726                        pos++;
4727                        continue;
4728                    }
4729                }
4730
4731                if (UNEXPECTED(!p->key)) {
4732                    if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4733                        ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
4734                    }
4735                    break;
4736                } else if (zend_check_property_access(zobj, p->key TSRMLS_CC) == SUCCESS) {
4737                    if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4738                        if (p->key->val[0]) {
4739                            ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
4740                        } else {
4741                            const char *class_name, *prop_name;
4742                            size_t prop_name_len;
4743                            zend_unmangle_property_name_ex(
4744                                p->key, &class_name, &prop_name, &prop_name_len);
4745                            ZVAL_STRINGL(EX_VAR((opline+1)->result.var), prop_name, prop_name_len);
4746                        }
4747                    }
4748                    break;
4749                }
4750                pos++;
4751            }
4752            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4753                ZVAL_MAKE_REF(value);
4754                Z_ADDREF_P(value);
4755                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4756            } else {
4757                ZVAL_COPY(EX_VAR(opline->result.var), value);
4758            }
4759            do {
4760                pos++;
4761                if (pos >= fe_ht->nNumUsed) {
4762                    fe_ht->nInternalPointer = ptr->pos = INVALID_IDX;
4763                    ZEND_VM_INC_OPCODE();
4764                    ZEND_VM_NEXT_OPCODE();
4765                }
4766                p = fe_ht->arData + pos;
4767            } while (Z_TYPE(p->val) == IS_UNDEF ||
4768                     (Z_TYPE(p->val) == IS_INDIRECT &&
4769                      Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF) ||
4770                     (EXPECTED(p->key != NULL) &&
4771                      zend_check_property_access(zobj, p->key TSRMLS_CC) == FAILURE));
4772            fe_ht->nInternalPointer = ptr->pos = pos;
4773            ptr->h = fe_ht->arData[pos].h;
4774            ptr->key = fe_ht->arData[pos].key;
4775            ZEND_VM_INC_OPCODE();
4776            ZEND_VM_NEXT_OPCODE();
4777        } else {
4778            /* !iter happens from exception */
4779            if (iter && ++iter->index > 0) {
4780                /* This could cause an endless loop if index becomes zero again.
4781                 * In case that ever happens we need an additional flag. */
4782                iter->funcs->move_forward(iter TSRMLS_CC);
4783                if (UNEXPECTED(EG(exception) != NULL)) {
4784                    zval_ptr_dtor(array_ref);
4785                    HANDLE_EXCEPTION();
4786                }
4787            }
4788            /* If index is zero we come from FE_RESET and checked valid() already. */
4789            if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
4790                /* reached end of iteration */
4791                if (UNEXPECTED(EG(exception) != NULL)) {
4792                    zval_ptr_dtor(array_ref);
4793                    HANDLE_EXCEPTION();
4794                }
4795                ZEND_VM_JMP(opline->op2.jmp_addr);
4796            }
4797            value = iter->funcs->get_current_data(iter TSRMLS_CC);
4798            if (UNEXPECTED(EG(exception) != NULL)) {
4799                zval_ptr_dtor(array_ref);
4800                HANDLE_EXCEPTION();
4801            }
4802            if (!value) {
4803                /* failure in get_current_data */
4804                ZEND_VM_JMP(opline->op2.jmp_addr);
4805            }
4806            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4807                ZVAL_MAKE_REF(value);
4808                Z_ADDREF_P(value);
4809                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4810            } else {
4811                ZVAL_COPY(EX_VAR(opline->result.var), value);
4812            }
4813            if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4814                if (iter->funcs->get_current_key) {
4815                    iter->funcs->get_current_key(iter, EX_VAR((opline+1)->result.var) TSRMLS_CC);
4816                    if (UNEXPECTED(EG(exception) != NULL)) {
4817                        zval_ptr_dtor(array_ref);
4818                        HANDLE_EXCEPTION();
4819                    }
4820                } else {
4821                    ZVAL_LONG(EX_VAR((opline+1)->result.var), iter->index);
4822                }
4823            }
4824            ZEND_VM_INC_OPCODE();
4825            ZEND_VM_NEXT_OPCODE();
4826        }
4827    } else {
4828        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
4829        ZEND_VM_JMP(opline->op2.jmp_addr);
4830    }
4831}
4832
4833ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
4834{
4835    USE_OPLINE
4836    zval *value;
4837
4838    SAVE_OPLINE();
4839    if (OP1_TYPE == IS_CV &&
4840        OP2_TYPE == IS_UNUSED &&
4841        (opline->extended_value & ZEND_QUICK_SET)) {
4842        value = EX_VAR(opline->op1.var);
4843        if (opline->extended_value & ZEND_ISSET) {
4844            ZVAL_BOOL(EX_VAR(opline->result.var),
4845                Z_TYPE_P(value) > IS_NULL &&
4846                (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL));
4847        } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4848            ZVAL_BOOL(EX_VAR(opline->result.var),
4849                !i_zend_is_true(value TSRMLS_CC));
4850            CHECK_EXCEPTION();
4851        }
4852        ZEND_VM_NEXT_OPCODE();
4853    } else {
4854        zend_free_op free_op1;
4855        zval tmp, *varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
4856
4857        if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4858            ZVAL_STR(&tmp, zval_get_string(varname));
4859            varname = &tmp;
4860        }
4861
4862        if (OP2_TYPE != IS_UNUSED) {
4863            zend_class_entry *ce;
4864
4865            if (OP2_TYPE == IS_CONST) {
4866                if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4867                    ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4868                } else {
4869                    ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4870                    if (UNEXPECTED(ce == NULL)) {
4871                        CHECK_EXCEPTION();
4872                        ZEND_VM_NEXT_OPCODE();
4873                    }
4874                    CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4875                }
4876            } else {
4877                ce = Z_CE_P(EX_VAR(opline->op2.var));
4878            }
4879            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);
4880        } else {
4881            HashTable *target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4882            value = zend_hash_find_ind(target_symbol_table, Z_STR_P(varname));
4883        }
4884
4885        if (OP1_TYPE != IS_CONST && varname == &tmp) {
4886            zval_dtor(&tmp);
4887        }
4888        FREE_OP1();
4889
4890        if (opline->extended_value & ZEND_ISSET) {
4891            ZVAL_BOOL(EX_VAR(opline->result.var),
4892                value && Z_TYPE_P(value) > IS_NULL &&
4893                (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL));
4894        } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4895            ZVAL_BOOL(EX_VAR(opline->result.var),
4896                !value || !i_zend_is_true(value TSRMLS_CC));
4897        }
4898
4899        CHECK_EXCEPTION();
4900        ZEND_VM_NEXT_OPCODE();
4901    }
4902}
4903
4904ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4905{
4906    USE_OPLINE
4907    zend_free_op free_op1, free_op2;
4908    zval *container;
4909    int result;
4910    zend_ulong hval;
4911    zval *offset;
4912
4913    SAVE_OPLINE();
4914    container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS);
4915    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4916
4917    if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
4918        HashTable *ht = Z_ARRVAL_P(container);
4919        zval *value;
4920        zend_string *str;
4921
4922ZEND_VM_C_LABEL(isset_again):
4923        if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
4924            str = Z_STR_P(offset);
4925            if (OP2_TYPE != IS_CONST) {
4926                if (ZEND_HANDLE_NUMERIC(str, hval)) {
4927                    ZEND_VM_C_GOTO(num_index_prop);
4928                }
4929            }
4930ZEND_VM_C_LABEL(str_index_prop):
4931            value = zend_hash_find_ind(ht, str);
4932        } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4933            hval = Z_LVAL_P(offset);
4934ZEND_VM_C_LABEL(num_index_prop):
4935            value = zend_hash_index_find(ht, hval);
4936        } else {
4937            switch (Z_TYPE_P(offset)) {
4938                case IS_DOUBLE:
4939                    hval = zend_dval_to_lval(Z_DVAL_P(offset));
4940                    ZEND_VM_C_GOTO(num_index_prop);
4941                case IS_NULL:
4942                    str = STR_EMPTY_ALLOC();
4943                    ZEND_VM_C_GOTO(str_index_prop);
4944                case IS_FALSE:
4945                    hval = 0;
4946                    ZEND_VM_C_GOTO(num_index_prop);
4947                case IS_TRUE:
4948                    hval = 1;
4949                    ZEND_VM_C_GOTO(num_index_prop);
4950                case IS_RESOURCE:
4951                    hval = Z_RES_HANDLE_P(offset);
4952                    ZEND_VM_C_GOTO(num_index_prop);
4953                case IS_REFERENCE:
4954                    offset = Z_REFVAL_P(offset);
4955                    ZEND_VM_C_GOTO(isset_again);
4956                default:
4957                    zend_error(E_WARNING, "Illegal offset type in isset or empty");
4958                    value = NULL;
4959                    break;
4960            }
4961        }
4962
4963        if (opline->extended_value & ZEND_ISSET) {
4964            /* > IS_NULL means not IS_UNDEF and not IS_NULL */
4965            result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
4966                (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
4967        } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4968            result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
4969        }
4970    } else if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
4971        if (EXPECTED(Z_OBJ_HT_P(container)->has_dimension)) {
4972            result = Z_OBJ_HT_P(container)->has_dimension(container, offset, (opline->extended_value & ZEND_ISSET) == 0 TSRMLS_CC);
4973        } else {
4974            zend_error(E_NOTICE, "Trying to check element of non-array");
4975            result = 0;
4976        }
4977        if ((opline->extended_value & ZEND_ISSET) == 0) {
4978            result = !result;
4979        }
4980    } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { /* string offsets */
4981        zval tmp;
4982
4983        result = 0;
4984        if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
4985            if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
4986                ZVAL_DEREF(offset);
4987            }
4988            if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
4989                    || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
4990                        && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
4991                ZVAL_DUP(&tmp, offset);
4992                convert_to_long(&tmp);
4993                offset = &tmp;
4994            }
4995        }
4996        if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4997            if (offset->value.lval >= 0 && (size_t)offset->value.lval < Z_STRLEN_P(container)) {
4998                if ((opline->extended_value & ZEND_ISSET) ||
4999                    Z_STRVAL_P(container)[offset->value.lval] != '0') {
5000                    result = 1;
5001                }
5002            }
5003        }
5004        if ((opline->extended_value & ZEND_ISSET) == 0) {
5005            result = !result;
5006        }
5007    } else {
5008        result = ((opline->extended_value & ZEND_ISSET) == 0);
5009    }
5010
5011    FREE_OP2();
5012    ZVAL_BOOL(EX_VAR(opline->result.var), result);
5013    FREE_OP1();
5014    CHECK_EXCEPTION();
5015    ZEND_VM_NEXT_OPCODE();
5016}
5017
5018ZEND_VM_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
5019{
5020    USE_OPLINE
5021    zend_free_op free_op1, free_op2;
5022    zval *container;
5023    int result;
5024    zval *offset;
5025
5026    SAVE_OPLINE();
5027    container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS);
5028    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
5029
5030    if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
5031        if (EXPECTED(Z_OBJ_HT_P(container)->has_property)) {
5032            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);
5033        } else {
5034            zend_error(E_NOTICE, "Trying to check property of non-object");
5035            result = 0;
5036        }
5037        if ((opline->extended_value & ZEND_ISSET) == 0) {
5038            result = !result;
5039        }
5040    } else {
5041        result = ((opline->extended_value & ZEND_ISSET) == 0);
5042    }
5043
5044    FREE_OP2();
5045    ZVAL_BOOL(EX_VAR(opline->result.var), result);
5046    FREE_OP1();
5047    CHECK_EXCEPTION();
5048    ZEND_VM_NEXT_OPCODE();
5049}
5050
5051ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMP|VAR|UNUSED|CV, ANY)
5052{
5053#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
5054    USE_OPLINE
5055
5056    SAVE_OPLINE();
5057    if (OP1_TYPE != IS_UNUSED) {
5058        zend_free_op free_op1;
5059        zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
5060
5061        if (Z_TYPE_P(ptr) == IS_LONG) {
5062            EG(exit_status) = Z_LVAL_P(ptr);
5063        } else {
5064            zend_print_variable(ptr TSRMLS_CC);
5065        }
5066        FREE_OP1();
5067    }
5068#endif
5069    zend_bailout();
5070    ZEND_VM_NEXT_OPCODE(); /* Never reached */
5071}
5072
5073ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY)
5074{
5075    USE_OPLINE
5076
5077    SAVE_OPLINE();
5078    ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));
5079    if (EX(silence_op_num) == -1) {
5080        EX(silence_op_num) = opline->op2.num;
5081        EX(old_error_reporting) = EG(error_reporting);
5082    }
5083
5084    if (EG(error_reporting)) {
5085        do {
5086            EG(error_reporting) = 0;
5087            if (!EG(error_reporting_ini_entry)) {
5088                zend_ini_entry *p = zend_hash_str_find_ptr(EG(ini_directives), "error_reporting", sizeof("error_reporting")-1);
5089                if (p) {
5090                    EG(error_reporting_ini_entry) = p;
5091                } else {
5092                    break;
5093                }
5094            }
5095            if (!EG(error_reporting_ini_entry)->modified) {
5096                if (!EG(modified_ini_directives)) {
5097                    ALLOC_HASHTABLE(EG(modified_ini_directives));
5098                    zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
5099                }
5100                if (EXPECTED(zend_hash_str_add_ptr(EG(modified_ini_directives), "error_reporting", sizeof("error_reporting")-1, EG(error_reporting_ini_entry)) != NULL)) {
5101                    EG(error_reporting_ini_entry)->orig_value = EG(error_reporting_ini_entry)->value;
5102                    EG(error_reporting_ini_entry)->orig_modifiable = EG(error_reporting_ini_entry)->modifiable;
5103                    EG(error_reporting_ini_entry)->modified = 1;
5104                }
5105            }
5106        } while (0);
5107    }
5108<