PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_execute.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 920 1093 84.2 %
Date: 2016-06-25 Functions: 38 52 73.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2016 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             : #define ZEND_INTENSIVE_DEBUGGING 0
      24             : 
      25             : #include <stdio.h>
      26             : #include <signal.h>
      27             : 
      28             : #include "zend.h"
      29             : #include "zend_compile.h"
      30             : #include "zend_execute.h"
      31             : #include "zend_API.h"
      32             : #include "zend_ptr_stack.h"
      33             : #include "zend_constants.h"
      34             : #include "zend_extensions.h"
      35             : #include "zend_ini.h"
      36             : #include "zend_exceptions.h"
      37             : #include "zend_interfaces.h"
      38             : #include "zend_closures.h"
      39             : #include "zend_generators.h"
      40             : #include "zend_vm.h"
      41             : #include "zend_dtrace.h"
      42             : #include "zend_inheritance.h"
      43             : 
      44             : /* Virtual current working directory support */
      45             : #include "zend_virtual_cwd.h"
      46             : 
      47             : #define _CONST_CODE  0
      48             : #define _TMP_CODE    1
      49             : #define _VAR_CODE    2
      50             : #define _UNUSED_CODE 3
      51             : #define _CV_CODE     4
      52             : 
      53             : typedef int (ZEND_FASTCALL *incdec_t)(zval *);
      54             : 
      55             : #define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type)
      56             : #define get_zval_ptr_deref(op_type, node, ex, should_free, type) _get_zval_ptr_deref(op_type, node, ex, should_free, type)
      57             : #define get_zval_ptr_r(op_type, node, ex, should_free) _get_zval_ptr_r(op_type, node, ex, should_free)
      58             : #define get_zval_ptr_r_deref(op_type, node, ex, should_free) _get_zval_ptr_r_deref(op_type, node, ex, should_free)
      59             : #define get_zval_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_undef(op_type, node, ex, should_free, type)
      60             : #define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
      61             : #define get_zval_ptr_ptr_undef(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type)
      62             : #define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type)
      63             : #define get_obj_zval_ptr_undef(op_type, node, ex, should_free, type) _get_obj_zval_ptr_undef(op_type, node, ex, should_free, type)
      64             : #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)
      65             : 
      66             : /* Prototypes */
      67             : static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array);
      68             : static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array);
      69             : static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array);
      70             : 
      71             : #define RETURN_VALUE_USED(opline) ((opline)->result_type != IS_UNUSED)
      72             : 
      73          71 : static ZEND_FUNCTION(pass)
      74             : {
      75          71 : }
      76             : 
      77             : static const zend_internal_function zend_pass_function = {
      78             :         ZEND_INTERNAL_FUNCTION, /* type              */
      79             :         {0, 0, 0},              /* arg_flags         */
      80             :         0,                      /* fn_flags          */
      81             :         NULL,                   /* name              */
      82             :         NULL,                   /* scope             */
      83             :         NULL,                   /* prototype         */
      84             :         0,                      /* num_args          */
      85             :         0,                      /* required_num_args */
      86             :         NULL,                   /* arg_info          */
      87             :         ZEND_FN(pass),          /* handler           */
      88             :         NULL                    /* module            */
      89             : };
      90             : 
      91             : #undef zval_ptr_dtor
      92             : #define zval_ptr_dtor(zv) i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC)
      93             : 
      94             : #define READY_TO_DESTROY(zv) \
      95             :         (UNEXPECTED(zv) && Z_REFCOUNTED_P(zv) && Z_REFCOUNT_P(zv) == 1)
      96             : 
      97             : #define EXTRACT_ZVAL_PTR(zv) do {               \
      98             :         zval *__zv = (zv);                                                              \
      99             :         if (EXPECTED(Z_TYPE_P(__zv) == IS_INDIRECT)) {  \
     100             :                 ZVAL_COPY(__zv, Z_INDIRECT_P(__zv));        \
     101             :         }                                                                                               \
     102             : } while (0)
     103             : 
     104             : #define FREE_OP(should_free) \
     105             :         if (should_free) { \
     106             :                 zval_ptr_dtor_nogc(should_free); \
     107             :         }
     108             : 
     109             : #define FREE_UNFETCHED_OP(type, var) \
     110             :         if ((type) & (IS_TMP_VAR|IS_VAR)) { \
     111             :                 zval_ptr_dtor_nogc(EX_VAR(var)); \
     112             :         }
     113             : 
     114             : #define FREE_OP_VAR_PTR(should_free) \
     115             :         if (should_free) { \
     116             :                 zval_ptr_dtor_nogc(should_free); \
     117             :         }
     118             : 
     119             : /* End of zend_execute_locks.h */
     120             : 
     121             : #define CV_DEF_OF(i) (EX(func)->op_array.vars[i])
     122             : 
     123             : #define CTOR_CALL_BIT    0x1
     124             : #define CTOR_USED_BIT    0x2
     125             : 
     126             : #define IS_CTOR_CALL(ce) (((zend_uintptr_t)(ce)) & CTOR_CALL_BIT)
     127             : #define IS_CTOR_USED(ce) (((zend_uintptr_t)(ce)) & CTOR_USED_BIT)
     128             : 
     129             : #define ENCODE_CTOR(ce, used) \
     130             :         ((zend_class_entry*)(((zend_uintptr_t)(ce)) | CTOR_CALL_BIT | ((used) ? CTOR_USED_BIT : 0)))
     131             : #define DECODE_CTOR(ce) \
     132             :         ((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT)))
     133             : 
     134             : #define ZEND_VM_MAIN_STACK_PAGE_SLOTS (16 * 1024) /* should be a power of 2 */
     135             : #define ZEND_VM_GENERATOR_STACK_PAGE_SLOTS (256)
     136             : 
     137             : #define ZEND_VM_STACK_PAGE_SLOTS(gen) ((gen) ? ZEND_VM_GENERATOR_STACK_PAGE_SLOTS : ZEND_VM_MAIN_STACK_PAGE_SLOTS)
     138             : 
     139             : #define ZEND_VM_STACK_PAGE_SIZE(gen)  (ZEND_VM_STACK_PAGE_SLOTS(gen) * sizeof(zval))
     140             : 
     141             : #define ZEND_VM_STACK_FREE_PAGE_SIZE(gen) \
     142             :         ((ZEND_VM_STACK_PAGE_SLOTS(gen) - ZEND_VM_STACK_HEADER_SLOTS) * sizeof(zval))
     143             : 
     144             : #define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(gen, size) \
     145             :         (((size) + (ZEND_VM_STACK_FREE_PAGE_SIZE(gen) - 1)) & ~(ZEND_VM_STACK_PAGE_SIZE(gen) - 1))
     146             : 
     147             : static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
     148       72985 :         zend_vm_stack page = (zend_vm_stack)emalloc(size);
     149             : 
     150       72985 :         page->top = ZEND_VM_STACK_ELEMENTS(page);
     151       72985 :         page->end = (zval*)((char*)page + size);
     152       72985 :         page->prev = prev;
     153       72985 :         return page;
     154             : }
     155             : 
     156       22541 : ZEND_API void zend_vm_stack_init(void)
     157             : {
     158       22541 :         EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE(0 /* main stack */), NULL);
     159       22541 :         EG(vm_stack)->top++;
     160       22541 :         EG(vm_stack_top) = EG(vm_stack)->top;
     161       22541 :         EG(vm_stack_end) = EG(vm_stack)->end;
     162       22541 : }
     163             : 
     164       22579 : ZEND_API void zend_vm_stack_destroy(void)
     165             : {
     166       22579 :         zend_vm_stack stack = EG(vm_stack);
     167             : 
     168       67737 :         while (stack != NULL) {
     169       22579 :                 zend_vm_stack p = stack->prev;
     170       22579 :                 efree(stack);
     171       22579 :                 stack = p;
     172             :         }
     173       22579 : }
     174             : 
     175          14 : ZEND_API void* zend_vm_stack_extend(size_t size)
     176             : {
     177             :         zend_vm_stack stack;
     178             :         void *ptr;
     179             : 
     180          14 :         stack = EG(vm_stack);
     181          14 :         stack->top = EG(vm_stack_top);
     182          34 :         EG(vm_stack) = stack = zend_vm_stack_new_page(
     183          14 :                 EXPECTED(size < ZEND_VM_STACK_FREE_PAGE_SIZE(0)) ?
     184           6 :                         ZEND_VM_STACK_PAGE_SIZE(0) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(0, size),
     185             :                 stack);
     186          14 :         ptr = stack->top;
     187          14 :         EG(vm_stack_top) = (void*)(((char*)ptr) + size);
     188          14 :         EG(vm_stack_end) = stack->end;
     189          14 :         return ptr;
     190             : }
     191             : 
     192           0 : ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
     193             : {
     194           0 :         return EX_VAR(var);
     195             : }
     196             : 
     197             : static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
     198             : {
     199     5053162 :         zval *ret = EX_VAR(var);
     200     5053162 :         *should_free = ret;
     201             : 
     202             :         ZEND_ASSERT(Z_TYPE_P(ret) != IS_REFERENCE);
     203             : 
     204     5053162 :         return ret;
     205             : }
     206             : 
     207             : static zend_always_inline zval *_get_zval_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
     208             : {
     209    48894282 :         zval *ret = EX_VAR(var);
     210             : 
     211    48894282 :         *should_free = ret;
     212    48894282 :         return ret;
     213             : }
     214             : 
     215             : static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
     216             : {
     217     1557359 :         zval *ret = EX_VAR(var);
     218             : 
     219     1557359 :         *should_free = ret;
     220     1557359 :         ZVAL_DEREF(ret);
     221     1557359 :         return ret;
     222             : }
     223             : 
     224         591 : static zend_never_inline ZEND_COLD void zval_undefined_cv(uint32_t var, const zend_execute_data *execute_data)
     225             : {
     226         591 :         zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
     227             : 
     228         591 :         zend_error(E_NOTICE, "Undefined variable: %s", ZSTR_VAL(cv));
     229         591 : }
     230             : 
     231           0 : static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type, const zend_execute_data *execute_data)
     232             : {
     233           0 :         switch (type) {
     234             :                 case BP_VAR_R:
     235             :                 case BP_VAR_UNSET:
     236           0 :                         zval_undefined_cv(var, execute_data);
     237             :                         /* break missing intentionally */
     238             :                 case BP_VAR_IS:
     239           0 :                         ptr = &EG(uninitialized_zval);
     240           0 :                         break;
     241             :                 case BP_VAR_RW:
     242           0 :                         zval_undefined_cv(var, execute_data);
     243             :                         /* break missing intentionally */
     244             :                 case BP_VAR_W:
     245           0 :                         ZVAL_NULL(ptr);
     246             :                         break;
     247             :         }
     248           0 :         return ptr;
     249             : }
     250             : 
     251             : static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
     252             : {
     253         587 :         zval_undefined_cv(var, execute_data);
     254         587 :         return &EG(uninitialized_zval);
     255             : }
     256             : 
     257             : static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
     258             : {
     259           0 :         zval_undefined_cv(var, execute_data);
     260           0 :         return &EG(uninitialized_zval);
     261             : }
     262             : 
     263             : static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
     264             : {
     265           4 :         ZVAL_NULL(ptr);
     266           4 :         zval_undefined_cv(var, execute_data);
     267           4 :         return ptr;
     268             : }
     269             : 
     270             : static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, uint32_t var, const zend_execute_data *execute_data)
     271             : {
     272       62480 :         ZVAL_NULL(ptr);
     273       62480 :         return ptr;
     274             : }
     275             : 
     276             : static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execute_data, uint32_t var, int type)
     277             : {
     278         120 :         zval *ret = EX_VAR(var);
     279             : 
     280         120 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     281           0 :                 return _get_zval_cv_lookup(ret, var, type, execute_data);
     282             :         }
     283         120 :         return ret;
     284             : }
     285             : 
     286             : static zend_always_inline zval *_get_zval_ptr_cv_undef(const zend_execute_data *execute_data, uint32_t var)
     287             : {
     288    52483646 :         return EX_VAR(var);
     289             : }
     290             : 
     291             : static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data *execute_data, uint32_t var, int type)
     292             : {
     293          77 :         zval *ret = EX_VAR(var);
     294             : 
     295          77 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     296           0 :                 return _get_zval_cv_lookup(ret, var, type, execute_data);
     297             :         }
     298          77 :         ZVAL_DEREF(ret);
     299          77 :         return ret;
     300             : }
     301             : 
     302             : static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
     303             : {
     304    25479624 :         zval *ret = EX_VAR(var);
     305             : 
     306    25479624 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     307         222 :                 return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
     308             :         }
     309    25479402 :         return ret;
     310             : }
     311             : 
     312             : static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execute_data *execute_data, uint32_t var)
     313             : {
     314     4127359 :         zval *ret = EX_VAR(var);
     315             : 
     316     4127359 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     317           7 :                 return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data);
     318             :         }
     319     4127352 :         ZVAL_DEREF(ret);
     320     4127352 :         return ret;
     321             : }
     322             : 
     323             : static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
     324             : {
     325       23669 :         zval *ret = EX_VAR(var);
     326             : 
     327       23669 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     328           0 :                 return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
     329             :         }
     330       23669 :         return ret;
     331             : }
     332             : 
     333             : static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_execute_data *execute_data, uint32_t var)
     334             : {
     335             :         zval *ret = EX_VAR(var);
     336             : 
     337             :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     338             :                 return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data);
     339             :         }
     340             :         ZVAL_DEREF(ret);
     341             :         return ret;
     342             : }
     343             : 
     344             : static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
     345             : {
     346      566101 :         zval *ret = EX_VAR(var);
     347             : 
     348      566101 :         return ret;
     349             : }
     350             : 
     351             : static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_execute_data *execute_data, uint32_t var)
     352             : {
     353             :         zval *ret = EX_VAR(var);
     354             : 
     355             :         ZVAL_DEREF(ret);
     356             :         return ret;
     357             : }
     358             : 
     359             : static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
     360             : {
     361     8974908 :         zval *ret = EX_VAR(var);
     362             : 
     363     8974908 :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     364           0 :                 return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
     365             :         }
     366     8974908 :         return ret;
     367             : }
     368             : 
     369             : static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
     370             : {
     371             :         zval *ret = EX_VAR(var);
     372             : 
     373             :         if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
     374             :                 return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data);
     375             :         }
     376             :         ZVAL_DEREF(ret);
     377             :         return ret;
     378             : }
     379             : 
     380             : static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
     381             : {
     382     4233892 :         zval *ret = EX_VAR(var);
     383             : 
     384     4233892 :         if (Z_TYPE_P(ret) == IS_UNDEF) {
     385       62480 :                 return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
     386             :         }
     387     4171412 :         return ret;
     388             : }
     389             : 
     390             : static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
     391             : {
     392    28048613 :         return EX_VAR(var);
     393             : }
     394             : 
     395             : static zend_always_inline zval *_get_zval_ptr_cv_undef_BP_VAR_RW(const zend_execute_data *execute_data, uint32_t var)
     396             : {
     397     7858826 :         return EX_VAR(var);
     398             : }
     399             : 
     400             : static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execute_data *execute_data, uint32_t var)
     401             : {
     402             :         zval *ret = EX_VAR(var);
     403             : 
     404             :         if (Z_TYPE_P(ret) == IS_UNDEF) {
     405             :                 return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data);
     406             :         }
     407             :         ZVAL_DEREF(ret);
     408             :         return ret;
     409             : }
     410             : 
     411             : static 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)
     412             : {
     413         163 :         if (op_type & (IS_TMP_VAR|IS_VAR)) {
     414          37 :                 if (op_type == IS_TMP_VAR) {
     415          46 :                         return _get_zval_ptr_tmp(node.var, execute_data, should_free);
     416             :                 } else {
     417             :                         ZEND_ASSERT(op_type == IS_VAR);
     418          28 :                         return _get_zval_ptr_var(node.var, execute_data, should_free);
     419             :                 }
     420             :         } else {
     421         126 :                 *should_free = NULL;
     422         126 :                 if (op_type == IS_CONST) {
     423           6 :                         return EX_CONSTANT(node);
     424         120 :                 } else if (op_type == IS_CV) {
     425         240 :                         return _get_zval_ptr_cv(execute_data, node.var, type);
     426             :                 } else {
     427           0 :                         return NULL;
     428             :                 }
     429             :         }
     430             : }
     431             : 
     432             : static zend_always_inline zval *_get_zval_ptr_r(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free)
     433             : {
     434     1130479 :         if (op_type & (IS_TMP_VAR|IS_VAR)) {
     435        1106 :                 if (op_type == IS_TMP_VAR) {
     436        2188 :                         return _get_zval_ptr_tmp(node.var, execute_data, should_free);
     437             :                 } else {
     438             :                         ZEND_ASSERT(op_type == IS_VAR);
     439          24 :                         return _get_zval_ptr_var(node.var, execute_data, should_free);
     440             :                 }
     441             :         } else {
     442     1129373 :                 *should_free = NULL;
     443     1129373 :                 if (op_type == IS_CONST) {
     444          55 :                         return EX_CONSTANT(node);
     445     1129318 :                 } else if (op_type == IS_CV) {
     446     2258636 :                         return _get_zval_ptr_cv_BP_VAR_R(execute_data, node.var);
     447             :                 } else {
     448           0 :                         return NULL;
     449             :                 }
     450             :         }
     451             : }
     452             : 
     453             : static 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)
     454             : {
     455        1560 :         if (op_type & (IS_TMP_VAR|IS_VAR)) {
     456          32 :                 if (op_type == IS_TMP_VAR) {
     457          34 :                         return _get_zval_ptr_tmp(node.var, execute_data, should_free);
     458             :                 } else {
     459             :                         ZEND_ASSERT(op_type == IS_VAR);
     460          30 :                         return _get_zval_ptr_var_deref(node.var, execute_data, should_free);
     461             :                 }
     462             :         } else {
     463        1528 :                 *should_free = NULL;
     464        1528 :                 if (op_type == IS_CONST) {
     465        1451 :                         return EX_CONSTANT(node);
     466          77 :                 } else if (op_type == IS_CV) {
     467         154 :                         return _get_zval_ptr_cv_deref(execute_data, node.var, type);
     468             :                 } else {
     469           0 :                         return NULL;
     470             :                 }
     471             :         }
     472             : }
     473             : 
     474             : static zend_always_inline zval *_get_zval_ptr_r_deref(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free)
     475             : {
     476             :         if (op_type & (IS_TMP_VAR|IS_VAR)) {
     477             :                 if (op_type == IS_TMP_VAR) {
     478             :                         return _get_zval_ptr_tmp(node.var, execute_data, should_free);
     479             :                 } else {
     480             :                         ZEND_ASSERT(op_type == IS_VAR);
     481             :                         return _get_zval_ptr_var_deref(node.var, execute_data, should_free);
     482             :                 }
     483             :         } else {
     484             :                 *should_free = NULL;
     485             :                 if (op_type == IS_CONST) {
     486             :                         return EX_CONSTANT(node);
     487             :                 } else if (op_type == IS_CV) {
     488             :                         return _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, node.var);
     489             :                 } else {
     490             :                         return NULL;
     491             :                 }
     492             :         }
     493             : }
     494             : 
     495             : static 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)
     496             : {
     497          65 :         if (op_type & (IS_TMP_VAR|IS_VAR)) {
     498          15 :                 if (op_type == IS_TMP_VAR) {
     499           0 :                         return _get_zval_ptr_tmp(node.var, execute_data, should_free);
     500             :                 } else {
     501             :                         ZEND_ASSERT(op_type == IS_VAR);
     502          30 :                         return _get_zval_ptr_var(node.var, execute_data, should_free);
     503             :                 }
     504             :         } else {
     505          50 :                 *should_free = NULL;
     506          50 :                 if (op_type == IS_CONST) {
     507          33 :                         return EX_CONSTANT(node);
     508          17 :                 } else if (op_type == IS_CV) {
     509          34 :                         return _get_zval_ptr_cv_undef(execute_data, node.var);
     510             :                 } else {
     511           0 :                         return NULL;
     512             :                 }
     513             :         }
     514             : }
     515             : 
     516             : static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_execute_data *execute_data, zend_free_op *should_free)
     517             : {
     518      727546 :         zval *ret = EX_VAR(var);
     519             : 
     520      727546 :         if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) {
     521      727277 :                 *should_free = NULL;
     522      727277 :                 ret = Z_INDIRECT_P(ret);
     523             :         } else {
     524         269 :                 *should_free = ret;
     525             :         }
     526      727546 :         return ret;
     527             : }
     528             : 
     529             : static 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)
     530             : {
     531             :         if (op_type == IS_CV) {
     532             :                 *should_free = NULL;
     533             :                 return _get_zval_ptr_cv(execute_data, node.var, type);
     534             :         } else /* if (op_type == IS_VAR) */ {
     535             :                 ZEND_ASSERT(op_type == IS_VAR);
     536             :                 return _get_zval_ptr_ptr_var(node.var, execute_data, should_free);
     537             :         }
     538             : }
     539             : 
     540             : static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data)
     541             : {       
     542      219579 :         return &EX(This);
     543             : }
     544             : 
     545             : static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type)
     546             : {
     547             :         if (op_type == IS_UNUSED) {
     548             :                 *should_free = NULL;
     549             :                 return &EX(This);
     550             :         }
     551             :         return get_zval_ptr(op_type, op, execute_data, should_free, type);
     552             : }
     553             : 
     554             : static inline zval *_get_obj_zval_ptr_undef(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type)
     555             : {
     556             :         if (op_type == IS_UNUSED) {
     557             :                 *should_free = NULL;
     558             :                 return &EX(This);
     559             :         }
     560             :         return get_zval_ptr_undef(op_type, op, execute_data, should_free, type);
     561             : }
     562             : 
     563             : static 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)
     564             : {
     565             :         if (op_type == IS_UNUSED) {
     566             :                 *should_free = NULL;
     567             :                 return &EX(This);
     568             :         }
     569             :         return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
     570             : }
     571             : 
     572      183139 : static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr)
     573             : {
     574             :         zend_reference *ref;
     575             : 
     576      183139 :         if (EXPECTED(!Z_ISREF_P(value_ptr))) {
     577      142252 :                 ZVAL_NEW_REF(value_ptr, value_ptr);
     578       40887 :         } else if (UNEXPECTED(variable_ptr == value_ptr)) {
     579           1 :                 return;
     580             :         }
     581             : 
     582      183138 :         ref = Z_REF_P(value_ptr);
     583      183138 :         GC_REFCOUNT(ref)++;
     584             :         zval_ptr_dtor(variable_ptr);
     585      183138 :         ZVAL_REF(variable_ptr, ref);
     586             : }
     587             : 
     588             : /* this should modify object only if it's empty */
     589          25 : static inline int make_real_object(zval *object)
     590             : {
     591          25 :         if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
     592          18 :                 if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE)) {
     593             :                         /* nothing to destroy */
     594          11 :                 } else if (EXPECTED((Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
     595             :                         zval_ptr_dtor_nogc(object);
     596             :                 } else {
     597           7 :                         return 0;
     598             :                 }
     599          11 :                 object_init(object);
     600          11 :                 zend_error(E_WARNING, "Creating default object from empty value");
     601             :         }
     602          18 :         return 1;
     603             : }
     604             : 
     605        1269 : static char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce)
     606             : {
     607             :         zend_string *key;
     608             :         ALLOCA_FLAG(use_heap);
     609             : 
     610        2538 :         ZSTR_ALLOCA_INIT(key, cur_arg_info->class_name, strlen(cur_arg_info->class_name), use_heap);
     611        1269 :         *pce = zend_fetch_class(key, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
     612        1269 :         ZSTR_ALLOCA_FREE(key, use_heap);
     613             : 
     614        1269 :         *class_name = (*pce) ? ZSTR_VAL((*pce)->name) : (char*)cur_arg_info->class_name;
     615        1269 :         if (*pce && (*pce)->ce_flags & ZEND_ACC_INTERFACE) {
     616         587 :                 return "implement interface ";
     617             :         } else {
     618         682 :                 return "be an instance of ";
     619             :         }
     620             : }
     621             : 
     622             : static zend_always_inline zend_class_entry* zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info)
     623             : {
     624         114 :         return zend_fetch_class(cur_arg_info->class_name, (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
     625             : }
     626             : 
     627         348 : static ZEND_COLD 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)
     628             : {
     629         348 :         zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
     630         348 :         const char *fname = ZSTR_VAL(zf->common.function_name);
     631             :         const char *fsep;
     632             :         const char *fclass;
     633             : 
     634         348 :         if (zf->common.scope) {
     635          30 :                 fsep =  "::";
     636          30 :                 fclass = ZSTR_VAL(zf->common.scope->name);
     637             :         } else {
     638         318 :                 fsep =  "";
     639         318 :                 fclass = "";
     640             :         }
     641             : 
     642         348 :         if (zf->common.type == ZEND_USER_FUNCTION) {
     643         302 :                 if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
     644         298 :                         zend_type_error("Argument %d passed to %s%s%s() must %s%s, %s%s given, called in %s on line %d",
     645             :                                         arg_num, fclass, fsep, fname, need_msg, need_kind, given_msg, given_kind,
     646         298 :                                         ZSTR_VAL(ptr->func->op_array.filename), ptr->opline->lineno);
     647             :                 } else {
     648           4 :                         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);
     649             :                 }
     650             :         } else {
     651         195 :                 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);
     652             :         }
     653         348 : }
     654             : 
     655           5 : static int is_null_constant(zval *default_value)
     656             : {
     657           5 :         if (Z_CONSTANT_P(default_value)) {
     658             :                 zval constant;
     659             : 
     660           5 :                 ZVAL_COPY_VALUE(&constant, default_value);
     661           5 :                 if (UNEXPECTED(zval_update_constant_ex(&constant, 0, NULL) != SUCCESS)) {
     662           0 :                         return 0;
     663             :                 }
     664           5 :                 if (Z_TYPE(constant) == IS_NULL) {
     665           4 :                         return 1;
     666             :                 }
     667             :                 zval_dtor(&constant);
     668             :         }
     669           1 :         return 0;
     670             : }
     671             : 
     672         132 : static zend_bool zend_verify_weak_scalar_type_hint(zend_uchar type_hint, zval *arg)
     673             : {
     674         132 :         switch (type_hint) {
     675             :                 case _IS_BOOL: {
     676             :                         zend_bool dest;
     677             : 
     678          27 :                         if (!zend_parse_arg_bool_weak(arg, &dest)) {
     679           8 :                                 return 0;
     680             :                         }
     681             :                         zval_ptr_dtor(arg);
     682          19 :                         ZVAL_BOOL(arg, dest);
     683          19 :                         return 1;
     684             :                 }
     685             :                 case IS_LONG: {
     686             :                         zend_long dest;
     687             : 
     688          33 :                         if (!zend_parse_arg_long_weak(arg, &dest)) {
     689          16 :                                 return 0;
     690             :                         }
     691             :                         zval_ptr_dtor(arg);
     692          17 :                         ZVAL_LONG(arg, dest);
     693          17 :                         return 1;
     694             :                 }
     695             :                 case IS_DOUBLE: {
     696             :                         double dest;
     697             : 
     698          30 :                         if (!zend_parse_arg_double_weak(arg, &dest)) {
     699          12 :                                 return 0;
     700             :                         }
     701             :                         zval_ptr_dtor(arg);
     702          18 :                         ZVAL_DOUBLE(arg, dest);
     703          18 :                         return 1;
     704             :                 }
     705             :                 case IS_STRING: {
     706             :                         zend_string *dest;
     707             : 
     708             :                         /* on success "arg" is converted to IS_STRING */
     709          28 :                         if (!zend_parse_arg_str_weak(arg, &dest)) {
     710           6 :                                 return 0;
     711             :                         }
     712          22 :                         return 1;
     713             :                 }
     714             :                 default:
     715          14 :                         return 0;
     716             :         }
     717             : }
     718             : 
     719         234 : static zend_bool zend_verify_scalar_type_hint(zend_uchar type_hint, zval *arg, zend_bool strict)
     720             : {
     721         234 :         if (UNEXPECTED(strict)) {
     722             :                 /* SSTH Exception: IS_LONG may be accepted as IS_DOUBLE (converted) */
     723         111 :                 if (type_hint != IS_DOUBLE || Z_TYPE_P(arg) != IS_LONG) {
     724          85 :                         return 0;
     725             :                 }
     726         145 :         } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
     727             :                 /* NULL may be accepted only by nullable hints (this is already checked) */
     728          17 :                 return 0;
     729             :         }
     730         132 :         return zend_verify_weak_scalar_type_hint(type_hint, arg);
     731             : }
     732             : 
     733        2332 : static int zend_verify_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg)
     734             : {
     735             :         zend_internal_arg_info *cur_arg_info;
     736             :         char *need_msg, *class_name;
     737             :         zend_class_entry *ce;
     738             : 
     739        2332 :         if (EXPECTED(arg_num <= zf->internal_function.num_args)) {
     740        2300 :                 cur_arg_info = &zf->internal_function.arg_info[arg_num-1];
     741          32 :         } else if (zf->internal_function.fn_flags & ZEND_ACC_VARIADIC) {
     742           0 :                 cur_arg_info = &zf->internal_function.arg_info[zf->internal_function.num_args];
     743             :         } else {
     744          32 :                 return 1;
     745             :         }
     746             : 
     747        2300 :         if (cur_arg_info->type_hint) {
     748        1597 :                 ZVAL_DEREF(arg);
     749        3194 :                 if (EXPECTED(cur_arg_info->type_hint == Z_TYPE_P(arg))) {
     750        1456 :                         if (cur_arg_info->class_name) {
     751        1151 :                                 need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
     752        1151 :                                 if (!ce || !instanceof_function(Z_OBJCE_P(arg), ce)) {
     753          70 :                                         zend_verify_arg_error(zf, arg_num, need_msg, class_name, "instance of ", ZSTR_VAL(Z_OBJCE_P(arg)->name), arg);
     754          70 :                                         return 0;
     755             :                                 }
     756             :                         }
     757         141 :                 } else if (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null) {
     758         125 :                         if (cur_arg_info->class_name) {
     759         118 :                                 need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info*)cur_arg_info, &class_name, &ce);
     760         118 :                                 zend_verify_arg_error(zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "", arg);
     761         118 :                                 return 0;
     762           7 :                         } else if (cur_arg_info->type_hint == IS_CALLABLE) {
     763           0 :                                 if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL)) {
     764           0 :                                         zend_verify_arg_error(zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
     765           0 :                                         return 0;
     766             :                                 }
     767           7 :                         } else if (cur_arg_info->type_hint == _IS_BOOL &&
     768             :                                    EXPECTED(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE)) {
     769             :                                 /* pass */
     770           7 :                         } else if (UNEXPECTED(!zend_verify_scalar_type_hint(cur_arg_info->type_hint, arg, ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))))) {
     771           7 :                                 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);
     772           7 :                                 return 0;
     773             :                         }
     774             :                 }
     775             :         }
     776        2105 :         return 1;
     777             : }
     778             : 
     779             : static zend_always_inline int zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value, void **cache_slot)
     780             : {
     781             :         zend_arg_info *cur_arg_info;
     782             :         char *need_msg;
     783             :         zend_class_entry *ce;
     784             : 
     785       88605 :         if (EXPECTED(arg_num <= zf->common.num_args)) {
     786       88595 :                 cur_arg_info = &zf->common.arg_info[arg_num-1];
     787          10 :         } else if (UNEXPECTED(zf->common.fn_flags & ZEND_ACC_VARIADIC)) {
     788          10 :                 cur_arg_info = &zf->common.arg_info[zf->common.num_args];
     789             :         } else {
     790           0 :                 return 1;
     791             :         }
     792             : 
     793       88605 :         if (cur_arg_info->type_hint) {
     794       88373 :                 ZVAL_DEREF(arg);
     795      176746 :                 if (EXPECTED(cur_arg_info->type_hint == Z_TYPE_P(arg))) {
     796       88133 :                         if (cur_arg_info->class_name) {
     797       87925 :                                 if (EXPECTED(*cache_slot)) {
     798       87839 :                                         ce = (zend_class_entry*)*cache_slot;
     799             :                                 } else {
     800          86 :                                         ce = zend_verify_arg_class_kind(cur_arg_info);
     801          86 :                                         if (UNEXPECTED(!ce)) {
     802           4 :                                                 zend_verify_arg_error(zf, arg_num, "be an instance of ", ZSTR_VAL(cur_arg_info->class_name), "instance of ", ZSTR_VAL(Z_OBJCE_P(arg)->name), arg);
     803           4 :                                                 return 0;
     804             :                                         }
     805          82 :                                         *cache_slot = (void*)ce;
     806             :                                 }
     807       87921 :                                 if (UNEXPECTED(!instanceof_function(Z_OBJCE_P(arg), ce))) {
     808          11 :                                         need_msg =
     809          11 :                                                 (ce->ce_flags & ZEND_ACC_INTERFACE) ?
     810             :                                                 "implement interface " : "be an instance of ";
     811          11 :                                         zend_verify_arg_error(zf, arg_num, need_msg, ZSTR_VAL(ce->name), "instance of ", ZSTR_VAL(Z_OBJCE_P(arg)->name), arg);
     812          11 :                                         return 0;
     813             :                                 }
     814             :                         }
     815         240 :                 } else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value)))) {
     816         188 :                         if (cur_arg_info->class_name) {
     817           8 :                                 if (EXPECTED(*cache_slot)) {
     818           1 :                                         ce = (zend_class_entry*)*cache_slot;
     819             :                                 } else {
     820           7 :                                         ce = zend_verify_arg_class_kind(cur_arg_info);
     821           7 :                                         if (UNEXPECTED(!ce)) {
     822           1 :                                                 if (Z_TYPE_P(arg) == IS_OBJECT) {
     823           0 :                                                         zend_verify_arg_error(zf, arg_num, "be an instance of ", ZSTR_VAL(cur_arg_info->class_name), "instance of ", ZSTR_VAL(Z_OBJCE_P(arg)->name), arg);
     824             :                                                 } else {
     825           1 :                                                         zend_verify_arg_error(zf, arg_num, "be an instance of ", ZSTR_VAL(cur_arg_info->class_name), "", zend_zval_type_name(arg), arg);
     826             :                                                 }
     827           1 :                                                 return 0;
     828             :                                         }
     829           6 :                                         *cache_slot = (void*)ce;
     830             :                                 }
     831           7 :                                 need_msg =
     832           7 :                                         (ce->ce_flags & ZEND_ACC_INTERFACE) ?
     833             :                                         "implement interface " : "be an instance of ";
     834           7 :                                 zend_verify_arg_error(zf, arg_num, need_msg, ZSTR_VAL(ce->name), zend_zval_type_name(arg), "", arg);
     835           7 :                                 return 0;
     836         180 :                         } else if (cur_arg_info->type_hint == IS_CALLABLE) {
     837          10 :                                 if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL)) {
     838           1 :                                         zend_verify_arg_error(zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg);
     839           1 :                                         return 0;
     840             :                                 }
     841         256 :                         } else if (cur_arg_info->type_hint == _IS_BOOL &&
     842             :                                    EXPECTED(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE)) {
     843             :                                 /* pass */
     844         162 :                         } else if (UNEXPECTED(!zend_verify_scalar_type_hint(cur_arg_info->type_hint, arg, ZEND_ARG_USES_STRICT_TYPES()))) {
     845         120 :                                 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);
     846         120 :                                 return 0;
     847             :                         }
     848             :                 }
     849             :         }
     850       88461 :         return 1;
     851             : }
     852             : 
     853             : static zend_always_inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num, void **cache_slot)
     854             : {
     855             :         zend_arg_info *cur_arg_info;
     856             :         char *need_msg;
     857             :         zend_class_entry *ce;
     858             : 
     859           9 :         if (EXPECTED(arg_num <= zf->common.num_args)) {
     860           9 :                 cur_arg_info = &zf->common.arg_info[arg_num-1];
     861           0 :         } else if (UNEXPECTED(zf->common.fn_flags & ZEND_ACC_VARIADIC)) {
     862           0 :                 cur_arg_info = &zf->common.arg_info[zf->common.num_args];
     863             :         } else {
     864           0 :                 return 1;
     865             :         }
     866             : 
     867           9 :         if (cur_arg_info->type_hint) {
     868           9 :                 if (cur_arg_info->class_name) {
     869           2 :                         if (EXPECTED(*cache_slot)) {
     870           0 :                                 ce = (zend_class_entry*)*cache_slot;
     871             :                         } else {
     872           2 :                                 ce = zend_verify_arg_class_kind(cur_arg_info);
     873           2 :                                 if (UNEXPECTED(!ce)) {
     874           0 :                                         zend_verify_arg_error(zf, arg_num, "be an instance of ", ZSTR_VAL(cur_arg_info->class_name), "none", "", NULL);
     875           0 :                                         return 0;
     876             :                                 }
     877           2 :                                 *cache_slot = (void*)ce;
     878             :                         }
     879           2 :                         need_msg =
     880           2 :                                 (ce->ce_flags & ZEND_ACC_INTERFACE) ?
     881             :                                 "implement interface " : "be an instance of ";
     882           2 :                         zend_verify_arg_error(zf, arg_num, need_msg, ZSTR_VAL(ce->name), "none", "", NULL);
     883           7 :                 } else if (cur_arg_info->type_hint == IS_CALLABLE) {
     884           1 :                         zend_verify_arg_error(zf, arg_num, "be callable", "", "none", "", NULL);
     885             :                 } else {
     886           6 :                         zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "none", "", NULL);
     887             :                 }
     888           9 :                 return 0;
     889             :         }
     890           0 :         return 1;
     891             : }
     892             : 
     893          75 : static ZEND_COLD void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num, void **cache_slot)
     894             : {
     895          84 :         if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
     896          18 :             UNEXPECTED(zend_verify_missing_arg_type(EX(func), arg_num, cache_slot))) {
     897          66 :                 const char *class_name = EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "";
     898          66 :                 const char *space = EX(func)->common.scope ? "::" : "";
     899          66 :                 const char *func_name = EX(func)->common.function_name ? ZSTR_VAL(EX(func)->common.function_name) : "main";
     900          66 :                 zend_execute_data *ptr = EX(prev_execute_data);
     901             : 
     902          82 :                 if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
     903          16 :                         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, ZSTR_VAL(ptr->func->op_array.filename), ptr->opline->lineno);
     904             :                 } else {
     905          50 :                         zend_error(E_WARNING, "Missing argument %u for %s%s%s()", arg_num, class_name, space, func_name);
     906             :                 }
     907             :         }
     908          75 : }
     909             : 
     910          37 : static ZEND_COLD 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)
     911             : {
     912          37 :         const char *fname = ZSTR_VAL(zf->common.function_name);
     913             :         const char *fsep;
     914             :         const char *fclass;
     915             : 
     916          37 :         if (zf->common.scope) {
     917           2 :                 fsep =  "::";
     918           2 :                 fclass = ZSTR_VAL(zf->common.scope->name);
     919             :         } else {
     920          35 :                 fsep =  "";
     921          35 :                 fclass = "";
     922             :         }
     923             : 
     924          37 :         zend_type_error("Return value of %s%s%s() must %s%s, %s%s returned",
     925             :                 fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
     926          37 : }
     927             : 
     928           0 : static ZEND_COLD 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)
     929             : {
     930           0 :         const char *fname = ZSTR_VAL(zf->common.function_name);
     931             :         const char *fsep;
     932             :         const char *fclass;
     933             : 
     934           0 :         if (zf->common.scope) {
     935           0 :                 fsep =  "::";
     936           0 :                 fclass = ZSTR_VAL(zf->common.scope->name);
     937             :         } else {
     938           0 :                 fsep =  "";
     939           0 :                 fclass = "";
     940             :         }
     941             : 
     942           0 :         zend_error_noreturn(E_CORE_ERROR, "Return value of %s%s%s() must %s%s, %s%s returned",
     943             :                 fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
     944             : }
     945             : 
     946           0 : static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, const char *returned_msg, const char *returned_kind)
     947             : {
     948           0 :         const char *fname = ZSTR_VAL(zf->common.function_name);
     949             :         const char *fsep;
     950             :         const char *fclass;
     951             : 
     952           0 :         if (zf->common.scope) {
     953           0 :                 fsep =  "::";
     954           0 :                 fclass = ZSTR_VAL(zf->common.scope->name);
     955             :         } else {
     956           0 :                 fsep =  "";
     957           0 :                 fclass = "";
     958             :         }
     959             : 
     960           0 :         zend_type_error("%s%s%s() must not return a value, %s%s returned",
     961             :                 fclass, fsep, fname, returned_msg, returned_kind);
     962           0 : }
     963             : 
     964             : #if ZEND_DEBUG
     965             : static int zend_verify_internal_return_type(zend_function *zf, zval *ret)
     966             : {
     967             :         zend_arg_info *ret_info = zf->common.arg_info - 1;
     968             :         char *need_msg, *class_name;
     969             :         zend_class_entry *ce;
     970             : 
     971             : 
     972             :         if (ret_info->type_hint) {
     973             :                 if (EXPECTED(ret_info->type_hint == Z_TYPE_P(ret))) {
     974             :                         if (ret_info->class_name) {
     975             :                                 need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info *)ret_info, &class_name, &ce);
     976             :                                 if (!ce || !instanceof_function(Z_OBJCE_P(ret), ce)) {
     977             :                                         zend_verify_internal_return_error(zf, need_msg, class_name, "instance of ", ZSTR_VAL(Z_OBJCE_P(ret)->name));
     978             :                                         return 0;
     979             :                                 }
     980             :                         }
     981             :                 } else if (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null) {
     982             :                         if (ret_info->class_name) {
     983             :                                 need_msg = zend_verify_internal_arg_class_kind((zend_internal_arg_info *)ret_info, &class_name, &ce);
     984             :                                 zend_verify_internal_return_error(zf, need_msg, class_name, zend_zval_type_name(ret), "");
     985             :                         } else if (ret_info->type_hint == IS_CALLABLE) {
     986             :                                 if (!zend_is_callable(ret, IS_CALLABLE_CHECK_SILENT, NULL) && (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null)) {
     987             :                                         zend_verify_internal_return_error(zf, "be callable", "", zend_zval_type_name(ret), "");
     988             :                                         return 0;
     989             :                                 }
     990             :                         } else if (ret_info->type_hint == _IS_BOOL &&
     991             :                                    EXPECTED(Z_TYPE_P(ret) == IS_FALSE || Z_TYPE_P(ret) == IS_TRUE)) {
     992             :                                 /* pass */
     993             :                         } else if (ret_info->type_hint == IS_VOID) {
     994             :                                 zend_verify_void_return_error(zf, zend_zval_type_name(ret), "");
     995             :                         } else {
     996             :                                 /* Use strict check to verify return value of internal function */
     997             :                                 zend_verify_internal_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), zend_zval_type_name(ret), "");
     998             :                                 return 0;
     999             :                         }
    1000             :                 }
    1001             :         }
    1002             :         return 1;
    1003             : }
    1004             : #endif
    1005             : 
    1006             : static zend_always_inline void zend_verify_return_type(zend_function *zf, zval *ret, void **cache_slot)
    1007             : {
    1008         109 :         zend_arg_info *ret_info = zf->common.arg_info - 1;
    1009             :         char *need_msg;
    1010             :         zend_class_entry *ce;
    1011             : 
    1012         109 :         if (ret_info->type_hint) {
    1013         218 :                 if (EXPECTED(ret_info->type_hint == Z_TYPE_P(ret))) {
    1014          37 :                         if (ret_info->class_name) {
    1015          18 :                                 if (EXPECTED(*cache_slot)) {
    1016           1 :                                         ce = (zend_class_entry*)*cache_slot;
    1017             :                                 } else {
    1018          17 :                                         ce = zend_verify_arg_class_kind(ret_info);
    1019          17 :                                         if (UNEXPECTED(!ce)) {
    1020           0 :                                                 zend_verify_return_error(zf, "be an instance of ", ZSTR_VAL(ret_info->class_name), "instance of ", ZSTR_VAL(Z_OBJCE_P(ret)->name));
    1021             :                                                 return;
    1022             :                                         }
    1023          17 :                                         *cache_slot = (void*)ce;
    1024             :                                 }
    1025          18 :                                 if (UNEXPECTED(!instanceof_function(Z_OBJCE_P(ret), ce))) {
    1026           1 :                                         need_msg =
    1027           1 :                                                 (ce->ce_flags & ZEND_ACC_INTERFACE) ?
    1028             :                                                 "implement interface " : "be an instance of ";
    1029           1 :                                         zend_verify_return_error(zf, need_msg, ZSTR_VAL(ce->name), "instance of ", ZSTR_VAL(Z_OBJCE_P(ret)->name));
    1030             :                                 }
    1031             :                         }
    1032          72 :                 } else if (Z_TYPE_P(ret) != IS_NULL || !ret_info->allow_null) {
    1033          72 :                         if (ret_info->class_name) {
    1034           2 :                                 if (EXPECTED(*cache_slot)) {
    1035           0 :                                         ce = (zend_class_entry*)*cache_slot;
    1036             :                                 } else {
    1037           2 :                                         ce = zend_verify_arg_class_kind(ret_info);
    1038           2 :                                         if (UNEXPECTED(!ce)) {
    1039           0 :                                                 zend_verify_return_error(zf, "be an instance of ", ZSTR_VAL(ret_info->class_name), zend_zval_type_name(ret), "");
    1040             :                                                 return;
    1041             :                                         }
    1042           2 :                                         *cache_slot = (void*)ce;
    1043             :                                 }
    1044           2 :                                 need_msg =
    1045           2 :                                         (ce->ce_flags & ZEND_ACC_INTERFACE) ?
    1046             :                                         "implement interface " : "be an instance of ";
    1047           2 :                                 zend_verify_return_error(zf, need_msg, ZSTR_VAL(ce->name), zend_zval_type_name(ret), "");
    1048          70 :                         } else if (ret_info->type_hint == IS_CALLABLE) {
    1049           3 :                                 if (!zend_is_callable(ret, IS_CALLABLE_CHECK_SILENT, NULL)) {
    1050           0 :                                         zend_verify_return_error(zf, "be callable", "", zend_zval_type_name(ret), "");
    1051             :                                 }
    1052          98 :                         } else if (ret_info->type_hint == _IS_BOOL &&
    1053             :                                    EXPECTED(Z_TYPE_P(ret) == IS_FALSE || Z_TYPE_P(ret) == IS_TRUE)) {
    1054             :                                 /* pass */
    1055             :                         /* There would be a check here for the IS_VOID type hint, which
    1056             :                          * would trigger an error because a value had been returned.
    1057             :                          * However, zend_compile.c already does a compile-time check
    1058             :                          * that bans `return ...;` within a void function. Thus we can skip
    1059             :                          * this part of the runtime check for non-internal functions.
    1060             :                          */
    1061          65 :                         } else if (UNEXPECTED(!zend_verify_scalar_type_hint(ret_info->type_hint, ret, ZEND_RET_USES_STRICT_TYPES()))) {
    1062          31 :                                 zend_verify_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), zend_zval_type_name(ret), "");
    1063             :                         }
    1064             :                 }
    1065             :         }
    1066             : }
    1067             : 
    1068           5 : static ZEND_COLD int zend_verify_missing_return_type(zend_function *zf, void **cache_slot)
    1069             : {
    1070           5 :         zend_arg_info *ret_info = zf->common.arg_info - 1;
    1071             :         char *need_msg;
    1072             :         zend_class_entry *ce;
    1073             : 
    1074           5 :         if (ret_info->type_hint && EXPECTED(ret_info->type_hint != IS_VOID)) {
    1075           3 :                 if (ret_info->class_name) {
    1076           0 :                         if (EXPECTED(*cache_slot)) {
    1077           0 :                                 ce = (zend_class_entry*)*cache_slot;
    1078             :                         } else {
    1079           0 :                                 ce = zend_verify_arg_class_kind(ret_info);
    1080           0 :                                 if (UNEXPECTED(!ce)) {
    1081           0 :                                         zend_verify_return_error(zf, "be an instance of ", ZSTR_VAL(ret_info->class_name), "none", "");
    1082           0 :                                         return 0;
    1083             :                                 }
    1084           0 :                                 *cache_slot = (void*)ce;
    1085             :                         }
    1086           0 :                         need_msg =
    1087           0 :                                 (ce->ce_flags & ZEND_ACC_INTERFACE) ?
    1088             :                                 "implement interface " : "be an instance of ";
    1089           0 :                         zend_verify_return_error(zf, need_msg, ZSTR_VAL(ce->name), "none", "");
    1090           0 :                         return 0;
    1091           3 :                 } else if (ret_info->type_hint == IS_CALLABLE) {
    1092           0 :                         zend_verify_return_error(zf, "be callable", "", "none", "");
    1093             :                 } else {
    1094           3 :                         zend_verify_return_error(zf, "be of the type ", zend_get_type_by_const(ret_info->type_hint), "none", "");
    1095             :                 }
    1096           3 :                 return 0;
    1097             :         }
    1098           2 :         return 1;
    1099             : }
    1100             : 
    1101        1560 : static 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)
    1102             : {
    1103             :         zend_free_op free_value;
    1104        1560 :         zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
    1105             :         zval tmp;
    1106             : 
    1107             :         /* Note:  property_name in this case is really the array index! */
    1108        1560 :         if (!Z_OBJ_HT_P(object)->write_dimension) {
    1109           0 :                 zend_throw_error(NULL, "Cannot use object as array");
    1110           0 :                 FREE_OP(free_value);
    1111           0 :                 return;
    1112             :         }
    1113             : 
    1114             :         /* separate our value if necessary */
    1115        1560 :         if (value_type == IS_CONST) {
    1116        1451 :                 if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
    1117           1 :                         ZVAL_COPY_VALUE(&tmp, value);
    1118           1 :                         zval_copy_ctor_func(&tmp);
    1119           1 :                         value = &tmp;
    1120             :                 }
    1121             :         }
    1122             : 
    1123        1560 :         Z_OBJ_HT_P(object)->write_dimension(object, property_name, value);
    1124             : 
    1125        1559 :         if (retval && EXPECTED(!EG(exception))) {
    1126           5 :                 ZVAL_COPY(retval, value);
    1127             :         }
    1128        1559 :         if (value_type == IS_CONST) {
    1129             :                 zval_ptr_dtor_nogc(value);
    1130             :         } else {
    1131         109 :                 FREE_OP(free_value);
    1132             :         }
    1133             : }
    1134             : 
    1135          13 : static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value, zval *retval, binary_op_type binary_op)
    1136             : {
    1137             :         zval *z;
    1138             :         zval rv, res;
    1139             : 
    1140          39 :         if (Z_OBJ_HT_P(object)->read_dimension &&
    1141          13 :                 (z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) {
    1142             : 
    1143          13 :                 if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
    1144             :                         zval rv2;
    1145           4 :                         zval *value = Z_OBJ_HT_P(z)->get(z, &rv2);
    1146             : 
    1147           4 :                         if (z == &rv) {
    1148             :                                 zval_ptr_dtor(&rv);
    1149             :                         }
    1150           4 :                         ZVAL_COPY_VALUE(z, value);
    1151             :                 }
    1152          13 :                 binary_op(&res, Z_ISREF_P(z) ? Z_REFVAL_P(z) : z, value);
    1153          13 :                 Z_OBJ_HT_P(object)->write_dimension(object, property, &res);
    1154          13 :                 if (z == &rv) {
    1155             :                         zval_ptr_dtor(&rv);
    1156             :                 }
    1157          13 :                 if (retval) {
    1158           1 :                         ZVAL_COPY(retval, &res);
    1159             :                 }
    1160             :                 zval_ptr_dtor(&res);
    1161             :         } else {
    1162           0 :                 zend_error(E_WARNING, "Attempt to assign property of non-object");
    1163           0 :                 if (retval) {
    1164           0 :                         ZVAL_NULL(retval);
    1165             :                 }
    1166             :         }
    1167          13 : }
    1168             : 
    1169         150 : static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result)
    1170             : {
    1171             :         zend_string *old_str;
    1172             :         zend_uchar c;
    1173             :         size_t string_len;
    1174             : 
    1175         150 :         if (offset < 0) {
    1176             :                 /* Error on negative offset */
    1177           1 :                 zend_error(E_WARNING, "Illegal string offset:  " ZEND_LONG_FMT, offset);
    1178           1 :                 zend_string_release(Z_STR_P(str));
    1179           1 :                 if (result) {
    1180           0 :                         ZVAL_NULL(result);
    1181             :                 }
    1182           1 :                 return;
    1183             :         }
    1184             : 
    1185         149 :         if (Z_TYPE_P(value) != IS_STRING) {
    1186             :                 /* Convert to string, just the time to pick the 1st byte */
    1187          11 :                 zend_string *tmp = zval_get_string(value);
    1188             : 
    1189          11 :                 string_len = ZSTR_LEN(tmp);
    1190          11 :                 c = (zend_uchar)ZSTR_VAL(tmp)[0];
    1191             :                 zend_string_release(tmp);
    1192             :         } else {
    1193         138 :                 string_len = Z_STRLEN_P(value);
    1194         138 :                 c = (zend_uchar)Z_STRVAL_P(value)[0];
    1195             :         }
    1196             : 
    1197         149 :         if (string_len == 0) {
    1198             :                 /* Error on empty input string */
    1199           4 :                 zend_error(E_WARNING, "Cannot assign an empty string to a string offset");
    1200           4 :                 zend_string_release(Z_STR_P(str));
    1201           4 :                 if (result) {
    1202           4 :                         ZVAL_NULL(result);
    1203             :                 }
    1204           4 :                 return;
    1205             :         }
    1206             : 
    1207         145 :         old_str = Z_STR_P(str);
    1208         145 :         if ((size_t)offset >= Z_STRLEN_P(str)) {
    1209             :                 /* Extend string if needed */
    1210           3 :                 zend_long old_len = Z_STRLEN_P(str);
    1211           6 :                 Z_STR_P(str) = zend_string_extend(Z_STR_P(str), offset + 1, 0);
    1212           3 :                 Z_TYPE_INFO_P(str) = IS_STRING_EX;
    1213           3 :                 memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);
    1214           3 :                 Z_STRVAL_P(str)[offset+1] = 0;
    1215         142 :         } else if (!Z_REFCOUNTED_P(str)) {
    1216          16 :                 Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
    1217           8 :                 Z_TYPE_INFO_P(str) = IS_STRING_EX;
    1218             :         }
    1219             : 
    1220         145 :         Z_STRVAL_P(str)[offset] = c;
    1221             : 
    1222             :         zend_string_release(old_str);
    1223         145 :         if (result) {
    1224             :                 /* Return the new character */
    1225          12 :                 if (CG(one_char_string)[c]) {
    1226           0 :                         ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
    1227             :                 } else {
    1228          24 :                         ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(str) + offset, 1, 0));
    1229             :                 }
    1230             :         }
    1231             : }
    1232             : 
    1233           9 : static zend_never_inline void zend_post_incdec_overloaded_property(zval *object, zval *property, void **cache_slot, int inc, zval *result)
    1234             : {
    1235          17 :         if (Z_OBJ_HT_P(object)->read_property && Z_OBJ_HT_P(object)->write_property) {
    1236             :                 zval rv, obj;
    1237             :                 zval *z;
    1238             :                 zval z_copy;
    1239             : 
    1240           9 :                 ZVAL_OBJ(&obj, Z_OBJ_P(object));
    1241             :                 Z_ADDREF(obj);
    1242           9 :                 z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv);
    1243           9 :                 if (UNEXPECTED(EG(exception))) {
    1244           1 :                         OBJ_RELEASE(Z_OBJ(obj));
    1245           1 :                         return;
    1246             :                 }
    1247             : 
    1248           8 :                 if (UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && Z_OBJ_HT_P(z)->get) {
    1249             :                         zval rv2;
    1250           0 :                         zval *value = Z_OBJ_HT_P(z)->get(z, &rv2);
    1251           0 :                         if (z == &rv) {
    1252             :                                 zval_ptr_dtor(&rv);
    1253             :                         }
    1254           0 :                         ZVAL_COPY_VALUE(z, value);
    1255             :                 }
    1256             : 
    1257           8 :                 if (UNEXPECTED(Z_TYPE_P(z) == IS_REFERENCE)) {
    1258           1 :                         ZVAL_COPY(result, Z_REFVAL_P(z));
    1259             :                 } else {
    1260           7 :                         ZVAL_COPY(result, z);
    1261             :                 }
    1262           8 :                 ZVAL_DUP(&z_copy, result);
    1263           8 :                 if (inc) {
    1264           8 :                         increment_function(&z_copy);
    1265             :                 } else {
    1266           0 :                         decrement_function(&z_copy);
    1267             :                 }
    1268           8 :                 Z_OBJ_HT(obj)->write_property(&obj, property, &z_copy, cache_slot);
    1269           8 :                 OBJ_RELEASE(Z_OBJ(obj));
    1270             :                 zval_ptr_dtor(&z_copy);
    1271             :                 zval_ptr_dtor(z);
    1272             :         } else {
    1273           0 :                 zend_error(E_WARNING, "Attempt to increment/decrement property of non-object");
    1274           0 :                 ZVAL_NULL(result);
    1275             :         }
    1276             : }
    1277             : 
    1278           5 : static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object, zval *property, void **cache_slot, int inc, zval *result)
    1279             : {
    1280             :         zval rv;
    1281             : 
    1282           8 :         if (Z_OBJ_HT_P(object)->read_property && Z_OBJ_HT_P(object)->write_property) {
    1283             :                 zval *z, obj;
    1284             :                                 
    1285           5 :                 ZVAL_OBJ(&obj, Z_OBJ_P(object));
    1286             :                 Z_ADDREF(obj);
    1287           5 :                 z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv);
    1288           5 :                 if (UNEXPECTED(EG(exception))) {
    1289           2 :                         OBJ_RELEASE(Z_OBJ(obj));
    1290           2 :                         return;
    1291             :                 }
    1292             : 
    1293           3 :                 if (UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && Z_OBJ_HT_P(z)->get) {
    1294             :                         zval rv2;
    1295           0 :                         zval *value = Z_OBJ_HT_P(z)->get(z, &rv2);
    1296             : 
    1297           0 :                         if (z == &rv) {
    1298             :                                 zval_ptr_dtor(&rv);
    1299             :                         }
    1300           0 :                         ZVAL_COPY_VALUE(z, value);
    1301             :                 }
    1302           3 :                 ZVAL_DEREF(z);
    1303           3 :                 SEPARATE_ZVAL_NOREF(z);
    1304           3 :                 if (inc) {
    1305           3 :                         increment_function(z);
    1306             :                 } else {
    1307           0 :                         decrement_function(z);
    1308             :                 }
    1309           3 :                 if (UNEXPECTED(result)) {
    1310           1 :                         ZVAL_COPY(result, z);
    1311             :                 }
    1312           3 :                 Z_OBJ_HT(obj)->write_property(&obj, property, z, cache_slot);
    1313           3 :                 OBJ_RELEASE(Z_OBJ(obj));
    1314             :                 zval_ptr_dtor(z);
    1315             :         } else {
    1316           0 :                 zend_error(E_WARNING, "Attempt to increment/decrement property of non-object");
    1317           0 :                 if (UNEXPECTED(result)) {
    1318           0 :                         ZVAL_NULL(result);
    1319             :                 }
    1320             :         }
    1321             : }
    1322             : 
    1323           9 : static zend_never_inline void zend_assign_op_overloaded_property(zval *object, zval *property, void **cache_slot, zval *value, binary_op_type binary_op, zval *result)
    1324             : {
    1325             :         zval *z;
    1326             :         zval rv, obj;
    1327             :         zval *zptr;
    1328             : 
    1329           9 :         ZVAL_OBJ(&obj, Z_OBJ_P(object));
    1330             :         Z_ADDREF(obj);
    1331           9 :         if (EXPECTED(Z_OBJ_HT(obj)->read_property)) {
    1332           9 :                 z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv);
    1333           9 :                 if (UNEXPECTED(EG(exception))) {
    1334           1 :                         OBJ_RELEASE(Z_OBJ(obj));
    1335           1 :                         return;
    1336             :                 }
    1337           8 :                 if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
    1338             :                         zval rv2;
    1339           3 :                         zval *value = Z_OBJ_HT_P(z)->get(z, &rv2);
    1340             : 
    1341           3 :                         if (z == &rv) {
    1342             :                                 zval_ptr_dtor(&rv);
    1343             :                         }
    1344           3 :                         ZVAL_COPY_VALUE(z, value);
    1345             :                 }
    1346           8 :                 zptr = z;
    1347           8 :                 ZVAL_DEREF(z);
    1348          10 :                 SEPARATE_ZVAL_NOREF(z);
    1349           8 :                 binary_op(z, z, value);
    1350           8 :                 Z_OBJ_HT(obj)->write_property(&obj, property, z, cache_slot);
    1351           8 :                 if (UNEXPECTED(result)) {
    1352           0 :                         ZVAL_COPY(result, z);
    1353             :                 }
    1354             :                 zval_ptr_dtor(zptr);
    1355             :         } else {
    1356           0 :                 zend_error(E_WARNING, "Attempt to assign property of non-object");
    1357           0 :                 if (UNEXPECTED(result)) {
    1358           0 :                         ZVAL_NULL(result);
    1359             :                 }
    1360             :         }
    1361           8 :         OBJ_RELEASE(Z_OBJ(obj));
    1362             : }
    1363             : 
    1364             : /* Utility Functions for Extensions */
    1365           0 : static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array)
    1366             : {
    1367           0 :         if (extension->statement_handler) {
    1368           0 :                 extension->statement_handler(op_array);
    1369             :         }
    1370           0 : }
    1371             : 
    1372             : 
    1373           0 : static void zend_extension_fcall_begin_handler(const zend_extension *extension, zend_op_array *op_array)
    1374             : {
    1375           0 :         if (extension->fcall_begin_handler) {
    1376           0 :                 extension->fcall_begin_handler(op_array);
    1377             :         }
    1378           0 : }
    1379             : 
    1380             : 
    1381           0 : static void zend_extension_fcall_end_handler(const zend_extension *extension, zend_op_array *op_array)
    1382             : {
    1383           0 :         if (extension->fcall_end_handler) {
    1384           0 :                 extension->fcall_end_handler(op_array);
    1385             :         }
    1386           0 : }
    1387             : 
    1388             : 
    1389             : static zend_always_inline HashTable *zend_get_target_symbol_table(zend_execute_data *execute_data, int fetch_type)
    1390             : {
    1391             :         HashTable *ht;
    1392             : 
    1393      212315 :         if (EXPECTED(fetch_type == ZEND_FETCH_GLOBAL_LOCK) ||
    1394      106155 :             EXPECTED(fetch_type == ZEND_FETCH_GLOBAL)) {
    1395       13690 :                 ht = &EG(symbol_table);
    1396             :         } else {
    1397             :                 ZEND_ASSERT(fetch_type == ZEND_FETCH_LOCAL);
    1398       92470 :                 if (!EX(symbol_table)) {
    1399       87394 :                         zend_rebuild_symbol_table();
    1400             :                 }
    1401       92470 :                 ht = EX(symbol_table);
    1402             :         }
    1403      106160 :         return ht;
    1404             : }
    1405             : 
    1406             : static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht, const zval *dim, int dim_type, int type)
    1407             : {
    1408             :         zval *retval;
    1409             :         zend_string *offset_key;
    1410             :         zend_ulong hval;
    1411             : 
    1412             : try_again:
    1413    10019061 :         if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
    1414     4593469 :                 hval = Z_LVAL_P(dim);
    1415             : num_index:
    1416     4773620 :                 retval = zend_hash_index_find(ht, hval);
    1417     4773620 :                 if (retval == NULL) {
    1418      395744 :                         switch (type) {
    1419             :                                 case BP_VAR_R:
    1420          12 :                                         zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval);
    1421             :                                         /* break missing intentionally */
    1422             :                                 case BP_VAR_UNSET:
    1423             :                                 case BP_VAR_IS:
    1424          15 :                                         retval = &EG(uninitialized_zval);
    1425             :                                         break;
    1426             :                                 case BP_VAR_RW:
    1427           6 :                                         zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval);
    1428           6 :                                         retval = zend_hash_index_update(ht, hval, &EG(uninitialized_zval));
    1429             :                                         break;
    1430             :                                 case BP_VAR_W:
    1431      395723 :                                         retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
    1432             :                                         break;
    1433             :                         }
    1434             :                 }
    1435     5425592 :         } else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) {
    1436     4268427 :                 offset_key = Z_STR_P(dim);
    1437     4268427 :                 if (dim_type != IS_CONST) {
    1438     6434854 :                         if (ZEND_HANDLE_NUMERIC(offset_key, hval)) {
    1439             :                                 goto num_index;
    1440             :                         }
    1441             :                 }
    1442             : str_index:
    1443     4088355 :                 retval = zend_hash_find(ht, offset_key);
    1444     4088355 :                 if (retval) {
    1445             :                         /* support for $GLOBALS[...] */
    1446     1994017 :                         if (UNEXPECTED(Z_TYPE_P(retval) == IS_INDIRECT)) {
    1447        7925 :                                 retval = Z_INDIRECT_P(retval);
    1448        7925 :                                 if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
    1449          21 :                                         switch (type) {
    1450             :                                                 case BP_VAR_R:
    1451           1 :                                                         zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key));
    1452             :                                                         /* break missing intentionally */
    1453             :                                                 case BP_VAR_UNSET:
    1454             :                                                 case BP_VAR_IS:
    1455           1 :                                                         retval = &EG(uninitialized_zval);
    1456             :                                                         break;
    1457             :                                                 case BP_VAR_RW:
    1458           0 :                                                         zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(offset_key));
    1459             :                                                         /* break missing intentionally */
    1460             :                                                 case BP_VAR_W:
    1461          20 :                                                         ZVAL_NULL(retval);
    1462             :                                                         break;
    1463             :                                         }
    1464             :                                 }
    1465             :                         }
    1466             :                 } else {
    1467     2094338 :                         switch (type) {
    1468             :                                 case BP_VAR_R:
    1469      173113 :                                         zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key));
    1470             :                                         /* break missing intentionally */
    1471             :                                 case BP_VAR_UNSET:
    1472             :                                 case BP_VAR_IS:
    1473      173113 :                                         retval = &EG(uninitialized_zval);
    1474             :                                         break;
    1475             :                                 case BP_VAR_RW:
    1476           2 :                                         zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(offset_key));
    1477           2 :                                         retval = zend_hash_update(ht, offset_key, &EG(uninitialized_zval));
    1478             :                                         break;
    1479             :                                 case BP_VAR_W:
    1480     1921223 :                                         retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval));
    1481             :                                         break;
    1482             :                         }
    1483             :                 }
    1484             :         } else {
    1485     1157165 :                 switch (Z_TYPE_P(dim)) {
    1486             :                         case IS_NULL:
    1487          12 :                                 offset_key = ZSTR_EMPTY_ALLOC();
    1488             :                                 goto str_index;
    1489             :                         case IS_DOUBLE:
    1490         108 :                                 hval = zend_dval_to_lval(Z_DVAL_P(dim));
    1491             :                                 goto num_index;
    1492             :                         case IS_RESOURCE:
    1493           3 :                                 zend_error(E_NOTICE, "Resource ID#%pd used as offset, casting to integer (%pd)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
    1494           3 :                                 hval = Z_RES_HANDLE_P(dim);
    1495             :                                 goto num_index;
    1496             :                         case IS_FALSE:
    1497           6 :                                 hval = 0;
    1498             :                                 goto num_index;
    1499             :                         case IS_TRUE:
    1500           4 :                                 hval = 1;
    1501             :                                 goto num_index;
    1502             :                         case IS_REFERENCE:
    1503     1157080 :                                 dim = Z_REFVAL_P(dim);
    1504             :                                 goto try_again;
    1505             :                         default:
    1506           6 :                                 zend_error(E_WARNING, "Illegal offset type");
    1507           6 :                                 retval = (type == BP_VAR_W || type == BP_VAR_RW) ?
    1508             :                                         NULL : &EG(uninitialized_zval);
    1509             :                 }
    1510             :         }
    1511     8861981 :         return retval;
    1512             : }
    1513             : 
    1514         161 : static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type)
    1515             : {
    1516             :         zend_long offset;
    1517             : 
    1518             : try_again:
    1519         161 :         if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
    1520          15 :                 switch(Z_TYPE_P(dim)) {
    1521             :                         case IS_STRING:
    1522          30 :                                 if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
    1523           0 :                                         break;
    1524             :                                 }
    1525          15 :                                 if (type != BP_VAR_UNSET) {
    1526          14 :                                         zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
    1527             :                                 }
    1528          15 :                                 break;
    1529             :                         case IS_DOUBLE:
    1530             :                         case IS_NULL:
    1531             :                         case IS_FALSE:
    1532             :                         case IS_TRUE:
    1533           0 :                                 zend_error(E_NOTICE, "String offset cast occurred");
    1534           0 :                                 break;
    1535             :                         case IS_REFERENCE:
    1536           0 :                                 dim = Z_REFVAL_P(dim);
    1537           0 :                                 goto try_again;
    1538             :                         default:
    1539           0 :                                 zend_error(E_WARNING, "Illegal offset type");
    1540             :                                 break;
    1541             :                 }
    1542             : 
    1543          15 :                 offset = zval_get_long(dim);
    1544             :         } else {
    1545         146 :                 offset = Z_LVAL_P(dim);
    1546             :         }
    1547             : 
    1548         161 :         return offset;
    1549             : }
    1550             : 
    1551          11 : static zend_never_inline ZEND_COLD void zend_wrong_string_offset(void)
    1552             : {
    1553          11 :         const char *msg = NULL;
    1554          11 :         const zend_op *opline = EG(current_execute_data)->opline;
    1555             :         const zend_op *end;
    1556             :         uint32_t var;
    1557             : 
    1558          11 :         switch (opline->opcode) {
    1559             :                 case ZEND_ASSIGN_ADD:
    1560             :                 case ZEND_ASSIGN_SUB:
    1561             :                 case ZEND_ASSIGN_MUL:
    1562             :                 case ZEND_ASSIGN_DIV:
    1563             :                 case ZEND_ASSIGN_MOD:
    1564             :                 case ZEND_ASSIGN_SL:
    1565             :                 case ZEND_ASSIGN_SR:
    1566             :                 case ZEND_ASSIGN_CONCAT:
    1567             :                 case ZEND_ASSIGN_BW_OR:
    1568             :                 case ZEND_ASSIGN_BW_AND:
    1569             :                 case ZEND_ASSIGN_BW_XOR:
    1570             :                 case ZEND_ASSIGN_POW:
    1571           0 :                         msg = "Cannot use assign-op operators with string offsets";
    1572           0 :                         break;
    1573             :                 case ZEND_FETCH_DIM_W:
    1574             :                 case ZEND_FETCH_DIM_RW:
    1575             :                 case ZEND_FETCH_DIM_FUNC_ARG:
    1576             :                 case ZEND_FETCH_DIM_UNSET:
    1577             :                         /* TODO: Encode the "reason" into opline->extended_value??? */
    1578          11 :                         var = opline->result.var;
    1579          11 :                         opline++;
    1580          33 :                         end = EG(current_execute_data)->func->op_array.opcodes +
    1581          22 :                                 EG(current_execute_data)->func->op_array.last;
    1582          22 :                         while (opline < end) {
    1583          11 :                                 if (opline->op1_type == IS_VAR && opline->op1.var == var) {
    1584          10 :                                         switch (opline->opcode) {
    1585             :                                                 case ZEND_ASSIGN_ADD:
    1586             :                                                 case ZEND_ASSIGN_SUB:
    1587             :                                                 case ZEND_ASSIGN_MUL:
    1588             :                                                 case ZEND_ASSIGN_DIV:
    1589             :                                                 case ZEND_ASSIGN_MOD:
    1590             :                                                 case ZEND_ASSIGN_SL:
    1591             :                                                 case ZEND_ASSIGN_SR:
    1592             :                                                 case ZEND_ASSIGN_CONCAT:
    1593             :                                                 case ZEND_ASSIGN_BW_OR:
    1594             :                                                 case ZEND_ASSIGN_BW_AND:
    1595             :                                                 case ZEND_ASSIGN_BW_XOR:
    1596             :                                                 case ZEND_ASSIGN_POW:
    1597           2 :                                                         if (opline->extended_value == ZEND_ASSIGN_OBJ) {
    1598           1 :                                                                 msg = "Cannot use string offset as an object";
    1599           1 :                                                         } else if (opline->extended_value == ZEND_ASSIGN_DIM) {
    1600           1 :                                                                 msg = "Cannot use string offset as an array";
    1601             :                                                         } else {
    1602           0 :                                                                 msg = "Cannot use assign-op operators with string offsets";
    1603             :                                                         }
    1604           2 :                                                         break;
    1605             :                                                 case ZEND_PRE_INC_OBJ:
    1606             :                                                 case ZEND_PRE_DEC_OBJ:
    1607             :                                                 case ZEND_POST_INC_OBJ:
    1608             :                                                 case ZEND_POST_DEC_OBJ:
    1609             :                                                 case ZEND_PRE_INC:
    1610             :                                                 case ZEND_PRE_DEC:
    1611             :                                                 case ZEND_POST_INC:
    1612             :                                                 case ZEND_POST_DEC:
    1613           1 :                                                         msg = "Cannot increment/decrement string offsets";
    1614           1 :                                                         break;
    1615             :                                                 case ZEND_FETCH_DIM_W:
    1616             :                                                 case ZEND_FETCH_DIM_RW:
    1617             :                                                 case ZEND_FETCH_DIM_FUNC_ARG:
    1618             :                                                 case ZEND_FETCH_DIM_UNSET:
    1619             :                                                 case ZEND_ASSIGN_DIM:
    1620           2 :                                                         msg = "Cannot use string offset as an array";
    1621           2 :                                                         break;
    1622             :                                                 case ZEND_FETCH_OBJ_W:
    1623             :                                                 case ZEND_FETCH_OBJ_RW:
    1624             :                                                 case ZEND_FETCH_OBJ_FUNC_ARG:
    1625             :                                                 case ZEND_FETCH_OBJ_UNSET:
    1626             :                                                 case ZEND_ASSIGN_OBJ:
    1627           2 :                                                         msg = "Cannot use string offset as an object";
    1628           2 :                                                         break;
    1629             :                                                 case ZEND_ASSIGN_REF:
    1630             :                                                 case ZEND_ADD_ARRAY_ELEMENT:
    1631             :                                                 case ZEND_INIT_ARRAY:
    1632           1 :                                                         msg = "Cannot create references to/from string offsets";
    1633           1 :                                                         break;
    1634             :                                                 case ZEND_RETURN_BY_REF:
    1635           0 :                                                         msg = "Cannot return string offsets by reference";
    1636           0 :                                                         break;
    1637             :                                                 case ZEND_UNSET_DIM:
    1638             :                                                 case ZEND_UNSET_OBJ:
    1639           1 :                                                         msg = "Cannot unset string offsets";
    1640           1 :                                                         break;
    1641             :                                                 case ZEND_YIELD:
    1642           0 :                                                         msg = "Cannot yield string offsets by reference";
    1643           0 :                                                         break;
    1644             :                                                 case ZEND_SEND_REF:
    1645             :                                                 case ZEND_SEND_VAR_EX:
    1646           1 :                                                         msg = "Only variables can be passed by reference";
    1647             :                                                         break;
    1648             :                                                 EMPTY_SWITCH_DEFAULT_CASE();
    1649             :                                         }
    1650          10 :                                         break;
    1651             :                                 }
    1652           1 :                                 if (opline->op2_type == IS_VAR && opline->op2.var == var) {
    1653             :                                         ZEND_ASSERT(opline->opcode == ZEND_ASSIGN_REF);
    1654           1 :                                         msg = "Cannot create references to/from string offsets";
    1655           1 :                                         break;
    1656             :                                 }
    1657             :                         }
    1658             :                         break;
    1659             :                 EMPTY_SWITCH_DEFAULT_CASE();
    1660             :         }
    1661             :         ZEND_ASSERT(msg != NULL);
    1662          11 :         zend_throw_error(NULL, msg);
    1663          11 : }
    1664             : 
    1665             : static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type)
    1666             : {
    1667         150 :         zend_long offset = zend_check_string_offset(dim, type);
    1668             : 
    1669         150 :         if (Z_REFCOUNTED_P(container)) {
    1670         137 :                 if (Z_REFCOUNT_P(container) > 1) {
    1671             :                         Z_DELREF_P(container);
    1672           6 :                         zval_copy_ctor_func(container);
    1673             :                 }
    1674             :                 Z_ADDREF_P(container);
    1675             :         }
    1676         150 :         return offset;
    1677             : }
    1678             : 
    1679             : static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *container, zval *dim, int dim_type, int type)
    1680             : {
    1681             :     zval *retval;
    1682             : 
    1683     1678608 :         if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
    1684             : try_array:
    1685     1678183 :                 SEPARATE_ARRAY(container);
    1686             : fetch_from_array:
    1687     1678532 :                 if (dim == NULL) {
    1688       96556 :                         retval = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
    1689       96556 :                         if (UNEXPECTED(retval == NULL)) {
    1690           0 :                                 zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
    1691           0 :                                 ZVAL_ERROR(result);
    1692             :                                 return;
    1693             :                         }
    1694             :                 } else {
    1695     3163952 :                         retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
    1696     1581976 :                         if (UNEXPECTED(!retval)) {
    1697           0 :                                 ZVAL_ERROR(result);
    1698             :                                 return;
    1699             :                         }
    1700             :                 }
    1701     1678532 :                 ZVAL_INDIRECT(result, retval);
    1702             :                 return;
    1703       25355 :         } else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
    1704       24930 :                 container = Z_REFVAL_P(container);
    1705       24930 :                 if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
    1706             :                         goto try_array;
    1707             :                 }
    1708             :         }
    1709         425 :         if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
    1710          15 :                 if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRLEN_P(container) == 0)) {
    1711             :                         zval_ptr_dtor_nogc(container);
    1712             : convert_to_array:
    1713         349 :                         ZVAL_NEW_ARR(container);
    1714         349 :                         zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
    1715             :                         goto fetch_from_array;
    1716             :                 }
    1717             : 
    1718          13 :                 if (dim == NULL) {
    1719           2 :                         zend_throw_error(NULL, "[] operator not supported for strings");
    1720             :                 } else {
    1721          11 :                         zend_check_string_offset(dim, type);
    1722          11 :                         zend_wrong_string_offset();
    1723             :                 }
    1724          13 :                 ZVAL_ERROR(result);
    1725         410 :         } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
    1726          54 :                 if (!Z_OBJ_HT_P(container)->read_dimension) {
    1727           0 :                         zend_throw_error(NULL, "Cannot use object as array");
    1728           0 :                         ZVAL_ERROR(result);
    1729             :                 } else {
    1730          54 :                         retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
    1731             : 
    1732          54 :                         if (UNEXPECTED(retval == &EG(uninitialized_zval))) {
    1733           2 :                                 zend_class_entry *ce = Z_OBJCE_P(container);
    1734             : 
    1735           2 :                                 ZVAL_NULL(result);
    1736           2 :                                 zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name));
    1737         100 :                         } else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) {
    1738          48 :                                 if (!Z_ISREF_P(retval)) {
    1739          76 :                                         if (Z_REFCOUNTED_P(retval) &&
    1740             :                                             Z_REFCOUNT_P(retval) > 1) {
    1741           7 :                                                 if (Z_TYPE_P(retval) != IS_OBJECT) {
    1742             :                                                         Z_DELREF_P(retval);
    1743           5 :                                                         ZVAL_DUP(result, retval);
    1744           5 :                                                         retval = result;
    1745             :                                                 } else {
    1746           2 :                                                         ZVAL_COPY_VALUE(result, retval);
    1747           2 :                                                         retval = result;
    1748             :                                                 }
    1749             :                                         }
    1750          40 :                                         if (Z_TYPE_P(retval) != IS_OBJECT) {
    1751           9 :                                                 zend_class_entry *ce = Z_OBJCE_P(container);
    1752           9 :                                                 zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name));
    1753             :                                         }
    1754           8 :                                 } else if (UNEXPECTED(Z_REFCOUNT_P(retval) == 1)) {
    1755           6 :                                         ZVAL_UNREF(retval);
    1756             :                                 }
    1757          48 :                                 if (result != retval) {
    1758           5 :                                         ZVAL_INDIRECT(result, retval);
    1759             :                                 }
    1760             :                         } else {
    1761           4 :                                 ZVAL_ERROR(result);
    1762             :                         }
    1763             :                 }
    1764         356 :         } else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
    1765         347 :                 if (type != BP_VAR_UNSET) {
    1766             :                         goto convert_to_array;
    1767             :                 } else {
    1768             :                         /* for read-mode only */
    1769           0 :                         ZVAL_NULL(result);
    1770             :                 }
    1771           9 :         } else if (EXPECTED(Z_ISERROR_P(container))) {
    1772           0 :                 ZVAL_ERROR(result);
    1773             :         } else {
    1774           9 :                 if (type == BP_VAR_UNSET) {
    1775           0 :                         zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
    1776           0 :                         ZVAL_NULL(result);
    1777             :                 } else {
    1778           9 :                         zend_error(E_WARNING, "Cannot use a scalar value as an array");
    1779           9 :                         ZVAL_ERROR(result);
    1780             :                 }
    1781             :         }
    1782             : }
    1783             : 
    1784      352207 : static zend_never_inline void zend_fetch_dimension_address_W(zval *result, zval *container_ptr, zval *dim, int dim_type)
    1785             : {
    1786             :         zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_W);
    1787      352207 : }
    1788             : 
    1789     1326379 : static zend_never_inline void zend_fetch_dimension_address_RW(zval *result, zval *container_ptr, zval *dim, int dim_type)
    1790             : {
    1791             :         zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_RW);
    1792     1326379 : }
    1793             : 
    1794          22 : static zend_never_inline void zend_fetch_dimension_address_UNSET(zval *result, zval *container_ptr, zval *dim, int dim_type)
    1795             : {
    1796             :         zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET);
    1797          22 : }
    1798             : 
    1799             : static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type)
    1800             : {
    1801             :         zval *retval;
    1802             : 
    1803     7128526 :         if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
    1804             : try_array:
    1805     9452894 :                 retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type);
    1806     4726447 :                 ZVAL_COPY(result, retval);
    1807             :                 return;
    1808     3540011 :         } else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
    1809     1137936 :                 container = Z_REFVAL_P(container);
    1810     1137936 :                 if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
    1811             :                         goto try_array;
    1812             :                 }
    1813             :         }
    1814     2402079 :         if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
    1815             :                 zend_long offset;
    1816             : 
    1817             : try_string_offset:
    1818     2401193 :                 if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
    1819          46 :                         switch(Z_TYPE_P(dim)) {
    1820             :                                 /* case IS_LONG: */
    1821             :                                 case IS_STRING:
    1822          60 :                                         if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
    1823             :                                                 break;
    1824             :                                         }
    1825          29 :                                         if (type == BP_VAR_IS) {
    1826           8 :                                                 ZVAL_NULL(result);
    1827             :                                                 return;
    1828             :                                         }
    1829          21 :                                         zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
    1830             :                                         break;
    1831             :                                 case IS_DOUBLE:
    1832             :                                 case IS_NULL:
    1833             :                                 case IS_FALSE:
    1834             :                                 case IS_TRUE:
    1835          13 :                                         if (type != BP_VAR_IS) {
    1836          11 :                                                 zend_error(E_NOTICE, "String offset cast occurred");
    1837             :                                         }
    1838             :                                         break;
    1839             :                                 case IS_REFERENCE:
    1840           0 :                                         dim = Z_REFVAL_P(dim);
    1841             :                                         goto try_string_offset;
    1842             :                                 default:
    1843           3 :                                         zend_error(E_WARNING, "Illegal offset type");
    1844             :                                         break;
    1845             :                         }
    1846             : 
    1847          38 :                         offset = zval_get_long(dim);
    1848             :                 } else {
    1849     2401147 :                         offset = Z_LVAL_P(dim);
    1850             :                 }
    1851             : 
    1852     2401185 :                 if (UNEXPECTED(offset < 0) || UNEXPECTED(Z_STRLEN_P(container) <= (size_t)offset)) {
    1853          35 :                         if (type != BP_VAR_IS) {
    1854          33 :                                 zend_error(E_NOTICE, "Uninitialized string offset: %pd", offset);
    1855          33 :                                 ZVAL_EMPTY_STRING(result);
    1856             :                         } else {
    1857           2 :                                 ZVAL_NULL(result);
    1858             :                         }
    1859             :                 } else {
    1860     2401150 :                         zend_uchar c = (zend_uchar)Z_STRVAL_P(container)[offset];
    1861             : 
    1862     2401150 :                         if (CG(one_char_string)[c]) {
    1863           0 :                                 ZVAL_INTERNED_STR(result, CG(one_char_string)[c]);
    1864             :                         } else {
    1865     4802300 :                                 ZVAL_NEW_STR(result, zend_string_init(Z_STRVAL_P(container) + offset, 1, 0));
    1866             :                         }
    1867             :                 }
    1868         886 :         } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
    1869         771 :                 if (!Z_OBJ_HT_P(container)->read_dimension) {
    1870           0 :                         zend_throw_error(NULL, "Cannot use object as array");
    1871           0 :                         ZVAL_NULL(result);
    1872             :                 } else {
    1873         771 :                         retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result);
    1874             : 
    1875             :                         ZEND_ASSERT(result != NULL);
    1876         771 :                         if (retval) {
    1877         762 :                                 if (result != retval) {
    1878         119 :                                         ZVAL_COPY(result, retval);
    1879             :                                 }
    1880             :                         } else {
    1881           9 :                                 ZVAL_NULL(result);
    1882             :                         }
    1883             :                 }
    1884             :         } else {
    1885         115 :                 ZVAL_NULL(result);
    1886             :         }
    1887             : }
    1888             : 
    1889     7127640 : static zend_never_inline void zend_fetch_dimension_address_read_R(zval *result, zval *container, zval *dim, int dim_type)
    1890             : {
    1891             :         zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_R);
    1892     7127640 : }
    1893             : 
    1894         886 : static zend_never_inline void zend_fetch_dimension_address_read_IS(zval *result, zval *container, zval *dim, int dim_type)
    1895             : {
    1896             :         zend_fetch_dimension_address_read(result, container, dim, dim_type, BP_VAR_IS);
    1897         886 : }
    1898             : 
    1899           9 : ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim)
    1900             : {
    1901           9 :         zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR);
    1902           9 : }
    1903             : 
    1904             : static 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)
    1905             : {
    1906      263444 :     if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
    1907             :                 do {
    1908         105 :                         if (container_op_type == IS_VAR && UNEXPECTED(Z_ISERROR_P(container))) {
    1909           1 :                                 ZVAL_ERROR(result);
    1910             :                                 return;
    1911             :                         }
    1912             : 
    1913          84 :                         if (Z_ISREF_P(container)) {
    1914          41 :                                 container = Z_REFVAL_P(container);
    1915          41 :                                 if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
    1916             :                                         break;
    1917             :                                 }
    1918             :                         }
    1919             : 
    1920             :                         /* this should modify object only if it's empty */
    1921          95 :                         if (type != BP_VAR_UNSET &&
    1922           3 :                             EXPECTED(Z_TYPE_P(container) <= IS_FALSE ||
    1923             :                               (Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0))) {
    1924             :                                 zval_ptr_dtor_nogc(container);
    1925          37 :                                 object_init(container);
    1926             :                         } else {
    1927           6 :                                 zend_error(E_WARNING, "Attempt to modify property of non-object");
    1928           6 :                                 ZVAL_ERROR(result);
    1929             :                                 return;
    1930             :                         }
    1931             :                 } while (0);
    1932             :         }
    1933      351108 :         if (prop_op_type == IS_CONST &&
    1934      175545 :             EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) {
    1935      175115 :                 uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR_EX(cache_slot + 1);
    1936      175115 :                 zend_object *zobj = Z_OBJ_P(container);
    1937             :                 zval *retval;
    1938             : 
    1939      175115 :                 if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
    1940      174906 :                         retval = OBJ_PROP(zobj, prop_offset);
    1941      174906 :                         if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) {
    1942      174906 :                                 ZVAL_INDIRECT(result, retval);
    1943             :                                 return;
    1944             :                         }
    1945         209 :                 } else if (EXPECTED(zobj->properties != NULL)) {
    1946         203 :                         if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) {
    1947           2 :                                 if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) {
    1948           2 :                                         GC_REFCOUNT(zobj->properties)--;
    1949             :                                 }
    1950           2 :                                 zobj->properties = zend_array_dup(zobj->properties);
    1951             :                         }
    1952         203 :                         retval = zend_hash_find(zobj->properties, Z_STR_P(prop_ptr));
    1953         203 :                         if (EXPECTED(retval)) {
    1954           4 :                                 ZVAL_INDIRECT(result, retval);
    1955             :                                 return;
    1956             :                         }
    1957             :                 }
    1958             :         }
    1959         653 :         if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) {
    1960         653 :                 zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot);
    1961         653 :                 if (NULL == ptr) {
    1962          59 :                         if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
    1963          59 :                                 ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
    1964          59 :                                 if (ptr != result) {
    1965           2 :                                         ZVAL_INDIRECT(result, ptr);
    1966          64 :                                 } else if (UNEXPECTED(Z_ISREF_P(ptr) && Z_REFCOUNT_P(ptr) == 1)) {
    1967           1 :                                         ZVAL_UNREF(ptr);
    1968             :                                 }
    1969             :                         } else {
    1970           0 :                                 zend_throw_error(NULL, "Cannot access undefined property for object with overloaded property access");
    1971           0 :                                 ZVAL_ERROR(result);
    1972             :                         }
    1973             :                 } else {
    1974         594 :                         ZVAL_INDIRECT(result, ptr);
    1975             :                 }
    1976           0 :         } else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
    1977           0 :                 zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
    1978           0 :                 if (ptr != result) {
    1979           0 :                         ZVAL_INDIRECT(result, ptr);
    1980           0 :                 } else if (UNEXPECTED(Z_ISREF_P(ptr) && Z_REFCOUNT_P(ptr) == 1)) {
    1981           0 :                         ZVAL_UNREF(ptr);
    1982             :                 }
    1983             :         } else {
    1984           0 :                 zend_error(E_WARNING, "This object doesn't support property references");
    1985           0 :                 ZVAL_ERROR(result);
    1986             :         }
    1987             : }
    1988             : 
    1989             : #if ZEND_INTENSIVE_DEBUGGING
    1990             : 
    1991             : #define CHECK_SYMBOL_TABLES()                                                                                                   \
    1992             :         zend_hash_apply(&EG(symbol_table), zend_check_symbol);                      \
    1993             :         if (&EG(symbol_table)!=EX(symbol_table)) {                                                  \
    1994             :                 zend_hash_apply(EX(symbol_table), zend_check_symbol);   \
    1995             :         }
    1996             : 
    1997             : static int zend_check_symbol(zval *pz)
    1998             : {
    1999             :         if (Z_TYPE_P(pz) == IS_INDIRECT) {
    2000             :                 pz = Z_INDIRECT_P(pz);
    2001             :         }
    2002             :         if (Z_TYPE_P(pz) > 10) {
    2003             :                 fprintf(stderr, "Warning!  %x has invalid type!\n", *pz);
    2004             : /* See http://support.microsoft.com/kb/190351 */
    2005             : #ifdef ZEND_WIN32
    2006             :                 fflush(stderr);
    2007             : #endif
    2008             :         } else if (Z_TYPE_P(pz) == IS_ARRAY) {
    2009             :                 zend_hash_apply(Z_ARRVAL_P(pz), zend_check_symbol);
    2010             :         } else if (Z_TYPE_P(pz) == IS_OBJECT) {
    2011             :                 /* OBJ-TBI - doesn't support new object model! */
    2012             :                 zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol);
    2013             :         }
    2014             : 
    2015             :         return 0;
    2016             : }
    2017             : 
    2018             : 
    2019             : #else
    2020             : #define CHECK_SYMBOL_TABLES()
    2021             : #endif
    2022             : 
    2023           0 : ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value)
    2024             : {
    2025           0 :         execute_data->func->internal_function.handler(execute_data, return_value);
    2026           0 : }
    2027             : 
    2028       87798 : ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
    2029             : {
    2030       87798 :         if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
    2031           0 :                 zend_array_destroy(symbol_table);
    2032             :         } else {
    2033             :                 /* clean before putting into the cache, since clean
    2034             :                    could call dtors, which could use cached hash */
    2035       87798 :                 zend_symtable_clean(symbol_table);
    2036       87798 :                 *(++EG(symtable_cache_ptr)) = symbol_table;
    2037             :         }
    2038       87798 : }
    2039             : /* }}} */
    2040             : 
    2041             : static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
    2042             : {
    2043     1842661 :         zval *cv = EX_VAR_NUM(0);
    2044     1842661 :         zval *end = cv + EX(func)->op_array.last_var;
    2045    10254041 :         while (EXPECTED(cv != end)) {
    2046     8411380 :                 if (Z_REFCOUNTED_P(cv)) {
    2047     4230502 :                         if (!Z_DELREF_P(cv)) {
    2048      808153 :                                 zend_refcounted *r = Z_COUNTED_P(cv);
    2049      808153 :                                 ZVAL_NULL(cv);
    2050      808153 :                                 zval_dtor_func_for_ptr(r);
    2051             :                         } else {
    2052             :                                 GC_ZVAL_CHECK_POSSIBLE_ROOT(cv);
    2053             :                         }
    2054             :                 }
    2055     8411380 :                 cv++;
    2056             :         }
    2057             : }
    2058             : /* }}} */
    2059             : 
    2060       50430 : void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
    2061             : {
    2062             :         i_free_compiled_variables(execute_data);
    2063       50430 : }
    2064             : /* }}} */
    2065             : 
    2066             : #ifdef ZEND_WIN32
    2067             : # define ZEND_VM_INTERRUPT_CHECK() do { \
    2068             :                 if (EG(timed_out)) { \
    2069             :                         zend_timeout(0); \
    2070             :                 } \
    2071             :         } while (0)
    2072             : #else
    2073             : # define ZEND_VM_INTERRUPT_CHECK() do { \
    2074             :         } while (0)
    2075             : #endif
    2076             : 
    2077             : /*
    2078             :  * Stack Frame Layout (the whole stack frame is allocated at once)
    2079             :  * ==================
    2080             :  *
    2081             :  *                             +========================================+
    2082             :  * EG(current_execute_data) -> | zend_execute_data                      |
    2083             :  *                             +----------------------------------------+
    2084             :  *     EX_CV_NUM(0) ---------> | VAR[0] = ARG[1]                        |
    2085             :  *                             | ...                                    |
    2086             :  *                             | VAR[op_array->num_args-1] = ARG[N]     |
    2087             :  *                             | ...                                    |
    2088             :  *                             | VAR[op_array->last_var-1]              |
    2089             :  *                             | VAR[op_array->last_var] = TMP[0]       |
    2090             :  *                             | ...                                    |
    2091             :  *                             | VAR[op_array->last_var+op_array->T-1]  |
    2092             :  *                             | ARG[N+1] (extra_args)                  |
    2093             :  *                             | ...                                    |
    2094             :  *                             +----------------------------------------+
    2095             :  */
    2096             : 
    2097             : static 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) /* {{{ */
    2098             : {
    2099             :         uint32_t first_extra_arg, num_args;
    2100             :         ZEND_ASSERT(EX(func) == (zend_function*)op_array);
    2101             : 
    2102     1386937 :         EX(opline) = op_array->opcodes;
    2103     1386937 :         EX(call) = NULL;
    2104     1386937 :         EX(return_value) = return_value;
    2105             : 
    2106             :         /* Handle arguments */
    2107     1386937 :         first_extra_arg = op_array->num_args;
    2108     1386937 :         num_args = EX_NUM_ARGS();
    2109     1386937 :         if (UNEXPECTED(num_args > first_extra_arg)) {
    2110         479 :                 if (EXPECTED(!(op_array->fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))) {
    2111             :                         zval *end, *src, *dst;
    2112         145 :                         uint32_t type_flags = 0;
    2113             : 
    2114         145 :                         if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
    2115             :                                 /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
    2116         141 :                                 EX(opline) += first_extra_arg;
    2117             :                         }
    2118             : 
    2119             :                         /* move extra args into separate array after all CV and TMP vars */
    2120         145 :                         end = EX_VAR_NUM(first_extra_arg - 1);
    2121         145 :                         src = end + (num_args - first_extra_arg);
    2122         145 :                         dst = src + (op_array->last_var + op_array->T - first_extra_arg);
    2123         145 :                         if (EXPECTED(src != dst)) {
    2124             :                                 do {
    2125       21243 :                                         type_flags |= Z_TYPE_INFO_P(src);
    2126       21243 :                                         ZVAL_COPY_VALUE(dst, src);
    2127       21243 :                                         ZVAL_UNDEF(src);
    2128       21243 :                                         src--;
    2129       21243 :                                         dst--;
    2130       21243 :                                 } while (src != end);
    2131             :                         } else {
    2132             :                                 do {
    2133         326 :                                         type_flags |= Z_TYPE_INFO_P(src);
    2134         326 :                                         src--;
    2135         326 :                                 } while (src != end);
    2136             :                         }
    2137         145 :                         ZEND_ADD_CALL_FLAG(execute_data, ((type_flags >> Z_TYPE_FLAGS_SHIFT) & IS_TYPE_REFCOUNTED));
    2138             :                 }
    2139     1386458 :         } else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
    2140             :                 /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
    2141     1298189 :                 EX(opline) += num_args;
    2142             :         }
    2143             : 
    2144             :         /* Initialize CV variables (skip arguments) */
    2145     1386937 :         if (EXPECTED((int)num_args < op_array->last_var)) {
    2146      727935 :                 zval *var = EX_VAR_NUM(num_args);
    2147      727935 :                 zval *end = EX_VAR_NUM(op_array->last_var);
    2148             : 
    2149             :                 do {
    2150     4071237 :                         ZVAL_UNDEF(var);
    2151     4071237 :                         var++;
    2152     4071237 :                 } while (var != end);
    2153             :         }
    2154             : 
    2155     1386937 :         if (check_this && op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
    2156       97822 :                 ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
    2157       97822 :                 GC_REFCOUNT(Z_OBJ(EX(This)))++;
    2158             :         }
    2159             : 
    2160     1386937 :         if (UNEXPECTED(!op_array->run_time_cache)) {
    2161       18438 :                 op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
    2162        9219 :                 memset(op_array->run_time_cache, 0, op_array->cache_size);
    2163             :         }
    2164     1386937 :         EX_LOAD_RUN_TIME_CACHE(op_array);
    2165     1386937 :         EX_LOAD_LITERALS(op_array);
    2166             : 
    2167     1386937 :         EG(current_execute_data) = execute_data;
    2168             :         ZEND_VM_INTERRUPT_CHECK();
    2169             : }
    2170             : /* }}} */
    2171             : 
    2172             : static zend_always_inline void i_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
    2173             : {
    2174             :         ZEND_ASSERT(EX(func) == (zend_function*)op_array);
    2175             : 
    2176       10575 :         EX(opline) = op_array->opcodes;
    2177       10575 :         EX(call) = NULL;
    2178       10575 :         EX(return_value) = return_value;
    2179             : 
    2180       10575 :         if (UNEXPECTED(op_array->this_var != (uint32_t)-1) && EXPECTED(Z_OBJ(EX(This)))) {
    2181           3 :                 GC_REFCOUNT(Z_OBJ(EX(This)))++;
    2182           3 :                 if (!zend_hash_str_add(EX(symbol_table), "this", sizeof("this")-1, &EX(This))) {
    2183           1 :                         GC_REFCOUNT(Z_OBJ(EX(This)))--;
    2184             :                 }
    2185             :         }
    2186             : 
    2187       10575 :         zend_attach_symbol_table(execute_data);
    2188             : 
    2189       10575 :         if (!op_array->run_time_cache) {
    2190       10575 :                 op_array->run_time_cache = emalloc(op_array->cache_size);
    2191       10575 :                 memset(op_array->run_time_cache, 0, op_array->cache_size);
    2192             :         }
    2193       10575 :         EX_LOAD_RUN_TIME_CACHE(op_array);
    2194       10575 :         EX_LOAD_LITERALS(op_array);
    2195             : 
    2196       10575 :         EG(current_execute_data) = execute_data;
    2197             :         ZEND_VM_INTERRUPT_CHECK();
    2198             : }
    2199             : /* }}} */
    2200             : 
    2201             : static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
    2202             : {
    2203             :         ZEND_ASSERT(EX(func) == (zend_function*)op_array);
    2204             : 
    2205      481682 :         EX(opline) = op_array->opcodes;
    2206      481682 :         EX(call) = NULL;
    2207      481682 :         EX(return_value) = return_value;
    2208             : 
    2209      481682 :         if (UNEXPECTED(EX(symbol_table) != NULL)) {
    2210       22365 :                 if (UNEXPECTED(op_array->this_var != (uint32_t)-1) && EXPECTED(Z_OBJ(EX(This)))) {
    2211           0 :                         GC_REFCOUNT(Z_OBJ(EX(This)))++;
    2212           0 :                         if (!zend_hash_str_add(EX(symbol_table), "this", sizeof("this")-1, &EX(This))) {
    2213           0 :                                 GC_REFCOUNT(Z_OBJ(EX(This)))--;
    2214             :                         }
    2215             :                 }
    2216             : 
    2217       22365 :                 zend_attach_symbol_table(execute_data);
    2218             :         } else {
    2219             :                 uint32_t first_extra_arg, num_args;
    2220             : 
    2221             :                 /* Handle arguments */
    2222      459317 :                 first_extra_arg = op_array->num_args;
    2223      459317 :                 num_args = EX_NUM_ARGS();
    2224      459317 :                 if (UNEXPECTED(num_args > first_extra_arg)) {
    2225         805 :                         if (EXPECTED(!(op_array->fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))) {
    2226             :                                 zval *end, *src, *dst;
    2227         803 :                                 uint32_t type_flags = 0;
    2228             : 
    2229         803 :                                 if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
    2230             :                                         /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
    2231         797 :                                         EX(opline) += first_extra_arg;
    2232             :                                 }
    2233             : 
    2234             :                                 /* move extra args into separate array after all CV and TMP vars */
    2235         803 :                                 end = EX_VAR_NUM(first_extra_arg - 1);
    2236         803 :                                 src = end + (num_args - first_extra_arg);
    2237         803 :                                 dst = src + (op_array->last_var + op_array->T - first_extra_arg);
    2238         803 :                                 if (EXPECTED(src != dst)) {
    2239             :                                         do {
    2240         827 :                                                 type_flags |= Z_TYPE_INFO_P(src);
    2241         827 :                                                 ZVAL_COPY_VALUE(dst, src);
    2242         827 :                                                 ZVAL_UNDEF(src);
    2243         827 :                                                 src--;
    2244         827 :                                                 dst--;
    2245         827 :                                         } while (src != end);
    2246             :                                 } else {
    2247             :                                         do {
    2248         752 :                                                 type_flags |= Z_TYPE_INFO_P(src);
    2249         752 :                                                 src--;
    2250         752 :                                         } while (src != end);
    2251             :                                 }
    2252         803 :                                 ZEND_ADD_CALL_FLAG(execute_data, ((type_flags >> Z_TYPE_FLAGS_SHIFT) & IS_TYPE_REFCOUNTED));
    2253             :                         }
    2254      458512 :                 } else if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
    2255             :                         /* Skip useless ZEND_RECV and ZEND_RECV_INIT opcodes */
    2256      458498 :                         EX(opline) += num_args;
    2257             :                 }
    2258             : 
    2259             :                 /* Initialize CV variables (skip arguments) */
    2260      459317 :                 if (EXPECTED((int)num_args < op_array->last_var)) {
    2261      216013 :                         zval *var = EX_VAR_NUM(num_args);
    2262      216013 :                         zval *end = EX_VAR_NUM(op_array->last_var);
    2263             : 
    2264             :                         do {
    2265      632471 :                                 ZVAL_UNDEF(var);
    2266      632471 :                                 var++;
    2267      632471 :                         } while (var != end);
    2268             :                 }
    2269             : 
    2270      459317 :                 if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
    2271       10347 :                         ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
    2272       10347 :                         GC_REFCOUNT(Z_OBJ(EX(This)))++;
    2273             :                 }
    2274             :         }
    2275             : 
    2276      481682 :         if (!op_array->run_time_cache) {
    2277       25282 :                 if (op_array->function_name) {
    2278        5834 :                         op_array->run_time_cache = zend_arena_alloc(&CG(arena), op_array->cache_size);
    2279             :                 } else {
    2280       22365 :                         op_array->run_time_cache = emalloc(op_array->cache_size);
    2281             :                 }
    2282       25282 :                 memset(op_array->run_time_cache, 0, op_array->cache_size);
    2283             :         }
    2284      481682 :         EX_LOAD_RUN_TIME_CACHE(op_array);
    2285      481682 :         EX_LOAD_LITERALS(op_array);
    2286             : 
    2287      481682 :         EG(current_execute_data) = execute_data;
    2288             :         ZEND_VM_INTERRUPT_CHECK();
    2289             : }
    2290             : /* }}} */
    2291             : 
    2292       50430 : ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value) /* {{{ */
    2293             : {
    2294             :         /*
    2295             :          * Normally the execute_data is allocated on the VM stack (because it does
    2296             :          * not actually do any allocation and thus is faster). For generators
    2297             :          * though this behavior would be suboptimal, because the (rather large)
    2298             :          * structure would have to be copied back and forth every time execution is
    2299             :          * suspended or resumed. That's why for generators the execution context
    2300             :          * is allocated using a separate VM stack, thus allowing to save and
    2301             :          * restore it simply by replacing a pointer.
    2302             :          */
    2303             :         zend_execute_data *execute_data;
    2304       50430 :         uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
    2305       50430 :         size_t stack_size = (ZEND_CALL_FRAME_SLOT + MAX(op_array->last_var + op_array->T, num_args)) * sizeof(zval);
    2306             :         uint32_t call_info;
    2307             : 
    2308      100861 :         EG(vm_stack) = zend_vm_stack_new_page(
    2309       50430 :                 EXPECTED(stack_size < ZEND_VM_STACK_FREE_PAGE_SIZE(1)) ?
    2310             :                         ZEND_VM_STACK_PAGE_SIZE(1) :
    2311           1 :                         ZEND_VM_STACK_PAGE_ALIGNED_SIZE(1, stack_size),
    2312             :                 NULL);
    2313       50430 :         EG(vm_stack_top) = EG(vm_stack)->top;
    2314       50430 :         EG(vm_stack_end) = EG(vm_stack)->end;
    2315             : 
    2316       50430 :         call_info = ZEND_CALL_TOP_FUNCTION | ZEND_CALL_ALLOCATED | (ZEND_CALL_INFO(call) & (ZEND_CALL_CLOSURE|ZEND_CALL_RELEASE_THIS));
    2317       50430 :         if (Z_OBJ(call->This)) {
    2318           7 :                 call_info |= ZEND_CALL_RELEASE_THIS;
    2319             :         }
    2320      100860 :         execute_data = zend_vm_stack_push_call_frame(
    2321             :                 call_info,
    2322             :                 (zend_function*)op_array,
    2323             :                 num_args,
    2324             :                 call->called_scope,
    2325             :                 Z_OBJ(call->This));
    2326       50430 :         EX(prev_execute_data) = NULL;
    2327       50430 :         EX_NUM_ARGS() = num_args;
    2328             : 
    2329             :         /* copy arguments */
    2330       50430 :         if (num_args > 0) {
    2331       50288 :                 zval *arg_src = ZEND_CALL_ARG(call, 1);
    2332       50288 :                 zval *arg_dst = ZEND_CALL_ARG(execute_data, 1);
    2333       50288 :                 zval *end = arg_src + num_args;
    2334             : 
    2335             :                 do {
    2336       50603 :                         ZVAL_COPY_VALUE(arg_dst, arg_src);
    2337       50603 :                         arg_src++;
    2338       50603 :                         arg_dst++;
    2339       50603 :                 } while (arg_src != end);
    2340             :         }
    2341             : 
    2342       50430 :         EX(symbol_table) = NULL;
    2343             : 
    2344             :         i_init_func_execute_data(execute_data, op_array, return_value, 1);
    2345             : 
    2346       50430 :         return execute_data;
    2347             : }
    2348             : /* }}} */
    2349             : 
    2350      459317 : ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */
    2351             : {
    2352      459317 :         EX(prev_execute_data) = EG(current_execute_data);
    2353             :         i_init_execute_data(execute_data, op_array, return_value);
    2354      459317 : }
    2355             : /* }}} */
    2356             : 
    2357             : static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(const zend_op *opline, zend_execute_data *call) /* {{{ */
    2358             : {
    2359     2353110 :         uint32_t arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
    2360     4706220 :         return ARG_SHOULD_BE_SENT_BY_REF(call->func, arg_num);
    2361             : }
    2362             : /* }}} */
    2363             : 
    2364           4 : static zend_execute_data *zend_vm_stack_copy_call_frame(zend_execute_data *call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
    2365             : {
    2366             :         zend_execute_data *new_call;
    2367           4 :         int used_stack = (EG(vm_stack_top) - (zval*)call) + additional_args;
    2368             : 
    2369             :         /* copy call frame into new stack segment */
    2370           4 :         new_call = zend_vm_stack_extend(used_stack * sizeof(zval));
    2371           4 :         *new_call = *call;
    2372           4 :         ZEND_SET_CALL_INFO(new_call, ZEND_CALL_INFO(new_call) | ZEND_CALL_ALLOCATED);
    2373             : 
    2374           4 :         if (passed_args) {
    2375           1 :                 zval *src = ZEND_CALL_ARG(call, 1);
    2376           1 :                 zval *dst = ZEND_CALL_ARG(new_call, 1);
    2377             :                 do {
    2378       10000 :                         ZVAL_COPY_VALUE(dst, src);
    2379       10000 :                         passed_args--;
    2380       10000 :                         src++;
    2381       10000 :                         dst++;
    2382       10000 :                 } while (passed_args);
    2383             :         }
    2384             : 
    2385             :         /* delete old call_frame from previous stack segment */
    2386           4 :         EG(vm_stack)->prev->top = (zval*)call;
    2387             : 
    2388             :         /* delete previous stack segment if it becames empty */
    2389           4 :         if (UNEXPECTED(EG(vm_stack)->prev->top == ZEND_VM_STACK_ELEMENTS(EG(vm_stack)->prev))) {
    2390           0 :                 zend_vm_stack r = EG(vm_stack)->prev;
    2391             : 
    2392           0 :                 EG(vm_stack)->prev = r->prev;
    2393           0 :                 efree(r);
    2394             :         }
    2395             : 
    2396           4 :         return new_call;
    2397             : }
    2398             : /* }}} */
    2399             : 
    2400             : static zend_always_inline void zend_vm_stack_extend_call_frame(zend_execute_data **call, uint32_t passed_args, uint32_t additional_args) /* {{{ */
    2401             : {
    2402         208 :         if (EXPECTED((uint32_t)(EG(vm_stack_end) - EG(vm_stack_top)) > additional_args)) {
    2403         204 :                 EG(vm_stack_top) += additional_args;
    2404             :         } else {
    2405           4 :                 *call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args);
    2406             :         }
    2407             : }
    2408             : /* }}} */
    2409             : 
    2410             : static zend_always_inline zend_generator *zend_get_running_generator(zend_execute_data *execute_data) /* {{{ */
    2411             : {
    2412             :         /* The generator object is stored in EX(return_value) */
    2413     2451009 :         zend_generator *generator = (zend_generator *) EX(return_value);
    2414             :         /* However control may currently be delegated to another generator.
    2415             :          * That's the one we're interested in. */
    2416     2451009 :         return generator;
    2417             : }
    2418             : /* }}} */
    2419             : 
    2420        3587 : static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t op_num) /* {{{ */
    2421             : {
    2422        3587 :         if (UNEXPECTED(EX(call))) {
    2423        1028 :                 zend_execute_data *call = EX(call);
    2424        1028 :                 zend_op *opline = EX(func)->op_array.opcodes + op_num;
    2425             :                 int level;
    2426             :                 int do_exit;
    2427             :                 
    2428        1028 :                 if (UNEXPECTED(opline->opcode == ZEND_INIT_FCALL ||
    2429             :                         opline->opcode == ZEND_INIT_FCALL_BY_NAME ||
    2430             :                         opline->opcode == ZEND_INIT_DYNAMIC_CALL ||
    2431             :                         opline->opcode == ZEND_INIT_METHOD_CALL ||
    2432             :                         opline->opcode == ZEND_INIT_STATIC_METHOD_CALL)) {
    2433             :                         ZEND_ASSERT(op_num);
    2434          20 :                         opline--;
    2435             :                 }
    2436             : 
    2437             :                 do {
    2438             :                         /* If the exception was thrown during a function call there might be
    2439             :                          * arguments pushed to the stack that have to be dtor'ed. */
    2440             : 
    2441             :                         /* find the number of actually passed arguments */
    2442        1051 :                         level = 0;
    2443        1051 :                         do_exit = 0;
    2444             :                         do {
    2445        3682 :                                 switch (opline->opcode) {
    2446             :                                         case ZEND_DO_FCALL:
    2447             :                                         case ZEND_DO_ICALL:
    2448             :                                         case ZEND_DO_UCALL:
    2449             :                                         case ZEND_DO_FCALL_BY_NAME:
    2450         697 :                                                 level++;
    2451         697 :                                                 break;
    2452             :                                         case ZEND_INIT_FCALL:
    2453             :                                         case ZEND_INIT_FCALL_BY_NAME:
    2454             :                                         case ZEND_INIT_NS_FCALL_BY_NAME:
    2455             :                                         case ZEND_INIT_DYNAMIC_CALL:
    2456             :                                         case ZEND_INIT_USER_CALL:
    2457             :                                         case ZEND_INIT_METHOD_CALL:
    2458             :                                         case ZEND_INIT_STATIC_METHOD_CALL:
    2459             :                                         case ZEND_NEW:
    2460        1729 :                                                 if (level == 0) {
    2461        1032 :                                                         ZEND_CALL_NUM_ARGS(call) = 0;
    2462        1032 :                                                         do_exit = 1;
    2463             :                                                 }
    2464        1729 :                                                 level--;
    2465        1729 :                                                 break;
    2466             :                                         case ZEND_SEND_VAL:
    2467             :                                         case ZEND_SEND_VAL_EX:
    2468             :                                         case ZEND_SEND_VAR:
    2469             :                                         case ZEND_SEND_VAR_EX:
    2470             :                                         case ZEND_SEND_REF:
    2471             :                                         case ZEND_SEND_VAR_NO_REF:
    2472             :                                         case ZEND_SEND_USER:
    2473         854 :                                                 if (level == 0) {
    2474          15 :                                                         ZEND_CALL_NUM_ARGS(call) = opline->op2.num;
    2475          15 :                                                         do_exit = 1;
    2476             :                                                 }
    2477         854 :                                                 break;
    2478             :                                         case ZEND_SEND_ARRAY:
    2479             :                                         case ZEND_SEND_UNPACK:
    2480           4 :                                                 if (level == 0) {
    2481           4 :                                                         do_exit = 1;
    2482             :                                                 }
    2483             :                                                 break;
    2484             :                                 }
    2485        3682 :                                 if (!do_exit) {
    2486        2631 :                                         opline--;
    2487             :                                 }
    2488        3682 :                         } while (!do_exit);
    2489        1051 :                         if (call->prev_execute_data) {
    2490             :                                 /* skip current call region */
    2491          23 :                                 level = 0;
    2492          23 :                                 do_exit = 0;
    2493             :                                 do {
    2494         129 :                                         switch (opline->opcode) {
    2495             :                                                 case ZEND_DO_FCALL:
    2496             :                                                 case ZEND_DO_ICALL:
    2497             :                                                 case ZEND_DO_UCALL:
    2498             :                                                 case ZEND_DO_FCALL_BY_NAME:
    2499          25 :                                                         level++;
    2500          25 :                                                         break;
    2501             :                                                 case ZEND_INIT_FCALL:
    2502             :                                                 case ZEND_INIT_FCALL_BY_NAME:
    2503             :                                                 case ZEND_INIT_NS_FCALL_BY_NAME:
    2504             :                                                 case ZEND_INIT_DYNAMIC_CALL:
    2505             :                                                 case ZEND_INIT_USER_CALL:
    2506             :                                                 case ZEND_INIT_METHOD_CALL:
    2507             :                                                 case ZEND_INIT_STATIC_METHOD_CALL:
    2508             :                                                 case ZEND_NEW:
    2509          48 :                                                         if (level == 0) {
    2510          23 :                                                                 do_exit = 1;
    2511             :                                                         }
    2512          48 :                                                         level--;
    2513             :                                                         break;
    2514             :                                         }
    2515         129 :                                         opline--;
    2516         129 :                                 } while (!do_exit);
    2517             :                         }
    2518             : 
    2519        1051 :                         zend_vm_stack_free_args(EX(call));
    2520             : 
    2521        1051 :                         if (ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS) {
    2522          13 :                                 if (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR) {
    2523           5 :                                         GC_REFCOUNT(Z_OBJ(call->This))--;
    2524           5 :                                         if (GC_REFCOUNT(Z_OBJ(call->This)) == 1) {
    2525           5 :                                                 zend_object_store_ctor_failed(Z_OBJ(call->This));
    2526             :                                         }
    2527             :                                 }
    2528          13 :                                 OBJ_RELEASE(Z_OBJ(call->This));
    2529             :                         }
    2530        1051 :                         if (call->func->common.fn_flags & ZEND_ACC_CLOSURE) {
    2531           4 :                                 zend_object_release((zend_object *) call->func->common.prototype);
    2532        1047 :                         } else if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
    2533           6 :                                 zend_string_release(call->func->common.function_name);
    2534           6 :                                 zend_free_trampoline(call->func);
    2535             :                         }
    2536             : 
    2537        1051 :                         EX(call) = call->prev_execute_data;
    2538             :                         zend_vm_stack_free_call_frame(call);
    2539        1051 :                         call = EX(call);
    2540        1051 :                 } while (call);
    2541             :         }
    2542        3587 : }
    2543             : /* }}} */
    2544             : 
    2545        3610 : static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) /* {{{ */
    2546             : {
    2547             :         int i;
    2548             : 
    2549        8782 :         for (i = 0; i < EX(func)->op_array.last_live_range; i++) {
    2550        5534 :                 const zend_live_range *range = &EX(func)->op_array.live_range[i];
    2551        5534 :                 if (range->start > op_num) {
    2552             :                         /* further blocks will not be relevant... */
    2553         362 :                         break;
    2554        5172 :                 } else if (op_num < range->end) {
    2555        1395 :                         if (!catch_op_num || catch_op_num >= range->end) {
    2556         117 :                                 uint32_t kind = range->var & ZEND_LIVE_MASK;
    2557         117 :                                 uint32_t var_num = range->var & ~ZEND_LIVE_MASK;
    2558         117 :                                 zval *var = EX_VAR(var_num);
    2559             : 
    2560         117 :                                 if (kind == ZEND_LIVE_TMPVAR) {
    2561             :                                         zval_ptr_dtor_nogc(var);
    2562          93 :                                 } else if (kind == ZEND_LIVE_LOOP) {
    2563          43 :                                         if (Z_TYPE_P(var) != IS_ARRAY && Z_FE_ITER_P(var) != (uint32_t)-1) {
    2564           0 :                                                 zend_hash_iterator_del(Z_FE_ITER_P(var));
    2565             :                                         }
    2566             :                                         zval_ptr_dtor_nogc(var);
    2567          50 :                                 } else if (kind == ZEND_LIVE_ROPE) {
    2568           6 :                                         zend_string **rope = (zend_string **)var;
    2569           6 :                                         zend_op *last = EX(func)->op_array.opcodes + op_num;
    2570          29 :                                         while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT)
    2571           8 :                                                         || last->result.var != var_num) {
    2572             :                                                 ZEND_ASSERT(last >= EX(func)->op_array.opcodes);
    2573           9 :                                                 last--;
    2574             :                                         }
    2575           6 :                                         if (last->opcode == ZEND_ROPE_INIT) {
    2576           4 :                                                 zend_string_release(*rope);
    2577             :                                         } else {
    2578           2 :                                                 int j = last->extended_value;
    2579             :                                                 do {
    2580           6 :                                                         zend_string_release(rope[j]);
    2581           6 :                                                 } while (j--);
    2582             :                                         }
    2583          44 :                                 } else if (kind == ZEND_LIVE_SILENCE) {
    2584             :                                         /* restore previous error_reporting value */
    2585          44 :                                         if (!EG(error_reporting) && Z_LVAL_P(var) != 0) {
    2586          30 :                                                 EG(error_reporting) = Z_LVAL_P(var);
    2587             :                                         }
    2588             :                                 }
    2589             :                         }
    2590             :                 }
    2591             :         }
    2592        3610 : }
    2593             : /* }}} */
    2594             : 
    2595         260 : void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) {
    2596         260 :         cleanup_unfinished_calls(execute_data, op_num);
    2597         260 :         cleanup_live_vars(execute_data, op_num, catch_op_num);
    2598         260 : }
    2599             : 
    2600             : #ifdef HAVE_GCC_GLOBAL_REGS
    2601             : # if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
    2602             : #  define ZEND_VM_FP_GLOBAL_REG "%esi"
    2603             : #  define ZEND_VM_IP_GLOBAL_REG "%edi"
    2604             : # elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__x86_64__)
    2605             : #  define ZEND_VM_FP_GLOBAL_REG "%r14"
    2606             : #  define ZEND_VM_IP_GLOBAL_REG "%r15"
    2607             : # elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
    2608             : #  define ZEND_VM_FP_GLOBAL_REG "r28"
    2609             : #  define ZEND_VM_IP_GLOBAL_REG "r29"
    2610             : # elif defined(__IBMC__) && ZEND_GCC_VERSION >= 4002 && defined(__powerpc64__)
    2611             : #  define ZEND_VM_FP_GLOBAL_REG "r28"
    2612             : #  define ZEND_VM_IP_GLOBAL_REG "r29"
    2613             : # endif
    2614             : #endif
    2615             : 
    2616             : #define ZEND_VM_NEXT_OPCODE_EX(check_exception, skip) \
    2617             :         CHECK_SYMBOL_TABLES() \
    2618             :         if (check_exception) { \
    2619             :                 OPLINE = EX(opline) + (skip); \
    2620             :         } else { \
    2621             :                 OPLINE = opline + (skip); \
    2622             :         } \
    2623             :         ZEND_VM_CONTINUE()
    2624             : 
    2625             : #define ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION() \
    2626             :         ZEND_VM_NEXT_OPCODE_EX(1, 1)
    2627             : 
    2628             : #define ZEND_VM_NEXT_OPCODE() \
    2629             :         ZEND_VM_NEXT_OPCODE_EX(0, 1)
    2630             : 
    2631             : #define ZEND_VM_SET_NEXT_OPCODE(new_op) \
    2632             :         CHECK_SYMBOL_TABLES() \
    2633             :         OPLINE = new_op
    2634             : 
    2635             : #define ZEND_VM_SET_OPCODE(new_op) \
    2636             :         CHECK_SYMBOL_TABLES() \
    2637             :         OPLINE = new_op; \
    2638             :         ZEND_VM_INTERRUPT_CHECK()
    2639             : 
    2640             : #define ZEND_VM_SET_RELATIVE_OPCODE(opline, offset) \
    2641             :         ZEND_VM_SET_OPCODE(ZEND_OFFSET_TO_OPLINE(opline, offset))
    2642             : 
    2643             : #define ZEND_VM_JMP(new_op) \
    2644             :         if (EXPECTED(!EG(exception))) { \
    2645             :                 ZEND_VM_SET_OPCODE(new_op); \
    2646             :         } else { \
    2647             :                 LOAD_OPLINE(); \
    2648             :         } \
    2649             :         ZEND_VM_CONTINUE()
    2650             : 
    2651             : #define ZEND_VM_INC_OPCODE() \
    2652             :         OPLINE++
    2653             : 
    2654             : 
    2655             : #ifndef VM_SMART_OPCODES
    2656             : # define VM_SMART_OPCODES 1
    2657             : #endif
    2658             : 
    2659             : #if VM_SMART_OPCODES
    2660             : # define ZEND_VM_REPEATABLE_OPCODE \
    2661             :         do {
    2662             : # define ZEND_VM_REPEAT_OPCODE(_opcode) \
    2663             :         } while (UNEXPECTED((++opline)->opcode == _opcode)); \
    2664             :         OPLINE = opline; \
    2665             :         ZEND_VM_CONTINUE()
    2666             : # define ZEND_VM_SMART_BRANCH(_result, _check) do { \
    2667             :                 int __result; \
    2668             :                 if (EXPECTED((opline+1)->opcode == ZEND_JMPZ)) { \
    2669             :                         __result = (_result); \
    2670             :                 } else if (EXPECTED((opline+1)->opcode == ZEND_JMPNZ)) { \
    2671             :                         __result = !(_result); \
    2672             :                 } else { \
    2673             :                         break; \
    2674             :                 } \
    2675             :                 if ((_check) && UNEXPECTED(EG(exception))) { \
    2676             :                         HANDLE_EXCEPTION(); \
    2677             :                 } \
    2678             :                 if (__result) { \
    2679             :                         ZEND_VM_SET_NEXT_OPCODE(opline + 2); \
    2680             :                 } else { \
    2681             :                         ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline + 1, (opline+1)->op2)); \
    2682             :                 } \
    2683             :                 ZEND_VM_CONTINUE(); \
    2684             :         } while (0)
    2685             : #else
    2686             : # define ZEND_VM_REPEATABLE_OPCODE
    2687             : # define ZEND_VM_REPEAT_OPCODE(_opcode)
    2688             : # define ZEND_VM_SMART_BRANCH(_result, _check)
    2689             : #endif
    2690             : 
    2691             : #ifdef __GNUC__
    2692             : # define ZEND_VM_GUARD(name) __asm__("#" #name)
    2693             : #else
    2694             : # define ZEND_VM_GUARD(name)
    2695             : #endif
    2696             : 
    2697             : #define GET_OP1_UNDEF_CV(ptr, type) \
    2698             :         _get_zval_cv_lookup_ ## type(ptr, opline->op1.var, execute_data)
    2699             : #define GET_OP2_UNDEF_CV(ptr, type) \
    2700             :         _get_zval_cv_lookup_ ## type(ptr, opline->op2.var, execute_data)
    2701             : 
    2702             : #include "zend_vm_execute.h"
    2703             : 
    2704           0 : ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)
    2705             : {
    2706           0 :         if (opcode != ZEND_USER_OPCODE) {
    2707           0 :                 if (handler == NULL) {
    2708             :                         /* restore the original handler */
    2709           0 :                         zend_user_opcodes[opcode] = opcode;
    2710             :                 } else {
    2711           0 :                         zend_user_opcodes[opcode] = ZEND_USER_OPCODE;
    2712             :                 }
    2713           0 :                 zend_user_opcode_handlers[opcode] = handler;
    2714           0 :                 return SUCCESS;
    2715             :         }
    2716           0 :         return FAILURE;
    2717             : }
    2718             : 
    2719           0 : ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
    2720             : {
    2721           0 :         return zend_user_opcode_handlers[opcode];
    2722             : }
    2723             : 
    2724           0 : ZEND_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)
    2725             : {
    2726           0 :         return get_zval_ptr(op_type, *node, execute_data, should_free, type);
    2727             : }
    2728             : 
    2729           0 : ZEND_API void ZEND_FASTCALL zend_check_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg)
    2730             : {
    2731           0 :         zend_verify_internal_arg_type(zf, arg_num, arg);
    2732           0 : }
    2733             : 
    2734           0 : ZEND_API int ZEND_FASTCALL zend_check_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value, void **cache_slot)
    2735             : {
    2736           0 :         return zend_verify_arg_type(zf, arg_num, arg, default_value, cache_slot);
    2737             : }
    2738             : 
    2739           0 : ZEND_API void ZEND_FASTCALL zend_check_missing_arg(zend_execute_data *execute_data, uint32_t arg_num, void **cache_slot)
    2740             : {
    2741           0 :         zend_verify_missing_arg(execute_data, arg_num, cache_slot);
    2742           0 : }
    2743             : 
    2744             : /*
    2745             :  * Local variables:
    2746             :  * tab-width: 4
    2747             :  * c-basic-offset: 4
    2748             :  * indent-tabs-mode: t
    2749             :  * End:
    2750             :  */

Generated by: LCOV version 1.10

Generated at Sat, 25 Jun 2016 07:08:51 +0000 (5 days ago)

Copyright © 2005-2016 The PHP Group
All rights reserved.