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