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_nested_call;
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        if (!Z_DELREF(EG(This))) {
2714            _zval_dtor_func_for_ptr(Z_COUNTED(EG(This)) ZEND_FILE_LINE_CC);
2715        } else if (UNEXPECTED(!Z_GC_INFO(EG(This)))) {
2716            gc_possible_root(Z_COUNTED(EG(This)) TSRMLS_CC);
2717        }
2718    }
2719    Z_OBJ(EG(This)) = EX(object);
2720    EG(scope) = EX(scope);
2721
2722ZEND_VM_C_LABEL(fcall_end):
2723    if (UNEXPECTED(EG(exception) != NULL)) {
2724        zend_throw_exception_internal(NULL TSRMLS_CC);
2725        if (RETURN_VALUE_USED(opline)) {
2726            zval_ptr_dtor(EX_VAR(opline->result.var));
2727        }
2728        HANDLE_EXCEPTION();
2729    }
2730
2731    ZEND_VM_NEXT_OPCODE();
2732}
2733
2734ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
2735{
2736    USE_OPLINE
2737    zval *retval_ptr;
2738    zend_free_op free_op1;
2739
2740    SAVE_OPLINE();
2741    retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2742
2743    if (!EX(return_value)) {
2744        FREE_OP1();
2745    } else {
2746        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) {
2747            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2748            if (OP1_TYPE == IS_CONST) {
2749                if (UNEXPECTED(Z_OPT_COPYABLE_P(EX(return_value)))) {
2750                    zval_copy_ctor_func(EX(return_value));
2751                }
2752            }
2753        } else if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(retval_ptr)) {
2754            ZVAL_COPY(EX(return_value), Z_REFVAL_P(retval_ptr));
2755            FREE_OP1_IF_VAR();
2756        } else {
2757            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2758            if (OP1_TYPE == IS_CV) {
2759                if (Z_OPT_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2760            }
2761        }
2762    }
2763    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
2764}
2765
2766ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
2767{
2768    USE_OPLINE
2769    zval *retval_ptr;
2770    zend_free_op free_op1;
2771
2772    SAVE_OPLINE();
2773
2774    do {
2775        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR ||
2776            (OP1_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
2777            /* Not supposed to happen, but we'll allow it */
2778            zend_error(E_NOTICE, "Only variable references should be returned by reference");
2779
2780            retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2781            if (!EX(return_value)) {
2782                if (OP1_TYPE == IS_TMP_VAR) {
2783                    FREE_OP1();
2784                }
2785            } else {
2786                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
2787                if (OP1_TYPE != IS_TMP_VAR) {
2788                    zval_opt_copy_ctor_no_imm(EX(return_value));
2789                }
2790            }
2791            break;
2792        }
2793
2794        retval_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
2795
2796        if (OP1_TYPE == IS_VAR && UNEXPECTED(retval_ptr == NULL)) {
2797            zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");
2798        }
2799
2800        if (OP1_TYPE == IS_VAR && !Z_ISREF_P(retval_ptr)) {
2801            if (opline->extended_value == ZEND_RETURNS_FUNCTION &&
2802                (Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF)) {
2803            } else {
2804                zend_error(E_NOTICE, "Only variable references should be returned by reference");
2805                if (EX(return_value)) {
2806                    ZVAL_NEW_REF(EX(return_value), retval_ptr);
2807                    if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
2808                }
2809                break;
2810            }
2811        }
2812
2813        if (EX(return_value)) {
2814            ZVAL_MAKE_REF(retval_ptr);
2815            Z_ADDREF_P(retval_ptr);
2816            ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
2817        }
2818    } while (0);
2819
2820    FREE_OP1_VAR_PTR();
2821    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
2822}
2823
2824ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY)
2825{
2826    /* The generator object is stored in EX(return_value) */
2827    zend_generator *generator = (zend_generator *) EX(return_value);
2828
2829    /* Close the generator to free up resources */
2830    zend_generator_close(generator, 1 TSRMLS_CC);
2831
2832    /* Pass execution back to handling code */
2833    ZEND_VM_RETURN();
2834}
2835
2836ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
2837{
2838    USE_OPLINE
2839    zval *value;
2840    zend_free_op free_op1;
2841
2842    SAVE_OPLINE();
2843    value = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
2844
2845    if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
2846        if (UNEXPECTED(EG(exception) != NULL)) {
2847            HANDLE_EXCEPTION();
2848        }
2849        zend_error_noreturn(E_ERROR, "Can only throw objects");
2850    }
2851
2852    zend_exception_save(TSRMLS_C);
2853    if (OP1_TYPE != IS_TMP_VAR) {
2854        if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
2855    }
2856
2857    zend_throw_exception_object(value TSRMLS_CC);
2858    zend_exception_restore(TSRMLS_C);
2859    FREE_OP1_IF_VAR();
2860    HANDLE_EXCEPTION();
2861}
2862
2863ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
2864{
2865    USE_OPLINE
2866    zend_class_entry *ce, *catch_ce;
2867    zend_object *exception;
2868
2869    SAVE_OPLINE();
2870    /* Check whether an exception has been thrown, if not, jump over code */
2871    zend_exception_restore(TSRMLS_C);
2872    if (EG(exception) == NULL) {
2873        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
2874        ZEND_VM_CONTINUE(); /* CHECK_ME */
2875    }
2876    if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
2877        catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
2878    } else {
2879        catch_ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD TSRMLS_CC);
2880
2881        CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), catch_ce);
2882    }
2883    ce = zend_get_class_entry(EG(exception) TSRMLS_CC);
2884
2885#ifdef HAVE_DTRACE
2886    if (DTRACE_EXCEPTION_CAUGHT_ENABLED()) {
2887        DTRACE_EXCEPTION_CAUGHT((char *)ce->name);
2888    }
2889#endif /* HAVE_DTRACE */
2890
2891    if (ce != catch_ce) {
2892        if (!instanceof_function(ce, catch_ce TSRMLS_CC)) {
2893            if (opline->result.num) {
2894                zend_throw_exception_internal(NULL TSRMLS_CC);
2895                HANDLE_EXCEPTION();
2896            }
2897            ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
2898            ZEND_VM_CONTINUE(); /* CHECK_ME */
2899        }
2900    }
2901
2902    exception = EG(exception);
2903    if (Z_REFCOUNTED_P(EX_VAR(opline->op2.var))) {
2904        zval_ptr_dtor(EX_VAR(opline->op2.var));
2905    }
2906    ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
2907    if (UNEXPECTED(EG(exception) != exception)) {
2908        GC_REFCOUNT(EG(exception))++;
2909        HANDLE_EXCEPTION();
2910    } else {
2911        EG(exception) = NULL;
2912        ZEND_VM_NEXT_OPCODE();
2913    }
2914}
2915
2916ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY)
2917{
2918    USE_OPLINE
2919    zval *value, *arg;
2920    zend_free_op free_op1;
2921
2922    SAVE_OPLINE();
2923    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
2924    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2925    EX(call)->num_args = opline->op2.num;
2926    ZVAL_COPY_VALUE(arg, value);
2927    if (OP1_TYPE == IS_CONST) {
2928        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2929            zval_copy_ctor_func(arg);
2930        }
2931    }
2932    ZEND_VM_NEXT_OPCODE();
2933}
2934
2935ZEND_VM_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, ANY)
2936{
2937    USE_OPLINE
2938    zval *value, *arg;
2939    zend_free_op free_op1;
2940
2941    SAVE_OPLINE();
2942    if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
2943        zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
2944    }
2945    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
2946    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2947    EX(call)->num_args = opline->op2.num;
2948    ZVAL_COPY_VALUE(arg, value);
2949    if (OP1_TYPE == IS_CONST) {
2950        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
2951            zval_copy_ctor_func(arg);
2952        }
2953    }
2954    ZEND_VM_NEXT_OPCODE();
2955}
2956
2957ZEND_VM_HANDLER(117, ZEND_SEND_VAR, VAR|CV, ANY)
2958{
2959    USE_OPLINE
2960    zval *varptr, *arg;
2961    zend_free_op free_op1;
2962
2963    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2964    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
2965    EX(call)->num_args = opline->op2.num;
2966    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
2967        ZVAL_COPY(arg, Z_REFVAL_P(varptr));
2968        FREE_OP1();
2969    } else {
2970        ZVAL_COPY_VALUE(arg, varptr);
2971        if (OP1_TYPE == IS_CV) {
2972            if (Z_OPT_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
2973        }
2974    }
2975    ZEND_VM_NEXT_OPCODE();
2976}
2977
2978ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
2979{
2980    USE_OPLINE
2981    zend_free_op free_op1;
2982    zval *varptr, *arg;
2983
2984    SAVE_OPLINE();
2985    if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
2986        if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) {
2987            ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
2988        }
2989    } else {
2990        if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
2991            ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
2992        }
2993    }
2994
2995    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
2996    if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
2997         (Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
2998        (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
2999
3000        ZVAL_MAKE_REF(varptr);
3001        if (OP1_TYPE == IS_CV) {
3002            Z_ADDREF_P(varptr);
3003        }
3004        arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3005        EX(call)->num_args = opline->op2.num;
3006        ZVAL_COPY_VALUE(arg, varptr);
3007    } else {
3008        if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
3009            !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
3010            !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3011            zend_error(E_STRICT, "Only variables should be passed by reference");
3012        }
3013        arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3014        EX(call)->num_args = opline->op2.num;
3015        ZVAL_COPY(arg, varptr);
3016        FREE_OP1_IF_VAR();
3017    }
3018    CHECK_EXCEPTION();
3019    ZEND_VM_NEXT_OPCODE();
3020}
3021
3022ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
3023{
3024    USE_OPLINE
3025    zend_free_op free_op1;
3026    zval *varptr, *arg;
3027
3028    SAVE_OPLINE();
3029    varptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3030
3031    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == NULL)) {
3032        zend_error_noreturn(E_ERROR, "Only variables can be passed by reference");
3033    }
3034
3035    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3036    EX(call)->num_args = opline->op2.num;
3037    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == &EG(error_zval))) {
3038        ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
3039        ZEND_VM_NEXT_OPCODE();
3040    }
3041
3042    if (Z_ISREF_P(varptr)) {
3043        Z_ADDREF_P(varptr);
3044        ZVAL_COPY_VALUE(arg, varptr);
3045    } else if (OP1_TYPE == IS_VAR &&
3046        UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) {
3047        ZVAL_COPY_VALUE(arg, varptr);
3048        ZVAL_MAKE_REF(arg);
3049    } else {
3050        ZVAL_MAKE_REF(varptr);
3051        Z_ADDREF_P(varptr);
3052        ZVAL_REF(arg, Z_REF_P(varptr));
3053    }
3054
3055    FREE_OP1_VAR_PTR();
3056    ZEND_VM_NEXT_OPCODE();
3057}
3058
3059ZEND_VM_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, ANY)
3060{
3061    USE_OPLINE
3062    zval *varptr, *arg;
3063    zend_free_op free_op1;
3064
3065    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3066        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
3067    }
3068    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3069    arg = ZEND_CALL_ARG(EX(call), opline->op2.num);
3070    EX(call)->num_args = opline->op2.num;
3071    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(varptr)) {
3072        ZVAL_COPY(arg, Z_REFVAL_P(varptr));
3073        FREE_OP1();
3074    } else {
3075        ZVAL_COPY_VALUE(arg, varptr);
3076        if (OP1_TYPE == IS_CV) {
3077            if (Z_OPT_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
3078        }
3079    }
3080    ZEND_VM_NEXT_OPCODE();
3081}
3082
3083ZEND_VM_HANDLER(165, ZEND_SEND_UNPACK, ANY, ANY)
3084{
3085    USE_OPLINE
3086    zend_free_op free_op1;
3087    zval *args;
3088    int arg_num;
3089    SAVE_OPLINE();
3090
3091    args = GET_OP1_ZVAL_PTR(BP_VAR_R);
3092    arg_num = EX(call)->num_args + 1;
3093
3094ZEND_VM_C_LABEL(send_again):
3095    switch (Z_TYPE_P(args)) {
3096        case IS_ARRAY: {
3097            HashTable *ht = Z_ARRVAL_P(args);
3098            zval *arg, *top;
3099            zend_string *name;
3100
3101            zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, zend_hash_num_elements(ht) TSRMLS_CC);
3102
3103            if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
3104                uint32_t i;
3105                int separate = 0;
3106
3107                /* check if any of arguments are going to be passed by reference */
3108                for (i = 0; i < zend_hash_num_elements(ht); i++) {
3109                    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
3110                        separate = 1;
3111                        break;
3112                    }
3113                }
3114                if (separate) {
3115                    zval_copy_ctor(args);
3116                    ht = Z_ARRVAL_P(args);
3117                }
3118            }
3119
3120            ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
3121                if (name) {
3122                    zend_error(E_RECOVERABLE_ERROR, "Cannot unpack array with string keys");
3123                    FREE_OP1();
3124                    CHECK_EXCEPTION();
3125                    ZEND_VM_NEXT_OPCODE();
3126                }
3127
3128                top = ZEND_CALL_ARG(EX(call), arg_num);
3129                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3130                    if (!Z_IMMUTABLE_P(args)) {
3131                        ZVAL_MAKE_REF(arg);
3132                        Z_ADDREF_P(arg);
3133                        ZVAL_REF(top, Z_REF_P(arg));
3134                    } else {
3135                        ZVAL_DUP(top, arg);
3136                    }
3137                } else if (Z_ISREF_P(arg)) {
3138                    ZVAL_COPY(top, Z_REFVAL_P(arg));
3139                } else {
3140                    ZVAL_COPY(top, arg);
3141                }
3142
3143                EX(call)->num_args++;
3144                arg_num++;
3145            } ZEND_HASH_FOREACH_END();
3146
3147            break;
3148        }
3149        case IS_OBJECT: {
3150            zend_class_entry *ce = Z_OBJCE_P(args);
3151            zend_object_iterator *iter;
3152
3153            if (!ce || !ce->get_iterator) {
3154                zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
3155                break;
3156            }
3157
3158            iter = ce->get_iterator(ce, args, 0 TSRMLS_CC);
3159            if (UNEXPECTED(!iter)) {
3160                FREE_OP1();
3161                if (!EG(exception)) {
3162                    zend_throw_exception_ex(
3163                        NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val
3164                    );
3165                }
3166                HANDLE_EXCEPTION();
3167            }
3168
3169            if (iter->funcs->rewind) {
3170                iter->funcs->rewind(iter TSRMLS_CC);
3171                if (UNEXPECTED(EG(exception) != NULL)) {
3172                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3173                }
3174            }
3175
3176            for (; iter->funcs->valid(iter TSRMLS_CC) == SUCCESS; ++arg_num) {
3177                zval *arg, *top;
3178
3179                if (UNEXPECTED(EG(exception) != NULL)) {
3180                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3181                }
3182
3183                arg = iter->funcs->get_current_data(iter TSRMLS_CC);
3184                if (UNEXPECTED(EG(exception) != NULL)) {
3185                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3186                }
3187
3188                if (iter->funcs->get_current_key) {
3189                    zval key;
3190                    iter->funcs->get_current_key(iter, &key TSRMLS_CC);
3191                    if (UNEXPECTED(EG(exception) != NULL)) {
3192                        ZEND_VM_C_GOTO(unpack_iter_dtor);
3193                    }
3194
3195                    if (Z_TYPE(key) == IS_STRING) {
3196                        zend_error(E_RECOVERABLE_ERROR,
3197                            "Cannot unpack Traversable with string keys");
3198                        zval_dtor(&key);
3199                        ZEND_VM_C_GOTO(unpack_iter_dtor);
3200                    }
3201
3202                    zval_dtor(&key);
3203                }
3204
3205                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3206                    zend_error(
3207                        E_WARNING, "Cannot pass by-reference argument %d of %s%s%s()"
3208                        " by unpacking a Traversable, passing by-value instead", arg_num,
3209                        EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3210                        EX(call)->func->common.scope ? "::" : "",
3211                        EX(call)->func->common.function_name->val
3212                    );
3213                }
3214
3215                if (Z_ISREF_P(arg)) {
3216                    ZVAL_DUP(arg, Z_REFVAL_P(arg));
3217                } else {
3218                    if (Z_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
3219                }
3220
3221                zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1 TSRMLS_CC);
3222                top = ZEND_CALL_ARG(EX(call), arg_num);
3223                ZVAL_COPY_VALUE(top, arg);
3224                EX(call)->num_args++;
3225
3226                iter->funcs->move_forward(iter TSRMLS_CC);
3227                if (UNEXPECTED(EG(exception) != NULL)) {
3228                    ZEND_VM_C_GOTO(unpack_iter_dtor);
3229                }
3230            }
3231
3232ZEND_VM_C_LABEL(unpack_iter_dtor):
3233            zend_iterator_dtor(iter TSRMLS_CC);
3234            break;
3235        }
3236        case IS_REFERENCE:
3237            args = Z_REFVAL_P(args);
3238            ZEND_VM_C_GOTO(send_again);
3239            break;
3240        default:
3241            zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
3242    }
3243
3244    FREE_OP1();
3245    CHECK_EXCEPTION();
3246    ZEND_VM_NEXT_OPCODE();
3247}
3248
3249ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
3250{
3251    USE_OPLINE
3252    zend_free_op free_op1;
3253    zval *args;
3254    SAVE_OPLINE();
3255
3256    args = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
3257
3258    if (Z_TYPE_P(args) != IS_ARRAY) {
3259        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)));
3260        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3261            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3262        }
3263        if (EX(call)->object) {
3264            OBJ_RELEASE(EX(call)->object);
3265        }
3266        EX(call)->func = (zend_function*)&zend_pass_function;
3267        EX(call)->called_scope = NULL;
3268        EX(call)->object = NULL;
3269    } else {
3270        uint32_t arg_num = 1;
3271
3272        HashTable *ht = Z_ARRVAL_P(args);
3273        zval *arg, *param, tmp;
3274
3275        zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht) TSRMLS_CC);
3276
3277        if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
3278            uint32_t i;
3279            int separate = 0;
3280
3281            /* check if any of arguments are going to be passed by reference */
3282            for (i = 0; i < zend_hash_num_elements(ht); i++) {
3283                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
3284                    separate = 1;
3285                    break;
3286                }
3287            }
3288            if (separate) {
3289                zval_copy_ctor(args);
3290                ht = Z_ARRVAL_P(args);
3291            }
3292        }
3293
3294        param = ZEND_CALL_ARG(EX(call), arg_num);
3295        ZEND_HASH_FOREACH_VAL(ht, arg) {
3296            if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3297                // TODO: Scalar values don't have reference counters anymore.
3298                // They are assumed to be 1, and they may be easily passed by
3299                // reference now. However, previously scalars with refcount==1
3300                // might be passed and with refcount>1 might not. We can support
3301                // only single behavior ???
3302#if 0
3303                if (Z_REFCOUNTED_P(arg) &&
3304                    // This solution breaks the following test (omit warning message) ???
3305                    // Zend/tests/bug61273.phpt
3306                    // ext/reflection/tests/bug42976.phpt
3307                    // ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt
3308#else
3309                if (!Z_REFCOUNTED_P(arg) ||
3310                    // This solution breaks the following test (emit warning message) ???
3311                    // ext/pdo_sqlite/tests/pdo_005.phpt
3312#endif
3313                    (!Z_ISREF_P(arg) && Z_REFCOUNT_P(arg) > 1)) {
3314
3315                    if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
3316
3317                        zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
3318                            arg_num,
3319                            EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3320                            EX(call)->func->common.scope ? "::" : "",
3321                            EX(call)->func->common.function_name->val);
3322
3323                        if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3324                            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3325                        }
3326                        if (EX(call)->object) {
3327                            OBJ_RELEASE(EX(call)->object);
3328                        }
3329                        EX(call)->func = (zend_function*)&zend_pass_function;
3330                        EX(call)->called_scope = NULL;
3331                        EX(call)->object = NULL;
3332
3333                        break;
3334                    }
3335
3336                    if (Z_REFCOUNTED_P(arg)) {
3337                        Z_DELREF_P(arg);
3338                    }
3339                    ZVAL_DUP(&tmp, arg);
3340                    ZVAL_NEW_REF(arg, &tmp);
3341                    Z_ADDREF_P(arg);
3342                } else if (!Z_ISREF_P(arg)) {
3343                    ZVAL_NEW_REF(arg, arg);
3344                    Z_ADDREF_P(arg);
3345                } else if (Z_REFCOUNTED_P(arg)) {
3346                    Z_ADDREF_P(arg);
3347                }
3348                ZVAL_COPY_VALUE(param, arg);
3349            } else if (Z_ISREF_P(arg) &&
3350                   /* don't separate references for __call */
3351                   (EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
3352                ZVAL_DUP(param, Z_REFVAL_P(arg));
3353            } else {
3354                ZVAL_COPY(param, arg);
3355            }
3356            EX(call)->num_args++;
3357            arg_num++;
3358            param++;
3359        } ZEND_HASH_FOREACH_END();
3360    }
3361    FREE_OP1();
3362    CHECK_EXCEPTION();
3363    ZEND_VM_NEXT_OPCODE();
3364}
3365
3366ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
3367{
3368    USE_OPLINE
3369    zval *arg, *param, tmp;
3370    zend_free_op free_op1;
3371
3372    arg = GET_OP1_ZVAL_PTR(BP_VAR_R);
3373    param = ZEND_CALL_ARG(EX(call), opline->op2.num);
3374
3375    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3376        // TODO: Scalar values don't have reference counters anymore.
3377        // They are assumed to be 1, and they may be easily passed by
3378        // reference now. However, previously scalars with refcount==1
3379        // might be passed and with refcount>1 might not. We can support
3380        // only single behavior ???
3381#if 0
3382        if (Z_REFCOUNTED_P(arg) &&
3383            // This solution breaks the following test (omit warning message) ???
3384            // Zend/tests/bug61273.phpt
3385            // ext/reflection/tests/bug42976.phpt
3386            // ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt
3387#else
3388        if (!Z_REFCOUNTED_P(arg) ||
3389            // This solution breaks the following test (emit warning message) ???
3390            // ext/pdo_sqlite/tests/pdo_005.phpt
3391#endif
3392            (!Z_ISREF_P(arg) /*&& Z_REFCOUNT_P(arg) > 1???*/)) {
3393
3394            if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
3395
3396                zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
3397                    opline->op2.num,
3398                    EX(call)->func->common.scope ? EX(call)->func->common.scope->name->val : "",
3399                    EX(call)->func->common.scope ? "::" : "",
3400                    EX(call)->func->common.function_name->val);
3401
3402                if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
3403                    OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
3404                }
3405                if (EX(call)->object) {
3406                    OBJ_RELEASE(EX(call)->object);
3407                }
3408                EX(call)->func = (zend_function*)&zend_pass_function;
3409                EX(call)->called_scope = NULL;
3410                EX(call)->object = NULL;
3411
3412                FREE_OP1();
3413                CHECK_EXCEPTION();
3414                ZEND_VM_NEXT_OPCODE();
3415            }
3416
3417            if (Z_REFCOUNTED_P(arg)) {
3418                Z_DELREF_P(arg);
3419            }
3420            ZVAL_DUP(&tmp, arg);
3421            ZVAL_NEW_REF(arg, &tmp);
3422            Z_ADDREF_P(arg);
3423        } else if (!Z_ISREF_P(arg)) {
3424            ZVAL_NEW_REF(arg, arg);
3425            Z_ADDREF_P(arg);
3426        } else if (Z_REFCOUNTED_P(arg)) {
3427            Z_ADDREF_P(arg);
3428        }
3429        ZVAL_COPY_VALUE(param, arg);
3430    } else if (Z_ISREF_P(arg) &&
3431               /* don't separate references for __call */
3432               (EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
3433        ZVAL_DUP(param, Z_REFVAL_P(arg));
3434    } else {
3435        ZVAL_COPY(param, arg);
3436    }
3437
3438    EX(call)->num_args = opline->op2.num;
3439
3440    FREE_OP1();
3441    CHECK_EXCEPTION();
3442    ZEND_VM_NEXT_OPCODE();
3443}
3444
3445ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
3446{
3447    USE_OPLINE
3448    uint32_t arg_num = opline->op1.num;
3449
3450    SAVE_OPLINE();
3451    if (UNEXPECTED(arg_num > EX(num_args))) {
3452        zend_verify_missing_arg(execute_data, arg_num TSRMLS_CC);
3453        CHECK_EXCEPTION();
3454    } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3455        zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3456
3457        zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
3458        CHECK_EXCEPTION();
3459    }
3460
3461    ZEND_VM_NEXT_OPCODE();
3462}
3463
3464ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
3465{
3466    USE_OPLINE
3467    uint32_t arg_num = opline->op1.num;
3468    zval *param;
3469
3470    SAVE_OPLINE();
3471    param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3472    if (arg_num > EX(num_args)) {
3473        ZVAL_COPY_VALUE(param, opline->op2.zv);
3474        if (Z_OPT_CONSTANT_P(param)) {
3475            zval_update_constant(param, 0 TSRMLS_CC);
3476        } else {
3477            /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
3478            if (UNEXPECTED(Z_OPT_COPYABLE_P(param))) {
3479                zval_copy_ctor_func(param);
3480            }
3481        }
3482    }
3483
3484    if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3485        zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
3486    }
3487
3488    CHECK_EXCEPTION();
3489    ZEND_VM_NEXT_OPCODE();
3490}
3491
3492ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
3493{
3494    USE_OPLINE
3495    uint32_t arg_num = opline->op1.num;
3496    uint32_t arg_count = EX(num_args);
3497    zval *params;
3498
3499    SAVE_OPLINE();
3500
3501    params = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
3502
3503    if (arg_num <= arg_count) {
3504        zval *param;
3505
3506        array_init_size(params, arg_count - arg_num + 1);
3507        param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
3508        if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
3509            do {
3510                zend_verify_arg_type(EX(func), arg_num, param, opline->extended_value TSRMLS_CC);
3511                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
3512                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
3513                param++;
3514            } while (++arg_num <= arg_count);
3515        } else {
3516            do {
3517                zend_hash_next_index_insert_new(Z_ARRVAL_P(params), param);
3518                if (Z_REFCOUNTED_P(param)) Z_ADDREF_P(param);
3519                param++;
3520            } while (++arg_num <= arg_count);
3521        }
3522    } else {
3523        array_init(params);
3524    }
3525
3526    CHECK_EXCEPTION();
3527    ZEND_VM_NEXT_OPCODE();
3528}
3529
3530ZEND_VM_HANDLER(52, ZEND_BOOL, CONST|TMP|VAR|CV, ANY)
3531{
3532    USE_OPLINE
3533    zend_free_op free_op1;
3534    zval *retval = EX_VAR(opline->result.var);
3535
3536    SAVE_OPLINE();
3537    /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */
3538    ZVAL_BOOL(retval, i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC));
3539    FREE_OP1();
3540
3541    CHECK_EXCEPTION();
3542    ZEND_VM_NEXT_OPCODE();
3543}
3544
3545ZEND_VM_HANDLER(50, ZEND_BRK, ANY, CONST)
3546{
3547    USE_OPLINE
3548    zend_brk_cont_element *el;
3549
3550    SAVE_OPLINE();
3551    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
3552                       &EX(func)->op_array, execute_data TSRMLS_CC);
3553    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->brk);
3554}
3555
3556ZEND_VM_HANDLER(51, ZEND_CONT, ANY, CONST)
3557{
3558    USE_OPLINE
3559    zend_brk_cont_element *el;
3560
3561    SAVE_OPLINE();
3562    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
3563                       &EX(func)->op_array, execute_data TSRMLS_CC);
3564    ZEND_VM_JMP(EX(func)->op_array.opcodes + el->cont);
3565}
3566
3567ZEND_VM_HANDLER(100, ZEND_GOTO, ANY, CONST)
3568{
3569    zend_op *brk_opline;
3570    USE_OPLINE
3571    zend_brk_cont_element *el;
3572
3573    SAVE_OPLINE();
3574    el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value,
3575                       &EX(func)->op_array, execute_data TSRMLS_CC);
3576
3577    brk_opline = EX(func)->op_array.opcodes + el->brk;
3578
3579    if (brk_opline->opcode == ZEND_FREE) {
3580        if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
3581            zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
3582        }
3583    }
3584    ZEND_VM_JMP(opline->op1.jmp_addr);
3585}
3586
3587ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)
3588{
3589    USE_OPLINE
3590    zend_free_op free_op1, free_op2;
3591    zval *result = EX_VAR(opline->result.var);
3592
3593    SAVE_OPLINE();
3594    fast_equal_function(result,
3595         GET_OP1_ZVAL_PTR(BP_VAR_R),
3596         GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC);
3597
3598    FREE_OP2();
3599    CHECK_EXCEPTION();
3600    ZEND_VM_NEXT_OPCODE();
3601}
3602
3603ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY)
3604{
3605    USE_OPLINE
3606    zval object_zval;
3607    zend_function *constructor;
3608
3609    SAVE_OPLINE();
3610    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)) {
3611        if (Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_INTERFACE) {
3612            zend_error_noreturn(E_ERROR, "Cannot instantiate interface %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
3613        } else if ((Z_CE_P(EX_VAR(opline->op1.var))->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
3614            zend_error_noreturn(E_ERROR, "Cannot instantiate trait %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
3615        } else {
3616            zend_error_noreturn(E_ERROR, "Cannot instantiate abstract class %s", Z_CE_P(EX_VAR(opline->op1.var))->name->val);
3617        }
3618    }
3619    object_init_ex(&object_zval, Z_CE_P(EX_VAR(opline->op1.var)));
3620    constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC);
3621
3622    if (constructor == NULL) {
3623        if (RETURN_VALUE_USED(opline)) {
3624            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
3625        } else {
3626            zval_ptr_dtor(&object_zval);
3627        }
3628        ZEND_VM_JMP(opline->op2.jmp_addr);
3629    } else {
3630        /* We are not handling overloaded classes right now */
3631        EX(call) = zend_vm_stack_push_call_frame(
3632            constructor, opline->extended_value,
3633            RETURN_VALUE_USED(opline) ?
3634                ZEND_CALL_CTOR : (ZEND_CALL_CTOR | ZEND_CALL_CTOR_RESULT_UNUSED),
3635            Z_CE_P(EX_VAR(opline->op1.var)),
3636            Z_OBJ(object_zval),
3637            EX(call) TSRMLS_CC);
3638
3639        if (RETURN_VALUE_USED(opline)) {
3640            ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
3641            EX(call)->return_value = EX_VAR(opline->result.var);
3642        } else {
3643            EX(call)->return_value = NULL;
3644        }
3645
3646        CHECK_EXCEPTION();
3647        ZEND_VM_NEXT_OPCODE();
3648    }
3649}
3650
3651ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
3652{
3653    USE_OPLINE
3654    zend_free_op free_op1;
3655    zval *obj;
3656    zend_class_entry *ce;
3657    zend_function *clone;
3658    zend_object_clone_obj_t clone_call;
3659
3660    SAVE_OPLINE();
3661    obj = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_R);
3662
3663    if (OP1_TYPE == IS_CONST ||
3664        UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT)) {
3665        if (UNEXPECTED(EG(exception) != NULL)) {
3666            HANDLE_EXCEPTION();
3667        }
3668        zend_error_noreturn(E_ERROR, "__clone method called on non-object");
3669    }
3670
3671    ce = Z_OBJCE_P(obj);
3672    clone = ce ? ce->clone : NULL;
3673    clone_call =  Z_OBJ_HT_P(obj)->clone_obj;
3674    if (UNEXPECTED(clone_call == NULL)) {
3675        if (ce) {
3676            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name->val);
3677        } else {
3678            zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");
3679        }
3680    }
3681
3682    if (ce && clone) {
3683        if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
3684            /* Ensure that if we're calling a private function, we're allowed to do so.
3685             */
3686            if (UNEXPECTED(ce != EX(scope))) {
3687                zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
3688            }
3689        } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
3690            /* Ensure that if we're calling a protected function, we're allowed to do so.
3691             */
3692            if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EX(scope)))) {
3693                zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name->val, EX(scope) ? EX(scope)->name->val : "");
3694            }
3695        }
3696    }
3697
3698    if (EXPECTED(EG(exception) == NULL)) {
3699        ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj TSRMLS_CC));
3700        if (!RETURN_VALUE_USED(opline) || UNEXPECTED(EG(exception) != NULL)) {
3701            zval_ptr_dtor(EX_VAR(opline->result.var));
3702        }
3703    }
3704    FREE_OP1_IF_VAR();
3705    CHECK_EXCEPTION();
3706    ZEND_VM_NEXT_OPCODE();
3707}
3708
3709ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
3710{
3711    USE_OPLINE
3712
3713    SAVE_OPLINE();
3714    if (OP1_TYPE == IS_UNUSED) {
3715        zend_constant *c;
3716        zval *retval;
3717
3718        if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
3719            c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
3720        } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) {
3721            if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
3722                char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv));
3723                if(!actual) {
3724                    actual = Z_STRVAL_P(opline->op2.zv);
3725                } else {
3726                    actual++;
3727                }
3728                /* non-qualified constant - allow text substitution */
3729                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
3730                ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv)));
3731                CHECK_EXCEPTION();
3732                ZEND_VM_NEXT_OPCODE();
3733            } else {
3734                zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL_P(opline->op2.zv));
3735            }
3736        } else {
3737            CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), c);
3738        }
3739        retval = EX_VAR(opline->result.var);
3740        ZVAL_COPY_VALUE(retval, &c->value);
3741        if (Z_OPT_COPYABLE_P(retval) || Z_OPT_REFCOUNTED_P(retval)) {
3742            if (Z_OPT_COPYABLE_P(retval)) {
3743                zval_copy_ctor_func(retval);
3744            } else {
3745                Z_ADDREF_P(retval);
3746            }
3747        }
3748    } else {
3749        /* class constant */
3750        zend_class_entry *ce;
3751        zval *value;
3752
3753        if (OP1_TYPE == IS_CONST) {
3754            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
3755                value = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
3756                ZVAL_DEREF(value);
3757                ZVAL_DUP(EX_VAR(opline->result.var), value);
3758                ZEND_VM_C_GOTO(constant_fetch_end);
3759            } else if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv))) {
3760                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op1.zv));
3761            } else {
3762                ce = zend_fetch_class_by_name(Z_STR_P(opline->op1.zv), opline->op1.zv + 1, opline->extended_value TSRMLS_CC);
3763                if (UNEXPECTED(EG(exception) != NULL)) {
3764                    HANDLE_EXCEPTION();
3765                }
3766                if (UNEXPECTED(ce == NULL)) {
3767                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
3768                }
3769                CACHE_PTR(Z_CACHE_SLOT_P(opline->op1.zv), ce);
3770            }
3771        } else {
3772            ce = Z_CE_P(EX_VAR(opline->op1.var));
3773            if ((value = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce)) != NULL) {
3774                ZVAL_DEREF(value);
3775                ZVAL_DUP(EX_VAR(opline->result.var), value);
3776                ZEND_VM_C_GOTO(constant_fetch_end);
3777            }
3778        }
3779
3780        if (EXPECTED((value = zend_hash_find(&ce->constants_table, Z_STR_P(opline->op2.zv))) != NULL)) {
3781            ZVAL_DEREF(value);
3782            if (Z_CONSTANT_P(value)) {
3783                EG(scope) = ce;
3784                zval_update_constant(value, 1 TSRMLS_CC);
3785                EG(scope) = EX(scope);
3786            }
3787            if (OP1_TYPE == IS_CONST) {
3788                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), value);
3789            } else {
3790                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value);
3791            }
3792            ZVAL_DUP(EX_VAR(opline->result.var), value);
3793        } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
3794            /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
3795            ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
3796        } else {
3797            zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
3798        }
3799    }
3800ZEND_VM_C_LABEL(constant_fetch_end):
3801    CHECK_EXCEPTION();
3802    ZEND_VM_NEXT_OPCODE();
3803}
3804
3805ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUSED|CV)
3806{
3807    USE_OPLINE
3808    zend_free_op free_op1;
3809    zval *expr_ptr, new_expr;
3810
3811    SAVE_OPLINE();
3812    if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) &&
3813        (opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) {
3814        expr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3815        if (OP1_TYPE == IS_VAR && UNEXPECTED(expr_ptr == NULL)) {
3816            zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
3817        }
3818        ZVAL_MAKE_REF(expr_ptr);
3819        Z_ADDREF_P(expr_ptr);
3820        FREE_OP1_VAR_PTR();
3821    } else {
3822        expr_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3823        if (OP1_TYPE == IS_TMP_VAR) {
3824            ZVAL_COPY_VALUE(&new_expr, expr_ptr);
3825            expr_ptr = &new_expr;
3826        } else if (OP1_TYPE == IS_CONST) {
3827            if (!Z_IMMUTABLE_P(expr_ptr)) {
3828                ZVAL_DUP(&new_expr, expr_ptr);
3829                expr_ptr = &new_expr;
3830            }
3831        } else if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) && Z_ISREF_P(expr_ptr)) {
3832            expr_ptr = Z_REFVAL_P(expr_ptr);
3833            if (Z_REFCOUNTED_P(expr_ptr)) Z_ADDREF_P(expr_ptr);
3834            FREE_OP1_IF_VAR();
3835        } else if (OP1_TYPE == IS_CV && Z_REFCOUNTED_P(expr_ptr)) {
3836            Z_ADDREF_P(expr_ptr);
3837        }
3838    }
3839
3840    if (OP2_TYPE != IS_UNUSED) {
3841        zend_free_op free_op2;
3842        zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
3843        zend_string *str;
3844        zend_ulong hval;
3845
3846ZEND_VM_C_LABEL(add_again):
3847        switch (Z_TYPE_P(offset)) {
3848            case IS_DOUBLE:
3849                hval = zend_dval_to_lval(Z_DVAL_P(offset));
3850                ZEND_VM_C_GOTO(num_index);
3851            case IS_LONG:
3852                hval = Z_LVAL_P(offset);
3853ZEND_VM_C_LABEL(num_index):
3854                zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr);
3855                break;
3856            case IS_STRING:
3857                str = Z_STR_P(offset);
3858                if (OP2_TYPE != IS_CONST) {
3859                    if (ZEND_HANDLE_NUMERIC(str, hval)) {
3860                        ZEND_VM_C_GOTO(num_index);
3861                    }
3862                }
3863ZEND_VM_C_LABEL(str_index):
3864                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
3865                break;
3866            case IS_NULL:
3867                str = STR_EMPTY_ALLOC();
3868                ZEND_VM_C_GOTO(str_index);
3869            case IS_FALSE:
3870                hval = 0;
3871                ZEND_VM_C_GOTO(num_index);
3872            case IS_TRUE:
3873                hval = 1;
3874                ZEND_VM_C_GOTO(num_index);
3875            case IS_REFERENCE:
3876                offset = Z_REFVAL_P(offset);
3877                ZEND_VM_C_GOTO(add_again);
3878                break;
3879            default:
3880                zend_error(E_WARNING, "Illegal offset type");
3881                zval_ptr_dtor(expr_ptr);
3882                /* do nothing */
3883                break;
3884        }
3885        FREE_OP2();
3886    } else {
3887        zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
3888    }
3889    CHECK_EXCEPTION();
3890    ZEND_VM_NEXT_OPCODE();
3891}
3892
3893ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|UNUSED|CV)
3894{
3895    zval *array;
3896    uint32_t size;
3897    USE_OPLINE
3898
3899    array = EX_VAR(opline->result.var);
3900    if (OP1_TYPE != IS_UNUSED) {
3901        size = opline->extended_value >> ZEND_ARRAY_SIZE_SHIFT;
3902    } else {
3903        size = 0;
3904    }
3905    ZVAL_NEW_ARR(array);
3906    zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0);
3907
3908    if (OP1_TYPE != IS_UNUSED) {
3909        /* Explicitly initialize array as not-packed if flag is set */
3910        if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
3911            zend_hash_real_init(Z_ARRVAL_P(array), 0);
3912        }
3913    }
3914
3915    if (OP1_TYPE == IS_UNUSED) {
3916        ZEND_VM_NEXT_OPCODE();
3917#if !defined(ZEND_VM_SPEC) || OP1_TYPE != IS_UNUSED
3918    } else {
3919        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
3920#endif
3921    }
3922}
3923
3924ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY)
3925{
3926    USE_OPLINE
3927    zend_free_op free_op1;
3928    zval *expr;
3929    zval *result = EX_VAR(opline->result.var);
3930
3931    SAVE_OPLINE();
3932    expr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
3933
3934    switch (opline->extended_value) {
3935        case IS_NULL:
3936            /* This code is taken from convert_to_null. However, it does not seems very useful,
3937             * because a conversion to null always results in the same value. This could only
3938             * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
3939#if 0
3940            if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
3941                ZVAL_DEREF(expr);
3942            }
3943            if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
3944                if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
3945                    break;
3946                }
3947            }
3948#endif
3949
3950            ZVAL_NULL(result);
3951            break;
3952        case _IS_BOOL:
3953            ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
3954            break;
3955        case IS_LONG:
3956            ZVAL_LONG(result, zval_get_long(expr));
3957            break;
3958        case IS_DOUBLE:
3959            ZVAL_DOUBLE(result, zval_get_double(expr));
3960            break;
3961        case IS_STRING:
3962            ZVAL_STR(result, zval_get_string(expr));
3963            break;
3964        default:
3965            /* If value is already of correct type, return it directly */
3966            if (Z_TYPE_P(expr) == opline->extended_value) {
3967                ZVAL_COPY_VALUE(result, expr);
3968                if (OP1_TYPE == IS_CONST) {
3969                    if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
3970                        zval_copy_ctor_func(result);
3971                    }
3972                } else if (OP1_TYPE != IS_TMP_VAR) {
3973                    if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
3974                }
3975
3976                FREE_OP1();
3977                CHECK_EXCEPTION();
3978                ZEND_VM_NEXT_OPCODE();
3979            }
3980
3981            if (opline->extended_value == IS_ARRAY) {
3982                if (Z_TYPE_P(expr) != IS_OBJECT) {
3983                    ZVAL_NEW_ARR(result);
3984                    zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
3985                    if (Z_TYPE_P(expr) != IS_NULL) {
3986                        expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
3987                        if (OP1_TYPE == IS_CONST) {
3988                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
3989                                zval_copy_ctor_func(expr);
3990                            }
3991                        } else if (OP1_TYPE != IS_TMP_VAR) {
3992                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
3993                        }
3994                    }
3995                } else {
3996                    ZVAL_COPY_VALUE(result, expr);
3997                    if (OP1_TYPE != IS_TMP_VAR) {
3998                        zval_opt_copy_ctor(result);
3999                    }
4000                    convert_to_array(result);
4001                }
4002            } else {
4003                if (Z_TYPE_P(expr) != IS_ARRAY) {
4004                    object_init(result);
4005                    if (Z_TYPE_P(expr) != IS_NULL) {
4006                        expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
4007                        if (OP1_TYPE == IS_CONST) {
4008                            if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
4009                                zval_copy_ctor_func(expr);
4010                            }
4011                        } else if (OP1_TYPE != IS_TMP_VAR) {
4012                            if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
4013                        }
4014                    }
4015                } else {
4016                    ZVAL_COPY_VALUE(result, expr);
4017                    if (OP1_TYPE != IS_TMP_VAR) {
4018                        zval_opt_copy_ctor(result);
4019                    }
4020                    convert_to_object(result);
4021                }
4022            }
4023
4024            FREE_OP1_IF_VAR();
4025            CHECK_EXCEPTION();
4026            ZEND_VM_NEXT_OPCODE();
4027    }
4028    FREE_OP1();
4029    CHECK_EXCEPTION();
4030    ZEND_VM_NEXT_OPCODE();
4031}
4032
4033ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
4034{
4035    USE_OPLINE
4036    zend_op_array *new_op_array=NULL;
4037    zend_free_op free_op1;
4038    zval *inc_filename;
4039    zval tmp_inc_filename;
4040    zend_bool failure_retval=0;
4041
4042    SAVE_OPLINE();
4043    inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R);
4044
4045    ZVAL_UNDEF(&tmp_inc_filename);
4046    if (Z_TYPE_P(inc_filename) != IS_STRING) {
4047        ZVAL_DUP(&tmp_inc_filename, inc_filename);
4048        convert_to_string(&tmp_inc_filename);
4049        inc_filename = &tmp_inc_filename;
4050    }
4051
4052    if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
4053        if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) {
4054            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4055        } else {
4056            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4057        }
4058    } else {
4059        switch (opline->extended_value) {
4060            case ZEND_INCLUDE_ONCE:
4061            case ZEND_REQUIRE_ONCE: {
4062                    zend_file_handle file_handle;
4063                    char *resolved_path;
4064
4065                    resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename) TSRMLS_CC);
4066                    if (resolved_path) {
4067                        failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, (int)strlen(resolved_path));
4068                    } else {
4069                        resolved_path = Z_STRVAL_P(inc_filename);
4070                    }
4071
4072                    if (failure_retval) {
4073                        /* do nothing, file already included */
4074                    } else if (SUCCESS == zend_stream_open(resolved_path, &file_handle TSRMLS_CC)) {
4075
4076                        if (!file_handle.opened_path) {
4077                            file_handle.opened_path = estrdup(resolved_path);
4078                        }
4079
4080                        if (zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, (int)strlen(file_handle.opened_path))) {
4081                            new_op_array = zend_compile_file(&file_handle, (opline->extended_value==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC);
4082                            zend_destroy_file_handle(&file_handle TSRMLS_CC);
4083                        } else {
4084                            zend_file_handle_dtor(&file_handle TSRMLS_CC);
4085                            failure_retval=1;
4086                        }
4087                    } else {
4088                        if (opline->extended_value == ZEND_INCLUDE_ONCE) {
4089                            zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4090                        } else {
4091                            zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
4092                        }
4093                    }
4094                    if (resolved_path != Z_STRVAL_P(inc_filename)) {
4095                        efree(resolved_path);
4096                    }
4097                }
4098                break;
4099            case ZEND_INCLUDE:
4100            case ZEND_REQUIRE:
4101                new_op_array = compile_filename(opline->extended_value, inc_filename TSRMLS_CC);
4102                break;
4103            case ZEND_EVAL: {
4104                    char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
4105
4106                    new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
4107                    efree(eval_desc);
4108                }
4109                break;
4110            EMPTY_SWITCH_DEFAULT_CASE()
4111        }
4112    }
4113    if (Z_TYPE(tmp_inc_filename) != IS_UNDEF) {
4114        zval_ptr_dtor(&tmp_inc_filename);
4115    }
4116    FREE_OP1();
4117    if (UNEXPECTED(EG(exception) != NULL)) {
4118        HANDLE_EXCEPTION();
4119    } else if (EXPECTED(new_op_array != NULL)) {
4120        zval *return_value = NULL;
4121        zend_execute_data *call;
4122
4123        if (RETURN_VALUE_USED(opline)) {
4124            return_value = EX_VAR(opline->result.var);
4125        }
4126
4127        call = zend_vm_stack_push_call_frame(
4128            (zend_function*)new_op_array, 0, 0, EX(called_scope), EX(object), NULL TSRMLS_CC);
4129
4130        if (EX(symbol_table)) {
4131            call->symbol_table = EX(symbol_table);
4132        } else {
4133            call->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
4134        }
4135
4136        call->prev_execute_data = execute_data;
4137        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);
4138        if (EXPECTED(zend_execute_ex == execute_ex)) {
4139            ZEND_VM_ENTER();
4140        } else {
4141            zend_execute_ex(call TSRMLS_CC);
4142        }
4143
4144        destroy_op_array(new_op_array TSRMLS_CC);
4145        efree_size(new_op_array, sizeof(zend_op_array));
4146        if (UNEXPECTED(EG(exception) != NULL)) {
4147            zend_throw_exception_internal(NULL TSRMLS_CC);
4148            HANDLE_EXCEPTION();
4149        }
4150
4151    } else if (RETURN_VALUE_USED(opline)) {
4152        ZVAL_BOOL(EX_VAR(opline->result.var), failure_retval);
4153    }
4154    ZEND_VM_NEXT_OPCODE();
4155}
4156
4157ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
4158{
4159    USE_OPLINE
4160    zval tmp, *varname;
4161    HashTable *target_symbol_table;
4162    zend_free_op free_op1;
4163
4164    SAVE_OPLINE();
4165    if (OP1_TYPE == IS_CV &&
4166        OP2_TYPE == IS_UNUSED &&
4167        (opline->extended_value & ZEND_QUICK_SET)) {
4168        zval *var = EX_VAR(opline->op1.var);
4169
4170        if (Z_REFCOUNTED_P(var)) {
4171            zend_refcounted *garbage = Z_COUNTED_P(var);
4172
4173            if (!--GC_REFCOUNT(garbage)) {
4174                ZVAL_UNDEF(var);
4175                _zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
4176            } else {
4177                GC_ZVAL_CHECK_POSSIBLE_ROOT(var);
4178                ZVAL_UNDEF(var);
4179            }
4180        } else {
4181            ZVAL_UNDEF(var);
4182        }
4183        CHECK_EXCEPTION();
4184        ZEND_VM_NEXT_OPCODE();
4185    }
4186
4187    varname = GET_OP1_ZVAL_PTR(BP_VAR_R);
4188
4189    ZVAL_UNDEF(&tmp);
4190    if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4191        ZVAL_DUP(&tmp, varname);
4192        convert_to_string(&tmp);
4193        varname = &tmp;
4194    }
4195
4196    if (OP2_TYPE != IS_UNUSED) {
4197        zend_class_entry *ce;
4198
4199        if (OP2_TYPE == IS_CONST) {
4200            if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4201                ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4202            } else {
4203                ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4204                if (UNEXPECTED(EG(exception) != NULL)) {
4205                    if (OP1_TYPE != IS_CONST) {
4206                        zval_dtor(&tmp);
4207                    }
4208                    FREE_OP1();
4209                    HANDLE_EXCEPTION();
4210                }
4211                if (UNEXPECTED(ce == NULL)) {
4212                    zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op2.zv));
4213                }
4214                CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4215            }
4216        } else {
4217            ce = Z_CE_P(EX_VAR(opline->op2.var));
4218        }
4219        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);
4220    } else {
4221        target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4222        zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
4223    }
4224
4225    if (OP1_TYPE != IS_CONST) {
4226        zval_dtor(&tmp);
4227    }
4228    FREE_OP1();
4229    CHECK_EXCEPTION();
4230    ZEND_VM_NEXT_OPCODE();
4231}
4232
4233ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4234{
4235    USE_OPLINE
4236    zend_free_op free_op1, free_op2;
4237    zval *container;
4238    zval *offset;
4239    zend_ulong hval;
4240
4241    SAVE_OPLINE();
4242    container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
4243    if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
4244        zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4245    }
4246    if (OP1_TYPE != IS_UNUSED) {
4247        ZVAL_DEREF(container);
4248        SEPARATE_ZVAL_NOREF(container);
4249    }
4250    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4251
4252    switch (Z_TYPE_P(container)) {
4253        case IS_ARRAY: {
4254            HashTable *ht = Z_ARRVAL_P(container);
4255ZEND_VM_C_LABEL(offset_again):
4256            switch (Z_TYPE_P(offset)) {
4257                case IS_DOUBLE:
4258                    hval = zend_dval_to_lval(Z_DVAL_P(offset));
4259                    zend_hash_index_del(ht, hval);
4260                    break;
4261                case IS_LONG:
4262                    hval = Z_LVAL_P(offset);
4263ZEND_VM_C_LABEL(num_index_dim):
4264                    zend_hash_index_del(ht, hval);
4265                    break;
4266                case IS_STRING:
4267                    if (OP2_TYPE != IS_CONST) {
4268                        if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
4269                            ZEND_VM_C_GOTO(num_index_dim);
4270                        }
4271                    }
4272                    if (ht == &EG(symbol_table).ht) {
4273                        zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
4274                    } else {
4275                        zend_hash_del(ht, Z_STR_P(offset));
4276                    }
4277                    break;
4278                case IS_NULL:
4279                    zend_hash_del(ht, STR_EMPTY_ALLOC());
4280                    break;
4281                case IS_FALSE:
4282                    hval = 0;
4283                    ZEND_VM_C_GOTO(num_index_dim);
4284                case IS_TRUE:
4285                    hval = 1;
4286                    ZEND_VM_C_GOTO(num_index_dim);
4287                case IS_RESOURCE:
4288                    hval = Z_RES_HANDLE_P(offset);
4289                    ZEND_VM_C_GOTO(num_index_dim);
4290                case IS_REFERENCE:
4291                    offset = Z_REFVAL_P(offset);
4292                    ZEND_VM_C_GOTO(offset_again);
4293                    break;
4294                default:
4295                    zend_error(E_WARNING, "Illegal offset type in unset");
4296                    break;
4297            }
4298            FREE_OP2();
4299            break;
4300        }
4301        case IS_OBJECT:
4302            if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) {
4303                zend_error_noreturn(E_ERROR, "Cannot use object as array");
4304            }
4305//???           if (OP2_TYPE == IS_CONST) {
4306//???               zval_copy_ctor(offset);
4307//???           }
4308            Z_OBJ_HT_P(container)->unset_dimension(container, offset TSRMLS_CC);
4309            FREE_OP2();
4310            break;
4311        case IS_STRING:
4312            zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4313            ZEND_VM_CONTINUE(); /* bailed out before */
4314        default:
4315            FREE_OP2();
4316            break;
4317    }
4318    FREE_OP1_VAR_PTR();
4319    CHECK_EXCEPTION();
4320    ZEND_VM_NEXT_OPCODE();
4321}
4322
4323ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4324{
4325    USE_OPLINE
4326    zend_free_op free_op1, free_op2;
4327    zval *container;
4328    zval *offset;
4329
4330    SAVE_OPLINE();
4331    container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
4332    if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) {
4333        zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
4334    }
4335    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4336
4337    ZVAL_DEREF(container);
4338    if (Z_TYPE_P(container) == IS_OBJECT) {
4339        if (Z_OBJ_HT_P(container)->unset_property) {
4340            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);
4341        } else {
4342            zend_error(E_NOTICE, "Trying to unset property of non-object");
4343        }
4344    }
4345    FREE_OP2();
4346    FREE_OP1_VAR_PTR();
4347    CHECK_EXCEPTION();
4348    ZEND_VM_NEXT_OPCODE();
4349}
4350
4351ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
4352{
4353    USE_OPLINE
4354    zend_free_op free_op1;
4355    zval *array_ptr, *array_ref, iterator, tmp;
4356    HashTable *fe_ht;
4357    zend_object_iterator *iter = NULL;
4358    zend_class_entry *ce = NULL;
4359    zend_bool is_empty = 0;
4360
4361    SAVE_OPLINE();
4362
4363    if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) &&
4364        (opline->extended_value & ZEND_FE_FETCH_BYREF)) {
4365        array_ptr = array_ref = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R);
4366        ZVAL_DEREF(array_ptr);
4367        if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
4368            SEPARATE_ARRAY(array_ptr);
4369            if (!Z_ISREF_P(array_ref)) {
4370                ZVAL_NEW_REF(array_ref, array_ref);
4371                array_ptr = Z_REFVAL_P(array_ref);
4372            }
4373            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
4374        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4375            if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
4376                zend_error(E_WARNING, "foreach() cannot iterate over objects without PHP class");
4377                ZEND_VM_JMP(opline->op2.jmp_addr);
4378            }
4379
4380            ce = Z_OBJCE_P(array_ptr);
4381            if (!ce || ce->get_iterator == NULL) {
4382                Z_ADDREF_P(array_ptr);
4383            }
4384            array_ref = array_ptr;
4385        } else {
4386            if (Z_REFCOUNTED_P(array_ref)) Z_ADDREF_P(array_ref);
4387        }
4388    } else {
4389        array_ptr = array_ref = GET_OP1_ZVAL_PTR(BP_VAR_R);
4390        ZVAL_DEREF(array_ptr);
4391        if (OP1_TYPE == IS_TMP_VAR) {
4392            ZVAL_COPY_VALUE(&tmp, array_ptr);
4393            if (Z_OPT_IMMUTABLE_P(&tmp)) {
4394                zval_copy_ctor_func(&tmp);
4395            }
4396            array_ref = array_ptr = &tmp;
4397            if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4398                ce = Z_OBJCE_P(array_ptr);
4399                if (ce && ce->get_iterator) {
4400                    Z_DELREF_P(array_ref);
4401                }
4402            }
4403        } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
4404            ce = Z_OBJCE_P(array_ptr);
4405            if (!ce || !ce->get_iterator) {
4406                if (OP1_TYPE == IS_CV) {
4407                    Z_ADDREF_P(array_ref);
4408                }
4409            }
4410        } else if (Z_IMMUTABLE_P(array_ref)) {
4411            if (OP1_TYPE == IS_CV) {
4412                zval_copy_ctor_func(array_ref);
4413                Z_ADDREF_P(array_ref);
4414            } else {
4415                ZVAL_COPY_VALUE(&tmp, array_ref);
4416                zval_copy_ctor_func(&tmp);
4417                array_ptr = array_ref = &tmp;
4418            }
4419        } else if (Z_REFCOUNTED_P(array_ref)) {
4420            if (OP1_TYPE == IS_CONST ||
4421                       (OP1_TYPE == IS_CV &&
4422                        !Z_ISREF_P(array_ref) &&
4423                        Z_REFCOUNT_P(array_ref) > 1) ||
4424                       (OP1_TYPE == IS_VAR &&
4425                        !Z_ISREF_P(array_ref) &&
4426                        Z_REFCOUNT_P(array_ref) > 2)) {
4427                if (OP1_TYPE == IS_VAR) {
4428                    Z_DELREF_P(array_ref);
4429                }
4430                ZVAL_DUP(&tmp, array_ref);
4431                array_ptr = array_ref = &tmp;
4432            } else if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
4433                if (Z_ISREF_P(array_ref) && Z_REFCOUNT_P(array_ref) == 1) {
4434                    ZVAL_UNREF(array_ref);
4435                    array_ptr = array_ref;
4436                }
4437                if (Z_IMMUTABLE_P(array_ptr)) {
4438                    zval_copy_ctor_func(array_ptr);
4439                } else if (Z_ISREF_P(array_ref) &&
4440                           Z_COPYABLE_P(array_ptr) &&
4441                           Z_REFCOUNT_P(array_ptr) > 1) {
4442                    Z_DELREF_P(array_ptr);
4443                    zval_copy_ctor_func(array_ptr);
4444                }
4445                if (OP1_TYPE == IS_CV) {
4446                    Z_ADDREF_P(array_ref);
4447                }
4448            }
4449        }
4450    }
4451
4452    if (ce && ce->get_iterator) {
4453        iter = ce->get_iterator(ce, array_ptr, opline->extended_value & ZEND_FE_FETCH_BYREF TSRMLS_CC);
4454
4455        if (OP1_TYPE == IS_VAR && !(opline->extended_value & ZEND_FE_FETCH_BYREF)) {
4456            FREE_OP1_IF_VAR();
4457        }
4458        if (iter && EXPECTED(EG(exception) == NULL)) {
4459            ZVAL_OBJ(&iterator, &iter->std);
4460            array_ptr = array_ref = &iterator;
4461        } else {
4462            if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4463                FREE_OP1_VAR_PTR();
4464            }
4465            if (!EG(exception)) {
4466                zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name->val);
4467            }
4468            zend_throw_exception_internal(NULL TSRMLS_CC);
4469            HANDLE_EXCEPTION();
4470        }
4471    }
4472
4473    ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
4474
4475    if (iter) {
4476        iter->index = 0;
4477        if (iter->funcs->rewind) {
4478            iter->funcs->rewind(iter TSRMLS_CC);
4479            if (UNEXPECTED(EG(exception) != NULL)) {
4480                zval_ptr_dtor(array_ref);
4481                if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4482                    FREE_OP1_VAR_PTR();
4483                }
4484                HANDLE_EXCEPTION();
4485            }
4486        }
4487        is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;
4488        if (UNEXPECTED(EG(exception) != NULL)) {
4489            zval_ptr_dtor(array_ref);
4490            if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4491                FREE_OP1_VAR_PTR();
4492            }
4493            HANDLE_EXCEPTION();
4494        }
4495        iter->index = -1; /* will be set to 0 before using next handler */
4496    } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
4497        HashPointer *ptr = (HashPointer*)EX_VAR((opline+2)->op1.var);
4498        HashPosition pos = 0;
4499        Bucket *p;
4500
4501        while (1) {
4502            if (pos >= fe_ht->nNumUsed) {
4503                is_empty = 1;
4504                if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4505                    FREE_OP1_VAR_PTR();
4506                }
4507                ZEND_VM_JMP(opline->op2.jmp_addr);
4508            }
4509            p = fe_ht->arData + pos;
4510            if (Z_TYPE(p->val) == IS_UNDEF ||
4511                (Z_TYPE(p->val) == IS_INDIRECT &&
4512                 Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF)) {
4513                pos++;
4514                continue;
4515            }
4516            if (!ce ||
4517                !p->key ||
4518                zend_check_property_access(Z_OBJ_P(array_ptr), p->key TSRMLS_CC) == SUCCESS) {
4519                break;
4520            }
4521            pos++;
4522        }
4523        fe_ht->nInternalPointer = pos;
4524        ptr->pos = pos;
4525        ptr->ht = fe_ht;
4526        ptr->h = fe_ht->arData[pos].h;
4527        is_empty = 0;
4528    } else {
4529        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
4530        is_empty = 1;
4531    }
4532
4533    if (OP1_TYPE == IS_VAR && opline->extended_value & ZEND_FE_FETCH_BYREF) {
4534        FREE_OP1_VAR_PTR();
4535    }
4536    if (is_empty) {
4537        ZEND_VM_JMP(opline->op2.jmp_addr);
4538    } else {
4539        CHECK_EXCEPTION();
4540        ZEND_VM_NEXT_OPCODE();
4541    }
4542}
4543
4544ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
4545{
4546    USE_OPLINE
4547    zend_free_op free_op1;
4548    zval *array, *array_ref;
4549    zval *value;
4550    HashTable *fe_ht;
4551    HashPointer *ptr;
4552    HashPosition pos;
4553    Bucket *p;
4554
4555    array = array_ref = EX_VAR(opline->op1.var);
4556    if (Z_ISREF_P(array)) {
4557        array = Z_REFVAL_P(array);
4558        // TODO: referenced value might be changed to different array ???
4559        if (Z_IMMUTABLE_P(array)) {
4560            zval_copy_ctor_func(array);
4561        }
4562    }
4563
4564    SAVE_OPLINE();
4565
4566    if (EXPECTED(Z_TYPE_P(array) == IS_ARRAY)) {
4567        fe_ht = Z_ARRVAL_P(array);
4568        ptr = (HashPointer*)EX_VAR((opline+1)->op1.var);
4569        pos = ptr->pos;
4570        if (UNEXPECTED(pos == INVALID_IDX)) {
4571            /* reached end of iteration */
4572            ZEND_VM_JMP(opline->op2.jmp_addr);
4573        } else if (UNEXPECTED(ptr->ht != fe_ht)) {
4574            ptr->ht = fe_ht;
4575            pos = 0;
4576        } else if (UNEXPECTED(fe_ht->nInternalPointer != ptr->pos)) {
4577            if (fe_ht->u.flags & HASH_FLAG_PACKED) {
4578                pos = ptr->h;
4579            } else {
4580                pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask];
4581                while (pos != INVALID_IDX) {
4582                    if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) {
4583                        break;
4584                    }
4585                    pos = Z_NEXT(fe_ht->arData[pos].val);
4586                }
4587            }
4588        }
4589        while (1) {
4590            if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
4591                /* reached end of iteration */
4592                ZEND_VM_JMP(opline->op2.jmp_addr);
4593            }
4594            p = fe_ht->arData + pos;
4595            value = &p->val;
4596            if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4597                pos++;
4598                continue;
4599            } else if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
4600                value = Z_INDIRECT_P(value);
4601                if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4602                    pos++;
4603                    continue;
4604                }
4605            }
4606            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4607                ZVAL_MAKE_REF(value);
4608                Z_ADDREF_P(value);
4609                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4610            } else {
4611                ZVAL_COPY(EX_VAR(opline->result.var), value);
4612            }
4613            if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4614                if (!p->key) {
4615                    ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
4616                } else {
4617                    ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
4618                }
4619            }
4620            break;
4621        }
4622        do {
4623            pos++;
4624            if (pos >= fe_ht->nNumUsed) {
4625                fe_ht->nInternalPointer = ptr->pos = INVALID_IDX;
4626                ZEND_VM_INC_OPCODE();
4627                ZEND_VM_NEXT_OPCODE();
4628            }
4629            p = fe_ht->arData + pos;
4630        } while (Z_TYPE(p->val) == IS_UNDEF ||
4631                 (Z_TYPE(p->val) == IS_INDIRECT &&
4632                  Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF));
4633        fe_ht->nInternalPointer = ptr->pos = pos;
4634        ptr->h = fe_ht->arData[pos].h;
4635        ZEND_VM_INC_OPCODE();
4636        ZEND_VM_NEXT_OPCODE();
4637    } else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) {
4638        zend_object_iterator *iter;
4639
4640        if ((iter = zend_iterator_unwrap(array TSRMLS_CC)) == NULL) {
4641            /* plain object */
4642            zend_object *zobj = Z_OBJ_P(array);
4643
4644            fe_ht = Z_OBJPROP_P(array);
4645            ptr = (HashPointer*)EX_VAR((opline+1)->op1.var);
4646            pos = ptr->pos;
4647            if (pos == INVALID_IDX) {
4648                /* reached end of iteration */
4649                ZEND_VM_JMP(opline->op2.jmp_addr);
4650            } else if (UNEXPECTED(ptr->ht != fe_ht)) {
4651                ptr->ht = fe_ht;
4652                pos = 0;
4653            } else if (UNEXPECTED(fe_ht->nInternalPointer != ptr->pos)) {
4654                if (fe_ht->u.flags & HASH_FLAG_PACKED) {
4655                    pos = ptr->h;
4656                } else {
4657                    pos = fe_ht->arHash[ptr->h & fe_ht->nTableMask];
4658                    while (pos != INVALID_IDX) {
4659                        if (fe_ht->arData[pos].h == ptr->h && pos == ptr->pos) {
4660                            break;
4661                        }
4662                        pos = Z_NEXT(fe_ht->arData[pos].val);
4663                    }
4664                }
4665            }
4666            while (1) {
4667                if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
4668                    /* reached end of iteration */
4669                    ZEND_VM_JMP(opline->op2.jmp_addr);
4670                }
4671
4672                p = fe_ht->arData + pos;
4673                value = &p->val;
4674                if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4675                    pos++;
4676                    continue;
4677                } else if (UNEXPECTED(Z_TYPE_P(value) == IS_INDIRECT)) {
4678                    value = Z_INDIRECT_P(value);
4679                    if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4680                        pos++;
4681                        continue;
4682                    }
4683                }
4684
4685                if (UNEXPECTED(!p->key)) {
4686                    if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4687                        ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
4688                    }
4689                    break;
4690                } else if (zend_check_property_access(zobj, p->key TSRMLS_CC) == SUCCESS) {
4691                    if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4692                        if (p->key->val[0]) {
4693                            ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
4694                        } else {
4695                            const char *class_name, *prop_name;
4696                            size_t prop_name_len;
4697                            zend_unmangle_property_name_ex(
4698                                p->key, &class_name, &prop_name, &prop_name_len);
4699                            ZVAL_STRINGL(EX_VAR((opline+1)->result.var), prop_name, prop_name_len);
4700                        }
4701                    }
4702                    break;
4703                }
4704                pos++;
4705            }
4706            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4707                ZVAL_MAKE_REF(value);
4708                Z_ADDREF_P(value);
4709                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4710            } else {
4711                ZVAL_COPY(EX_VAR(opline->result.var), value);
4712            }
4713            do {
4714                pos++;
4715                if (pos >= fe_ht->nNumUsed) {
4716                    fe_ht->nInternalPointer = ptr->pos = INVALID_IDX;
4717                    ZEND_VM_INC_OPCODE();
4718                    ZEND_VM_NEXT_OPCODE();
4719                }
4720                p = fe_ht->arData + pos;
4721            } while (Z_TYPE(p->val) == IS_UNDEF ||
4722                     (Z_TYPE(p->val) == IS_INDIRECT &&
4723                      Z_TYPE_P(Z_INDIRECT(p->val)) == IS_UNDEF) ||
4724                     (EXPECTED(p->key != NULL) &&
4725                      zend_check_property_access(zobj, p->key TSRMLS_CC) == FAILURE));
4726            fe_ht->nInternalPointer = ptr->pos = pos;
4727            ptr->h = fe_ht->arData[pos].h;
4728            ZEND_VM_INC_OPCODE();
4729            ZEND_VM_NEXT_OPCODE();
4730        } else {
4731            /* !iter happens from exception */
4732            if (iter && ++iter->index > 0) {
4733                /* This could cause an endless loop if index becomes zero again.
4734                 * In case that ever happens we need an additional flag. */
4735                iter->funcs->move_forward(iter TSRMLS_CC);
4736                if (UNEXPECTED(EG(exception) != NULL)) {
4737                    zval_ptr_dtor(array_ref);
4738                    HANDLE_EXCEPTION();
4739                }
4740            }
4741            /* If index is zero we come from FE_RESET and checked valid() already. */
4742            if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
4743                /* reached end of iteration */
4744                if (UNEXPECTED(EG(exception) != NULL)) {
4745                    zval_ptr_dtor(array_ref);
4746                    HANDLE_EXCEPTION();
4747                }
4748                ZEND_VM_JMP(opline->op2.jmp_addr);
4749            }
4750            value = iter->funcs->get_current_data(iter TSRMLS_CC);
4751            if (UNEXPECTED(EG(exception) != NULL)) {
4752                zval_ptr_dtor(array_ref);
4753                HANDLE_EXCEPTION();
4754            }
4755            if (!value) {
4756                /* failure in get_current_data */
4757                ZEND_VM_JMP(opline->op2.jmp_addr);
4758            }
4759            if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
4760                ZVAL_MAKE_REF(value);
4761                Z_ADDREF_P(value);
4762                ZVAL_REF(EX_VAR(opline->result.var), Z_REF_P(value));
4763            } else {
4764                ZVAL_COPY(EX_VAR(opline->result.var), value);
4765            }
4766            if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
4767                if (iter->funcs->get_current_key) {
4768                    iter->funcs->get_current_key(iter, EX_VAR((opline+1)->result.var) TSRMLS_CC);
4769                    if (UNEXPECTED(EG(exception) != NULL)) {
4770                        zval_ptr_dtor(array_ref);
4771                        HANDLE_EXCEPTION();
4772                    }
4773                } else {
4774                    ZVAL_LONG(EX_VAR((opline+1)->result.var), iter->index);
4775                }
4776            }
4777            ZEND_VM_INC_OPCODE();
4778            ZEND_VM_NEXT_OPCODE();
4779        }
4780    } else {
4781        zend_error(E_WARNING, "Invalid argument supplied for foreach()");
4782        ZEND_VM_JMP(opline->op2.jmp_addr);
4783    }
4784}
4785
4786ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
4787{
4788    USE_OPLINE
4789    zval *value;
4790    zend_bool isset = 1;
4791
4792    SAVE_OPLINE();
4793    if (OP1_TYPE == IS_CV &&
4794        OP2_TYPE == IS_UNUSED &&
4795        (opline->extended_value & ZEND_QUICK_SET)) {
4796        if (Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_UNDEF) {
4797            value = EX_VAR(opline->op1.var);
4798            ZVAL_DEREF(value);
4799        } else {
4800            isset = 0;
4801        }
4802    } else {
4803        HashTable *target_symbol_table;
4804        zend_free_op free_op1;
4805        zval tmp, *varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
4806
4807        if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
4808            ZVAL_DUP(&tmp, varname);
4809            convert_to_string(&tmp);
4810            varname = &tmp;
4811        }
4812
4813        if (OP2_TYPE != IS_UNUSED) {
4814            zend_class_entry *ce;
4815
4816            if (OP2_TYPE == IS_CONST) {
4817                if (CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv))) {
4818                    ce = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv));
4819                } else {
4820                    ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC);
4821                    if (UNEXPECTED(ce == NULL)) {
4822                        CHECK_EXCEPTION();
4823                        ZEND_VM_NEXT_OPCODE();
4824                    }
4825                    CACHE_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce);
4826                }
4827            } else {
4828                ce = Z_CE_P(EX_VAR(opline->op2.var));
4829            }
4830            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);
4831            if (!value) {
4832                isset = 0;
4833            }
4834        } else {
4835            target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
4836            if ((value = zend_hash_find(target_symbol_table, Z_STR_P(varname))) == NULL) {
4837                isset = 0;
4838            }
4839        }
4840
4841        if (OP1_TYPE != IS_CONST && varname == &tmp) {
4842            zval_dtor(&tmp);
4843        }
4844        FREE_OP1();
4845    }
4846
4847    if (opline->extended_value & ZEND_ISSET) {
4848        if (isset && Z_TYPE_P(value) != IS_NULL &&
4849            (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL)) {
4850            ZVAL_BOOL(EX_VAR(opline->result.var), 1);
4851        } else {
4852            ZVAL_BOOL(EX_VAR(opline->result.var), 0);
4853        }
4854    } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4855        if (!isset || !i_zend_is_true(value TSRMLS_CC)) {
4856            ZVAL_BOOL(EX_VAR(opline->result.var), 1);
4857        } else {
4858            ZVAL_BOOL(EX_VAR(opline->result.var), 0);
4859        }
4860    }
4861
4862    CHECK_EXCEPTION();
4863    ZEND_VM_NEXT_OPCODE();
4864}
4865
4866ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4867{
4868    USE_OPLINE
4869    zend_free_op free_op1, free_op2;
4870    zval *container;
4871    int result;
4872    zend_ulong hval;
4873    zval *offset;
4874
4875    SAVE_OPLINE();
4876    container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS);
4877    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4878
4879    if (Z_TYPE_P(container) == IS_ARRAY) {
4880        HashTable *ht = Z_ARRVAL_P(container);
4881        zval *value;
4882        zend_string *str;
4883
4884ZEND_VM_C_LABEL(isset_again):
4885        if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
4886            str = Z_STR_P(offset);
4887            if (OP2_TYPE != IS_CONST) {
4888                if (ZEND_HANDLE_NUMERIC(str, hval)) {
4889                    ZEND_VM_C_GOTO(num_index_prop);
4890                }
4891            }
4892ZEND_VM_C_LABEL(str_index_prop):
4893            value = zend_hash_find_ind(ht, str);
4894        } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4895            hval = Z_LVAL_P(offset);
4896ZEND_VM_C_LABEL(num_index_prop):
4897            value = zend_hash_index_find(ht, hval);
4898        } else {
4899            switch (Z_TYPE_P(offset)) {
4900                case IS_DOUBLE:
4901                    hval = zend_dval_to_lval(Z_DVAL_P(offset));
4902                    ZEND_VM_C_GOTO(num_index_prop);
4903                case IS_NULL:
4904                    str = STR_EMPTY_ALLOC();
4905                    ZEND_VM_C_GOTO(str_index_prop);
4906                case IS_FALSE:
4907                    hval = 0;
4908                    ZEND_VM_C_GOTO(num_index_prop);
4909                case IS_TRUE:
4910                    hval = 1;
4911                    ZEND_VM_C_GOTO(num_index_prop);
4912                case IS_RESOURCE:
4913                    hval = Z_RES_HANDLE_P(offset);
4914                    ZEND_VM_C_GOTO(num_index_prop);
4915                case IS_REFERENCE:
4916                    offset = Z_REFVAL_P(offset);
4917                    ZEND_VM_C_GOTO(isset_again);
4918                default:
4919                    zend_error(E_WARNING, "Illegal offset type in isset or empty");
4920                    value = NULL;
4921                    break;
4922            }
4923        }
4924
4925        if (opline->extended_value & ZEND_ISSET) {
4926            /* > IS_NULL means not IS_UNDEF and not IS_NULL */
4927            result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
4928                (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
4929        } else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
4930            result = (value == NULL || !i_zend_is_true(value TSRMLS_CC));
4931        }
4932    } else if (Z_TYPE_P(container) == IS_OBJECT) {
4933        if (Z_OBJ_HT_P(container)->has_dimension) {
4934            result = Z_OBJ_HT_P(container)->has_dimension(container, offset, (opline->extended_value & ZEND_ISSET) == 0 TSRMLS_CC);
4935        } else {
4936            zend_error(E_NOTICE, "Trying to check element of non-array");
4937            result = 0;
4938        }
4939        if ((opline->extended_value & ZEND_ISSET) == 0) {
4940            result = !result;
4941        }
4942    } else if (Z_TYPE_P(container) == IS_STRING) { /* string offsets */
4943        zval tmp;
4944
4945        result = 0;
4946        if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) {
4947            if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
4948                ZVAL_DEREF(offset);
4949            }
4950            if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
4951                    || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
4952                        && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
4953                ZVAL_DUP(&tmp, offset);
4954                convert_to_long(&tmp);
4955                offset = &tmp;
4956            }
4957        }
4958        if (Z_TYPE_P(offset) == IS_LONG) {
4959            if (offset->value.lval >= 0 && (size_t)offset->value.lval < Z_STRLEN_P(container)) {
4960                if ((opline->extended_value & ZEND_ISSET) ||
4961                    Z_STRVAL_P(container)[offset->value.lval] != '0') {
4962                    result = 1;
4963                }
4964            }
4965        }
4966        if ((opline->extended_value & ZEND_ISSET) == 0) {
4967            result = !result;
4968        }
4969    } else {
4970        result = ((opline->extended_value & ZEND_ISSET) == 0);
4971    }
4972
4973    FREE_OP2();
4974    ZVAL_BOOL(EX_VAR(opline->result.var), result);
4975    FREE_OP1();
4976    CHECK_EXCEPTION();
4977    ZEND_VM_NEXT_OPCODE();
4978}
4979
4980ZEND_VM_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)
4981{
4982    USE_OPLINE
4983    zend_free_op free_op1, free_op2;
4984    zval *container;
4985    int result;
4986    zval *offset;
4987
4988    SAVE_OPLINE();
4989    container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS);
4990    offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
4991
4992    if (Z_TYPE_P(container) == IS_OBJECT) {
4993        if (Z_OBJ_HT_P(container)->has_property) {
4994            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);
4995        } else {
4996            zend_error(E_NOTICE, "Trying to check property of non-object");
4997            result = 0;
4998        }
4999        if ((opline->extended_value & ZEND_ISSET) == 0) {
5000            result = !result;
5001        }
5002    } else {
5003        result = ((opline->extended_value & ZEND_ISSET) == 0);
5004    }
5005
5006    FREE_OP2();
5007    ZVAL_BOOL(EX_VAR(opline->result.var), result);
5008    FREE_OP1();
5009    CHECK_EXCEPTION();
5010    ZEND_VM_NEXT_OPCODE();
5011}
5012
5013ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMP|VAR|UNUSED|CV, ANY)
5014{
5015#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
5016    USE_OPLINE
5017
5018    SAVE_OPLINE();
5019    if (OP1_TYPE != IS_UNUSED) {
5020        zend_free_op free_op1;
5021        zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
5022
5023        if (Z_TYPE_P(ptr) == IS_LONG) {
5024            EG(exit_status) = Z_LVAL_P(ptr);
5025        } else {
5026            zend_print_variable(ptr TSRMLS_CC);
5027        }
5028        FREE_OP1();
5029    }
5030#endif
5031    zend_bailout();
5032    ZEND_VM_NEXT_OPCODE(); /* Never reached */
5033}
5034
5035ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY)
5036{
5037    USE_OPLINE
5038
5039    SAVE_OPLINE();
5040    ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));
5041    if (Z_TYPE(EX(old_error_reporting)) == IS_UNDEF) {
5042        ZVAL_LONG(&EX(old_error_reporting), EG(error_reporting));
5043        EX(old_error_reporting).u2.silence_num = opline->op2.num;
5044    }
5045
5046    if (EG(error_reporting)) {
5047        do {
5048            EG(error_reporting) = 0;
5049            if (!EG(error_reporting_ini_entry)) {
5050                zend_ini_entry *p = zend_hash_str_find_ptr(EG(ini_directives), "error_reporting", sizeof("error_reporting")-1);
5051                if (p) {
5052                    EG(error_reporting_ini_entry) = p;
5053                } else {
5054                    break;
5055                }
5056            }
5057            if (!EG(error_reporting_ini_entry)->modified) {
5058                if (!EG(modified_ini_directives)) {
5059                    ALLOC_HASHTABLE(EG(modified_ini_directives));
5060                    zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
5061                }
5062                if (EXPECTED(zend_hash_str_add_ptr(EG(modified_ini_directives), "error_reporting", sizeof("error_reporting")-1, EG(error_reporting_ini_entry)) != NULL)) {
5063                    EG(error_reporting_ini_entry)->orig_value = EG(error_reporting_ini_entry)->value;
5064                    EG(error_reporting_ini_entry)->orig_modifiable = EG(error_reporting_ini_entry)->modifiable;
5065                    EG(error_reporting_ini_entry)->modified = 1;
5066                }
5067            }
5068        } while (0);
5069    }
5070    CHECK_EXCEPTION();
5071    ZEND_VM_NEXT_OPCODE();
5072}
5073
5074ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY)
5075{
5076    USE_OPLINE
5077
5078    SAVE_OPLINE();
5079    if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) {
5080        EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var));
5081    }
5082    if (Z_TYPE(EX(old_error_reporting)) != IS_UNDEF &&
5083        EX(old_error_reporting).u2.silence_num == opline->op2.num) {
5084        ZVAL_UNDEF(&EX(old_error_reporting));
5085    }
5086    ZEND_VM_NEXT_OPCODE();
5087}
5088
5089ZEND_VM_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, ANY)
5090{
5091    USE_OPLINE
5092    zend_free_op free_op1;
5093    zval *value;
5094    int is_ref = 0;
5095
5096    SAVE_OPLINE();
5097    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
5098
5099    if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && Z_ISREF_P(value)) {
5100        is_ref = 1;
5101        value = Z_REFVAL_P(value);
5102    }
5103    if (i_zend_is_true(value TSRMLS_CC)) {
5104        ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
5105        if (OP1_TYPE == IS_CONST) {
5106            i