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