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   +----------------------------------------------------------------------+
18*/
19
20/* $Id$ */
21
22#define ZEND_INTENSIVE_DEBUGGING 0
23
24#include <stdio.h>
25#include <signal.h>
26
27#include "zend.h"
28#include "zend_compile.h"
29#include "zend_execute.h"
30#include "zend_API.h"
31#include "zend_ptr_stack.h"
32#include "zend_constants.h"
33#include "zend_extensions.h"
34#include "zend_ini.h"
35#include "zend_exceptions.h"
36#include "zend_interfaces.h"
37#include "zend_closures.h"
38#include "zend_generators.h"
39#include "zend_vm.h"
40#include "zend_dtrace.h"
41#include "zend_inheritance.h"
42
43/* Virtual current working directory support */
44#include "zend_virtual_cwd.h"
45
46#define _CONST_CODE  0
47#define _TMP_CODE    1
48#define _VAR_CODE    2
49#define _UNUSED_CODE 3
50#define _CV_CODE     4
51
52typedef int (ZEND_FASTCALL *incdec_t)(zval *);
53
54#define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type)
55#define get_zval_ptr_deref(op_type, node, ex, should_free, type) _get_zval_ptr_deref(op_type, node, ex, should_free, type)
56#define get_zval_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_undef(op_type, node, ex, should_free, type)
57#define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
58#define get_zval_ptr_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
59#define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type)
60#define get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type)
61
62/* Prototypes */
63static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array);
64static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array);
65static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array);
66
67#define RETURN_VALUE_USED(opline) (!((opline)->result_type & EXT_TYPE_UNUSED))
68
69static ZEND_FUNCTION(pass)
70{
71}
72
73static const zend_internal_function zend_pass_function = {
74    ZEND_INTERNAL_FUNCTION, /* type              */
75    {0, 0, 0},              /* arg_flags         */
76    0,                      /* fn_flags          */
77    NULL,                   /* name              */
78    NULL,                   /* scope             */
79    NULL,                   /* prototype         */
80    0,                      /* num_args          */
81    0,                      /* required_num_args */
82    NULL,                   /* arg_info          */
83    ZEND_FN(pass),          /* handler           */
84    NULL                    /* module            */
85};
86
87#undef zval_ptr_dtor
88#define zval_ptr_dtor(zv) i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC)
89
90#define PZVAL_LOCK(z) if (Z_REFCOUNTED_P(z)) Z_ADDREF_P((z))
91#define SELECTIVE_PZVAL_LOCK(pzv, opline)   if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(pzv); }
92
93#define READY_TO_DESTROY(zv) \
94    (zv && Z_REFCOUNTED_P(zv) && Z_REFCOUNT_P(zv) == 1)
95
96#define EXTRACT_ZVAL_PTR(zv) do {                       \
97        zval *__zv = (zv);                              \
98        if (Z_TYPE_P(__zv) == IS_INDIRECT) {            \
99            ZVAL_COPY(__zv, Z_INDIRECT_P(__zv));        \
100        }                                               \
101    } while (0)
102
103#define FREE_OP(should_free) \
104    if (should_free) { \
105        zval_ptr_dtor_nogc(should_free); \
106    }
107
108#define FREE_UNFETCHED_OP(type, var) \
109    if ((type) & (IS_TMP_VAR|IS_VAR)) { \
110        zval_ptr_dtor_nogc(EX_VAR(var)); \
111    }
112
113#define FREE_OP_VAR_PTR(should_free) \
114    if (should_free) { \
115        zval_ptr_dtor_nogc(should_free); \
116    }
117
118/* End of zend_execute_locks.h */
119
120#define CV_DEF_OF(i) (EX(func)->op_array.vars[i])
121
122#define CTOR_CALL_BIT    0x1
123#define CTOR_USED_BIT    0x2
124
125#define IS_CTOR_CALL(ce) (((zend_uintptr_t)(ce)) & CTOR_CALL_BIT)
126#define IS_CTOR_USED(ce) (((zend_uintptr_t)(ce)) & CTOR_USED_BIT)
127
128#define ENCODE_CTOR(ce, used) \
129    ((zend_class_entry*)(((zend_uintptr_t)(ce)) | CTOR_CALL_BIT | ((used) ? CTOR_USED_BIT : 0)))
130#define DECODE_CTOR(ce) \
131    ((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT)))
132
133#define ZEND_VM_MAIN_STACK_PAGE_SLOTS (16 * 1024) /* should be a power of 2 */
134#define ZEND_VM_GENERATOR_STACK_PAGE_SLOTS (256)
135
136#define ZEND_VM_STACK_PAGE_SLOTS(gen) ((gen) ? ZEND_VM_GENERATOR_STACK_PAGE_SLOTS : ZEND_VM_MAIN_STACK_PAGE_SLOTS)
137
138#define ZEND_VM_STACK_PAGE_SIZE(gen)  (ZEND_VM_STACK_PAGE_SLOTS(gen) * sizeof(zval))
139
140#define ZEND_VM_STACK_FREE_PAGE_SIZE(gen) \
141    ((ZEND_VM_STACK_PAGE_SLOTS(gen) - ZEND_VM_STACK_HEADER_SLOTS) * sizeof(zval))
142
143#define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(gen, size) \
144    (((size) + (ZEND_VM_STACK_FREE_PAGE_SIZE(gen) - 1)) & ~ZEND_VM_STACK_PAGE_SIZE(gen))
145
146static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
147    zend_vm_stack page = (zend_vm_stack)emalloc(size);
148
149    page->top = ZEND_VM_STACK_ELEMETS(page);
150    page->end = (zval*)((char*)page + size);
151    page->prev = prev;
152    return page;
153}
154
155ZEND_API void zend_vm_stack_init(void)
156{
157    EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE(0 /* main stack */), NULL);
158    EG(vm_stack)->top++;
159    EG(vm_stack_top) = EG(vm_stack)->top;
160    EG(vm_stack_end) = EG(vm_stack)->end;
161}
162
163ZEND_API void zend_vm_stack_destroy(void)
164{
165    zend_vm_stack stack = EG(vm_stack);
166
167    while (stack != NULL) {
168        zend_vm_stack p = stack->prev;
169        efree(stack);
170        stack = p;
171    }
172}
173
174ZEND_API void* zend_vm_stack_extend(size_t size)
175{
176    zend_vm_stack stack;
177    void *ptr;
178
179    stack = EG(vm_stack);
180    stack->top = EG(vm_stack_top);
181    EG(vm_stack) = stack = zend_vm_stack_new_page(
182        EXPECTED(size < ZEND_VM_STACK_FREE_PAGE_SIZE(0)) ?
183            ZEND_VM_STACK_PAGE_SIZE(0) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(0, size),
184        stack);
185    ptr = stack->top;
186    EG(vm_stack_top) = (void*)(((char*)ptr) + size);
187    EG(vm_stack_end) = stack->end;
188    return ptr;
189}
190
191ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
192{
193    return EX_VAR(var);
194}
195
196static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
197{
198    zval *ret = EX_VAR(var);
199    *should_free = ret;
200
201    ZEND_ASSERT(Z_TYPE_P(ret) != IS_REFERENCE);
202
203    return ret;
204}
205
206static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
207{
208    zval *ret = EX_VAR(var);
209
210    *should_free = ret;
211    return ret;
212}
213
214static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
215{
216    zval *ret = EX_VAR(var);
217
218    *should_free = ret;
219    ZVAL_DEREF(ret);
220    return ret;
221}
222
223static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type, const zend_execute_data *execute_data)
224{
225    zend_string *cv;
226
227    switch (type) {
228        case BP_VAR_R:
229        case BP_VAR_UNSET:
230            cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
231            zend_error(E_NOTICE, "Undefined variable: %s", cv->val);
232            /* break missing intentionally */
233        case BP_VAR_IS:
234            ptr = &EG(uninitialized_zval);
235            break;
236        case BP_VAR_RW:
237            cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
238            zend_error(E_NOTICE, "Undefined variable: %s", cv->val);
239            /* break missing intentionally */
240        case BP_VAR_W:
241            ZVAL_NULL(ptr);
242            break;
243    }
244    return ptr;
245}
246
247static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
248{
249    zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
250
251    zend_error(E_NOTICE, "Undefined variable: %s", cv->val);
252    return &EG(uninitialized_zval);
253}
254
255static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
256{
257    zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
258
259    zend_error(E_NOTICE, "Undefined variable: %s", cv->val);
260    return &EG(uninitialized_zval);
261}
262
263static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
264{
265    zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
266
267    ZVAL_NULL(ptr);
268    zend_error(E_NOTICE, "Undefined variable: %s", cv->val);
269    return ptr;
270}
271
272static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
273{
274    ZVAL_NULL(ptr);
275    return ptr;
276}
277
278static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, uint32_t var, int type)
279{
280    zval *ret = EX_VAR(var);
281
282    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
283        return _get_zval_cv_lookup(ret, var, type, execute_data);
284    }
285    return ret;
286}
287
288static zend_always_inline zval *_get_zval_ptr_cv_undef(const zend_execute_data *execute_data, uint32_t var)
289{
290    return EX_VAR(var);
291}
292
293static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, uint32_t var, int type)
294{
295    zval *ret = EX_VAR(var);
296
297    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
298        return _get_zval_cv_lookup(ret, var, type, execute_data);
299    }
300    ZVAL_DEREF(ret);
301    return ret;
302}
303
304static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
305{
306    zval *ret = EX_VAR(var);
307
308    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
309        return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
310    }
311    return ret;
312}
313
314static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
315{
316    zval *ret = EX_VAR(var);
317
318    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
319        return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
320    }
321    ZVAL_DEREF(ret);
322    return ret;
323}
324
325static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
326{
327    zval *ret = EX_VAR(var);
328
329    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
330        return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
331    }
332    return ret;
333}
334
335static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
336{
337    zval *ret = EX_VAR(var);
338
339    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
340        return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
341    }
342    ZVAL_DEREF(ret);
343    return ret;
344}
345
346static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
347{
348    zval *ret = EX_VAR(var);
349
350    return ret;
351}
352
353static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
354{
355    zval *ret = EX_VAR(var);
356
357    ZVAL_DEREF(ret);
358    return ret;
359}
360
361static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
362{
363    zval *ret = EX_VAR(var);
364
365    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
366        return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
367    }
368    return ret;
369}
370
371static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
372{
373    zval *ret = EX_VAR(var);
374
375    if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
376        return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
377    }
378    ZVAL_DEREF(ret);
379    return ret;
380}
381
382static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
383{
384    zval *ret = EX_VAR(var);
385
386    if (Z_TYPE_P(ret) == IS_UNDEF) {
387        return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
388    }
389    return ret;
390}
391
392static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
393{
394    return EX_VAR(var);
395}
396
397static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
398{
399    return EX_VAR(var);
400}
401
402static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
403{
404    zval *ret = EX_VAR(var);
405
406    if (Z_TYPE_P(ret) == IS_UNDEF) {
407        return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
408    }
409    ZVAL_DEREF(ret);
410    return ret;
411}
412
413static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
414{
415    if (op_type & (IS_TMP_VAR|IS_VAR)) {
416        if (op_type == IS_TMP_VAR) {
417            return _get_zval_ptr_tmp(node.var, execute_data, should_free);
418        } else {
419            ZEND_ASSERT(op_type == IS_VAR);
420            return _get_zval_ptr_var(node.var, execute_data, should_free);
421        }
422    } else {
423        *should_free = NULL;
424        if (op_type == IS_CONST) {
425            return EX_CONSTANT(node);
426        } else if (op_type == IS_CV) {
427            return _get_zval_ptr_cv(execute_data, node.var, type);
428        } else {
429            return NULL;
430        }
431    }
432}
433
434static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
435{
436    if (op_type & (IS_TMP_VAR|IS_VAR)) {
437        if (op_type == IS_TMP_VAR) {
438            return _get_zval_ptr_tmp(node.var, execute_data, should_free);
439        } else {
440            ZEND_ASSERT(op_type == IS_VAR);
441            return _get_zval_ptr_var_deref(node.var, execute_data, should_free);
442        }
443    } else {
444        *should_free = NULL;
445        if (op_type == IS_CONST) {
446            return EX_CONSTANT(node);
447        } else if (op_type == IS_CV) {
448            return _get_zval_ptr_cv_deref(execute_data, node.var, type);
449        } else {
450            return NULL;
451        }
452    }
453}
454
455static zend_always_inline zval *_get_zval_ptr_undef(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
456{
457    if (op_type & (IS_TMP_VAR|IS_VAR)) {
458        if (op_type == IS_TMP_VAR) {
459            return _get_zval_ptr_tmp(node.var, execute_data, should_free);
460        } else {
461            ZEND_ASSERT(op_type == IS_VAR);
462            return _get_zval_ptr_var(node.var, execute_data, should_free);
463        }
464    } else {
465        *should_free = NULL;
466        if (op_type == IS_CONST) {
467            return EX_CONSTANT(node);
468        } else if (op_type == IS_CV) {
469            return _get_zval_ptr_cv_undef(execute_data, node.var);
470        } else {
471            return NULL;
472        }
473    }
474}
475
476static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
477{
478    zval *ret = EX_VAR(var);
479
480    if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) {
481        *should_free = NULL;
482        ret = Z_INDIRECT_P(ret);
483    } else if (!Z_REFCOUNTED_P(ret)) {
484        *should_free = ret; /* immutable array may be converted to regular */
485    } else if (Z_REFCOUNT_P(ret) == 1) {
486        *should_free = ret;
487    } else {
488        *should_free = NULL;
489        Z_DELREF_P(ret);
490    }
491    return ret;
492}
493
494static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type)
495{
496    if (op_type == IS_CV) {
497        *should_free = NULL;
498        return _get_zval_ptr_cv(execute_data, node.var, type);
499    } else /* if (op_type == IS_VAR) */ {
500        ZEND_ASSERT(op_type == IS_VAR);
501        return _get_zval_ptr_ptr_var(node.var, execute_data, should_free);
502    }
503}
504
505static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data)
506{
507    return &EX(This);
508}
509
510static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type)
511{
512    if (op_type == IS_UNUSED) {
513        *should_free = NULL;
514        return &EX(This);
515    }
516    return get_zval_ptr(op_type, op, execute_data, should_free, type);
517}
518
519static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execute_data *execute_data, zend_free_op *should_free, int type)
520{
521    if (op_type == IS_UNUSED) {
522        *should_free = NULL;
523        return &EX(This);
524    }
525    return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
526}
527
528static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr)
529{
530    zend_reference *ref;
531
532    if (EXPECTED(!Z_ISREF_P(value_ptr))) {
533        ZVAL_NEW_REF(value_ptr, value_ptr);
534    } else if (UNEXPECTED(variable_ptr == value_ptr)) {
535        return;
536    }
537
538    ref = Z_REF_P(value_ptr);
539    GC_REFCOUNT(ref)++;
540    zval_ptr_dtor(variable_ptr);
541    ZVAL_REF(variable_ptr, ref);
542}
543
544/* this should modify object only if it's empty */
545static inline int make_real_object(zval *object)
546{
547    if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
548        if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE)) {
549            /* nothing to destroy */
550        } else if (EXPECTED((Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
551            zval_ptr_dtor_nogc(object);
552        } else {
553            return 0;
554        }
555        object_init(object);
556        zend_error(E_WARNING, "Creating default object from empty value");
557    }
558    return 1;
559}
560
561ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce)
562{
563    zend_string *key;
564    ALLOCA_FLAG(use_heap);
565
566    STR_ALLOCA_INIT(key, cur_arg_info->class_name, strlen(cur_arg_info->class_name), use_heap);
567    *pce = zend_fetch_class(key, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
568    STR_ALLOCA_FREE(key, use_heap);
569
570    *class_name = (*pce) ? (*pce)->name->val : (char*)cur_arg_info->class_name;
571    if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) {
572        return "implement interface ";
573    } else {
574        return "be an instance of ";
575    }
576}
577
578ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce)
579{
580    *pce = zend_fetch_class(cur_arg_info->class_name, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
581
582    *class_name = (*pce) ? (*pce)->name->val : cur_arg_info->class_name->val;
583    if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) {
584        return "implement interface ";
585    } else {
586        return "be an instance of ";
587    }
588}
589
590ZEND_API void zend_verify_arg_error(const zend_function *zf, uint32_t arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind, zval *arg)
591{
592    zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
593    const char *fname = zf->common.function_name->val;
594    const char *fsep;
595    const char *fclass;
596
597    if (zf->common.scope) {
598        fsep =  "::";
599        fclass = zf->common.scope->name->val;
600    } else {
601        fsep =  "";
602        fclass = "";
603    }
604
605    if (zf->common.type == ZEND_USER_FUNCTION) {
606        if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
607            zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d",
608                    arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind,
609                    ptr->func->op_array.filename->val, ptr->opline->lineno);
610        } else {
611            zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
612        }
613    } else {
614        zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given", arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind);
615    }
616}
617
618static int is_null_constant(zval *default_value)
619{
620    if (Z_CONSTANT_P(default_value)) {
621        zval constant;
622
623        ZVAL_COPY_VALUE(&constant, default_value);
624        if (UNEXPECTED(zval_update_constant_ex(&constant, 0, NULL) != SUCCESS)) {
625            return 0;
626        }
627        if (Z_TYPE(constant) == IS_NULL) {
628            return 1;
629        }
630        zval_dtor(&constant);
631    }
632    return 0;
633}
634
635static zend_bool zend_verify_weak_scalar_type_hint(zend_uchar type_hint, zval *arg)
636{
637    switch (type_hint) {
638        case _IS_BOOL: {
639            zend_bool dest;
640
641            if (!zend_parse_arg_bool_weak(arg, &dest)) {
642                return 0;
643            }
644            zval_ptr_dtor(arg);
645            ZVAL_BOOL(arg, dest);
646            return 1;
647        }
648        case IS_LONG: {
649            zend_long dest;
650
651            if (!zend_parse_arg_long_weak(arg, &dest)) {
652                return 0;
653            }
654            zval_ptr_dtor(arg);
655            ZVAL_LONG(arg, dest);
656            return 1;
657        }
658        case IS_DOUBLE: {
659            double dest;
660
661            if (!zend_parse_arg_double_weak(arg, &dest)) {
662                return 0;
663            }
664            zval_ptr_dtor(arg);
665            ZVAL_DOUBLE(arg, dest);
666            return 1;
667        }
668        case IS_STRING: {
669            zend_string *dest;
670
671            /* on success "arg" is converted to IS_STRING */
672            if (!zend_parse_arg_str_weak(arg, &dest)) {
673                return 0;
674            }
675            return 1;
676        }
677        default:
678            return 0;
679    }
680}
681
682static zend_bool zend_verify_scalar_type_hint(zend_uchar type_hint, zval *arg, zend_bool strict)
683{
684    if (UNEXPECTED(strict)) {
685        /* SSTH Exception: IS_LONG may be accepted as IS_DOUBLE (converted) */
686        if (type_hint != IS_DOUBLE || Z_TYPE_P(arg) != IS_LONG) {
687            return 0;
688        }
689    } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
690        /* NULL may be accepted only by nullable hints (this is already checked) */
691        return 0;
692    }
693    return zend_verify_weak_scalar_type_hint(type_hint, arg);
694}
695
696static void zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg)
697{
698    zend_internal_arg_info *cur_arg_info;
699    char *need_msg, *class_name;
700    zend_class_entry *ce;
701
702    if (EXPECTED(arg_num <= zf->internal_function.num_args)) {
703        cur_arg_info = &zf->internal_function.arg_info[arg_num-1];
704    } else if (zf->internal_function.fn_flags & ZEND_ACC_VARIADIC) {
705        cur_arg_info = &zf->internal_function.arg_info[zf->internal_function.num_args];
706    } else {
707        return;
708    }
709
710    if (cur_arg_info->type_hint) {
711        ZVAL_DEREF(arg);
712        if (EXPECTED(cur_arg_info->type_hint == Z_TYPE_P(arg))) {
713            if (cur_arg_info->class_name) {
714                need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
715                if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce)) {
716                    zend_verify_arg_error(zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg);
717                }
718            }
719        } else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) {
720            if (cur_arg_info->class_name) {
721                need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
722                zend_verify_arg_error(zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg);
723            } else if (cur_arg_info->type_hint == IS_CALLABLE) {
724                if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL)) {
725                    zend_verify_arg_error(zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
726                }
727            } else if (cur_arg_info->type_hint == _IS_BOOL &&
728                       EXPECTED(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE)) {
729                /* pass */
730            } else if (UNEXPECTED(!zend_verify_scalar_type_hint(cur_arg_info->type_hint, arg, ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))))) {
731                zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), zend_zval_type_name(arg), "", arg);
732            }
733        }
734    }
735}
736
737static int zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value)
738{
739    zend_arg_info *cur_arg_info;
740    char *need_msg, *class_name;
741    zend_class_entry *ce;
742
743    if (EXPECTED(arg_num <= zf->common.num_args)) {
744        cur_arg_info = &zf->common.arg_info[arg_num-1];
745    } else if (zf->common.fn_flags & ZEND_ACC_VARIADIC) {
746        cur_arg_info = &zf->common.arg_info[zf->common.num_args];
747    } else {
748        return 1;
749    }
750
751    if (cur_arg_info->type_hint) {
752        ZVAL_DEREF(arg);
753        if (EXPECTED(cur_arg_info->type_hint == Z_TYPE_P(arg))) {
754            if (cur_arg_info->class_name) {
755                need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
756                if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce)) {
757                    zend_verify_arg_error(zf, arg_num, need_msg, class_name, "instance of ", Z_OBJCE_P(arg)->name->val, arg);
758                    return 0;
759                }
760            }
761        } else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value)))) {
762            if (cur_arg_info->class_name) {
763                need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
764                zend_verify_arg_error(zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg);
765                return 0;
766            } else if (cur_arg_info->type_hint == IS_CALLABLE) {
767                if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL)) {
768                    zend_verify_arg_error(zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
769                    return 0;
770                }
771            } else if (cur_arg_info->type_hint == _IS_BOOL &&
772                       EXPECTED(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE)) {
773                /* pass */
774            } else if (UNEXPECTED(!zend_verify_scalar_type_hint(cur_arg_info->type_hint, arg, ZEND_ARG_USES_STRICT_TYPES()))) {
775                zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), zend_zval_type_name(arg), "", arg);
776                return 0;
777            }
778        }
779    }
780    return 1;
781}
782
783static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num)
784{
785    zend_arg_info *cur_arg_info;
786    char *need_msg;
787    zend_class_entry *ce;
788
789    if (EXPECTED(arg_num <= zf->common.num_args)) {
790        cur_arg_info = &zf->common.arg_info[arg_num-1];
791    } else if (zf->common.fn_flags & ZEND_ACC_VARIADIC) {
792        cur_arg_info = &zf->common.arg_info[zf->common.num_args];
793    } else {
794        return 1;
795    }
796
797    if (cur_arg_info->type_hint) {
798        if (cur_arg_info->class_name) {
799            char *class_name;
800
801            need_msg = zend_verify_arg_class_kind(cur_arg_info, &class_name, &ce);
802            zend_verify_arg_error(zf, arg_num, need_msg, class_name, "none", "", NULL);
803        } else if (cur_arg_info->type_hint == IS_CALLABLE) {
804            zend_verify_arg_error(zf, arg_num, "be callable", "", "none", "", NULL);
805        } else {
806            zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "none", "", NULL);
807        }
808        return 0;
809    }
810    return 1;
811}
812
813static int zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num)
814{
815    if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
816        zend_verify_missing_arg_type(EX(func), arg_num)) {
817        const char *class_name = EX(func)->common.scope ? EX(func)->common.scope->name->val : "";
818        const char *space = EX(func)->common.scope ? "::" : "";
819        const char *func_name = EX(func)->common.function_name ? EX(func)->common.function_name->val : "main";
820        zend_execute_data *ptr = EX(prev_execute_data);
821
822        if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
823            zend_error(E_WARNING, "Missing argument %u for %s%s%s(), called in %s on line %d and defined", arg_num, class_name, space, func_name, ptr->func->op_array.filename->val, ptr->opline->lineno);
824        } else {
825            zend_error(E_WARNING, "Missing argument %u for %s%s%s()", arg_num, class_name, space, func_name);
826        }
827        return 1;
828    }
829    return 0;
830}
831
832ZEND_API void zend_verify_return_error(const zend_function *zf, const char *need_msg, const char *need_kind, const char *returned_msg, const char *returned_kind)
833{
834    const char *fname = zf->common.function_name->val;
835    const char *fsep;
836    const char *fclass;
837
838    if (zf->common.scope) {
839        fsep =  "::";
840        fclass = zf->common.scope->name->val;
841    } else {
842        fsep =  "";
843        fclass = "";
844    }
845
846    if (zf->common.type == ZEND_USER_FUNCTION) {
847        zend_type_error("Return value of %s%s%s() must %s%s, %s%s returned in %s on line %d",
848            fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind,
849            zf->op_array.filename->val, EG(current_execute_data)->opline->lineno);
850    } else {
851        zend_type_error("Return value of %s%s%s() must %s%s, %s%s returned",
852            fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
853    }
854}
855
856ZEND_API void zend_verify_internal_return_error(const zend_function *zf, const char *need_msg, const char *need_kind, const char *returned_msg, const char *returned_kind)
857{
858    const char *fname = zf->common.function_name->val;
859    const char *fsep;
860    const char *fclass;
861
862    if (zf->common.scope) {
863        fsep =  "::";
864        fclass = zf->common.scope->name->val;
865    } else {
866        fsep =  "";
867        fclass = "";
868    }
869
870    zend_error_noreturn(E_CORE_ERROR, "Return value of %s%s%s() must %s%s, %s%s returned",
871        fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
872}
873
874#if ZEND_DEBUG
875static int zend_verify_internal_return_type(zend_function *zf, zval *ret)
876{
877    zend_arg_info *ret_info = zf->common.arg_info - 1;
878    char *need_msg, *class_name;
879    zend_class_entry *ce;
880
881
882    if (ret_info->type_hint) {
883        if (EXPECTED(ret_info->type_hint == Z_TYPE_P(ret))) {
884            if (ret_info->class_name) {
885                need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info *)ret_info, &class_name, &ce);
886                if (!ce || !instanceof_function(Z_OBJCE_P(ret), ce)) {
887                    zend_verify_internal_return_error(zf, need_msg, class_name, "instance of ", Z_OBJCE_P(ret)->name->val);
888                    return 0;
889                }
890            }
891        } else if (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null) {
892            if (ret_info->class_name) {
893                need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info *)ret_info, &class_name, &ce);
894                zend_verify_internal_return_error(zf, need_msg, class_name, zend_zval_type_name(ret), "");
895            } else if (ret_info->type_hint == IS_CALLABLE) {
896                if (!zend_is_callable(ret, IS_CALLABLE_CHECK_SILENT, NULL) && (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null)) {
897                    zend_verify_internal_return_error(zf, "be callable", "", zend_zval_type_name(ret), "");
898                    return 0;
899                }
900            } else if (ret_info->type_hint == _IS_BOOL &&
901                       EXPECTED(Z_TYPE_P(ret) == IS_FALSE || Z_TYPE_P(ret) == IS_TRUE)) {
902                /* pass */
903            } else {
904                /* Use strict check to verify return value of internal function */
905                zend_verify_internal_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), zend_zval_type_name(ret), "");
906                return 0;
907            }
908        }
909    }
910    return 1;
911}
912#endif
913
914static void zend_verify_return_type(zend_function *zf, zval *ret)
915{
916    zend_arg_info *ret_info = zf->common.arg_info - 1;
917    char *need_msg, *class_name;
918    zend_class_entry *ce;
919
920    if (ret_info->type_hint) {
921        if (EXPECTED(ret_info->type_hint == Z_TYPE_P(ret))) {
922            if (ret_info->class_name) {
923                need_msg = zend_verify_arg_class_kind(ret_info, &class_name, &ce);
924                if (!ce || !instanceof_function(Z_OBJCE_P(ret), ce)) {
925                    zend_verify_return_error(zf, need_msg, class_name, "instance of ", Z_OBJCE_P(ret)->name->val);
926                }
927            }
928        } else if (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null) {
929            if (ret_info->class_name) {
930                need_msg = zend_verify_arg_class_kind(ret_info, &class_name, &ce);
931                zend_verify_return_error(zf, need_msg, class_name, zend_zval_type_name(ret), "");
932            } else if (ret_info->type_hint == IS_CALLABLE) {
933                if (!zend_is_callable(ret, IS_CALLABLE_CHECK_SILENT, NULL)) {
934                    zend_verify_return_error(zf, "be callable", "", zend_zval_type_name(ret), "");
935                }
936            } else if (ret_info->type_hint == _IS_BOOL &&
937                       EXPECTED(Z_TYPE_P(ret) == IS_FALSE || Z_TYPE_P(ret) == IS_TRUE)) {
938                /* pass */
939            } else if (UNEXPECTED(!zend_verify_scalar_type_hint(ret_info->type_hint, ret, ZEND_RET_USES_STRICT_TYPES()))) {
940                zend_verify_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), zend_zval_type_name(ret), "");
941            }
942        }
943    }
944}
945
946static inline int zend_verify_missing_return_type(zend_function *zf)
947{
948    zend_arg_info *ret_info = zf->common.arg_info - 1;
949    char *need_msg;
950    zend_class_entry *ce;
951
952    if (ret_info->type_hint) {
953        if (ret_info->class_name) {
954            char *class_name;
955
956            need_msg = zend_verify_arg_class_kind(ret_info, &class_name, &ce);
957            zend_verify_return_error(zf, need_msg, class_name, "none", "");
958            return 0;
959        } else if (ret_info->type_hint == IS_CALLABLE) {
960            zend_verify_return_error(zf, "be callable", "", "none", "");
961        } else {
962            zend_verify_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), "none", "");
963        }
964        return 0;
965    }
966    return 1;
967}
968
969static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, uint32_t property_op_type, int value_type, znode_op value_op, const zend_execute_data *execute_data, void **cache_slot)
970{
971    zend_free_op free_value;
972    zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R);
973    zval tmp;
974
975    if (object_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
976        do {
977            if (object_op_type == IS_VAR && UNEXPECTED(object == &EG(error_zval))) {
978                if (retval) {
979                    ZVAL_NULL(retval);
980                }
981                FREE_OP(free_value);
982                return;
983            }
984            if (Z_ISREF_P(object)) {
985                object = Z_REFVAL_P(object);
986                if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
987                    break;
988                }
989            }
990            if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE ||
991                (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
992                zend_object *obj;
993
994                zval_ptr_dtor(object);
995                object_init(object);
996                Z_ADDREF_P(object);
997                obj = Z_OBJ_P(object);
998                zend_error(E_WARNING, "Creating default object from empty value");
999                if (GC_REFCOUNT(obj) == 1) {
1000                    /* the enclosing container was deleted, obj is unreferenced */
1001                    if (retval) {
1002                        ZVAL_NULL(retval);
1003                    }
1004                    FREE_OP(free_value);
1005                    OBJ_RELEASE(obj);
1006                    return;
1007                }
1008                Z_DELREF_P(object);
1009            } else {
1010                zend_error(E_WARNING, "Attempt to assign property of non-object");
1011                if (retval) {
1012                    ZVAL_NULL(retval);
1013                }
1014                FREE_OP(free_value);
1015                return;
1016            }
1017        } while (0);
1018    }
1019
1020    if (property_op_type == IS_CONST &&
1021        EXPECTED(Z_OBJCE_P(object) == CACHED_PTR_EX(cache_slot))) {
1022        uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR_EX(cache_slot + 1);
1023        zend_object *zobj = Z_OBJ_P(object);
1024        zval *property;
1025
1026        if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
1027            property = OBJ_PROP(zobj, prop_offset);
1028            if (Z_TYPE_P(property) != IS_UNDEF) {
1029fast_assign:
1030                value = zend_assign_to_variable(property, value, value_type);
1031                if (retval && EXPECTED(!EG(exception))) {
1032                    ZVAL_COPY(retval, value);
1033                }
1034                return;
1035            }
1036        } else {
1037            if (EXPECTED(zobj->properties != NULL)) {
1038                property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
1039                if (property) {
1040                    goto fast_assign;
1041                }
1042            }
1043
1044            if (!zobj->ce->__set) {
1045
1046                if (EXPECTED(zobj->properties == NULL)) {
1047                    rebuild_object_properties(zobj);
1048                }
1049                /* separate our value if necessary */
1050                if (value_type == IS_CONST) {
1051                    if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
1052                        ZVAL_COPY_VALUE(&tmp, value);
1053                        zval_copy_ctor_func(&tmp);
1054                        value = &tmp;
1055                    }
1056                } else if (value_type != IS_TMP_VAR) {
1057                    if (Z_ISREF_P(value)) {
1058                        if (value_type == IS_VAR) {
1059                            zend_reference *ref = Z_REF_P(value);
1060                            if (--(GC_REFCOUNT(ref)) == 0) {
1061                                ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value));
1062                                efree_size(ref, sizeof(zend_reference));
1063                                value = &tmp;
1064                            } else {
1065                                value = Z_REFVAL_P(value);
1066                                if (Z_REFCOUNTED_P(value)) {
1067                                    Z_ADDREF_P(value);
1068                                }
1069                            }
1070                        } else {
1071                            value = Z_REFVAL_P(value);
1072                            if (Z_REFCOUNTED_P(value)) {
1073                                Z_ADDREF_P(value);
1074                            }
1075                        }
1076                    } else if (value_type == IS_CV && Z_REFCOUNTED_P(value)) {
1077                        Z_ADDREF_P(value);
1078                    }
1079                }
1080                zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
1081                if (retval) {
1082                    ZVAL_COPY(retval, value);
1083                }
1084                return;
1085            }
1086        }
1087    }
1088
1089    if (!Z_OBJ_HT_P(object)->write_property) {
1090        zend_error(E_WARNING, "Attempt to assign property of non-object");
1091        if (retval) {
1092            ZVAL_NULL(retval);
1093        }
1094        FREE_OP(free_value);
1095        return;
1096    }
1097
1098    /* separate our value if necessary */
1099    if (value_type == IS_CONST) {
1100        if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
1101            ZVAL_COPY_VALUE(&tmp, value);
1102            zval_copy_ctor_func(&tmp);
1103            value = &tmp;
1104        }
1105    } else if (value_type != IS_TMP_VAR) {
1106        ZVAL_DEREF(value);
1107    }
1108
1109    Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot);
1110
1111    if (retval && EXPECTED(!EG(exception))) {
1112        ZVAL_COPY(retval, value);
1113    }
1114    if (value_type == IS_CONST) {
1115        zval_ptr_dtor_nogc(value);
1116    } else {
1117        FREE_OP(free_value);
1118    }
1119}
1120
1121static zend_never_inline void zend_assign_to_object_dim(zval *retval, zval *object, zval *property_name, int value_type, znode_op value_op, const zend_execute_data *execute_data)
1122{
1123    zend_free_op free_value;
1124    zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
1125    zval tmp;
1126
1127    /* Note:  property_name in this case is really the array index! */
1128    if (!Z_OBJ_HT_P(object)->write_dimension) {
1129        zend_error(E_EXCEPTION | E_ERROR, "Cannot use object as array");
1130        FREE_OP(free_value);
1131        return;
1132    }
1133
1134    /* separate our value if necessary */
1135    if (value_type == IS_CONST) {
1136        if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
1137            ZVAL_COPY_VALUE(&tmp, value);
1138            zval_copy_ctor_func(&tmp);
1139            value = &tmp;
1140        }
1141    }
1142
1143    Z_OBJ_HT_P(object)->write_dimension(object, property_name, value);
1144
1145    if (retval && EXPECTED(!EG(exception))) {
1146        ZVAL_COPY(retval, value);
1147    }
1148    if (value_type == IS_CONST) {
1149        zval_ptr_dtor_nogc(value);
1150    } else {
1151        FREE_OP(free_value);
1152    }
1153}
1154
1155static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value, zval *retval, binary_op_type binary_op)
1156{
1157    zval *z;
1158    zval rv, res;
1159
1160    if (Z_OBJ_HT_P(object)->read_dimension &&
1161        (z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) {
1162
1163        if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
1164            zval rv2;
1165            zval *value = Z_OBJ_HT_P(z)->get(z, &rv2);
1166
1167            if (z == &rv) {
1168                zval_ptr_dtor(&rv);
1169            }
1170            ZVAL_COPY_VALUE(z, value);
1171        }
1172        binary_op(&res, Z_ISREF_P(z) ? Z_REFVAL_P(z) : z, value);
1173        Z_OBJ_HT_P(object)->write_dimension(object, property, &res);
1174        if (z == &rv) {
1175            zval_ptr_dtor(&rv);
1176        }
1177        if (retval) {
1178            ZVAL_COPY(retval, &res);
1179        }
1180        zval_ptr_dtor(&res);
1181    } else {
1182        zend_error(E_WARNING, "Attempt to assign property of non-object");
1183        if (retval) {
1184            ZVAL_NULL(retval);
1185        }
1186    }
1187}
1188
1189static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result)
1190{
1191    zend_string *old_str;
1192
1193    if (offset < 0) {
1194        zend_error(E_WARNING, "Illegal string offset:  " ZEND_LONG_FMT, offset);
1195        zend_string_release(Z_STR_P(str));
1196        if (result) {
1197            ZVAL_NULL(result);
1198        }
1199        return;
1200    }
1201
1202    old_str = Z_STR_P(str);
1203    if ((size_t)offset >= Z_STRLEN_P(str)) {
1204        zend_long old_len = Z_STRLEN_P(str);
1205        Z_STR_P(str) = zend_string_extend(Z_STR_P(str), offset + 1, 0);
1206        Z_TYPE_INFO_P(str) = IS_STRING_EX;
1207        memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);
1208        Z_STRVAL_P(str)[offset+1] = 0;
1209    } else if (!Z_REFCOUNTED_P(str)) {
1210        Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
1211        Z_TYPE_INFO_P(str) = IS_STRING_EX;
1212    }
1213
1214    if (Z_TYPE_P(value) != IS_STRING) {
1215        zend_string *tmp = zval_get_string(value);
1216
1217        Z_STRVAL_P(str)[offset] = tmp->val[0];
1218        zend_string_release(tmp);
1219    } else {
1220        Z_STRVAL_P(str)[offset] = Z_STRVAL_P(value)[0];
1221    }
1222    /*
1223     * the value of an assignment to a string offset is undefined
1224    T(result->u.var).var = &T->str_offset.str;
1225    */
1226
1227    zend_string_release(old_str);
1228    if (result) {
1229        zend_uchar c = (zend_uchar)Z_STRVAL_P(str)[offset];
1230
1231        if (CG(one_char_string)[c]) {
1232            ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
1233        } else {
1234            ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(str) + offset, 1, 0));
1235        }
1236    }
1237}
1238
1239/* Utility Functions for Extensions */
1240static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array)
1241{
1242    if (extension->statement_handler) {
1243        extension->statement_handler(op_array);
1244    }
1245}
1246
1247
1248static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array)
1249{
1250    if (extension->fcall_begin_handler) {
1251        extension->fcall_begin_handler(op_array);
1252    }
1253}
1254
1255
1256static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array)
1257{
1258    if (extension->fcall_end_handler) {
1259        extension->fcall_end_handler(op_array);
1260    }
1261}
1262
1263
1264static zend_always_inline HashTable *zend_get_target_symbol_table(zend_execute_data *execute_data, int fetch_type)
1265{
1266    HashTable *ht;
1267
1268    if (EXPECTED(fetch_type == ZEND_FETCH_GLOBAL_LOCK) ||
1269        EXPECTED(fetch_type == ZEND_FETCH_GLOBAL)) {
1270        ht = &EG(symbol_table);
1271    } else if (EXPECTED(fetch_type == ZEND_FETCH_STATIC)) {
1272        ZEND_ASSERT(EX(func)->op_array.static_variables != NULL);
1273        ht = EX(func)->op_array.static_variables;
1274        if (GC_REFCOUNT(ht) > 1) {
1275            if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
1276                GC_REFCOUNT(ht)--;
1277            }
1278            EX(func)->op_array.static_variables = ht = zend_array_dup(ht);
1279        }
1280    } else {
1281        ZEND_ASSERT(fetch_type == ZEND_FETCH_LOCAL);
1282        if (!EX(symbol_table)) {
1283            zend_rebuild_symbol_table();
1284        }
1285        ht = EX(symbol_table);
1286    }
1287    return ht;
1288}
1289
1290static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht, const zval *dim, int dim_type, int type)
1291{
1292    zval *retval;
1293    zend_string *offset_key;
1294    zend_ulong hval;
1295
1296try_again:
1297    if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
1298        hval = Z_LVAL_P(dim);
1299num_index:
1300        retval = zend_hash_index_find(ht, hval);
1301        if (retval == NULL) {
1302            switch (type) {
1303                case BP_VAR_R:
1304                    zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
1305                    /* break missing intentionally */
1306                case BP_VAR_UNSET:
1307                case BP_VAR_IS:
1308                    retval = &EG(uninitialized_zval);
1309                    break;
1310                case BP_VAR_RW:
1311                    zend_error(E_NOTICE,"Undefined offset: " ZEND_ULONG_FMT, hval);
1312                    /* break missing intentionally */
1313                case BP_VAR_W:
1314                    retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
1315                    break;
1316            }
1317        }
1318    } else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) {
1319        offset_key = Z_STR_P(dim);
1320        if (dim_type != IS_CONST) {
1321            if (ZEND_HANDLE_NUMERIC(offset_key, hval)) {
1322                goto num_index;
1323            }
1324        }
1325str_index:
1326        retval = zend_hash_find(ht, offset_key);
1327        if (retval) {
1328            /* support for $GLOBALS[...] */
1329            if (UNEXPECTED(Z_TYPE_P(retval) == IS_INDIRECT)) {
1330                retval = Z_INDIRECT_P(retval);
1331                if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
1332                    switch (type) {
1333                        case BP_VAR_R:
1334                            zend_error(E_NOTICE, "Undefined index: %s", offset_key->val);
1335                            /* break missing intentionally */
1336                        case BP_VAR_UNSET:
1337                        case BP_VAR_IS:
1338                            retval = &EG(uninitialized_zval);
1339                            break;
1340                        case BP_VAR_RW:
1341                            zend_error(E_NOTICE,"Undefined index: %s", offset_key->val);
1342                            /* break missing intentionally */
1343                        case BP_VAR_W:
1344                            ZVAL_NULL(retval);
1345                            break;
1346                    }
1347                }
1348            }
1349        } else {
1350            switch (type) {
1351                case BP_VAR_R:
1352                    zend_error(E_NOTICE, "Undefined index: %s", offset_key->val);
1353                    /* break missing intentionally */
1354                case BP_VAR_UNSET:
1355                case BP_VAR_IS:
1356                    retval = &EG(uninitialized_zval);
1357                    break;
1358                case BP_VAR_RW:
1359                    zend_error(E_NOTICE,"Undefined index: %s", offset_key->val);
1360                    /* break missing intentionally */
1361                case BP_VAR_W:
1362                    retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval));
1363                    break;
1364            }
1365        }
1366    } else {
1367        switch (Z_TYPE_P(dim)) {
1368            case IS_NULL:
1369                offset_key = STR_EMPTY_ALLOC();
1370                goto str_index;
1371            case IS_DOUBLE:
1372                hval = zend_dval_to_lval(Z_DVAL_P(dim));
1373                goto num_index;
1374            case IS_RESOURCE:
1375                zend_error(E_NOTICE, "Resource ID#%pd used as offset, casting to integer (%pd)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
1376                hval = Z_RES_HANDLE_P(dim);
1377                goto num_index;
1378            case IS_FALSE:
1379                hval = 0;
1380                goto num_index;
1381            case IS_TRUE:
1382                hval = 1;
1383                goto num_index;
1384            case IS_REFERENCE:
1385                dim = Z_REFVAL_P(dim);
1386                goto try_again;
1387            default:
1388                zend_error(E_WARNING, "Illegal offset type");
1389                retval = (type == BP_VAR_W || type == BP_VAR_RW) ?
1390                    &EG(error_zval) : &EG(uninitialized_zval);
1391        }
1392    }
1393    return retval;
1394}
1395
1396static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type)
1397{
1398    zend_long offset;
1399
1400try_again:
1401    if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
1402        switch(Z_TYPE_P(dim)) {
1403            case IS_STRING:
1404                if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
1405                    break;
1406                }
1407                if (type != BP_VAR_UNSET) {
1408                    zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
1409                }
1410                break;
1411            case IS_DOUBLE:
1412            case IS_NULL:
1413            case IS_FALSE:
1414            case IS_TRUE:
1415                zend_error(E_NOTICE, "String offset cast occurred");
1416                break;
1417            case IS_REFERENCE:
1418                dim = Z_REFVAL_P(dim);
1419                goto try_again;
1420            default:
1421                zend_error(E_WARNING, "Illegal offset type");
1422                break;
1423        }
1424
1425        offset = zval_get_long(dim);
1426    } else {
1427        offset = Z_LVAL_P(dim);
1428    }
1429
1430    return offset;
1431}
1432
1433static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type)
1434{
1435    zend_long offset = zend_check_string_offset(dim, type);
1436
1437    if (Z_REFCOUNTED_P(container)) {
1438        if (Z_REFCOUNT_P(container) > 1) {
1439            Z_DELREF_P(container);
1440            zval_copy_ctor_func(container);
1441        }
1442        Z_ADDREF_P(container);
1443    }
1444    return offset;
1445}
1446
1447static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *container, zval *dim, int dim_type, int type)
1448{
1449    zval *retval;
1450
1451try_again:
1452    if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
1453        SEPARATE_ARRAY(container);
1454fetch_from_array:
1455        if (dim == NULL) {
1456            retval = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
1457            if (UNEXPECTED(retval == NULL)) {
1458                zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
1459                retval = &EG(error_zval);
1460            }
1461        } else {
1462            retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
1463        }
1464        ZVAL_INDIRECT(result, retval);
1465    } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
1466        if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRLEN_P(container) == 0)) {
1467            zval_ptr_dtor_nogc(container);
1468convert_to_array:
1469            ZVAL_NEW_ARR(container);
1470            zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
1471            goto fetch_from_array;
1472        }
1473
1474        if (dim == NULL) {
1475            zend_error(E_EXCEPTION | E_ERROR, "[] operator not supported for strings");
1476        } else {
1477            zend_check_string_offset(dim, type);
1478        }
1479
1480        ZVAL_INDIRECT(result, NULL); /* wrong string offset */
1481    } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1482        if (!Z_OBJ_HT_P(container)->read_dimension) {
1483            zend_error(E_EXCEPTION | E_ERROR, "Cannot use object as array");
1484            retval = &EG(error_zval);
1485        } else {
1486            retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
1487
1488            if (UNEXPECTED(retval == &EG(uninitialized_zval))) {
1489                zend_class_entry *ce = Z_OBJCE_P(container);
1490
1491                ZVAL_NULL(result);
1492                zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ce->name->val);
1493            } else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) {
1494                if (!Z_ISREF_P(retval)) {
1495                    if (Z_REFCOUNTED_P(retval) &&
1496                        Z_REFCOUNT_P(retval) > 1) {
1497                        if (Z_TYPE_P(retval) != IS_OBJECT) {
1498                            Z_DELREF_P(retval);
1499                            ZVAL_DUP(result, retval);
1500                            retval = result;
1501                        } else {
1502                            ZVAL_COPY(result, retval);
1503                            retval = result;
1504                        }
1505                    }
1506                    if (Z_TYPE_P(retval) != IS_OBJECT) {
1507                        zend_class_entry *ce = Z_OBJCE_P(container);
1508                        zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ce->name->val);
1509                    }
1510                }
1511                if (result != retval) {
1512                    ZVAL_INDIRECT(result, retval);
1513                }
1514            } else {
1515                ZVAL_INDIRECT(result, &EG(error_zval));
1516            }
1517        }
1518    } else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
1519        if (UNEXPECTED(container == &EG(error_zval))) {
1520            ZVAL_INDIRECT(result, &EG(error_zval));
1521        } else if (type != BP_VAR_UNSET) {
1522            goto convert_to_array;
1523        } else {
1524            /* for read-mode only */
1525            ZVAL_NULL(result);
1526        }
1527    } else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
1528        container = Z_REFVAL_P(container);
1529        goto try_again;
1530    } else {
1531        if (type == BP_VAR_UNSET) {
1532            zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
1533            ZVAL_NULL(result);
1534        } else {
1535            zend_error(E_WARNING, "Cannot use a scalar value as an array");
1536            ZVAL_INDIRECT(result, &EG(error_zval));
1537        }
1538    }
1539}
1540
1541static zend_never_inline void zend_fetch_dimension_address_W(zval *result, zval *container_ptr, zval *dim, int dim_type)
1542{
1543    zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W);
1544}
1545
1546static zend_never_inline void zend_fetch_dimension_address_RW(zval *result, zval *container_ptr, zval *dim, int dim_type)
1547{
1548    zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW);
1549}
1550
1551static zend_never_inline void zend_fetch_dimension_address_UNSET(zval *result, zval *container_ptr, zval *dim, int dim_type)
1552{
1553    zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET);
1554}
1555
1556static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type)
1557{
1558    zval *retval;
1559
1560try_again:
1561    if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
1562        retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
1563        ZVAL_COPY(result, retval);
1564    } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
1565        zend_long offset;
1566
1567try_string_offset:
1568        if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
1569            switch(Z_TYPE_P(dim)) {
1570                /* case IS_LONG: */
1571                case IS_STRING:
1572                    if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
1573                        break;
1574                    }
1575                    if (type != BP_VAR_IS) {
1576                        zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
1577                    }
1578                    break;
1579                case IS_DOUBLE:
1580                case IS_NULL:
1581                case IS_FALSE:
1582                case IS_TRUE:
1583                    if (type != BP_VAR_IS) {
1584                        zend_error(E_NOTICE, "String offset cast occurred");
1585                    }
1586                    break;
1587                case IS_REFERENCE:
1588                    dim = Z_REFVAL_P(dim);
1589                    goto try_string_offset;
1590                default:
1591                    zend_error(E_WARNING, "Illegal offset type");
1592                    break;
1593            }
1594
1595            offset = zval_get_long(dim);
1596        } else {
1597            offset = Z_LVAL_P(dim);
1598        }
1599
1600        if (UNEXPECTED(offset < 0) || UNEXPECTED(Z_STRLEN_P(container) <= (size_t)offset)) {
1601            if (type != BP_VAR_IS) {
1602                zend_error(E_NOTICE, "Uninitialized string offset: %pd", offset);
1603            }
1604            ZVAL_EMPTY_STRING(result);
1605        } else {
1606            zend_uchar c = (zend_uchar)Z_STRVAL_P(container)[offset];
1607
1608            if (CG(one_char_string)[c]) {
1609                ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
1610            } else {
1611                ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(container) + offset, 1, 0));
1612            }
1613        }
1614    } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1615        if (!Z_OBJ_HT_P(container)->read_dimension) {
1616            zend_error(E_EXCEPTION | E_ERROR, "Cannot use object as array");
1617            ZVAL_NULL(result);
1618        } else {
1619            retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
1620
1621            ZEND_ASSERT(result != NULL);
1622            if (retval) {
1623                if (result != retval) {
1624                    ZVAL_COPY(result, retval);
1625                }
1626            } else {
1627                ZVAL_NULL(result);
1628            }
1629        }
1630    } else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
1631        container = Z_REFVAL_P(container);
1632        goto try_again;
1633    } else {
1634        ZVAL_NULL(result);
1635    }
1636}
1637
1638static zend_never_inline void zend_fetch_dimension_address_read_R(zval *result, zval *container, zval *dim, int dim_type)
1639{
1640    zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R);
1641}
1642
1643static zend_never_inline void zend_fetch_dimension_address_read_IS(zval *result, zval *container, zval *dim, int dim_type)
1644{
1645    zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS);
1646}
1647
1648ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim)
1649{
1650    zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR);
1651}
1652
1653static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type)
1654{
1655    if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
1656        do {
1657            if (container_op_type == IS_VAR && UNEXPECTED(container == &EG(error_zval))) {
1658                ZVAL_INDIRECT(result, &EG(error_zval));
1659                return;
1660            }
1661
1662            if (Z_ISREF_P(container)) {
1663                container = Z_REFVAL_P(container);
1664                if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1665                    break;
1666                }
1667            }
1668
1669            /* this should modify object only if it's empty */
1670            if (type != BP_VAR_UNSET &&
1671                EXPECTED(Z_TYPE_P(container) <= IS_FALSE ||
1672                  (Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0))) {
1673                zval_ptr_dtor_nogc(container);
1674                object_init(container);
1675            } else {
1676                zend_error(E_WARNING, "Attempt to modify property of non-object");
1677                ZVAL_INDIRECT(result, &EG(error_zval));
1678                return;
1679            }
1680        } while (0);
1681    }
1682    if (prop_op_type == IS_CONST &&
1683        EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) {
1684        uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR_EX(cache_slot + 1);
1685        zend_object *zobj = Z_OBJ_P(container);
1686        zval *retval;
1687
1688        if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
1689            retval = OBJ_PROP(zobj, prop_offset);
1690            if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) {
1691                ZVAL_INDIRECT(result, retval);
1692                return;
1693            }
1694        } else if (EXPECTED(zobj->properties != NULL)) {
1695            retval = zend_hash_find(zobj->properties, Z_STR_P(prop_ptr));
1696            if (EXPECTED(retval)) {
1697                ZVAL_INDIRECT(result, retval);
1698                return;
1699            }
1700        }
1701    }
1702    if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) {
1703        zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot);
1704        if (NULL == ptr) {
1705            if (Z_OBJ_HT_P(container)->read_property &&
1706                (ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result)) != NULL) {
1707                if (ptr != result) {
1708                    ZVAL_INDIRECT(result, ptr);
1709                }
1710            } else {
1711                zend_error(E_EXCEPTION | E_ERROR, "Cannot access undefined property for object with overloaded property access");
1712                ZVAL_INDIRECT(result, &EG(error_zval));
1713            }
1714        } else {
1715            ZVAL_INDIRECT(result, ptr);
1716        }
1717    } else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
1718        zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
1719        if (ptr != result) {
1720            ZVAL_INDIRECT(result, ptr);
1721        }
1722    } else {
1723        zend_error(E_WARNING, "This object doesn't support property references");
1724        ZVAL_INDIRECT(result, &EG(error_zval));
1725    }
1726}
1727
1728static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const zend_execute_data *execute_data)
1729{
1730    zend_brk_cont_element *jmp_to;
1731
1732    do {
1733        ZEND_ASSERT(array_offset != -1);
1734        jmp_to = &op_array->brk_cont_array[array_offset];
1735        if (nest_levels > 1 && jmp_to->start >= 0) {
1736            zend_op *brk_opline = &op_array->opcodes[jmp_to->brk];
1737
1738            if (brk_opline->opcode == ZEND_FREE) {
1739                zval_ptr_dtor_nogc(EX_VAR(brk_opline->op1.var));
1740            } else if (brk_opline->opcode == ZEND_FE_FREE) {
1741                zval *var = EX_VAR(brk_opline->op1.var);
1742                if (Z_TYPE_P(var) != IS_ARRAY && Z_FE_ITER_P(var) != (uint32_t)-1) {
1743                    zend_hash_iterator_del(Z_FE_ITER_P(var));
1744                }
1745                zval_ptr_dtor_nogc(var);
1746            }
1747        }
1748        array_offset = jmp_to->parent;
1749    } while (--nest_levels > 0);
1750    return jmp_to;
1751}
1752
1753#if ZEND_INTENSIVE_DEBUGGING
1754
1755#define CHECK_SYMBOL_TABLES()                                                   \
1756    zend_hash_apply(&EG(symbol_table), zend_check_symbol);          \
1757    if (&EG(symbol_table)!=EX(symbol_table)) {                          \
1758        zend_hash_apply(EX(symbol_table), zend_check_symbol);   \
1759    }
1760
1761static int zend_check_symbol(zval *pz)
1762{
1763    if (Z_TYPE_P(pz) == IS_INDIRECT) {
1764        pz = Z_INDIRECT_P(pz);
1765    }
1766    if (Z_TYPE_P(pz) > 10) {
1767        fprintf(stderr, "Warning!  %x has invalid type!\n", *pz);
1768/* See http://support.microsoft.com/kb/190351 */
1769#ifdef PHP_WIN32
1770        fflush(stderr);
1771#endif
1772    } else if (Z_TYPE_P(pz) == IS_ARRAY) {
1773        zend_hash_apply(Z_ARRVAL_P(pz), zend_check_symbol);
1774    } else if (Z_TYPE_P(pz) == IS_OBJECT) {
1775        /* OBJ-TBI - doesn't support new object model! */
1776        zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol);
1777    }
1778
1779    return 0;
1780}
1781
1782
1783#else
1784#define CHECK_SYMBOL_TABLES()
1785#endif
1786
1787ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value)
1788{
1789    execute_data->func->internal_function.handler(execute_data, return_value);
1790}
1791
1792ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
1793{
1794    if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
1795        zend_array_destroy(symbol_table);
1796    } else {
1797        /* clean before putting into the cache, since clean
1798           could call dtors, which could use cached hash */
1799        zend_symtable_clean(symbol_table);
1800        *(++EG(symtable_cache_ptr)) = symbol_table;
1801    }
1802}
1803/* }}} */
1804
1805static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1806{
1807    zval *cv = EX_VAR_NUM(0);
1808    zval *end = cv + EX(func)->op_array.last_var;
1809    while (EXPECTED(cv != end)) {
1810        if (Z_REFCOUNTED_P(cv)) {
1811            if (!Z_DELREF_P(cv)) {
1812                zend_refcounted *r = Z_COUNTED_P(cv);
1813                ZVAL_NULL(cv);
1814                zval_dtor_func_for_ptr(r);
1815            } else {
1816                GC_ZVAL_CHECK_POSSIBLE_ROOT(cv);
1817            }
1818        }
1819        cv++;
1820    }
1821}
1822/* }}} */
1823
1824void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1825{
1826    i_free_compiled_variables(execute_data);
1827}
1828/* }}} */
1829
1830#ifdef ZEND_WIN32
1831# define ZEND_VM_INTERRUPT_CHECK() do { \
1832        if (EG(timed_out)) { \
1833            zend_timeout(0); \
1834        } \
1835    } while (0)
1836#else
1837# define ZEND_VM_INTERRUPT_CHECK() do { \
1838    } while (0)
1839#endif
1840
1841/*
1842 * Stack Frame Layout (the whole stack frame is allocated at once)
1843 * ==================
1844 *
1845 *                             +========================================+
1846 * EG(current_execute_data) -> | zend_execute_data                      |
1847 *                             +----------------------------------------+
1848 *     EX_CV_NUM(0) ---------> | VAR[0] = ARG[1]                        |
1849 *                             | ...                                    |
1850 *                             | VAR[op_array->num_args-1] = ARG[N]     |
1851 *                             | ...                                    |
1852 *                             | VAR[op_array->last_var-1]              |
1853 *                             | VAR[op_array->last_var] = TMP[0]       |
1854 *                             | ...                                    |
1855 *                             | VAR[op_array->last_var+op_array->T-1]  |
1856 *                             | ARG[N+1] (extra_args)                  |
1857 *                             | ...                                    |
1858 *                             +----------------------------------------+
1859 */
1860
1861static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value, int check_this) /* {{{ */
1862{
1863    uint32_t first_extra_arg, num_args;
1864    ZEND_ASSERT(EX(func) == (zend_function*)op_array);
1865
1866    EX(opline) = op_array->opcodes;
1867    EX(call) = NULL;
1868    EX(return_value) = return_value;
1869
1870    /* Handle arguments */
1871    first_extra_arg = op_array->num_args;
1872    num_args = EX_NUM_ARGS();
1873    if (UNEXPECTED(num_args > first_extra_arg)) {
1874        zval *end, *src, *dst;
1875        uint32_t type_flags = 0;
1876
1877        if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
1878            /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
1879            EX(opline) += first_extra_arg;
1880        }
1881
1882        /* move extra args into separate array after all CV and TMP vars */
1883        end = EX_VAR_NUM(first_extra_arg - 1);
1884        src = end + (num_args - first_extra_arg);
1885        dst = src + (op_array->last_var + op_array->T - first_extra_arg);
1886        if (EXPECTED(src != dst)) {
1887            do {
1888                type_flags |= Z_TYPE_INFO_P(src);
1889                ZVAL_COPY_VALUE(dst, src);
1890                ZVAL_UNDEF(src);
1891                src--;
1892                dst--;
1893            } while (src != end);
1894        } else {
1895            do {
1896                type_flags |= Z_TYPE_INFO_P(src);
1897                src--;
1898            } while (src != end);
1899        }
1900        ZEND_ADD_CALL_FLAG(execute_data, ((type_flags >> Z_TYPE_FLAGS_SHIFT) & IS_TYPE_REFCOUNTED));
1901    } else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
1902        /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
1903        EX(opline) += num_args;
1904    }
1905
1906    /* Initialize CV variables (skip arguments) */
1907    if (EXPECTED((int)num_args < op_array->last_var)) {
1908        zval *var = EX_VAR_NUM(num_args);
1909        zval *end = EX_VAR_NUM(op_array->last_var);
1910
1911        do {
1912            ZVAL_UNDEF(var);
1913            var++;
1914        } while (var != end);
1915    }
1916
1917    if (check_this && op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
1918        ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
1919        GC_REFCOUNT(Z_OBJ(EX(This)))++;
1920    }
1921
1922    if (UNEXPECTED(!op_array->run_time_cache)) {
1923        op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
1924        memset(op_array->run_time_cache, 0, op_array->cache_size);
1925    }
1926    EX_LOAD_RUN_TIME_CACHE(op_array);
1927    EX_LOAD_LITERALS(op_array);
1928
1929    EG(current_execute_data) = execute_data;
1930    ZEND_VM_INTERRUPT_CHECK();
1931}
1932/* }}} */
1933
1934static zend_always_inline void i_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
1935{
1936    ZEND_ASSERT(EX(func) == (zend_function*)op_array);
1937
1938    EX(opline) = op_array->opcodes;
1939    EX(call) = NULL;
1940    EX(return_value) = return_value;
1941
1942    zend_attach_symbol_table(execute_data);
1943
1944    if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
1945        ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
1946        GC_REFCOUNT(Z_OBJ(EX(This)))++;
1947    }
1948
1949    if (!op_array->run_time_cache) {
1950        op_array->run_time_cache = emalloc(op_array->cache_size);
1951        memset(op_array->run_time_cache, 0, op_array->cache_size);
1952    }
1953    EX_LOAD_RUN_TIME_CACHE(op_array);
1954    EX_LOAD_LITERALS(op_array);
1955
1956    EG(current_execute_data) = execute_data;
1957    ZEND_VM_INTERRUPT_CHECK();
1958}
1959/* }}} */
1960
1961static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
1962{
1963    ZEND_ASSERT(EX(func) == (zend_function*)op_array);
1964
1965    EX(opline) = op_array->opcodes;
1966    EX(call) = NULL;
1967    EX(return_value) = return_value;
1968
1969    if (UNEXPECTED(EX(symbol_table) != NULL)) {
1970        zend_attach_symbol_table(execute_data);
1971    } else {
1972        uint32_t first_extra_arg, num_args;
1973
1974        /* Handle arguments */
1975        first_extra_arg = op_array->num_args;
1976        num_args = EX_NUM_ARGS();
1977        if (UNEXPECTED(num_args > first_extra_arg)) {
1978            zval *end, *src, *dst;
1979            uint32_t type_flags = 0;
1980
1981            if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
1982                /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
1983                EX(opline) += first_extra_arg;
1984            }
1985
1986            /* move extra args into separate array after all CV and TMP vars */
1987            end = EX_VAR_NUM(first_extra_arg - 1);
1988            src = end + (num_args - first_extra_arg);
1989            dst = src + (op_array->last_var + op_array->T - first_extra_arg);
1990            if (EXPECTED(src != dst)) {
1991                do {
1992                    type_flags |= Z_TYPE_INFO_P(src);
1993                    ZVAL_COPY_VALUE(dst, src);
1994                    ZVAL_UNDEF(src);
1995                    src--;
1996                    dst--;
1997                } while (src != end);
1998            } else {
1999                do {
2000                    type_flags |= Z_TYPE_INFO_P(src);
2001                    src--;
2002                } while (src != end);
2003            }
2004            ZEND_ADD_CALL_FLAG(execute_data, ((type_flags >> Z_TYPE_FLAGS_SHIFT) & IS_TYPE_REFCOUNTED));
2005        } else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
2006            /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
2007            EX(opline) += num_args;
2008        }
2009
2010        /* Initialize CV variables (skip arguments) */
2011        if (EXPECTED((int)num_args < op_array->last_var)) {
2012            zval *var = EX_VAR_NUM(num_args);
2013            zval *end = EX_VAR_NUM(op_array->last_var);
2014
2015            do {
2016                ZVAL_UNDEF(var);
2017                var++;
2018            } while (var != end);
2019        }
2020    }
2021
2022    if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
2023        ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
2024        GC_REFCOUNT(Z_OBJ(EX(This)))++;
2025    }
2026
2027    if (!op_array->run_time_cache) {
2028        if (op_array->function_name) {
2029            op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
2030        } else {
2031            op_array->run_time_cache = emalloc(op_array->cache_size);
2032        }
2033        memset(op_array->run_time_cache, 0, op_array->cache_size);
2034    }
2035    EX_LOAD_RUN_TIME_CACHE(op_array);
2036    EX_LOAD_LITERALS(op_array);
2037
2038    EG(current_execute_data) = execute_data;
2039    ZEND_VM_INTERRUPT_CHECK();
2040}
2041/* }}} */
2042
2043ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value) /* {{{ */
2044{
2045    /*
2046     * Normally the execute_data is allocated on the VM stack (because it does
2047     * not actually do any allocation and thus is faster). For generators
2048     * though this behavior would be suboptimal, because the (rather large)
2049     * structure would have to be copied back and forth every time execution is
2050     * suspended or resumed. That's why for generators the execution context
2051     * is allocated using a separate VM stack, thus allowing to save and
2052     * restore it simply by replacing a pointer.
2053     */
2054    zend_execute_data *execute_data;
2055    uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
2056    size_t stack_size = (ZEND_CALL_FRAME_SLOT + MAX(op_array->last_var + op_array->T, num_args)) * sizeof(zval);
2057    uint32_t call_info;
2058
2059    EG(vm_stack) = zend_vm_stack_new_page(
2060        EXPECTED(stack_size < ZEND_VM_STACK_FREE_PAGE_SIZE(1)) ?
2061            ZEND_VM_STACK_PAGE_SIZE(1) :
2062            ZEND_VM_STACK_PAGE_ALIGNED_SIZE(1, stack_size),
2063        NULL);
2064    EG(vm_stack_top) = EG(vm_stack)->top;
2065    EG(vm_stack_end) = EG(vm_stack)->end;
2066
2067    call_info = ZEND_CALL_TOP_FUNCTION | ZEND_CALL_ALLOCATED | (ZEND_CALL_INFO(call) & (ZEND_CALL_CLOSURE|ZEND_CALL_RELEASE_THIS));
2068    if (Z_OBJ(call->This)) {
2069        call_info |= ZEND_CALL_RELEASE_THIS;
2070    }
2071    execute_data = zend_vm_stack_push_call_frame(
2072        call_info,
2073        (zend_function*)op_array,
2074        num_args,
2075        call->called_scope,
2076        Z_OBJ(call->This));
2077    EX(prev_execute_data) = NULL;
2078    EX_NUM_ARGS() = num_args;
2079
2080    /* copy arguments */
2081    if (num_args > 0) {
2082        zval *arg_src = ZEND_CALL_ARG(call, 1);
2083        zval *arg_dst = ZEND_CALL_ARG(execute_data, 1);
2084        zval *end = arg_src + num_args;
2085
2086        do {
2087            ZVAL_COPY_VALUE(arg_dst, arg_src);
2088            arg_src++;
2089            arg_dst++;
2090        } while (arg_src != end);
2091    }
2092
2093    EX(symbol_table) = NULL;
2094
2095    i_init_func_execute_data(execute_data, op_array, return_value, 1);
2096
2097    return execute_data;
2098}
2099/* }}} */
2100
2101ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
2102{
2103    EX(prev_execute_data) = EG(current_execute_data);
2104    i_init_execute_data(execute_data, op_array, return_value);
2105}
2106/* }}} */
2107
2108static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(const zend_op *opline, zend_execute_data *call) /* {{{ */
2109{
2110    uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
2111    return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num);
2112}
2113/* }}} */
2114
2115static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
2116{
2117    zend_execute_data *new_call;
2118    int used_stack = (EG(vm_stack_top) - (zval*)call) + additional_args;
2119
2120    /* copy call frame into new stack segment */
2121    new_call = zend_vm_stack_extend(used_stack * sizeof(zval));
2122    *new_call = *call;
2123    if (passed_args) {
2124        zval *src = ZEND_CALL_ARG(call, 1);
2125        zval *dst = ZEND_CALL_ARG(new_call, 1);
2126        do {
2127            ZVAL_COPY_VALUE(dst, src);
2128            passed_args--;
2129            src++;
2130            dst++;
2131        } while (passed_args);
2132    }
2133
2134    /* delete old call_frame from previous stack segment */
2135    EG(vm_stack)->prev->top = (zval*)call;
2136
2137    /* delete previous stack segment if it becames empty */
2138    if (UNEXPECTED(EG(vm_stack)->prev->top == ZEND_VM_STACK_ELEMETS(EG(vm_stack)->prev))) {
2139        zend_vm_stack r = EG(vm_stack)->prev;
2140
2141        EG(vm_stack)->prev = r->prev;
2142        efree(r);
2143    }
2144
2145    return new_call;
2146}
2147/* }}} */
2148
2149static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
2150{
2151    if (EXPECTED((uint32_t)(EG(vm_stack_end) - EG(vm_stack_top)) > additional_args)) {
2152        EG(vm_stack_top) += additional_args;
2153    } else {
2154        *call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args);
2155    }
2156}
2157/* }}} */
2158
2159static zend_always_inline zend_generator *zend_get_running_generator(zend_execute_data *execute_data) /* {{{ */
2160{
2161    /* The generator object is stored in EX(return_value) */
2162    zend_generator *generator = (zend_generator *) EX(return_value);
2163    /* However control may currently be delegated to another generator.
2164     * That's the one we're interested in. */
2165    return generator;
2166}
2167/* }}} */
2168
2169#ifdef HAVE_GCC_GLOBAL_REGS
2170# if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
2171#  define ZEND_VM_FP_GLOBAL_REG "%esi"
2172#  define ZEND_VM_IP_GLOBAL_REG "%edi"
2173# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__x86_64__)
2174#  define ZEND_VM_FP_GLOBAL_REG "%r14"
2175#  define ZEND_VM_IP_GLOBAL_REG "%r15"
2176# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
2177#  define ZEND_VM_FP_GLOBAL_REG "r28"
2178#  define ZEND_VM_IP_GLOBAL_REG "r29"
2179# endif
2180#endif
2181
2182#define ZEND_VM_NEXT_OPCODE() \
2183    CHECK_SYMBOL_TABLES() \
2184    ZEND_VM_INC_OPCODE(); \
2185    ZEND_VM_CONTINUE()
2186
2187#define ZEND_VM_SET_NEXT_OPCODE(new_op) \
2188    CHECK_SYMBOL_TABLES() \
2189    OPLINE = new_op
2190
2191#define ZEND_VM_SET_OPCODE(new_op) \
2192    CHECK_SYMBOL_TABLES() \
2193    OPLINE = new_op; \
2194    ZEND_VM_INTERRUPT_CHECK()
2195
2196#define ZEND_VM_SET_RELATIVE_OPCODE(opline, offset) \
2197    ZEND_VM_SET_OPCODE(ZEND_OFFSET_TO_OPLINE(opline, offset))
2198
2199#define ZEND_VM_JMP(new_op) \
2200    if (EXPECTED(!EG(exception))) { \
2201        ZEND_VM_SET_OPCODE(new_op); \
2202    } else { \
2203        LOAD_OPLINE(); \
2204    } \
2205    ZEND_VM_CONTINUE()
2206
2207#define ZEND_VM_INC_OPCODE() \
2208    OPLINE++
2209
2210
2211#ifndef VM_SMART_OPCODES
2212# define VM_SMART_OPCODES 1
2213#endif
2214
2215#if VM_SMART_OPCODES
2216# define ZEND_VM_REPEATABLE_OPCODE \
2217    do {
2218# define ZEND_VM_REPEAT_OPCODE(_opcode) \
2219    } while (UNEXPECTED((++opline)->opcode == _opcode)); \
2220    OPLINE = opline; \
2221    ZEND_VM_CONTINUE()
2222# define ZEND_VM_SMART_BRANCH(_result, _check) do { \
2223        int __result; \
2224        if (EXPECTED((opline+1)->opcode == ZEND_JMPZ)) { \
2225            __result = (_result); \
2226        } else if (EXPECTED((opline+1)->opcode == ZEND_JMPNZ)) { \
2227            __result = !(_result); \
2228        } else { \
2229            break; \
2230        } \
2231        if ((_check) && UNEXPECTED(EG(exception))) { \
2232            HANDLE_EXCEPTION(); \
2233        } \
2234        if (__result) { \
2235            ZEND_VM_SET_NEXT_OPCODE(opline + 2); \
2236        } else { \
2237            ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline + 1, (opline+1)->op2)); \
2238        } \
2239        ZEND_VM_CONTINUE(); \
2240    } while (0)
2241#else
2242# define ZEND_VM_REPEATABLE_OPCODE
2243# define ZEND_VM_REPEAT_OPCODE(_opcode)
2244# define ZEND_VM_SMART_BRANCH(_result, _check)
2245#endif
2246
2247#ifdef __GNUC__
2248# define ZEND_VM_GUARD(name) __asm__("#" #name)
2249#else
2250# define ZEND_VM_GUARD(name)
2251#endif
2252
2253#define GET_OP1_UNDEF_CV(ptr, type) \
2254    _get_zval_cv_lookup_ ## type(ptr, opline->op1.var, execute_data)
2255#define GET_OP2_UNDEF_CV(ptr, type) \
2256    _get_zval_cv_lookup_ ## type(ptr, opline->op2.var, execute_data)
2257
2258#include "zend_vm_execute.h"
2259
2260ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)
2261{
2262    if (opcode != ZEND_USER_OPCODE) {
2263        if (handler == NULL) {
2264            /* restore the original handler */
2265            zend_user_opcodes[opcode] = opcode;
2266        } else {
2267            zend_user_opcodes[opcode] = ZEND_USER_OPCODE;
2268        }
2269        zend_user_opcode_handlers[opcode] = handler;
2270        return SUCCESS;
2271    }
2272    return FAILURE;
2273}
2274
2275ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
2276{
2277    return zend_user_opcode_handlers[opcode];
2278}
2279
2280ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type) {
2281    return get_zval_ptr(op_type, *node, execute_data, should_free, type);
2282}
2283
2284/*
2285 * Local variables:
2286 * tab-width: 4
2287 * c-basic-offset: 4
2288 * indent-tabs-mode: t
2289 * End:
2290 */
2291