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.h (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 66 68 97.1 %
Date: 2015-04-14 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #ifndef ZEND_EXECUTE_H
      23             : #define ZEND_EXECUTE_H
      24             : 
      25             : #include "zend_compile.h"
      26             : #include "zend_hash.h"
      27             : #include "zend_operators.h"
      28             : #include "zend_variables.h"
      29             : 
      30             : BEGIN_EXTERN_C()
      31             : struct _zend_fcall_info;
      32             : ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
      33             : ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
      34             : 
      35             : void init_executor(void);
      36             : void shutdown_executor(void);
      37             : void shutdown_destructors(void);
      38             : ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
      39             : ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value);
      40             : ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
      41             : ZEND_API void execute_ex(zend_execute_data *execute_data);
      42             : ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
      43             : ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
      44             : ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload);
      45             : ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name);
      46             : ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name);
      47             : ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions);
      48             : ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions);
      49             : 
      50             : ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce);
      51             : ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce);
      52             : ZEND_API void zend_verify_arg_error(int error_type, 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);
      53             : ZEND_API void zend_verify_return_error(int error_type, const zend_function *zf, const char *need_msg, const char *need_kind, const char *returned_msg, const char *returned_kind);
      54             : 
      55             : static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
      56             : {
      57             :         do {
      58    19680170 :                 if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
      59             :                         zend_refcounted *garbage;
      60             : 
      61    12424561 :                         if (Z_ISREF_P(variable_ptr)) {
      62     2793154 :                                 variable_ptr = Z_REFVAL_P(variable_ptr);
      63     2793154 :                                 if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
      64             :                                         break;
      65             :                                 }
      66             :                         }
      67    11501114 :                         if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
      68      860694 :                         UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
      69           0 :                                 Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
      70           0 :                                 return variable_ptr;
      71             :                         }
      72    10640420 :                         if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
      73         120 :                                 return variable_ptr;
      74             :                         }
      75    10640300 :                         garbage = Z_COUNTED_P(variable_ptr);
      76    10640300 :                         if (--GC_REFCOUNT(garbage) == 0) {
      77     5120010 :                                 ZVAL_COPY_VALUE(variable_ptr, value);
      78     5120010 :                                 if (value_type == IS_CONST) {
      79             :                                         /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
      80      110992 :                                         if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
      81       14698 :                                                 zval_copy_ctor_func(variable_ptr);
      82             :                                         }
      83     5009018 :                                 } else if (value_type != IS_TMP_VAR) {
      84     4925832 :                                         if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
      85             :                                                 Z_ADDREF_P(variable_ptr);
      86             :                                         }
      87             :                                 }
      88     5120010 :                                 _zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
      89     5120006 :                                 return variable_ptr;
      90             :                         } else { /* we need to split */
      91             :                                 /* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
      92     5747512 :                                 if ((Z_COLLECTABLE_P(variable_ptr)) &&
      93      227222 :                                 UNEXPECTED(!GC_INFO(garbage))) {
      94       18256 :                                         gc_possible_root(garbage);
      95             :                                 }
      96             :                         }
      97             :                 }
      98             :         } while (0);
      99             : 
     100    14560040 :         ZVAL_COPY_VALUE(variable_ptr, value);
     101    14560040 :         if (value_type == IS_CONST) {
     102             :                 /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
     103     2996998 :                 if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
     104      204515 :                         zval_copy_ctor_func(variable_ptr);
     105             :                 }
     106    11563042 :         } else if (value_type != IS_TMP_VAR) {
     107     8816747 :                 if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
     108             :                         Z_ADDREF_P(variable_ptr);
     109             :                 }
     110             :         }
     111    14560040 :         return variable_ptr;
     112             : }
     113             : 
     114             : ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change);
     115             : ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope);
     116             : ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope);
     117             : ZEND_API int zval_update_constant_ex(zval *pp, zend_bool inline_change, zend_class_entry *scope);
     118             : 
     119             : /* dedicated Zend executor functions - do not use! */
     120             : struct _zend_vm_stack {
     121             :         zval *top;
     122             :         zval *end;
     123             :         zend_vm_stack prev;
     124             : };
     125             : 
     126             : #define ZEND_VM_STACK_HEADER_SLOTS \
     127             :         ((ZEND_MM_ALIGNED_SIZE(sizeof(struct _zend_vm_stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
     128             : 
     129             : #define ZEND_VM_STACK_ELEMETS(stack) \
     130             :         (((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
     131             : 
     132             : ZEND_API void zend_vm_stack_init(void);
     133             : ZEND_API void zend_vm_stack_destroy(void);
     134             : ZEND_API void* zend_vm_stack_extend(size_t size);
     135             : 
     136             : static zend_always_inline zval* zend_vm_stack_alloc(size_t size)
     137             : {
     138    18424662 :         char *top = (char*)EG(vm_stack_top);
     139             : 
     140    18424662 :         if (UNEXPECTED(size > (size_t)(((char*)EG(vm_stack_end)) - top))) {
     141           4 :                 return (zval*)zend_vm_stack_extend(size);
     142             :         }
     143    18424658 :         EG(vm_stack_top) = (zval*)(top + size);
     144    18424658 :         return (zval*)top;
     145             : }
     146             : 
     147             : static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(uint32_t used_stack, uint32_t call_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev)
     148             : {
     149    36849324 :         zend_execute_data *call = (zend_execute_data*)zend_vm_stack_alloc(used_stack);
     150             : 
     151    18424662 :         call->func = func;
     152    18424662 :         Z_OBJ(call->This) = object;
     153    18424662 :         ZEND_SET_CALL_INFO(call, call_info);
     154    18424662 :         ZEND_CALL_NUM_ARGS(call) = num_args;
     155    18424662 :         call->called_scope = called_scope;
     156    18424662 :         call->prev_execute_data = prev;
     157    18424662 :         return call;
     158             : }
     159             : 
     160             : static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, zend_function *func)
     161             : {
     162     1959241 :         uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args;
     163             : 
     164     1959241 :         if (ZEND_USER_CODE(func->type)) {
     165      869487 :                 used_stack += func->op_array.last_var + func->op_array.T - MIN(func->op_array.num_args, num_args);
     166             :         }
     167     1959241 :         return used_stack * sizeof(zval);
     168             : }
     169             : 
     170             : static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev)
     171             : {
     172     1714721 :         uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);
     173             : 
     174     1714721 :         return zend_vm_stack_push_call_frame_ex(used_stack, call_info,
     175             :                 func, num_args, called_scope, object, prev);
     176             : }
     177             : 
     178             : static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call)
     179             : {
     180     1716954 :         if (ZEND_CALL_INFO(call) & ZEND_CALL_FREE_EXTRA_ARGS) {
     181         777 :                 zval *end = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
     182         777 :                 zval *p = end + (ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args);
     183             :                 do {
     184        2441 :                         p--;
     185             :                         zval_ptr_dtor_nogc(p);
     186        2441 :                 } while (p != end);
     187             :         }
     188             : }
     189             : 
     190             : static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
     191             : {
     192    16677205 :         uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
     193             : 
     194    16677205 :         if (EXPECTED(num_args > 0)) {
     195    16092985 :                 zval *end = ZEND_CALL_ARG(call, 1);
     196    16092985 :                 zval *p = end + num_args;
     197             : 
     198             :                 do {
     199    30262364 :                         p--;
     200             :                         zval_ptr_dtor_nogc(p);
     201    30262364 :                 } while (p != end);
     202             :         }
     203             : }
     204             : 
     205             : static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call)
     206             : {
     207    18422466 :         zend_vm_stack p = EG(vm_stack);
     208    18422466 :         if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(p) == (zval*)call)) {
     209           7 :                 zend_vm_stack prev = p->prev;
     210             : 
     211           7 :                 EG(vm_stack_top) = prev->top;
     212           7 :                 EG(vm_stack_end) = prev->end;
     213           7 :                 EG(vm_stack) = prev;
     214           7 :                 efree(p);
     215             :         } else {
     216    18422459 :                 EG(vm_stack_top) = (zval*)call;
     217             :         }
     218             : }
     219             : 
     220             : /* services */
     221             : ZEND_API const char *get_active_class_name(const char **space);
     222             : ZEND_API const char *get_active_function_name(void);
     223             : ZEND_API const char *zend_get_executed_filename(void);
     224             : ZEND_API uint zend_get_executed_lineno(void);
     225             : ZEND_API zend_bool zend_is_executing(void);
     226             : 
     227             : ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
     228             : ZEND_API void zend_unset_timeout(void);
     229             : ZEND_API void zend_timeout(int dummy);
     230             : ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
     231             : ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type);
     232             : void zend_verify_abstract_class(zend_class_entry *ce);
     233             : 
     234             : ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim);
     235             : 
     236             : ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
     237             : 
     238             : #define ZEND_USER_OPCODE_CONTINUE   0 /* execute next opcode */
     239             : #define ZEND_USER_OPCODE_RETURN     1 /* exit from executor (return from function) */
     240             : #define ZEND_USER_OPCODE_DISPATCH   2 /* call original opcode handler */
     241             : #define ZEND_USER_OPCODE_ENTER      3 /* enter into new op_array without recursion */
     242             : #define ZEND_USER_OPCODE_LEAVE      4 /* return to calling op_array within the same executor */
     243             : 
     244             : #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
     245             : 
     246             : ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler);
     247             : ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
     248             : 
     249             : /* former zend_execute_locks.h */
     250             : typedef zval* zend_free_op;
     251             : 
     252             : 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);
     253             : 
     254             : ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
     255             : 
     256             : ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
     257             : void zend_free_compiled_variables(zend_execute_data *execute_data);
     258             : 
     259             : #define CACHED_PTR(num) \
     260             :         EX_RUN_TIME_CACHE()[(num)]
     261             : 
     262             : #define CACHE_PTR(num, ptr) do { \
     263             :                 EX_RUN_TIME_CACHE()[(num)] = (ptr); \
     264             :         } while (0)
     265             : 
     266             : #define CACHED_POLYMORPHIC_PTR(num, ce) \
     267             :         ((EX_RUN_TIME_CACHE()[(num)] == (ce)) ? \
     268             :                 EX_RUN_TIME_CACHE()[(num) + 1] : \
     269             :                 NULL)
     270             : 
     271             : #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
     272             :                 EX_RUN_TIME_CACHE()[(num)] = (ce); \
     273             :                 EX_RUN_TIME_CACHE()[(num) + 1] = (ptr); \
     274             :         } while (0)
     275             : 
     276             : #define CACHED_PTR_EX(slot) \
     277             :         (slot)[0]
     278             : 
     279             : #define CACHE_PTR_EX(slot, ptr) do { \
     280             :                 (slot)[0] = (ptr); \
     281             :         } while (0)
     282             : 
     283             : #define CACHED_POLYMORPHIC_PTR_EX(slot, ce) \
     284             :         (((slot)[0] == (ce)) ? (slot)[1] : NULL)
     285             : 
     286             : #define CACHE_POLYMORPHIC_PTR_EX(slot, ce, ptr) do { \
     287             :                 (slot)[0] = (ce); \
     288             :                 (slot)[1] = (ptr); \
     289             :         } while (0)
     290             : 
     291             : END_EXTERN_C()
     292             : 
     293             : #endif /* ZEND_EXECUTE_H */
     294             : 
     295             : /*
     296             :  * Local variables:
     297             :  * tab-width: 4
     298             :  * c-basic-offset: 4
     299             :  * indent-tabs-mode: t
     300             :  * End:
     301             :  */

Generated by: LCOV version 1.10

Generated at Tue, 14 Apr 2015 11:48:39 +0000 (4 days ago)

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