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        if (EXPECTED(destroy_op_array(&EX(func)->op_array) != 0)) {
2368            efree_size(EX(func), sizeof(zend_op_array));
2369        }
2370        old_execute_data = execute_data;
2371        execute_data = EG(current_execute_data) = EX(prev_execute_data);
2372        zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
2373
2374        zend_attach_symbol_table(execute_data);
2375        if (UNEXPECTED(EG(exception) != NULL)) {
2376            zend_throw_exception_internal(NULL);
2377            HANDLE_EXCEPTION_LEAVE();
2378        }
2379
2380        LOAD_NEXT_OPLINE();
2381        ZEND_VM_LEAVE();
2382    } else {
2383        if (ZEND_CALL_KIND_EX(call_info) == ZEND_CALL_TOP_FUNCTION) {
2384            i_free_compiled_variables(execute_data);
2385            if (UNEXPECTED(EX(symbol_table) != NULL)) {
2386                zend_clean_and_cache_symbol_table(EX(symbol_table));
2387            }
2388            zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2389            EG(current_execute_data) = EX(prev_execute_data);
2390            if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2391                OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
2392            }
2393        } else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
2394            zend_array *symbol_table = EX(symbol_table);
2395
2396            zend_detach_symbol_table(execute_data);
2397            old_execute_data = EX(prev_execute_data);
2398            while (old_execute_data) {
2399                if (old_execute_data->func && ZEND_USER_CODE(old_execute_data->func->op_array.type)) {
2400                    if (old_execute_data->symbol_table == symbol_table) {
2401                        zend_attach_symbol_table(old_execute_data);
2402                    }
2403                    break;
2404                }
2405                old_execute_data = old_execute_data->prev_execute_data;
2406            }
2407            EG(current_execute_data) = EX(prev_execute_data);
2408        }
2409
2410        ZEND_VM_RETURN();
2411    }
2412}
2413
2414ZEND_VM_HANDLER(42, ZEND_JMP, ANY, ANY)
2415{
2416    USE_OPLINE
2417
2418    ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op1));
2419    ZEND_VM_CONTINUE();
2420}
2421
2422ZEND_VM_HANDLER(43, ZEND_JMPZ, CONST|TMPVAR|CV, ANY)
2423{
2424    USE_OPLINE
2425    zend_free_op free_op1;
2426    zval *val;
2427
2428    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2429
2430    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2431        ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2432        ZEND_VM_CONTINUE();
2433    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2434        if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2435            SAVE_OPLINE();
2436            GET_OP1_UNDEF_CV(val, BP_VAR_R);
2437            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2438        } else {
2439            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2440            ZEND_VM_CONTINUE();
2441        }
2442    }
2443
2444    SAVE_OPLINE();
2445    if (i_zend_is_true(val)) {
2446        opline++;
2447    } else {
2448        opline = OP_JMP_ADDR(opline, opline->op2);
2449    }
2450    FREE_OP1();
2451    if (UNEXPECTED(EG(exception) != NULL)) {
2452        HANDLE_EXCEPTION();
2453    }
2454    ZEND_VM_JMP(opline);
2455}
2456
2457ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMPVAR|CV, ANY)
2458{
2459    USE_OPLINE
2460    zend_free_op free_op1;
2461    zval *val;
2462
2463    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2464
2465    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2466        ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2467        ZEND_VM_CONTINUE();
2468    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2469        if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2470            SAVE_OPLINE();
2471            GET_OP1_UNDEF_CV(val, BP_VAR_R);
2472            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2473        } else {
2474            ZEND_VM_NEXT_OPCODE();
2475        }
2476    }
2477
2478    SAVE_OPLINE();
2479    if (i_zend_is_true(val)) {
2480        opline = OP_JMP_ADDR(opline, opline->op2);
2481    } else {
2482        opline++;
2483    }
2484    FREE_OP1();
2485    if (UNEXPECTED(EG(exception) != NULL)) {
2486        HANDLE_EXCEPTION();
2487    }
2488    ZEND_VM_JMP(opline);
2489}
2490
2491ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, ANY)
2492{
2493    USE_OPLINE
2494    zend_free_op free_op1;
2495    zval *val;
2496
2497    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2498
2499    if (EXPECTED(Z_TYPE_INFO_P(val) == IS_TRUE)) {
2500        ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
2501        ZEND_VM_CONTINUE();
2502    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2503        if (OP1_TYPE == IS_CV) {
2504            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2505                SAVE_OPLINE();
2506                GET_OP1_UNDEF_CV(val, BP_VAR_R);
2507            }
2508            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2509        } else {
2510            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2511            ZEND_VM_CONTINUE();
2512        }
2513    }
2514
2515    SAVE_OPLINE();
2516    if (i_zend_is_true(val)) {
2517        opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
2518    } else {
2519        opline = OP_JMP_ADDR(opline, opline->op2);
2520    }
2521    FREE_OP1();
2522    if (UNEXPECTED(EG(exception) != NULL)) {
2523        HANDLE_EXCEPTION();
2524    }
2525    ZEND_VM_JMP(opline);
2526}
2527
2528ZEND_VM_HANDLER(46, ZEND_JMPZ_EX, CONST|TMPVAR|CV, ANY)
2529{
2530    USE_OPLINE
2531    zend_free_op free_op1;
2532    zval *val;
2533    int ret;
2534
2535    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2536
2537    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2538        ZVAL_TRUE(EX_VAR(opline->result.var));
2539        ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2540        ZEND_VM_CONTINUE();
2541    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2542        ZVAL_FALSE(EX_VAR(opline->result.var));
2543        if (OP1_TYPE == IS_CV) {
2544            if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2545                SAVE_OPLINE();
2546                GET_OP1_UNDEF_CV(val, BP_VAR_R);
2547            }
2548            ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2549        } else {
2550            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2551            ZEND_VM_CONTINUE();
2552        }
2553    }
2554
2555    SAVE_OPLINE();
2556    ret = i_zend_is_true(val);
2557    FREE_OP1();
2558    if (ret) {
2559        ZVAL_TRUE(EX_VAR(opline->result.var));
2560        opline++;
2561    } else {
2562        ZVAL_FALSE(EX_VAR(opline->result.var));
2563        opline = OP_JMP_ADDR(opline, opline->op2);
2564    }
2565    if (UNEXPECTED(EG(exception) != NULL)) {
2566        HANDLE_EXCEPTION();
2567    }
2568    ZEND_VM_JMP(opline);
2569}
2570
2571ZEND_VM_HANDLER(47, ZEND_JMPNZ_EX, CONST|TMPVAR|CV, ANY)
2572{
2573    USE_OPLINE
2574    zend_free_op free_op1;
2575    zval *val;
2576    int ret;
2577
2578    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2579
2580    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2581        ZVAL_TRUE(EX_VAR(opline->result.var));
2582        ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2583        ZEND_VM_CONTINUE();
2584    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2585        ZVAL_FALSE(EX_VAR(opline->result.var));
2586        if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2587            SAVE_OPLINE();
2588            GET_OP1_UNDEF_CV(val, BP_VAR_R);
2589            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2590        } else {
2591            ZEND_VM_NEXT_OPCODE();
2592        }
2593    }
2594
2595    SAVE_OPLINE();
2596    ret = i_zend_is_true(val);
2597    FREE_OP1();
2598    if (ret) {
2599        ZVAL_TRUE(EX_VAR(opline->result.var));
2600        opline = OP_JMP_ADDR(opline, opline->op2);
2601    } else {
2602        ZVAL_FALSE(EX_VAR(opline->result.var));
2603        opline++;
2604    }
2605    if (UNEXPECTED(EG(exception) != NULL)) {
2606        HANDLE_EXCEPTION();
2607    }
2608    ZEND_VM_JMP(opline);
2609}
2610
2611ZEND_VM_HANDLER(70, ZEND_FREE, TMPVAR, ANY)
2612{
2613    zval *var;
2614    USE_OPLINE
2615
2616    SAVE_OPLINE();
2617    var = EX_VAR(opline->op1.var);
2618    zval_ptr_dtor_nogc(var);
2619    ZVAL_NULL(var);
2620    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2621}
2622
2623ZEND_VM_HANDLER(127, ZEND_FE_FREE, TMPVAR, ANY)
2624{
2625    zval *var;
2626    USE_OPLINE
2627
2628    SAVE_OPLINE();
2629    var = EX_VAR(opline->op1.var);
2630    if (Z_TYPE_P(var) != IS_ARRAY && Z_FE_ITER_P(var) != (uint32_t)-1) {
2631        zend_hash_iterator_del(Z_FE_ITER_P(var));
2632        Z_FE_ITER_P(var) = (uint32_t)-1;
2633    }
2634    zval_ptr_dtor_nogc(var);
2635    ZVAL_NULL(var);
2636    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2637}
2638
2639ZEND_VM_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
2640{
2641    USE_OPLINE
2642    zend_free_op free_op1, free_op2;
2643    zval *op1, *op2;
2644    zend_string *op1_str, *op2_str, *str;
2645
2646    SAVE_OPLINE();
2647    op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2648    if (OP1_TYPE == IS_CONST) {
2649        op1_str = Z_STR_P(op1);
2650    } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
2651        op1_str = zend_string_copy(Z_STR_P(op1));
2652    } else {
2653        if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
2654            GET_OP1_UNDEF_CV(op1, BP_VAR_R);
2655        }
2656        op1_str = _zval_get_string_func(op1);
2657    }
2658    op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2659    if (OP2_TYPE == IS_CONST) {
2660        op2_str = Z_STR_P(op2);
2661    } else if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
2662        op2_str = zend_string_copy(Z_STR_P(op2));
2663    } else {
2664        if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
2665            GET_OP2_UNDEF_CV(op2, BP_VAR_R);
2666        }
2667        op2_str = _zval_get_string_func(op2);
2668    }
2669    do {
2670        if (OP1_TYPE != IS_CONST) {
2671            if (UNEXPECTED(ZSTR_LEN(op1_str) == 0)) {
2672                if (OP2_TYPE == IS_CONST) {
2673                    zend_string_addref(op2_str);
2674                }
2675                ZVAL_STR(EX_VAR(opline->result.var), op2_str);
2676                zend_string_release(op1_str);
2677                break;
2678            }
2679        }
2680        if (OP2_TYPE != IS_CONST) {
2681            if (UNEXPECTED(ZSTR_LEN(op2_str) == 0)) {
2682                if (OP1_TYPE == IS_CONST) {
2683                    zend_string_addref(op1_str);
2684                }
2685                ZVAL_STR(EX_VAR(opline->result.var), op1_str);
2686                zend_string_release(op2_str);
2687                break;
2688            }
2689        }
2690        str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
2691        memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
2692        memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
2693        ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
2694        if (OP1_TYPE != IS_CONST) {
2695            zend_string_release(op1_str);
2696        }
2697        if (OP2_TYPE != IS_CONST) {
2698            zend_string_release(op2_str);
2699        }
2700    } while (0);
2701    FREE_OP1();
2702    FREE_OP2();
2703    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2704}
2705
2706ZEND_VM_HANDLER(54, ZEND_ROPE_INIT, UNUSED, CONST|TMPVAR|CV)
2707{
2708    USE_OPLINE
2709    zend_free_op free_op2;
2710    zend_string **rope;
2711    zval *var;
2712
2713    /* Compiler allocates the necessary number of zval slots to keep the rope */
2714    rope = (zend_string**)EX_VAR(opline->result.var);
2715    if (OP2_TYPE == IS_CONST) {
2716        var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2717        rope[0] = zend_string_copy(Z_STR_P(var));
2718    } else {
2719        var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2720        if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2721            if (OP2_TYPE == IS_CV) {
2722                rope[0] = zend_string_copy(Z_STR_P(var));
2723            } else {
2724                rope[0] = Z_STR_P(var);
2725            }
2726        } else {
2727            SAVE_OPLINE();
2728            if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
2729                GET_OP2_UNDEF_CV(var, BP_VAR_R);
2730            }
2731            rope[0] = _zval_get_string_func(var);
2732            FREE_OP2();
2733            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2734        }
2735    }
2736    ZEND_VM_NEXT_OPCODE();
2737}
2738
2739ZEND_VM_HANDLER(55, ZEND_ROPE_ADD, TMP, CONST|TMPVAR|CV)
2740{
2741    USE_OPLINE
2742    zend_free_op free_op2;
2743    zend_string **rope;
2744    zval *var;
2745
2746    /* op1 and result are the same */
2747    rope = (zend_string**)EX_VAR(opline->op1.var);
2748    if (OP2_TYPE == IS_CONST) {
2749        var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2750        rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2751    } else {
2752        var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2753        if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2754            if (OP2_TYPE == IS_CV) {
2755                rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2756            } else {
2757                rope[opline->extended_value] = Z_STR_P(var);
2758            }
2759        } else {
2760            SAVE_OPLINE();
2761            if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
2762                GET_OP2_UNDEF_CV(var, BP_VAR_R);
2763            }
2764            rope[opline->extended_value] = _zval_get_string_func(var);
2765            FREE_OP2();
2766            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2767        }
2768    }
2769    ZEND_VM_NEXT_OPCODE();
2770}
2771
2772ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV)
2773{
2774    USE_OPLINE
2775    zend_free_op free_op2;
2776    zend_string **rope;
2777    zval *var, *ret;
2778    uint32_t i;
2779    size_t len = 0;
2780    char *target;
2781
2782    rope = (zend_string**)EX_VAR(opline->op1.var);
2783    if (OP2_TYPE == IS_CONST) {
2784        var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2785        rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2786    } else {
2787        var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2788        if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2789            if (OP2_TYPE == IS_CV) {
2790                rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2791            } else {
2792                rope[opline->extended_value] = Z_STR_P(var);
2793            }
2794        } else {
2795            SAVE_OPLINE();
2796            if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
2797                GET_OP2_UNDEF_CV(var, BP_VAR_R);
2798            }
2799            rope[opline->extended_value] = _zval_get_string_func(var);
2800            FREE_OP2();
2801            if (UNEXPECTED(EG(exception))) {
2802                for (i = 0; i <= opline->extended_value; i++) {
2803                    zend_string_release(rope[i]);
2804                }
2805                HANDLE_EXCEPTION();
2806            }
2807        }
2808    }
2809    for (i = 0; i <= opline->extended_value; i++) {
2810        len += ZSTR_LEN(rope[i]);
2811    }
2812    ret = EX_VAR(opline->result.var);
2813    ZVAL_STR(ret, zend_string_alloc(len, 0));
2814    target = Z_STRVAL_P(ret);
2815    for (i = 0; i <= opline->extended_value; i++) {
2816        memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
2817        target += ZSTR_LEN(rope[i]);
2818        zend_string_release(rope[i]);
2819    }
2820    *target = '\0';
2821
2822    ZEND_VM_NEXT_OPCODE();
2823}
2824
2825ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMPVAR|UNUSED|CV)
2826{
2827    USE_OPLINE
2828
2829    SAVE_OPLINE();
2830    if (OP2_TYPE == IS_UNUSED) {
2831        Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
2832        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2833    } else {
2834        zend_free_op free_op2;
2835        zval *class_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2836
2837ZEND_VM_C_LABEL(try_class_name):
2838        if (OP2_TYPE == IS_CONST) {
2839            if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) {
2840                Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
2841            } else {
2842                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);
2843                CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var)));
2844            }
2845        } else if (Z_TYPE_P(class_name) == IS_OBJECT) {
2846            Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
2847        } else if (Z_TYPE_P(class_name) == IS_STRING) {
2848            Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
2849        } else if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
2850            class_name = Z_REFVAL_P(class_name);
2851            ZEND_VM_C_GOTO(try_class_name);
2852        } else {
2853            if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
2854                GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
2855            }
2856            if (UNEXPECTED(EG(exception) != NULL)) {
2857                HANDLE_EXCEPTION();
2858            }
2859            zend_throw_error(NULL, "Class name must be a valid object or a string");
2860        }
2861
2862        FREE_OP2();
2863        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2864    }
2865}
2866
2867ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|CV, CONST|TMPVAR|CV)
2868{
2869    USE_OPLINE
2870    zval *function_name;
2871    zend_free_op free_op1, free_op2;
2872    zval *object;
2873    zend_function *fbc;
2874    zend_class_entry *called_scope;
2875    zend_object *obj;
2876    zend_execute_data *call;
2877    uint32_t call_info;
2878
2879    SAVE_OPLINE();
2880
2881    function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2882
2883    if (OP2_TYPE != IS_CONST &&
2884        UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
2885        do {
2886            if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(function_name)) {
2887                function_name = Z_REFVAL_P(function_name);
2888                if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
2889                    break;
2890                }
2891            }
2892            if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
2893                GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
2894            }
2895            if (UNEXPECTED(EG(exception) != NULL)) {
2896                HANDLE_EXCEPTION();
2897            }
2898            zend_throw_error(NULL, "Method name must be a string");
2899            FREE_OP2();
2900            FREE_UNFETCHED_OP1();
2901            HANDLE_EXCEPTION();
2902        } while (0);
2903    }
2904
2905    object = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_R);
2906
2907    if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_OBJ_P(object) == NULL)) {
2908        zend_throw_error(NULL, "Using $this when not in object context");
2909        FREE_OP2();
2910        HANDLE_EXCEPTION();
2911    }
2912
2913    if (OP1_TYPE != IS_UNUSED) {
2914        do {
2915            if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
2916                if ((OP1_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) {
2917                    object = Z_REFVAL_P(object);
2918                    if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
2919                        break;
2920                    }
2921                }
2922                if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
2923                    GET_OP1_UNDEF_CV(object, BP_VAR_R);
2924                }
2925                if (UNEXPECTED(EG(exception) != NULL)) {
2926                    HANDLE_EXCEPTION();
2927                }
2928                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)));
2929                FREE_OP2();
2930                FREE_OP1();
2931                HANDLE_EXCEPTION();
2932            }
2933        } while (0);
2934    }
2935
2936    obj = Z_OBJ_P(object);
2937    called_scope = obj->ce;
2938
2939    if (OP2_TYPE != IS_CONST ||
2940        UNEXPECTED((fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope)) == NULL)) {
2941        zend_object *orig_obj = obj;
2942
2943        if (UNEXPECTED(obj->handlers->get_method == NULL)) {
2944            zend_throw_error(NULL, "Object does not support method calls");
2945            FREE_OP2();
2946            FREE_OP1();
2947            HANDLE_EXCEPTION();
2948        }
2949
2950        /* First, locate the function. */
2951        fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (EX_CONSTANT(opline->op2) + 1) : NULL));
2952        if (UNEXPECTED(fbc == NULL)) {
2953            if (EXPECTED(!EG(exception))) {
2954                zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(obj->ce->name), Z_STRVAL_P(function_name));
2955            }
2956            FREE_OP2();
2957            FREE_OP1();
2958            HANDLE_EXCEPTION();
2959        }
2960        if (OP2_TYPE == IS_CONST &&
2961            EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
2962            EXPECTED(!(fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE|ZEND_ACC_NEVER_CACHE))) &&
2963            EXPECTED(obj == orig_obj)) {
2964            CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope, fbc);
2965        }
2966    }
2967
2968    call_info = ZEND_CALL_NESTED_FUNCTION;
2969    if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) {
2970        obj = NULL;
2971    } else if (OP1_TYPE & (IS_VAR|IS_TMP_VAR|IS_CV)) {
2972        /* CV may be changed indirectly (e.g. when it's a reference) */
2973        call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS;
2974        GC_REFCOUNT(obj)++; /* For $this pointer */
2975    }
2976
2977    call = zend_vm_stack_push_call_frame(call_info,
2978        fbc, opline->extended_value, called_scope, obj);
2979    call->prev_execute_data = EX(call);
2980    EX(call) = call;
2981
2982    FREE_OP2();
2983    FREE_OP1();
2984
2985    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2986}
2987
2988ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMPVAR|UNUSED|CV)
2989{
2990    USE_OPLINE
2991    zval *function_name;
2992    zend_class_entry *ce;
2993    zend_object *object;
2994    zend_function *fbc;
2995    zend_execute_data *call;
2996
2997    SAVE_OPLINE();
2998
2999    if (OP1_TYPE == IS_CONST) {
3000        /* no function found. try a static method in class */
3001        if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
3002            ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
3003        } else {
3004            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);
3005            if (UNEXPECTED(EG(exception) != NULL)) {
3006                HANDLE_EXCEPTION();
3007            }
3008            if (UNEXPECTED(ce == NULL)) {
3009                zend_throw_error(NULL, "Class '%s' not found", Z_STRVAL_P(EX_CONSTANT(opline->op1)));
3010                HANDLE_EXCEPTION();
3011            }
3012            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
3013        }
3014    } else {
3015        ce = Z_CE_P(EX_VAR(opline->op1.var));
3016    }
3017
3018    if (OP1_TYPE == IS_CONST &&
3019        OP2_TYPE == IS_CONST &&
3020        CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
3021        fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
3022    } else if (OP1_TYPE != IS_CONST &&
3023               OP2_TYPE == IS_CONST &&
3024               (fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce))) {
3025        /* do nothing */
3026    } else if (OP2_TYPE != IS_UNUSED) {
3027        zend_free_op free_op2;
3028
3029        function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3030        if (OP2_TYPE != IS_CONST) {
3031            if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
3032                if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
3033                    GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
3034                }
3035                if (UNEXPECTED(EG(exception) != NULL)) {
3036                    HANDLE_EXCEPTION();
3037                }
3038                zend_throw_error(NULL, "Function name must be a string");
3039                FREE_OP2();
3040                HANDLE_EXCEPTION();
3041            }
3042        }
3043
3044        if (ce->get_static_method) {
3045            fbc = ce->get_static_method(ce, Z_STR_P(function_name));
3046        } else {
3047            fbc = zend_std_get_static_method(ce, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (EX_CONSTANT(opline->op2) + 1) : NULL));
3048        }
3049        if (UNEXPECTED(fbc == NULL)) {
3050            if (EXPECTED(!EG(exception))) {
3051                zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(ce->name), Z_STRVAL_P(function_name));
3052            }
3053            FREE_OP2();
3054            HANDLE_EXCEPTION();
3055        }
3056        if (OP2_TYPE == IS_CONST &&
3057            EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
3058            EXPECTED(!(fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE|ZEND_ACC_NEVER_CACHE)))) {
3059            if (OP1_TYPE == IS_CONST) {
3060                CACHE_PTR(Z_CACHE_SLOT_P(function_name), fbc);
3061            } else {
3062                CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), ce, fbc);
3063            }
3064        }
3065        if (OP2_TYPE != IS_CONST) {
3066            FREE_OP2();
3067        }
3068    } else {
3069        if (UNEXPECTED(ce->constructor == NULL)) {
3070            zend_throw_error(NULL, "Cannot call constructor");
3071            HANDLE_EXCEPTION();
3072        }
3073        if (Z_OBJ(EX(This)) && Z_OBJ(EX(This))->ce != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
3074            zend_throw_error(NULL, "Cannot call private %s::__construct()", ZSTR_VAL(ce->name));
3075            HANDLE_EXCEPTION();
3076        }
3077        fbc = ce->constructor;
3078    }
3079
3080    object = NULL;
3081    if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
3082        if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
3083            object = Z_OBJ(EX(This));
3084        }
3085        if (!object) {
3086            if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
3087                /* Allowed for PHP 4 compatibility. */
3088                zend_error(
3089                    E_DEPRECATED,
3090                    "Non-static method %s::%s() should not be called statically",
3091                    ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3092                if (UNEXPECTED(EG(exception) != NULL)) {
3093                    HANDLE_EXCEPTION();
3094                }
3095            } else {
3096                /* An internal function assumes $this is present and won't check that.
3097                 * So PHP would crash by allowing the call. */
3098                zend_throw_error(
3099                    zend_ce_error,
3100                    "Non-static method %s::%s() cannot be called statically",
3101                    ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3102                HANDLE_EXCEPTION();
3103            }
3104        }
3105    }
3106
3107    if (OP1_TYPE != IS_CONST) {
3108        /* previous opcode is ZEND_FETCH_CLASS */
3109        if (((opline-1)->extended_value & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_PARENT ||
3110            ((opline-1)->extended_value & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF) {
3111            ce = EX(called_scope);
3112        }
3113    }
3114
3115    call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3116        fbc, opline->extended_value, ce, object);
3117    call->prev_execute_data = EX(call);
3118    EX(call) = call;
3119
3120    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3121}
3122
3123ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST)
3124{
3125    USE_OPLINE
3126    zend_function *fbc;
3127    zval *function_name, *func;
3128    zend_execute_data *call;
3129
3130    if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2))))) {
3131        fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
3132    } else {
3133        function_name = (zval*)(EX_CONSTANT(opline->op2)+1);
3134        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(function_name))) == NULL)) {
3135            SAVE_OPLINE();
3136            zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
3137            HANDLE_EXCEPTION();
3138        } else {
3139            fbc = Z_FUNC_P(func);
3140            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
3141        }
3142    }
3143    call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3144        fbc, opline->extended_value, NULL, NULL);
3145    call->prev_execute_data = EX(call);
3146    EX(call) = call;
3147
3148    ZEND_VM_NEXT_OPCODE();
3149}
3150
3151ZEND_VM_HANDLER(128, ZEND_INIT_DYNAMIC_CALL, ANY, CONST|TMPVAR|CV)
3152{
3153    USE_OPLINE
3154    zend_function *fbc;
3155    zval *function_name, *func;
3156    zend_string *lcname;
3157    zend_free_op free_op2;
3158    zend_class_entry *called_scope;
3159    zend_object *object;
3160    zend_execute_data *call;
3161    uint32_t call_info = ZEND_CALL_NESTED_FUNCTION;
3162
3163    SAVE_OPLINE();
3164    function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3165
3166ZEND_VM_C_LABEL(try_function_name):
3167    if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
3168        const char *colon;
3169
3170        if ((colon = zend_memrchr(Z_STRVAL_P(function_name), ':', Z_STRLEN_P(function_name))) != NULL &&
3171            colon > Z_STRVAL_P(function_name) &&
3172            *(colon-1) == ':'
3173        ) {
3174            zend_string *mname;
3175            size_t cname_length = colon - Z_STRVAL_P(function_name) - 1;
3176            size_t mname_length = Z_STRLEN_P(function_name) - cname_length - (sizeof("::") - 1);
3177
3178            lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
3179
3180            object = NULL;
3181            called_scope = zend_fetch_class_by_name(lcname, NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
3182            if (UNEXPECTED(called_scope == NULL)) {
3183                zend_string_release(lcname);
3184                ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3185            }
3186
3187            mname = zend_string_init(Z_STRVAL_P(function_name) + (cname_length + sizeof("::") - 1), mname_length, 0);
3188
3189            if (called_scope->get_static_method) {
3190                fbc = called_scope->get_static_method(called_scope, mname);
3191            } else {
3192                fbc = zend_std_get_static_method(called_scope, mname, NULL);
3193            }
3194            if (UNEXPECTED(fbc == NULL)) {
3195                if (EXPECTED(!EG(exception))) {
3196                    zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), ZSTR_VAL(mname));
3197                }
3198                zend_string_release(lcname);
3199                zend_string_release(mname);
3200                FREE_OP2();
3201                HANDLE_EXCEPTION();
3202            }
3203
3204            zend_string_release(lcname);
3205            zend_string_release(mname);
3206
3207            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
3208                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
3209                    zend_error(E_DEPRECATED,
3210                        "Non-static method %s::%s() should not be called statically",
3211                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3212                    if (UNEXPECTED(EG(exception) != NULL)) {
3213                        HANDLE_EXCEPTION();
3214                    }
3215                } else {
3216                    zend_throw_error(
3217                        zend_ce_error,
3218                        "Non-static method %s::%s() cannot be called statically",
3219                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3220                    FREE_OP2();
3221                    HANDLE_EXCEPTION();
3222                }
3223            }
3224        } else {
3225            if (Z_STRVAL_P(function_name)[0] == '\\') {
3226                lcname = zend_string_alloc(Z_STRLEN_P(function_name) - 1, 0);
3227                zend_str_tolower_copy(ZSTR_VAL(lcname), Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1);
3228            } else {
3229                lcname = zend_string_tolower(Z_STR_P(function_name));
3230            }
3231            if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) {
3232                zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(function_name));
3233                zend_string_release(lcname);
3234                FREE_OP2();
3235                HANDLE_EXCEPTION();
3236            }
3237            zend_string_release(lcname);
3238
3239            fbc = Z_FUNC_P(func);
3240            called_scope = NULL;
3241            object = NULL;
3242        }
3243        FREE_OP2();
3244    } else if (OP2_TYPE != IS_CONST &&
3245        EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) &&
3246        Z_OBJ_HANDLER_P(function_name, get_closure) &&
3247        Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &called_scope, &fbc, &object) == SUCCESS) {
3248        if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) {
3249            /* Delay closure destruction until its invocation */
3250            ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT);
3251            GC_REFCOUNT(fbc->common.prototype)++;
3252            call_info |= ZEND_CALL_CLOSURE;
3253        } else {
3254            call_info |= ZEND_CALL_RELEASE_THIS;
3255            GC_REFCOUNT(object)++; /* For $this pointer */
3256        }
3257        FREE_OP2();
3258    } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
3259            zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
3260        zval *obj;
3261        zval *method;
3262        obj = zend_hash_index_find(Z_ARRVAL_P(function_name), 0);
3263        method = zend_hash_index_find(Z_ARRVAL_P(function_name), 1);
3264
3265        if (!obj || !method) {
3266            zend_throw_error(NULL, "Array callback has to contain indices 0 and 1");
3267            FREE_OP2();
3268            HANDLE_EXCEPTION();
3269        }
3270
3271        ZVAL_DEREF(obj);
3272        if (Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_OBJECT) {
3273            zend_throw_error(NULL, "First array member is not a valid class name or object");
3274            FREE_OP2();
3275            HANDLE_EXCEPTION();
3276        }
3277
3278        ZVAL_DEREF(method);
3279        if (Z_TYPE_P(method) != IS_STRING) {
3280            zend_throw_error(NULL, "Second array member is not a valid method");
3281            FREE_OP2();
3282            HANDLE_EXCEPTION();
3283        }
3284
3285        if (Z_TYPE_P(obj) == IS_STRING) {
3286            object = NULL;
3287            called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
3288            if (UNEXPECTED(called_scope == NULL)) {
3289                ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3290            }
3291
3292            if (called_scope->get_static_method) {
3293                fbc = called_scope->get_static_method(called_scope, Z_STR_P(method));
3294            } else {
3295                fbc = zend_std_get_static_method(called_scope, Z_STR_P(method), NULL);
3296            }
3297            if (UNEXPECTED(fbc == NULL)) {
3298                if (EXPECTED(!EG(exception))) {
3299                    zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(called_scope->name), Z_STRVAL_P(method));
3300                }
3301                FREE_OP2();
3302                HANDLE_EXCEPTION();
3303            }
3304            if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
3305                if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
3306                    zend_error(E_DEPRECATED,
3307                        "Non-static method %s::%s() should not be called statically",
3308                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3309                    if (UNEXPECTED(EG(exception) != NULL)) {
3310                        HANDLE_EXCEPTION();
3311                    }
3312                } else {
3313                    zend_throw_error(
3314                        zend_ce_error,
3315                        "Non-static method %s::%s() cannot be called statically",
3316                        ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3317                    FREE_OP2();
3318                    HANDLE_EXCEPTION();
3319                }
3320            }
3321        } else {
3322            called_scope = Z_OBJCE_P(obj);
3323            object = Z_OBJ_P(obj);
3324
3325            fbc = Z_OBJ_HT_P(obj)->get_method(&object, Z_STR_P(method), NULL);
3326            if (UNEXPECTED(fbc == NULL)) {
3327                if (EXPECTED(!EG(exception))) {
3328                    zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(object->ce->name), Z_STRVAL_P(method));
3329                }
3330                FREE_OP2();
3331                HANDLE_EXCEPTION();
3332            }
3333
3334            if ((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
3335                object = NULL;
3336            } else {
3337                call_info |= ZEND_CALL_RELEASE_THIS;
3338                GC_REFCOUNT(object)++; /* For $this pointer */
3339            }
3340        }
3341        FREE_OP2();
3342    } else if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_TYPE_P(function_name) == IS_REFERENCE) {
3343        function_name = Z_REFVAL_P(function_name);
3344        ZEND_VM_C_GOTO(try_function_name);
3345    } else {
3346        if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
3347            GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
3348        }
3349        if (UNEXPECTED(EG(exception) != NULL)) {
3350            HANDLE_EXCEPTION();
3351        }
3352        zend_throw_error(NULL, "Function name must be a string");
3353        FREE_OP2();
3354        HANDLE_EXCEPTION();
3355    }
3356    call = zend_vm_stack_push_call_frame(call_info,
3357        fbc, opline->extended_value, called_scope, object);
3358    call->prev_execute_data = EX(call);
3359    EX(call) = call;
3360
3361    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3362}
3363
3364ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV)
3365{
3366    USE_OPLINE
3367    zend_free_op free_op2;
3368    zval *function_name;
3369    zend_fcall_info_cache fcc;
3370    char *error = NULL;
3371    zend_function *func;
3372    zend_class_entry *called_scope;
3373    zend_object *object;
3374    zend_execute_data *call;
3375    uint32_t call_info = ZEND_CALL_NESTED_FUNCTION;
3376
3377    SAVE_OPLINE();
3378    function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
3379    if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
3380        func = fcc.function_handler;
3381        if (func->common.fn_flags & ZEND_ACC_CLOSURE) {
3382            /* Delay closure destruction until its invocation */
3383            if (OP2_TYPE & (IS_VAR|IS_CV)) {
3384                ZVAL_DEREF(function_name);
3385            }
3386            ZEND_ASSERT(GC_TYPE(func->common.prototype) == IS_OBJECT);
3387            GC_REFCOUNT(func->common.prototype)++;
3388            call_info |= ZEND_CALL_CLOSURE;
3389        }
3390        called_scope = fcc.called_scope;
3391        object = fcc.object;
3392        if (object) {
3393            call_info |= ZEND_CALL_RELEASE_THIS;
3394            GC_REFCOUNT(object)++; /* For $this pointer */
3395        }
3396        if (error) {
3397            efree(error);
3398            /* This is the only soft error is_callable() can generate */
3399            zend_error(E_DEPRECATED,
3400                "Non-static method %s::%s() should not be called statically",
3401                ZSTR_VAL(func->common.scope->name), ZSTR_VAL(func->common.function_name));
3402            if (UNEXPECTED(EG(exception) != NULL)) {
3403                HANDLE_EXCEPTION();
3404            }
3405        }
3406    } else {
3407        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);
3408        efree(error);
3409        func = (zend_function*)&zend_pass_function;
3410        called_scope = NULL;
3411        object = NULL;
3412    }
3413
3414    call = zend_vm_stack_push_call_frame(call_info,
3415        func, opline->extended_value, called_scope, object);
3416    call->prev_execute_data = EX(call);
3417    EX(call) = call;
3418
3419    FREE_OP2();
3420    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3421}
3422
3423ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST)
3424{
3425    USE_OPLINE
3426    zval *func_name;
3427    zval *func;
3428    zend_function *fbc;
3429    zend_execute_data *call;
3430
3431    func_name = EX_CONSTANT(opline->op2) + 1;
3432    if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
3433        fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
3434    } else if ((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL) {
3435        func_name++;
3436        if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(func_name))) == NULL)) {
3437            SAVE_OPLINE();
3438            zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
3439            HANDLE_EXCEPTION();
3440        } else {
3441            fbc = Z_FUNC_P(func);
3442            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
3443        }
3444    } else {
3445        fbc = Z_FUNC_P(func);
3446        CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
3447    }
3448
3449    call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3450        fbc, opline->extended_value, NULL, NULL);
3451    call->prev_execute_data = EX(call);
3452    EX(call) = call;
3453
3454    ZEND_VM_NEXT_OPCODE();
3455}
3456
3457ZEND_VM_HANDLER(61, ZEND_INIT_FCALL, ANY, CONST)
3458{
3459    USE_OPLINE
3460    zend_free_op free_op2;
3461    zval *fname = GET_OP2_ZVAL_PTR(BP_VAR_R);
3462    zval *func;
3463    zend_function *fbc;
3464    zend_execute_data *call;
3465
3466    if (CACHED_PTR(Z_CACHE_SLOT_P(fname))) {
3467        fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname));
3468    } else if (UNEXPECTED((func = zend_hash_find(EG(function_table), Z_STR_P(fname))) == NULL)) {
3469        SAVE_OPLINE();
3470        zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(fname));
3471        HANDLE_EXCEPTION();
3472    } else {
3473        fbc = Z_FUNC_P(func);
3474        CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
3475    }
3476
3477    call = zend_vm_stack_push_call_frame_ex(
3478        opline->op1.num, ZEND_CALL_NESTED_FUNCTION,
3479        fbc, opline->extended_value, NULL, NULL);
3480    call->prev_execute_data = EX(call);
3481    EX(call) = call;
3482
3483    ZEND_VM_NEXT_OPCODE();
3484}
3485
3486ZEND_VM_HANDLER(129, ZEND_DO_ICALL, ANY, ANY)
3487{
3488    USE_OPLINE
3489    zend_execute_data *call = EX(call);
3490    zend_function *fbc = call->func;
3491    zval *ret;
3492
3493    SAVE_OPLINE();
3494    EX(call) = call->prev_execute_data;
3495
3496    call->prev_execute_data = execute_data;
3497    EG(current_execute_data) = call;
3498
3499    ret = EX_VAR(opline->result.var);
3500    ZVAL_NULL(ret);
3501    Z_VAR_FLAGS_P(ret) = 0;
3502
3503    fbc->internal_function.handler(call, ret);
3504
3505#if ZEND_DEBUG
3506    ZEND_ASSERT(
3507        !call->func ||
3508        !(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3509        zend_verify_internal_return_type(call->func, EX_VAR(opline->result.var)));
3510#endif
3511
3512    EG(current_execute_data) = call->prev_execute_data;
3513    zend_vm_stack_free_args(call);
3514    zend_vm_stack_free_call_frame(call);
3515
3516    if (!RETURN_VALUE_USED(opline)) {
3517        zval_ptr_dtor(EX_VAR(opline->result.var));
3518    }
3519
3520    if (UNEXPECTED(EG(exception) != NULL)) {
3521        zend_throw_exception_internal(NULL);
3522        if (RETURN_VALUE_USED(opline)) {
3523            zval_ptr_dtor(EX_VAR(opline->result.var));
3524        }
3525        HANDLE_EXCEPTION();
3526    }
3527
3528    ZEND_VM_INTERRUPT_CHECK();
3529    ZEND_VM_NEXT_OPCODE();
3530}
3531
3532ZEND_VM_HANDLER(130, ZEND_DO_UCALL, ANY, ANY)
3533{
3534    USE_OPLINE
3535    zend_execute_data *call = EX(call);
3536    zend_function *fbc = call->func;
3537    zval *ret;
3538
3539    SAVE_OPLINE();
3540    EX(call) = call->prev_execute_data;
3541
3542    EG(scope) = NULL;
3543    ret = NULL;
3544    call->symbol_table = NULL;
3545    if (RETURN_VALUE_USED(opline)) {
3546        ret = EX_VAR(opline->result.var);
3547        ZVAL_NULL(ret);
3548        Z_VAR_FLAGS_P(ret) = 0;
3549    }
3550
3551    call->prev_execute_data = execute_data;
3552    i_init_func_execute_data(call, &fbc->op_array, ret, 0);
3553
3554    ZEND_VM_ENTER();
3555}
3556
3557ZEND_VM_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY)
3558{
3559    USE_OPLINE
3560    zend_execute_data *call = EX(call);
3561    zend_function *fbc = call->func;
3562    zval *ret;
3563
3564    SAVE_OPLINE();
3565    EX(call) = call->prev_execute_data;
3566
3567    if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
3568        EG(scope) = NULL;
3569        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
3570            if (EXPECTED(RETURN_VALUE_USED(opline))) {
3571                ret = EX_VAR(opline->result.var);
3572                zend_generator_create_zval(call, &fbc->op_array, ret);
3573                Z_VAR_FLAGS_P(ret) = 0;
3574            } else {
3575                zend_vm_stack_free_args(call);
3576            }
3577
3578            zend_vm_stack_free_call_frame(call);
3579        } else {
3580            ret = NULL;
3581            call->symbol_table = NULL;
3582            if (RETURN_VALUE_USED(opline)) {
3583                ret = EX_VAR(opline->result.var);
3584                ZVAL_NULL(ret);
3585                Z_VAR_FLAGS_P(ret) = 0;
3586            }
3587
3588            call->prev_execute_data = execute_data;
3589            i_init_func_execute_data(call, &fbc->op_array, ret, 0);
3590
3591            ZEND_VM_ENTER();
3592        }
3593        EG(scope) = EX(func)->op_array.scope;
3594    } else {
3595        ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
3596
3597        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
3598            zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
3599                fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
3600                fbc->common.scope ? "::" : "",
3601                ZSTR_VAL(fbc->common.function_name));
3602            if (UNEXPECTED(EG(exception) != NULL)) {
3603                HANDLE_EXCEPTION();
3604            }
3605        }
3606
3607        call->prev_execute_data = execute_data;
3608        EG(current_execute_data) = call;
3609
3610        if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
3611            uint32_t i;
3612            uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
3613            zval *p = ZEND_CALL_ARG(call, 1);
3614
3615            for (i = 0; i < num_args; ++i) {
3616                zend_verify_internal_arg_type(fbc, i + 1, p);
3617                p++;
3618            }
3619            if (UNEXPECTED(EG(exception) != NULL)) {
3620                EG(current_execute_data) = call->prev_execute_data;
3621                zend_vm_stack_free_args(call);
3622                zend_vm_stack_free_call_frame(call);
3623                zend_throw_exception_internal(NULL);
3624                HANDLE_EXCEPTION();
3625            }
3626        }
3627
3628        ret = EX_VAR(opline->result.var);
3629        ZVAL_NULL(ret);
3630        Z_VAR_FLAGS_P(ret) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
3631
3632        fbc->internal_function.handler(call, ret);
3633
3634#if ZEND_DEBUG
3635        ZEND_ASSERT(
3636            !call->func ||
3637            !(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3638            zend_verify_internal_return_type(call->func, EX_VAR(opline->result.var)));
3639#endif
3640
3641        EG(current_execute_data) = call->prev_execute_data;
3642        zend_vm_stack_free_args(call);
3643        zend_vm_stack_free_call_frame(call);
3644
3645        if (!RETURN_VALUE_USED(opline)) {
3646            zval_ptr_dtor(EX_VAR(opline->result.var));
3647        }
3648    }
3649
3650    if (UNEXPECTED(EG(exception) != NULL)) {
3651        zend_throw_exception_internal(NULL);
3652        if (RETURN_VALUE_USED(opline)) {
3653            zval_ptr_dtor(EX_VAR(opline->result.var));
3654        }
3655        HANDLE_EXCEPTION();
3656    }
3657    ZEND_VM_INTERRUPT_CHECK();
3658    ZEND_VM_NEXT_OPCODE();
3659}
3660
3661ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
3662{
3663    USE_OPLINE
3664    zend_execute_data *call = EX(call);
3665    zend_function *fbc = call->func;
3666    zend_object *object;
3667    zval *ret;
3668
3669    SAVE_OPLINE();
3670    EX(call) = call->prev_execute_data;
3671    if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
3672        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
3673            zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3674            HANDLE_EXCEPTION();
3675        }
3676        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
3677            zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
3678                fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
3679                fbc->common.scope ? "::" : "",
3680                ZSTR_VAL(fbc->common.function_name));
3681            if (UNEXPECTED(EG(exception) != NULL)) {
3682                HANDLE_EXCEPTION();
3683            }
3684        }
3685    }
3686
3687    LOAD_OPLINE();
3688
3689    if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
3690        EG(scope) = fbc->common.scope;
3691        if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
3692            if (EXPECTED(RETURN_VALUE_USED(opline))) {
3693                ret = EX_VAR(opline->result.var);
3694                zend_generator_create_zval(call, &fbc->op_array, ret);
3695                Z_VAR_FLAGS_P(ret) = 0;
3696            } else {
3697                if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_CLOSURE)) {
3698                    OBJ_RELEASE((zend_object*)fbc->op_array.prototype);
3699                }
3700                zend_vm_stack_free_args(call);
3701            }
3702        } else {
3703            ret = NULL;
3704            call->symbol_table = NULL;
3705            if (RETURN_VALUE_USED(opline)) {
3706                ret = EX_VAR(opline->result.var);
3707                ZVAL_NULL(ret);
3708                Z_VAR_FLAGS_P(ret) = 0;
3709            }
3710
3711            call->prev_execute_data = execute_data;
3712            i_init_func_execute_data(call, &fbc->op_array, ret, 1);
3713
3714            if (EXPECTED(zend_execute_ex == execute_ex)) {
3715                ZEND_VM_ENTER();
3716            } else {
3717                ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
3718                zend_execute_ex(call);
3719            }
3720        }
3721    } else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
3722        int should_change_scope = 0;
3723
3724        if (fbc->common.scope) {
3725            should_change_scope = 1;
3726            EG(scope) = fbc->common.scope;
3727        }
3728
3729        call->prev_execute_data = execute_data;
3730        EG(current_execute_data) = call;
3731
3732        if (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
3733            uint32_t i;
3734            uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
3735            zval *p = ZEND_CALL_ARG(call, 1);
3736
3737            for (i = 0; i < num_args; ++i) {
3738                zend_verify_internal_arg_type(fbc, i + 1, p);
3739                if (UNEXPECTED(EG(exception) != NULL)) {
3740                    EG(current_execute_data) = call->prev_execute_data;
3741                    zend_vm_stack_free_args(call);
3742                    if (RETURN_VALUE_USED(opline)) {
3743                        ZVAL_UNDEF(EX_VAR(opline->result.var));
3744                    }
3745                    if (UNEXPECTED(should_change_scope)) {
3746                        ZEND_VM_C_GOTO(fcall_end_change_scope);
3747                    } else {
3748                        ZEND_VM_C_GOTO(fcall_end);
3749                    }
3750                }
3751                p++;
3752            }
3753        }
3754
3755        ret = EX_VAR(opline->result.var);
3756        ZVAL_NULL(ret);
3757        Z_VAR_FLAGS_P(ret) = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0 ? IS_VAR_RET_REF : 0;
3758
3759        if (!zend_execute_internal) {
3760            /* saves one function call if zend_execute_internal is not used */
3761            fbc->internal_function.handler(call, ret);
3762        } else {
3763            zend_execute_internal(call, ret);
3764        }
3765
3766#if ZEND_DEBUG
3767        ZEND_ASSERT(
3768            !call->func ||
3769            !(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3770            zend_verify_internal_return_type(call->func, EX_VAR(opline->result.var)));
3771#endif
3772
3773        EG(current_execute_data) = call->prev_execute_data;
3774        zend_vm_stack_free_args(call);
3775
3776        if (!RETURN_VALUE_USED(opline)) {
3777            zval_ptr_dtor(EX_VAR(opline->result.var));
3778        }
3779
3780        if (UNEXPECTED(should_change_scope)) {
3781            ZEND_VM_C_GOTO(fcall_end_change_scope);
3782        } else {
3783            ZEND_VM_C_GOTO(fcall_end);
3784        }
3785    } else { /* ZEND_OVERLOADED_FUNCTION */
3786        EG(scope) = fbc->common.scope;
3787
3788        ZVAL_NULL(EX_VAR(opline->result.var));
3789
3790        /* Not sure what should be done here if it's a static method */
3791        object = Z_OBJ(call->This);
3792        if (EXPECTED(object != NULL)) {
3793            call->prev_execute_data = execute_data;
3794            EG(current_execute_data) = call;
3795            object->handlers->call_method(fbc->common.function_name, object, call, EX_VAR(opline->result.var));
3796            EG(current_execute_data) = call->prev_execute_data;
3797        } else {
3798            zend_throw_error(NULL, "Cannot call overloaded function for non-object");
3799#if 0
3800            //TODO: implement clean exit ???
3801            zend_vm_stack_free_args(call);
3802
3803            zend_vm_stack_free_call_frame(call);
3804
3805            if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
3806                zend_string_release(fbc->common.function_name);
3807            }
3808            efree(fbc);
3809#endif
3810            HANDLE_EXCEPTION();
3811        }
3812
3813        zend_vm_stack_free_args(call);
3814
3815        if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
3816            zend_string_release(fbc->common.function_name);
3817        }
3818        efree(fbc);
3819
3820        if (!RETURN_VALUE_USED(opline)) {
3821            zval_ptr_dtor(EX_VAR(opline->result.var));
3822        } else {
3823            Z_VAR_FLAGS_P(EX_VAR(opline->result.var)) = 0;
3824        }
3825    }
3826
3827ZEND_VM_C_LABEL(fcall_end_change_scope):
3828    if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS)) {
3829        object = Z_OBJ(call->This);
3830#if 0
3831        if (UNEXPECTED(EG(exception) != NULL) && (opline->op1.num & ZEND_CALL_CTOR)) {
3832            if (!(opline->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
3833#else
3834        if (UNEXPECTED(EG(exception) != NULL) && (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR)) {
3835            if (!(ZEND_CALL_INFO(call) & ZEND_CALL_CTOR_RESULT_UNUSED)) {
3836#endif
3837                GC_REFCOUNT(object)--;
3838            }
3839            if (GC_REFCOUNT(object) == 1) {
3840                zend_object_store_ctor_failed(object);
3841            }
3842        }
3843        OBJ_RELEASE(object);
3844    }
3845    EG(scope) = EX(func)->op_array.scope;
3846
3847ZEND_VM_C_LABEL(fcall_end):
3848    zend_vm_stack_free_call_frame(call);
3849    if (UNEXPECTED(EG(exception) != NULL)) {
3850        zend_throw_exception_internal(NULL);
3851        if (RETURN_VALUE_USED(opline)) {
3852            zval_ptr_dtor(EX_VAR(opline->result.var));
3853        }
3854        HANDLE_EXCEPTION();
3855    }
3856
3857    ZEND_VM_INTERRUPT_CHECK();
3858    ZEND_VM_NEXT_OPCODE();
3859}
3860
3861ZEND_VM_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV, UNUSED)
3862{
3863    USE_OPLINE
3864
3865    SAVE_OPLINE();
3866    if (OP1_TYPE == IS_UNUSED) {
3867        zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
3868    } else {
3869/* prevents "undefined variable opline" errors */
3870#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
3871        zval *retval_ref, *retval_ptr;
3872        zend_free_op free_op1;
3873        zend_arg_info *ret_info = EX(func)->common.arg_info - 1;
3874
3875        retval_ref = retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3876
3877        if (OP1_TYPE == IS_CONST) {
3878            ZVAL_COPY(EX_VAR(opline->result.var), retval_ptr);
3879            retval_ref = retval_ptr = EX_VAR(opline->result.var);
3880        } else if (OP1_TYPE == IS_VAR) {
3881            if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
3882                retval_ptr = Z_INDIRECT_P(retval_ptr);
3883            }
3884            ZVAL_DEREF(retval_ptr);
3885        } else if (OP1_TYPE == IS_CV) {
3886            ZVAL_DEREF(retval_ptr);
3887        }
3888
3889        if (UNEXPECTED(!ret_info->class_name
3890            && ret_info->type_hint != IS_CALLABLE
3891            && !ZEND_SAME_FAKE_TYPE(ret_info->type_hint, Z_TYPE_P(retval_ptr))
3892            && !(EX(func)->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE)
3893            && retval_ref != retval_ptr)
3894        ) {
3895            /* A cast might happen - unwrap the reference if this is a by-value return */
3896            if (Z_REFCOUNT_P(retval_ref) == 1) {
3897                ZVAL_UNREF(retval_ref);
3898            } else {
3899                Z_DELREF_P(retval_ref);
3900                ZVAL_COPY(retval_ref, retval_ptr);
3901            }
3902            retval_ptr = retval_ref;
3903        }
3904        zend_verify_return_type(EX(func), retval_ptr, CACHE_ADDR(opline->op2.num));
3905
3906        if (UNEXPECTED(EG(exception) != NULL)) {
3907            FREE_OP1();
3908        }
3909#endif
3910    }
3911    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3912}
3913
3914ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
3915{
3916    USE_OPLINE
3917    zval *retval_ptr;
3918    zend_free_op free_op1;
3919
3920    retval_ptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
3921    if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(retval_ptr) == IS_UNDEF)) {
3922        SAVE_OPLINE();
3923        retval_ptr = GET_OP1_UNDEF_CV(retval_ptr, BP_VAR_R);
3924        if (EX(return_value)) {
3925            ZVAL_NULL(EX(return_value));
3926        }
3927    } else if (!EX(return_value)) {
3928        if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_TMP_VAR ) {
3929            if (Z_REFCOUNTED_P(free_op1) && !Z_DELREF_P(free_op1)) {
3930                SAVE_OPLINE();
3931                zval_dtor_func_for_ptr(Z_COUNTED_P(free_op1));
3932            }
3933        }
3934    } else {
3935        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) {
3936            ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3937            if (OP1_TYPE == IS_CONST) {
3938                if (UNEXPECTED(Z_OPT_COPYABLE_P(EX(return_value)))) {
3939                    zval_copy_ctor_func(EX(return_value));
3940                }
3941            }
3942        } else if (OP1_TYPE == IS_CV) {
3943            ZVAL_DEREF(retval_ptr);
3944            ZVAL_COPY(EX(return_value), retval_ptr);
3945        } else /* if (OP1_TYPE == IS_VAR) */ {
3946            if (UNEXPECTED(Z_ISREF_P(retval_ptr))) {
3947                zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
3948
3949                retval_ptr = Z_REFVAL_P(retval_ptr);
3950                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3951                if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
3952                    efree_size(ref, sizeof(zend_reference));
3953                } else if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
3954                    Z_ADDREF_P(retval_ptr);
3955                }
3956            } else {
3957                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3958            }
3959        }
3960    }
3961    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
3962}
3963
3964ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY)
3965{
3966    USE_OPLINE
3967    zval *retval_ptr;
3968    zend_free_op free_op1;
3969
3970    SAVE_OPLINE();
3971
3972    do {
3973        if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR ||
3974            (OP1_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
3975            /* Not supposed to happen, but we'll allow it */
3976            zend_error(E_NOTICE, "Only variable references should be returned by reference");
3977
3978            retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3979            if (!EX(return_value)) {
3980                if (OP1_TYPE == IS_TMP_VAR) {
3981                    FREE_OP1();
3982                }
3983            } else {
3984                ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3985                Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
3986                if (OP1_TYPE != IS_TMP_VAR) {
3987                    zval_opt_copy_ctor_no_imm(EX(return_value));
3988                }
3989            }
3990            break;
3991        }
3992
3993        retval_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3994
3995        if (OP1_TYPE == IS_VAR && UNEXPECTED(retval_ptr == NULL)) {
3996            zend_throw_error(NULL, "Cannot return string offsets by reference");
3997            HANDLE_EXCEPTION();
3998        }
3999
4000        if (OP1_TYPE == IS_VAR) {
4001            if (retval_ptr == &EG(uninitialized_zval) ||
4002                (opline->extended_value == ZEND_RETURNS_FUNCTION &&
4003                 !(Z_VAR_FLAGS_P(retval_ptr) & IS_VAR_RET_REF))) {
4004                zend_error(E_NOTICE, "Only variable references should be returned by reference");
4005                if (EX(return_value)) {
4006                    ZVAL_NEW_REF(EX(return_value), retval_ptr);
4007                    Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
4008                    if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
4009                }
4010                break;
4011            }
4012        }
4013
4014        if (EX(return_value)) {
4015            ZVAL_MAKE_REF(retval_ptr);
4016            Z_ADDREF_P(retval_ptr);
4017            ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
4018            Z_VAR_FLAGS_P(EX(return_value)) = IS_VAR_RET_REF;
4019        }
4020    } while (0);
4021
4022    FREE_OP1_VAR_PTR();
4023    ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
4024}
4025
4026ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, CONST|TMP|VAR|CV, ANY)
4027{
4028    USE_OPLINE
4029    zval *retval;
4030    zend_free_op free_op1;
4031
4032    zend_generator *generator = zend_get_running_generator(execute_data);
4033
4034    SAVE_OPLINE();
4035    retval = GET_OP1_ZVAL_PTR(BP_VAR_R);
4036
4037    /* Copy return value into generator->retval */
4038    if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) {
4039        ZVAL_COPY_VALUE(&generator->retval, retval);
4040        if (OP1_TYPE == IS_CONST) {
4041            if (UNEXPECTED(Z_OPT_COPYABLE(generator->retval))) {
4042                zval_copy_ctor_func(&generator->retval);
4043            }
4044        }
4045    } else if (OP1_TYPE == IS_CV) {
4046        ZVAL_DEREF(retval);
4047        ZVAL_COPY(&generator->retval, retval);
4048    } else /* if (OP1_TYPE == IS_VAR) */ {
4049        if (UNEXPECTED(Z_ISREF_P(retval))) {
4050            zend_refcounted *ref = Z_COUNTED_P(retval);
4051
4052            retval = Z_REFVAL_P(retval);
4053            ZVAL_COPY_VALUE(&generator->retval, retval);
4054            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4055                efree_size(ref, sizeof(zend_reference));
4056            } else if (Z_OPT_REFCOUNTED_P(retval)) {
4057                Z_ADDREF_P(retval);
4058            }
4059        } else {
4060            ZVAL_COPY_VALUE(&generator->retval, retval);
4061        }
4062    }
4063
4064    /* Close the generator to free up resources */
4065    zend_generator_close(generator, 1);
4066
4067    /* Pass execution back to handling code */
4068    ZEND_VM_RETURN();
4069}
4070
4071ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
4072{
4073    USE_OPLINE
4074    zval *value;
4075    zend_free_op free_op1;
4076
4077    SAVE_OPLINE();
4078    value = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4079
4080    do {
4081        if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
4082            if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
4083                value = Z_REFVAL_P(value);
4084                if (EXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
4085                    break;
4086                }
4087            }
4088            if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4089                GET_OP1_UNDEF_CV(value, BP_VAR_R);
4090            }
4091            if (UNEXPECTED(EG(exception) != NULL)) {
4092                HANDLE_EXCEPTION();
4093            }
4094            zend_throw_error(NULL, "Can only throw objects");
4095            FREE_OP1();
4096            HANDLE_EXCEPTION();
4097        }
4098    } while (0);
4099
4100    zend_exception_save();
4101    if (OP1_TYPE != IS_TMP_VAR) {
4102        if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4103    }
4104
4105    zend_throw_exception_object(value);
4106    zend_exception_restore();
4107    FREE_OP1_IF_VAR();
4108    HANDLE_EXCEPTION();
4109}
4110
4111ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
4112{
4113    USE_OPLINE
4114    zend_class_entry *ce, *catch_ce;
4115    zend_object *exception;
4116
4117    SAVE_OPLINE();
4118    /* Check whether an exception has been thrown, if not, jump over code */
4119    zend_exception_restore();
4120    if (EG(exception) == NULL) {
4121        ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
4122        ZEND_VM_CONTINUE(); /* CHECK_ME */
4123    }
4124    if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
4125        catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
4126    } else {
4127        catch_ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op1)), EX_CONSTANT(opline->op1) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD);
4128
4129        CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), catch_ce);
4130    }
4131    ce = EG(exception)->ce;
4132
4133#ifdef HAVE_DTRACE
4134    if (DTRACE_EXCEPTION_CAUGHT_ENABLED()) {
4135        DTRACE_EXCEPTION_CAUGHT((char *)ce->name);
4136    }
4137#endif /* HAVE_DTRACE */
4138
4139    if (ce != catch_ce) {
4140        if (!catch_ce || !instanceof_function(ce, catch_ce)) {
4141            if (opline->result.num) {
4142                zend_throw_exception_internal(NULL);
4143                HANDLE_EXCEPTION();
4144            }
4145            ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[opline->extended_value]);
4146            ZEND_VM_CONTINUE(); /* CHECK_ME */
4147        }
4148    }
4149
4150    exception = EG(exception);
4151    zval_ptr_dtor(EX_VAR(opline->op2.var));
4152    ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
4153    if (UNEXPECTED(EG(exception) != exception)) {
4154        GC_REFCOUNT(EG(exception))++;
4155        HANDLE_EXCEPTION();
4156    } else {
4157        EG(exception) = NULL;
4158        ZEND_VM_NEXT_OPCODE();
4159    }
4160}
4161
4162ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY)
4163{
4164    USE_OPLINE
4165    zval *value, *arg;
4166    zend_free_op free_op1;
4167
4168    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
4169    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4170    ZVAL_COPY_VALUE(arg, value);
4171    if (OP1_TYPE == IS_CONST) {
4172        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
4173            zval_copy_ctor_func(arg);
4174        }
4175    }
4176    ZEND_VM_NEXT_OPCODE();
4177}
4178
4179ZEND_VM_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, ANY)
4180{
4181    USE_OPLINE
4182    zval *value, *arg;
4183    zend_free_op free_op1;
4184
4185    if (EXPECTED(opline->op2.num <= MAX_ARG_FLAG_NUM)) {
4186        if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4187            ZEND_VM_C_GOTO(send_val_by_ref);
4188        }
4189    } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4190ZEND_VM_C_LABEL(send_val_by_ref):
4191        SAVE_OPLINE();
4192        zend_throw_error(NULL, "Cannot pass parameter %d by reference", opline->op2.num);
4193        FREE_UNFETCHED_OP1();
4194        arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4195        ZVAL_UNDEF(arg);
4196        HANDLE_EXCEPTION();
4197    }
4198    value = GET_OP1_ZVAL_PTR(BP_VAR_R);
4199    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4200    ZVAL_COPY_VALUE(arg, value);
4201    if (OP1_TYPE == IS_CONST) {
4202        if (UNEXPECTED(Z_OPT_COPYABLE_P(arg))) {
4203            zval_copy_ctor_func(arg);
4204        }
4205    }
4206    ZEND_VM_NEXT_OPCODE();
4207}
4208
4209ZEND_VM_HANDLER(117, ZEND_SEND_VAR, VAR|CV, ANY)
4210{
4211    USE_OPLINE
4212    zval *varptr, *arg;
4213    zend_free_op free_op1;
4214
4215    varptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4216    if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) {
4217        SAVE_OPLINE();
4218        GET_OP1_UNDEF_CV(varptr, BP_VAR_R);
4219        arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4220        ZVAL_NULL(arg);
4221        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4222    }
4223
4224    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4225
4226    if (OP1_TYPE == IS_CV) {
4227        ZVAL_OPT_DEREF(varptr);
4228        ZVAL_COPY(arg, varptr);
4229    } else /* if (OP1_TYPE == IS_VAR) */ {
4230        if (UNEXPECTED(Z_ISREF_P(varptr))) {
4231            zend_refcounted *ref = Z_COUNTED_P(varptr);
4232
4233            varptr = Z_REFVAL_P(varptr);
4234            ZVAL_COPY_VALUE(arg, varptr);
4235            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4236                efree_size(ref, sizeof(zend_reference));
4237            } else if (Z_OPT_REFCOUNTED_P(arg)) {
4238                Z_ADDREF_P(arg);
4239            }
4240        } else {
4241            ZVAL_COPY_VALUE(arg, varptr);
4242        }
4243    }
4244
4245    ZEND_VM_NEXT_OPCODE();
4246}
4247
4248ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR, ANY)
4249{
4250    USE_OPLINE
4251    zend_free_op free_op1;
4252    zval *varptr, *arg;
4253
4254    if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) {
4255        if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4256            ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
4257        }
4258    }
4259
4260    varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
4261
4262    if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) ||
4263         (Z_VAR_FLAGS_P(varptr) & IS_VAR_RET_REF)) &&
4264        (Z_ISREF_P(varptr) || Z_TYPE_P(varptr) == IS_OBJECT)) {
4265
4266        ZVAL_MAKE_REF(varptr);
4267    } else {
4268        if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
4269            !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
4270            !ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4271            SAVE_OPLINE();
4272            zend_error(E_NOTICE, "Only variables should be passed by reference");
4273            arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4274            ZVAL_COPY_VALUE(arg, varptr);
4275            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4276        }
4277    }
4278
4279    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4280    ZVAL_COPY_VALUE(arg, varptr);
4281
4282    ZEND_VM_NEXT_OPCODE();
4283}
4284
4285ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
4286{
4287    USE_OPLINE
4288    zend_free_op free_op1;
4289    zval *varptr, *arg;
4290
4291    SAVE_OPLINE();
4292    varptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
4293
4294    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == NULL)) {
4295        zend_throw_error(NULL, "Only variables can be passed by reference");
4296        HANDLE_EXCEPTION();
4297    }
4298
4299    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4300    if (OP1_TYPE == IS_VAR && UNEXPECTED(varptr == &EG(error_zval))) {
4301        ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
4302        ZEND_VM_NEXT_OPCODE();
4303    }
4304
4305    if (Z_ISREF_P(varptr)) {
4306        Z_ADDREF_P(varptr);
4307        ZVAL_COPY_VALUE(arg, varptr);
4308    } else if (OP1_TYPE == IS_VAR &&
4309        UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT)) {
4310        ZVAL_NEW_REF(arg, varptr);
4311    } else {
4312        ZVAL_NEW_REF(arg, varptr);
4313        Z_ADDREF_P(arg);
4314        ZVAL_REF(varptr, Z_REF_P(arg));
4315    }
4316
4317    FREE_OP1_VAR_PTR();
4318    ZEND_VM_NEXT_OPCODE();
4319}
4320
4321ZEND_VM_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, ANY)
4322{
4323    USE_OPLINE
4324    zval *varptr, *arg;
4325    zend_free_op free_op1;
4326
4327    if (EXPECTED(opline->op2.num <= MAX_ARG_FLAG_NUM)) {
4328        if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4329            ZEND_VM_C_GOTO(send_var_by_ref);
4330        }
4331    } else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4332ZEND_VM_C_LABEL(send_var_by_ref):
4333        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
4334    }
4335
4336    varptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4337    if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) {
4338        SAVE_OPLINE();
4339        GET_OP1_UNDEF_CV(varptr, BP_VAR_R);
4340        arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4341        ZVAL_NULL(arg);
4342        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4343    }
4344
4345    arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4346
4347    if (OP1_TYPE == IS_CV) {
4348        ZVAL_OPT_DEREF(varptr);
4349        ZVAL_COPY(arg, varptr);
4350    } else /* if (OP1_TYPE == IS_VAR) */ {
4351        if (UNEXPECTED(Z_ISREF_P(varptr))) {
4352            zend_refcounted *ref = Z_COUNTED_P(varptr);
4353
4354            varptr = Z_REFVAL_P(varptr);
4355            ZVAL_COPY_VALUE(arg, varptr);
4356            if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4357                efree_size(ref, sizeof(zend_reference));
4358            } else if (Z_OPT_REFCOUNTED_P(arg)) {
4359                Z_ADDREF_P(arg);
4360            }
4361        } else {
4362            ZVAL_COPY_VALUE(arg, varptr);
4363        }
4364    }
4365
4366    ZEND_VM_NEXT_OPCODE();
4367}
4368
4369ZEND_VM_HANDLER(165, ZEND_SEND_UNPACK, ANY, ANY)
4370{
4371    USE_OPLINE
4372    zend_free_op free_op1;
4373    zval *args;
4374    int arg_num;
4375
4376    SAVE_OPLINE();
4377    args = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4378    arg_num = ZEND_CALL_NUM_ARGS(EX(call)) + 1;
4379
4380ZEND_VM_C_LABEL(send_again):
4381    if (EXPECTED(Z_TYPE_P(args) == IS_ARRAY)) {
4382        HashTable *ht = Z_ARRVAL_P(args);
4383        zval *arg, *top;
4384        zend_string *name;
4385
4386        zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, zend_hash_num_elements(ht));
4387
4388        if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
4389            uint32_t i;
4390            int separate = 0;
4391
4392            /* check if any of arguments are going to be passed by reference */
4393            for (i = 0; i < zend_hash_num_elements(ht); i++) {
4394                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
4395                    separate = 1;
4396                    break;
4397                }
4398            }
4399            if (separate) {
4400                zval_copy_ctor(args);
4401                ht = Z_ARRVAL_P(args);
4402            }
4403        }
4404
4405        ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
4406            if (name) {
4407                zend_throw_error(NULL, "Cannot unpack array with string keys");
4408                FREE_OP1();
4409                HANDLE_EXCEPTION();
4410            }
4411
4412            top = ZEND_CALL_ARG(EX(call), arg_num);
4413            if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4414                if (!Z_IMMUTABLE_P(args)) {
4415                    ZVAL_MAKE_REF(arg);
4416                    Z_ADDREF_P(arg);
4417                    ZVAL_REF(top, Z_REF_P(arg));
4418                } else {
4419                    ZVAL_DUP(top, arg);
4420                }
4421            } else if (Z_ISREF_P(arg)) {
4422                ZVAL_COPY(top, Z_REFVAL_P(arg));
4423            } else {
4424                ZVAL_COPY(top, arg);
4425            }
4426
4427            ZEND_CALL_NUM_ARGS(EX(call))++;
4428            arg_num++;
4429        } ZEND_HASH_FOREACH_END();
4430
4431    } else if (EXPECTED(Z_TYPE_P(args) == IS_OBJECT)) {
4432        zend_class_entry *ce = Z_OBJCE_P(args);
4433        zend_object_iterator *iter;
4434
4435        if (!ce || !ce->get_iterator) {
4436            zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
4437        } else {
4438
4439            iter = ce->get_iterator(ce, args, 0);
4440            if (UNEXPECTED(!iter)) {
4441                FREE_OP1();
4442                if (!EG(exception)) {
4443                    zend_throw_exception_ex(
4444                        NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name)
4445                    );
4446                }
4447                HANDLE_EXCEPTION();
4448            }
4449
4450            if (iter->funcs->rewind) {
4451                iter->funcs->rewind(iter);
4452                if (UNEXPECTED(EG(exception) != NULL)) {
4453                    ZEND_VM_C_GOTO(unpack_iter_dtor);
4454                }
4455            }
4456
4457            for (; iter->funcs->valid(iter) == SUCCESS; ++arg_num) {
4458                zval *arg, *top;
4459
4460                if (UNEXPECTED(EG(exception) != NULL)) {
4461                    ZEND_VM_C_GOTO(unpack_iter_dtor);
4462                }
4463
4464                arg = iter->funcs->get_current_data(iter);
4465                if (UNEXPECTED(EG(exception) != NULL)) {
4466                    ZEND_VM_C_GOTO(unpack_iter_dtor);
4467                }
4468
4469                if (iter->funcs->get_current_key) {
4470                    zval key;
4471                    iter->funcs->get_current_key(iter, &key);
4472                    if (UNEXPECTED(EG(exception) != NULL)) {
4473                        ZEND_VM_C_GOTO(unpack_iter_dtor);
4474                    }
4475
4476                    if (Z_TYPE(key) == IS_STRING) {
4477                        zend_throw_error(NULL,
4478                            "Cannot unpack Traversable with string keys");
4479                        zend_string_release(Z_STR(key));
4480                        ZEND_VM_C_GOTO(unpack_iter_dtor);
4481                    }
4482
4483                    zval_dtor(&key);
4484                }
4485
4486                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4487                    zend_error(
4488                        E_WARNING, "Cannot pass by-reference argument %d of %s%s%s()"
4489                        " by unpacking a Traversable, passing by-value instead", arg_num,
4490                        EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4491                        EX(call)->func->common.scope ? "::" : "",
4492                        ZSTR_VAL(EX(call)->func->common.function_name)
4493                    );
4494                }
4495
4496                if (Z_ISREF_P(arg)) {
4497                    ZVAL_DUP(arg, Z_REFVAL_P(arg));
4498                } else {
4499                    if (Z_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
4500                }
4501
4502                zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1);
4503                top = ZEND_CALL_ARG(EX(call), arg_num);
4504                ZVAL_COPY_VALUE(top, arg);
4505                ZEND_CALL_NUM_ARGS(EX(call))++;
4506
4507                iter->funcs->move_forward(iter);
4508                if (UNEXPECTED(EG(exception) != NULL)) {
4509                    ZEND_VM_C_GOTO(unpack_iter_dtor);
4510                }
4511            }
4512
4513ZEND_VM_C_LABEL(unpack_iter_dtor):
4514            zend_iterator_dtor(iter);
4515        }
4516    } else if (EXPECTED(Z_ISREF_P(args))) {
4517        args = Z_REFVAL_P(args);
4518        ZEND_VM_C_GOTO(send_again);
4519    } else {
4520        if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(args) == IS_UNDEF)) {
4521            GET_OP1_UNDEF_CV(args, BP_VAR_R);
4522        }
4523        zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
4524    }
4525
4526    FREE_OP1();
4527    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4528}
4529
4530ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
4531{
4532    USE_OPLINE
4533    zend_free_op free_op1;
4534    zval *args;
4535    SAVE_OPLINE();
4536
4537    SAVE_OPLINE();
4538    args = GET_OP1_ZVAL_PTR(BP_VAR_R);
4539
4540    if (UNEXPECTED(Z_TYPE_P(args) != IS_ARRAY)) {
4541        if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(args)) {
4542            args = Z_REFVAL_P(args);
4543            if (EXPECTED(Z_TYPE_P(args) == IS_ARRAY)) {
4544                ZEND_VM_C_GOTO(send_array);
4545            }
4546        }
4547        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)));
4548        if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4549            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4550        }
4551        if (Z_OBJ(EX(call)->This)) {
4552            OBJ_RELEASE(Z_OBJ(EX(call)->This));
4553        }
4554        EX(call)->func = (zend_function*)&zend_pass_function;
4555        EX(call)->called_scope = NULL;
4556        Z_OBJ(EX(call)->This) = NULL;
4557    } else {
4558        uint32_t arg_num;
4559        HashTable *ht;
4560        zval *arg, *param;
4561
4562ZEND_VM_C_LABEL(send_array):
4563        ht = Z_ARRVAL_P(args);
4564        zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht));
4565
4566        if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
4567            int separate = 0;
4568
4569            /* check if any of arguments are going to be passed by reference */
4570            for (arg_num = 0; arg_num < zend_hash_num_elements(ht); arg_num++) {
4571                if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + 1)) {
4572                    separate = 1;
4573                    break;
4574                }
4575            }
4576            if (separate) {
4577                zval_copy_ctor(args);
4578                ht = Z_ARRVAL_P(args);
4579            }
4580        }
4581
4582        arg_num = 1;
4583        param = ZEND_CALL_ARG(EX(call), 1);
4584        ZEND_HASH_FOREACH_VAL(ht, arg) {
4585            if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4586                if (UNEXPECTED(!Z_ISREF_P(arg))) {
4587                    if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4588
4589                        zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
4590                            arg_num,
4591                            EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4592                            EX(call)->func->common.scope ? "::" : "",
4593                            ZSTR_VAL(EX(call)->func->common.function_name));
4594
4595                        if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4596                            OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4597                        }
4598                        if (Z_OBJ(EX(call)->This)) {
4599                            OBJ_RELEASE(Z_OBJ(EX(call)->This));
4600                        }
4601                        EX(call)->func = (zend_function*)&zend_pass_function;
4602                        EX(call)->called_scope = NULL;
4603                        Z_OBJ(EX(call)->This) = NULL;
4604
4605                        break;
4606                    }
4607
4608                    ZVAL_NEW_REF(arg, arg);
4609                }
4610                Z_ADDREF_P(arg);
4611            } else{
4612                if (Z_ISREF_P(arg) &&
4613                    !(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
4614                    /* don't separate references for __call */
4615                    arg = Z_REFVAL_P(arg);
4616                }
4617                if (Z_OPT_REFCOUNTED_P(arg)) {
4618                    Z_ADDREF_P(arg);
4619                }
4620            }
4621            ZVAL_COPY_VALUE(param, arg);
4622            ZEND_CALL_NUM_ARGS(EX(call))++;
4623            arg_num++;
4624            param++;
4625        } ZEND_HASH_FOREACH_END();
4626    }
4627    FREE_OP1();
4628    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4629}
4630
4631ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
4632{
4633    USE_OPLINE
4634    zval *arg, *param;
4635    zend_free_op free_op1;
4636
4637    SAVE_OPLINE();
4638    arg = GET_OP1_ZVAL_PTR(BP_VAR_R);
4639    param = ZEND_CALL_VAR(EX(call), opline->result.var);
4640
4641    if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4642        if (UNEXPECTED(!Z_ISREF_P(arg))) {
4643
4644            if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4645
4646                zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
4647                    opline->op2.num,
4648                    EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4649                    EX(call)->func->common.scope ? "::" : "",
4650                    ZSTR_VAL(EX(call)->func->common.function_name));
4651
4652                if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4653                    OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4654                }
4655                if (Z_OBJ(EX(call)->This)) {
4656                    OBJ_RELEASE(Z_OBJ(EX(call)->This));
4657                }
4658                ZVAL_UNDEF(param);
4659                EX(call)->func = (zend_function*)&zend_pass_function;
4660                EX(call)->called_scope = NULL;
4661                Z_OBJ(EX(call)->This) = NULL;
4662
4663                FREE_OP1();
4664                ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4665            }
4666
4667            ZVAL_NEW_REF(arg, arg);
4668        }
4669        Z_ADDREF_P(arg);
4670    } else {
4671        if (Z_ISREF_P(arg) &&
4672            !(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
4673            /* don't separate references for __call */
4674            arg = Z_REFVAL_P(arg);
4675        }
4676        if (Z_OPT_REFCOUNTED_P(arg)) {
4677            Z_ADDREF_P(arg);
4678        }
4679    }
4680    ZVAL_COPY_VALUE(param, arg);
4681
4682    FREE_OP1();
4683    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4684}
4685
4686ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
4687{
4688    USE_OPLINE
4689    uint32_t arg_num = opline->op1.num;
4690
4691    if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
4692        SAVE_OPLINE();
4693        if (UNEXPECTED(!zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num)))) {
4694            HANDLE_EXCEPTION();
4695        }
4696    } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4697        zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4698
4699        SAVE_OPLINE();
4700        if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)))) {
4701            HANDLE_EXCEPTION();
4702        }
4703    }
4704
4705    ZEND_VM_NEXT_OPCODE();
4706}
4707
4708ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
4709{
4710    USE_OPLINE
4711    uint32_t arg_num;
4712    zval *param;
4713
4714    ZEND_VM_REPEATABLE_OPCODE
4715
4716    arg_num = opline->op1.num;
4717    param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4718    if (arg_num > EX_NUM_ARGS()) {
4719        ZVAL_COPY_VALUE(param, EX_CONSTANT(opline->op2));
4720        if (Z_OPT_CONSTANT_P(param)) {
4721            SAVE_OPLINE();
4722            if (UNEXPECTED(zval_update_constant_ex(param, 0, NULL) != SUCCESS)) {
4723                ZVAL_UNDEF(param);
4724                HANDLE_EXCEPTION();
4725            }
4726        } else {
4727            /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
4728            if (UNEXPECTED(Z_OPT_COPYABLE_P(param))) {
4729                zval_copy_ctor_func(param);
4730            }
4731        }
4732    }
4733
4734    if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4735        zval *default_value = EX_CONSTANT(opline->op2);
4736
4737        SAVE_OPLINE();
4738        if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))))) {
4739            HANDLE_EXCEPTION();
4740        }
4741    }
4742
4743    ZEND_VM_REPEAT_OPCODE(ZEND_RECV_INIT);
4744    ZEND_VM_NEXT_OPCODE();
4745}
4746
4747ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, ANY, ANY)
4748{
4749    USE_OPLINE
4750    uint32_t arg_num = opline->op1.num;
4751    uint32_t arg_count = EX_NUM_ARGS();
4752    zval *params;
4753
4754    SAVE_OPLINE();
4755
4756    params = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4757
4758    if (arg_num <= arg_count) {
4759        zval *param;
4760
4761        array_init_size(params, arg_count - arg_num + 1);
4762        zend_hash_real_init(Z_ARRVAL_P(params), 1);
4763        ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
4764            param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
4765            if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4766                do {
4767                    zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num));
4768                    if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
4769                    ZEND_HASH_FILL_ADD(param);
4770                    param++;
4771                } while (++arg_num <= arg_count);
4772            } else {
4773                do {
4774                    if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
4775                    ZEND_HASH_FILL_ADD(param);
4776                    param++;
4777                } while (++arg_num <= arg_count);
4778            }
4779        } ZEND_HASH_FILL_END();
4780    } else {
4781        array_init(params);
4782    }
4783
4784    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4785}
4786
4787ZEND_VM_HANDLER(52, ZEND_BOOL, CONST|TMPVAR|CV, ANY)
4788{
4789    USE_OPLINE
4790    zval *val;
4791    zend_free_op free_op1;
4792
4793    val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4794    if (Z_TYPE_INFO_P(val) == IS_TRUE) {
4795        ZVAL_TRUE(EX_VAR(opline->result.var));
4796    } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
4797        ZVAL_FALSE(EX_VAR(opline->result.var));
4798        if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
4799            SAVE_OPLINE();
4800            GET_OP1_UNDEF_CV(val, BP_VAR_R);
4801            ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4802        }
4803    } else {
4804        SAVE_OPLINE();
4805        ZVAL_BOOL(EX_VAR(opline->result.var), i_zend_is_true(val));
4806        FREE_OP1();
4807        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4808    }
4809    ZEND_VM_NEXT_OPCODE();
4810}
4811
4812ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
4813{
4814    USE_OPLINE
4815    zend_free_op free_op1, free_op2;
4816    zval *op1, *op2, *result;
4817
4818    op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4819    op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
4820    do {
4821        int result;
4822
4823        if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
4824            if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4825                result = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
4826            } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4827                result = ((double)Z_LVAL_P(op1) == Z_DVAL_P(op2));
4828            } else {
4829                break;
4830            }
4831        } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
4832            if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4833                result = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
4834            } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4835                result = (Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)));
4836            } else {
4837                break;
4838            }
4839        } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
4840            if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
4841                if (Z_STR_P(op1) == Z_STR_P(op2)) {
4842                    result = 1;
4843                } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
4844                    if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
4845                        result = 0;
4846                    } else {
4847                        result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0);
4848                    }
4849                } else {
4850                    result = (zendi_smart_strcmp(op1, op2) == 0);
4851                }
4852                FREE_OP2();
4853            } else {
4854                break;
4855            }
4856        } else {
4857            break;
4858        }
4859        ZEND_VM_SMART_BRANCH(result, 0);
4860        ZVAL_BOOL(EX_VAR(opline->result.var), result);
4861        ZEND_VM_NEXT_OPCODE();
4862    } while (0);
4863
4864    SAVE_OPLINE();
4865    if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
4866        op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4867    }
4868    if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
4869        op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4870    }
4871    result = EX_VAR(opline->result.var);
4872    compare_function(result, op1, op2);
4873    ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
4874    FREE_OP2();
4875    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4876}
4877
4878ZEND_VM_HANDLER(68, ZEND_NEW, CONST|VAR, ANY)
4879{
4880    USE_OPLINE
4881    zval object_zval;
4882    zend_function *constructor;
4883    zend_class_entry *ce;
4884
4885    SAVE_OPLINE();
4886    if (OP1_TYPE == IS_CONST) {
4887        if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
4888            ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
4889        } else {
4890            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);
4891            if (UNEXPECTED(ce == NULL)) {
4892                ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4893            }
4894            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
4895        }
4896    } else {
4897        ce = Z_CE_P(EX_VAR(opline->op1.var));
4898    }
4899    if (UNEXPECTED(object_init_ex(&object_zval, ce) != SUCCESS)) {
4900        HANDLE_EXCEPTION();
4901    }
4902    constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval));
4903
4904    if (constructor == NULL) {
4905        if (EXPECTED(RETURN_VALUE_USED(opline))) {
4906            ZVAL_COPY_VALUE(EX_VAR(opline->result.var), &object_zval);
4907        } else {
4908            OBJ_RELEASE(Z_OBJ(object_zval));
4909        }
4910        ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
4911    } else {
4912        /* We are not handling overloaded classes right now */
4913        zend_execute_data *call = zend_vm_stack_push_call_frame(
4914                ZEND_CALL_FUNCTION | ZEND_CALL_RELEASE_THIS | ZEND_CALL_CTOR |
4915                (EXPECTED(RETURN_VALUE_USED(opline)) ? 0 : ZEND_CALL_CTOR_RESULT_UNUSED),
4916            constructor,
4917            opline->extended_value,
4918            ce,
4919            Z_OBJ(object_zval));
4920        call->prev_execute_data = EX(call);
4921        EX(call) = call;
4922
4923        if (EXPECTED(RETURN_VALUE_USED(opline))) {
4924            ZVAL_COPY(EX_VAR(opline->result.var), &object_zval);
4925        }
4926
4927        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4928    }
4929}
4930
4931ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|CV, ANY)
4932{
4933    USE_OPLINE
4934    zend_free_op free_op1;
4935    zval *obj;
4936    zend_class_entry *ce;
4937    zend_function *clone;
4938    zend_object_clone_obj_t clone_call;
4939
4940    SAVE_OPLINE();
4941    obj = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_R);
4942
4943    if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_OBJ_P(obj) == NULL)) {
4944        zend_throw_error(NULL, "Using $this when not in object context");
4945        HANDLE_EXCEPTION();
4946    }
4947
4948    do {
4949        if (OP1_TYPE == IS_CONST ||
4950            (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) {
4951            if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(obj)) {
4952                obj = Z_REFVAL_P(obj);
4953                if (EXPECTED(Z_TYPE_P(obj) == IS_OBJECT)) {
4954                    break;
4955                }
4956            }
4957            if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(obj) == IS_UNDEF)) {
4958                GET_OP1_UNDEF_CV(obj, BP_VAR_R);
4959            }
4960            if (UNEXPECTED(EG(exception) != NULL)) {
4961                HANDLE_EXCEPTION();
4962            }
4963            zend_throw_error(NULL, "__clone method called on non-object");
4964            FREE_OP1();
4965            HANDLE_EXCEPTION();
4966        }
4967    } while (0);
4968
4969    ce = Z_OBJCE_P(obj);
4970    clone = ce ? ce->clone : NULL;
4971    clone_call =  Z_OBJ_HT_P(obj)->clone_obj;
4972    if (UNEXPECTED(clone_call == NULL)) {
4973        if (ce) {
4974            zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name));
4975        } else {
4976            zend_throw_error(NULL, "Trying to clone an uncloneable object");
4977        }
4978        FREE_OP1();
4979        HANDLE_EXCEPTION();
4980    }
4981
4982    if (ce && clone) {
4983        if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
4984            /* Ensure that if we're calling a private function, we're allowed to do so.
4985             */
4986            if (UNEXPECTED(ce != EG(scope))) {
4987                zend_throw_error(NULL, "Call to private %s::__clone() from context '%s'", ZSTR_VAL(ce->name), EG(scope) ? ZSTR_VAL(EG(scope)->name) : "");
4988                FREE_OP1();
4989                HANDLE_EXCEPTION();
4990            }
4991        } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
4992            /* Ensure that if we're calling a protected function, we're allowed to do so.
4993             */
4994            if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), EG(scope)))) {
4995                zend_throw_error(NULL, "Call to protected %s::__clone() from context '%s'", ZSTR_VAL(ce->name), EG(scope) ? ZSTR_VAL(EG(scope)->name) : "");
4996                FREE_OP1();
4997                HANDLE_EXCEPTION();
4998            }
4999        }
5000    }
5001
5002    if (EXPECTED(EG(exception) == NULL)) {
5003        ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj));
5004        if (UNEXPECTED(!RETURN_VALUE_USED(opline)) || UNEXPECTED(EG(exception) != NULL)) {
5005            OBJ_RELEASE(Z_OBJ_P(EX_VAR(opline->result.var)));
5006        }
5007    }
5008    FREE_OP1();
5009    ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5010}
5011
5012ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
5013{
5014    USE_OPLINE
5015
5016    SAVE_OPLINE();
5017    if (OP1_TYPE == IS_UNUSED) {
5018        zend_constant *c;
5019
5020        if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
5021            c = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5022        } else if ((c = zend_quick_get_constant(EX_CONSTANT(opline->op2) + 1, opline->extended_value)) == NULL) {
5023            if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
5024                char *actual = (char *)zend_memrchr(Z_STRVAL_P(EX_CONSTANT(opline->op2)), '\\', Z_STRLEN_P(EX_CONSTANT(opline->op2)));
5025                if (!actual) {
5026                    ZVAL_STR_COPY(EX_VAR(opline->result.var), Z_STR_P(EX_CONSTANT(opline->op2)));
5027                } else {
5028                    actual++;
5029                    ZVAL_STRINGL(EX_VAR(opline->result.var),
5030                            actual, Z_STRLEN_P(EX_CONSTANT(opline->op2)) - (actual - Z_STRVAL_P(EX_CONSTANT(opline->op2))));
5031                }
5032                /* non-qualified constant - allow text substitution */
5033                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
5034                        Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var)));
5035                ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5036            } else {
5037                zend_throw_error(NULL, "Undefined constant '%s'", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
5038                HANDLE_EXCEPTION();
5039            }
5040        } else {
5041            CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), c);
5042        }
5043#ifdef ZTS
5044        if (c->flags & CONST_PERSISTENT) {
5045            ZVAL_DUP(EX_VAR(opline->result.var), &c->value);
5046        } else {
5047            ZVAL_COPY(EX_VAR(opline->result.var), &c->value);
5048        }
5049#else
5050        ZVAL_COPY(EX_VAR(opline->result.var), &c->value);
5051#endif
5052    } else {
5053        /* class constant */
5054        zend_class_entry *ce;
5055        zval *value;
5056
5057        do {
5058            if (OP1_TYPE == IS_CONST) {
5059                if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) {
5060                    value = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5061                    ZVAL_DEREF(value);
5062#ifdef ZTS
5063                    ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
5064#endif
5065                    break;
5066                } else if (CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) {
5067                    ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
5068                } else {
5069                    ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(