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-01-26 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             : 
      54             : static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
      55             : {
      56             :         do {
      57    19920568 :                 if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
      58             :                         zend_refcounted *garbage;
      59             : 
      60    12392039 :                         if (Z_ISREF_P(variable_ptr)) {
      61     2792865 :                                 variable_ptr = Z_REFVAL_P(variable_ptr);
      62     2792865 :                                 if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
      63             :                                         break;
      64             :                                 }
      65             :                         }
      66    11468454 :                         if (Z_TYPE_P(variable_ptr) == IS_OBJECT &&
      67      860689 :                         UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) {
      68           0 :                                 Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
      69           0 :                                 return variable_ptr;
      70             :                         }
      71    10607765 :                         if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
      72         120 :                                 return variable_ptr;
      73             :                         }
      74    10607645 :                         garbage = Z_COUNTED_P(variable_ptr);
      75    10607645 :                         if (--GC_REFCOUNT(garbage) == 0) {
      76     5124169 :                                 ZVAL_COPY_VALUE(variable_ptr, value);
      77     5124169 :                                 if (value_type == IS_CONST) {
      78             :                                         /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
      79      110851 :                                         if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
      80       14616 :                                                 zval_copy_ctor_func(variable_ptr);
      81             :                                         }
      82     5013318 :                                 } else if (value_type != IS_TMP_VAR) {
      83     4932199 :                                         if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
      84             :                                                 Z_ADDREF_P(variable_ptr);
      85             :                                         }
      86             :                                 }
      87     5124169 :                                 _zval_dtor_func_for_ptr(garbage ZEND_FILE_LINE_CC);
      88     5124165 :                                 return variable_ptr;
      89             :                         } else { /* we need to split */
      90             :                                 /* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
      91     5710715 :                                 if ((Z_COLLECTABLE_P(variable_ptr)) &&
      92      227239 :                                 UNEXPECTED(!GC_INFO(garbage))) {
      93       18277 :                                         gc_possible_root(garbage);
      94             :                                 }
      95             :                         }
      96             :                 }
      97             :         } while (0);
      98             : 
      99    14796279 :         ZVAL_COPY_VALUE(variable_ptr, value);
     100    14796279 :         if (value_type == IS_CONST) {
     101             :                 /* IS_CONST can't be IS_OBJECT, IS_RESOURCE or IS_REFERENCE */
     102     3115984 :                 if (UNEXPECTED(Z_OPT_COPYABLE_P(variable_ptr))) {
     103      204229 :                         zval_copy_ctor_func(variable_ptr);
     104             :                 }
     105    11680295 :         } else if (value_type != IS_TMP_VAR) {
     106     8881374 :                 if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
     107             :                         Z_ADDREF_P(variable_ptr);
     108             :                 }
     109             :         }
     110    14796279 :         return variable_ptr;
     111             : }
     112             : 
     113             : ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change);
     114             : ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope);
     115             : ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope);
     116             : ZEND_API int zval_update_constant_ex(zval *pp, zend_bool inline_change, zend_class_entry *scope);
     117             : 
     118             : /* dedicated Zend executor functions - do not use! */
     119             : struct _zend_vm_stack {
     120             :         zval *top;
     121             :         zval *end;
     122             :         zend_vm_stack prev;
     123             : };
     124             : 
     125             : #define ZEND_VM_STACK_HEADER_SLOTS \
     126             :         ((ZEND_MM_ALIGNED_SIZE(sizeof(struct _zend_vm_stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
     127             : 
     128             : #define ZEND_VM_STACK_ELEMETS(stack) \
     129             :         (((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
     130             : 
     131             : ZEND_API void zend_vm_stack_init(void);
     132             : ZEND_API void zend_vm_stack_destroy(void);
     133             : ZEND_API void* zend_vm_stack_extend(size_t size);
     134             : 
     135             : static zend_always_inline zval* zend_vm_stack_alloc(size_t size)
     136             : {
     137    18740189 :         char *top = (char*)EG(vm_stack_top);
     138             : 
     139    18740189 :         if (UNEXPECTED(size > (size_t)(((char*)EG(vm_stack_end)) - top))) {
     140           4 :                 return (zval*)zend_vm_stack_extend(size);
     141             :         }
     142    18740185 :         EG(vm_stack_top) = (zval*)(top + size);
     143    18740185 :         return (zval*)top;
     144             : }
     145             : 
     146             : 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)
     147             : {
     148    37480378 :         zend_execute_data *call = (zend_execute_data*)zend_vm_stack_alloc(used_stack);
     149             : 
     150    18740189 :         call->func = func;
     151    18740189 :         Z_OBJ(call->This) = object;
     152    18740189 :         ZEND_SET_CALL_INFO(call, call_info);
     153    18740189 :         ZEND_CALL_NUM_ARGS(call) = num_args;
     154    18740189 :         call->called_scope = called_scope;
     155    18740189 :         call->prev_execute_data = prev;
     156    18740189 :         return call;
     157             : }
     158             : 
     159             : static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, zend_function *func)
     160             : {
     161     2037449 :         uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args;
     162             : 
     163     2037449 :         if (ZEND_USER_CODE(func->type)) {
     164      946824 :                 used_stack += func->op_array.last_var + func->op_array.T - MIN(func->op_array.num_args, num_args);
     165             :         }
     166     2037449 :         return used_stack * sizeof(zval);
     167             : }
     168             : 
     169             : 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)
     170             : {
     171     1791935 :         uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);
     172             : 
     173     1791935 :         return zend_vm_stack_push_call_frame_ex(used_stack, call_info,
     174             :                 func, num_args, called_scope, object, prev);
     175             : }
     176             : 
     177             : static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call)
     178             : {
     179     1984809 :         if (ZEND_CALL_INFO(call) & ZEND_CALL_FREE_EXTRA_ARGS) {
     180         776 :                 zval *end = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
     181         776 :                 zval *p = end + (ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args);
     182             :                 do {
     183        2440 :                         p--;
     184             :                         zval_ptr_dtor_nogc(p);
     185        2440 :                 } while (p != end);
     186             :         }
     187             : }
     188             : 
     189             : static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
     190             : {
     191    16724918 :         uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
     192             : 
     193    16724918 :         if (EXPECTED(num_args > 0)) {
     194    16152168 :                 zval *end = ZEND_CALL_ARG(call, 1);
     195    16152168 :                 zval *p = end + num_args;
     196             : 
     197             :                 do {
     198    30387266 :                         p--;
     199             :                         zval_ptr_dtor_nogc(p);
     200    30387266 :                 } while (p != end);
     201             :         }
     202             : }
     203             : 
     204             : static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call)
     205             : {
     206    18737995 :         zend_vm_stack p = EG(vm_stack);
     207    18737995 :         if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(p) == (zval*)call)) {
     208           7 :                 zend_vm_stack prev = p->prev;
     209             : 
     210           7 :                 EG(vm_stack_top) = prev->top;
     211           7 :                 EG(vm_stack_end) = prev->end;
     212           7 :                 EG(vm_stack) = prev;
     213           7 :                 efree(p);
     214             :         } else {
     215    18737988 :                 EG(vm_stack_top) = (zval*)call;
     216             :         }
     217             : }
     218             : 
     219             : /* services */
     220             : ZEND_API const char *get_active_class_name(const char **space);
     221             : ZEND_API const char *get_active_function_name(void);
     222             : ZEND_API const char *zend_get_executed_filename(void);
     223             : ZEND_API uint zend_get_executed_lineno(void);
     224             : ZEND_API zend_bool zend_is_executing(void);
     225             : 
     226             : ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
     227             : ZEND_API void zend_unset_timeout(void);
     228             : ZEND_API void zend_timeout(int dummy);
     229             : ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
     230             : ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type);
     231             : void zend_verify_abstract_class(zend_class_entry *ce);
     232             : 
     233             : ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim);
     234             : 
     235             : ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
     236             : 
     237             : #define ZEND_USER_OPCODE_CONTINUE   0 /* execute next opcode */
     238             : #define ZEND_USER_OPCODE_RETURN     1 /* exit from executor (return from function) */
     239             : #define ZEND_USER_OPCODE_DISPATCH   2 /* call original opcode handler */
     240             : #define ZEND_USER_OPCODE_ENTER      3 /* enter into new op_array without recursion */
     241             : #define ZEND_USER_OPCODE_LEAVE      4 /* return to calling op_array within the same executor */
     242             : 
     243             : #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
     244             : 
     245             : ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler);
     246             : ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
     247             : 
     248             : /* former zend_execute_locks.h */
     249             : typedef zval* zend_free_op;
     250             : 
     251             : 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);
     252             : 
     253             : ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
     254             : 
     255             : ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
     256             : void zend_free_compiled_variables(zend_execute_data *execute_data);
     257             : 
     258             : #define CACHED_PTR(num) \
     259             :         EX_RUN_TIME_CACHE()[(num)]
     260             : 
     261             : #define CACHE_PTR(num, ptr) do { \
     262             :                 EX_RUN_TIME_CACHE()[(num)] = (ptr); \
     263             :         } while (0)
     264             : 
     265             : #define CACHED_POLYMORPHIC_PTR(num, ce) \
     266             :         ((EX_RUN_TIME_CACHE()[(num)] == (ce)) ? \
     267             :                 EX_RUN_TIME_CACHE()[(num) + 1] : \
     268             :                 NULL)
     269             : 
     270             : #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
     271             :                 EX_RUN_TIME_CACHE()[(num)] = (ce); \
     272             :                 EX_RUN_TIME_CACHE()[(num) + 1] = (ptr); \
     273             :         } while (0)
     274             : 
     275             : #define CACHED_PTR_EX(slot) \
     276             :         (slot)[0]
     277             : 
     278             : #define CACHE_PTR_EX(slot, ptr) do { \
     279             :                 (slot)[0] = (ptr); \
     280             :         } while (0)
     281             : 
     282             : #define CACHED_POLYMORPHIC_PTR_EX(slot, ce) \
     283             :         (((slot)[0] == (ce)) ? (slot)[1] : NULL)
     284             : 
     285             : #define CACHE_POLYMORPHIC_PTR_EX(slot, ce, ptr) do { \
     286             :                 (slot)[0] = (ce); \
     287             :                 (slot)[1] = (ptr); \
     288             :         } while (0)
     289             : 
     290             : END_EXTERN_C()
     291             : 
     292             : #endif /* ZEND_EXECUTE_H */
     293             : 
     294             : /*
     295             :  * Local variables:
     296             :  * tab-width: 4
     297             :  * c-basic-offset: 4
     298             :  * indent-tabs-mode: t
     299             :  * End:
     300             :  */

Generated by: LCOV version 1.10

Generated at Mon, 26 Jan 2015 14:46:41 +0000 (3 days ago)

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