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