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: 56 64 87.5 %
Date: 2014-10-30 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 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 TSRMLS_DC);
      33             : ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value TSRMLS_DC);
      34             : 
      35             : void init_executor(TSRMLS_D);
      36             : void shutdown_executor(TSRMLS_D);
      37             : void shutdown_destructors(TSRMLS_D);
      38             : ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value TSRMLS_DC);
      39             : ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data *call, zend_op_array *op_array, zval *return_value TSRMLS_DC);
      40             : ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value TSRMLS_DC);
      41             : ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC);
      42             : ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC);
      43             : ZEND_API int zend_is_true(zval *op TSRMLS_DC);
      44             : ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC);
      45             : ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *key, int use_autoload TSRMLS_DC);
      46             : ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
      47             : ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name TSRMLS_DC);
      48             : ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
      49             : ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
      50             : 
      51             : ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC);
      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 TSRMLS_DC);
      53             : 
      54             : static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
      55             : {
      56    29267990 :         if (Z_REFCOUNTED_P(zval_ptr)) {
      57    18122006 :                 if (!Z_DELREF_P(zval_ptr)) {
      58             :                         ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
      59     6805720 :                         _zval_dtor_func_for_ptr(Z_COUNTED_P(zval_ptr) ZEND_FILE_LINE_RELAY_CC);
      60             :                 } else {
      61             :                         GC_ZVAL_CHECK_POSSIBLE_ROOT(zval_ptr);
      62             :                 }
      63             :         }
      64             : }
      65             : 
      66             : static zend_always_inline int i_zend_is_true(zval *op TSRMLS_DC)
      67             : {
      68             :         int result;
      69             : 
      70             : again:
      71     7740962 :         switch (Z_TYPE_P(op)) {
      72             :                 case IS_UNDEF:
      73             :                 case IS_NULL:
      74             :                 case IS_FALSE:
      75     1754323 :                         result = 0;
      76             :                         break;
      77             :                 case IS_TRUE:
      78     3655637 :                         result = 1;
      79             :                         break;
      80             :                 case IS_LONG:
      81     2059614 :                         result = (Z_LVAL_P(op)?1:0);
      82             :                         break;
      83             :                 case IS_RESOURCE:
      84       13814 :                         result = (Z_RES_HANDLE_P(op)?1:0);
      85             :                         break;
      86             :                 case IS_DOUBLE:
      87          48 :                         result = (Z_DVAL_P(op) ? 1 : 0);
      88             :                         break;
      89             :                 case IS_STRING:
      90      147762 :                         if (Z_STRLEN_P(op) == 0
      91       95972 :                                 || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
      92        8114 :                                 result = 0;
      93             :                         } else {
      94       43676 :                                 result = 1;
      95             :                         }
      96             :                         break;
      97             :                 case IS_ARRAY:
      98       66065 :                         result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
      99             :                         break;
     100             :                 case IS_OBJECT:
     101       87692 :                         if (Z_OBJ_HT_P(op)->cast_object) {
     102             :                                 zval tmp;
     103       87692 :                                 if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, _IS_BOOL TSRMLS_CC) == SUCCESS) {
     104       87691 :                                         result = Z_TYPE(tmp) == IS_TRUE;
     105             :                                         break;
     106             :                                 }
     107           1 :                                 zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to boolean", Z_OBJ_P(op)->ce->name->val);
     108           0 :                         } else if (Z_OBJ_HT_P(op)->get) {
     109             :                                 zval rv;
     110           0 :                                 zval *tmp = Z_OBJ_HT_P(op)->get(op, &rv TSRMLS_CC);
     111           0 :                                 if (Z_TYPE_P(tmp) != IS_OBJECT) {
     112             :                                         /* for safety - avoid loop */
     113           0 :                                         convert_to_boolean(tmp);
     114           0 :                                         result = Z_TYPE_P(tmp) == IS_TRUE;
     115           0 :                                         zval_ptr_dtor(tmp);
     116             :                                         break;
     117             :                                 }
     118             :                         }
     119           0 :                         result = 1;
     120             :                         break;
     121             :                 case IS_REFERENCE:
     122       51979 :                         op = Z_REFVAL_P(op);
     123             :                         goto again;
     124             :                         break;
     125             :                 default:
     126           0 :                         result = 0;
     127             :                         break;
     128             :         }
     129     7688982 :         return result;
     130             : }
     131             : 
     132             : ZEND_API int zval_update_constant(zval *pp, zend_bool inline_change TSRMLS_DC);
     133             : ZEND_API int zval_update_constant_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC);
     134             : ZEND_API int zval_update_constant_no_inline_change(zval *pp, zend_class_entry *scope TSRMLS_DC);
     135             : ZEND_API int zval_update_constant_ex(zval *pp, zend_bool inline_change, zend_class_entry *scope TSRMLS_DC);
     136             : 
     137             : /* dedicated Zend executor functions - do not use! */
     138             : struct _zend_vm_stack {
     139             :         zval *top;
     140             :         zval *end;
     141             :         zend_vm_stack prev;
     142             : };
     143             : 
     144             : #define ZEND_VM_STACK_HEADER_SLOTS \
     145             :         ((ZEND_MM_ALIGNED_SIZE(sizeof(struct _zend_vm_stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
     146             : 
     147             : #define ZEND_VM_STACK_ELEMETS(stack) \
     148             :         (((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
     149             : 
     150             : ZEND_API void zend_vm_stack_init(TSRMLS_D);
     151             : ZEND_API void zend_vm_stack_destroy(TSRMLS_D);
     152             : ZEND_API void* zend_vm_stack_extend(size_t size TSRMLS_DC);
     153             : 
     154             : static zend_always_inline zval* zend_vm_stack_alloc(size_t size TSRMLS_DC)
     155             : {
     156    18787027 :         char *top = (char*)EG(vm_stack_top);
     157             : 
     158    18787027 :         if (UNEXPECTED(size > (size_t)(((char*)EG(vm_stack_end)) - top))) {
     159           4 :                 return (zval*)zend_vm_stack_extend(size TSRMLS_CC);
     160             :         }
     161    18787023 :         EG(vm_stack_top) = (zval*)(top + size);
     162    18787023 :         return (zval*)top;
     163             : }
     164             : 
     165             : static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t frame_info, zend_function *func, uint32_t num_args, zend_class_entry *called_scope, zend_object *object, zend_execute_data *prev TSRMLS_DC)
     166             : {
     167    18787027 :         uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args;
     168             :         zend_execute_data *call;
     169             :         
     170    18787027 :         if (ZEND_USER_CODE(func->type)) {
     171     2090534 :                 used_stack += func->op_array.last_var + func->op_array.T - MIN(func->op_array.num_args, num_args);
     172             :         }
     173    37574054 :         call = (zend_execute_data*)zend_vm_stack_alloc(used_stack * sizeof(zval) TSRMLS_CC);
     174    18787027 :         call->func = func;
     175    18787027 :         ZVAL_OBJ(&call->This, object);
     176    18787027 :         call->called_scope = called_scope;
     177    18787027 :         call->prev_execute_data = prev;
     178    18787027 :         call->frame_info = frame_info;
     179    18787027 :         call->num_args = 0;
     180    18787027 :         return call;
     181             : }
     182             : 
     183             : static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call TSRMLS_DC)
     184             : {
     185     2060973 :         uint32_t first_extra_arg = call->func->op_array.num_args - ((call->func->common.fn_flags & ZEND_ACC_VARIADIC) != 0);
     186             : 
     187     2060973 :         if (UNEXPECTED(call->num_args > first_extra_arg)) {
     188        1061 :                 zval *end = EX_VAR_NUM_2(call, call->func->op_array.last_var + call->func->op_array.T);
     189        1061 :                 zval *p = end + (call->num_args - first_extra_arg);
     190             :                 do {
     191       23116 :                         p--;
     192             :                         zval_ptr_dtor_nogc(p);
     193       23116 :                 } while (p != end);
     194             :         }
     195             : }
     196             : 
     197             : static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call TSRMLS_DC)
     198             : {
     199    16696203 :         uint32_t num_args = call->num_args;  
     200             : 
     201    16696203 :         if (num_args > 0) {
     202    16130156 :                 zval *end = ZEND_CALL_ARG(call, 1);
     203    16130156 :                 zval *p = end + num_args;
     204             : 
     205             :                 do {
     206    30349431 :                         p--;
     207             :                         zval_ptr_dtor_nogc(p);
     208    30349431 :                 } while (p != end);
     209             :         }
     210             : }
     211             : 
     212             : static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call TSRMLS_DC)
     213             : {
     214    18784695 :         zend_vm_stack p = EG(vm_stack);
     215    18784695 :         if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(p) == (zval*)call)) {
     216           7 :                 zend_vm_stack prev = p->prev;
     217             : 
     218           7 :                 EG(vm_stack_top) = prev->top;
     219           7 :                 EG(vm_stack_end) = prev->end;
     220           7 :                 EG(vm_stack) = prev;
     221           7 :                 efree(p);
     222             :         } else {
     223    18784688 :                 EG(vm_stack_top) = (zval*)call;
     224             :         }
     225             : }
     226             : 
     227             : /* services */
     228             : ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC);
     229             : ZEND_API const char *get_active_function_name(TSRMLS_D);
     230             : ZEND_API const char *zend_get_executed_filename(TSRMLS_D);
     231             : ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
     232             : ZEND_API zend_bool zend_is_executing(TSRMLS_D);
     233             : 
     234             : ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
     235             : ZEND_API void zend_unset_timeout(TSRMLS_D);
     236             : ZEND_API void zend_timeout(int dummy);
     237             : ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type TSRMLS_DC);
     238             : ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *key, int fetch_type TSRMLS_DC);
     239             : void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
     240             : 
     241             : ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *dim TSRMLS_DC);
     242             : 
     243             : #ifdef ZEND_WIN32
     244             : void zend_init_timeout_thread(void);
     245             : void zend_shutdown_timeout_thread(void);
     246             : #define WM_REGISTER_ZEND_TIMEOUT                (WM_USER+1)
     247             : #define WM_UNREGISTER_ZEND_TIMEOUT              (WM_USER+2)
     248             : #endif
     249             : 
     250             : ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
     251             : 
     252             : #define ZEND_USER_OPCODE_CONTINUE   0 /* execute next opcode */
     253             : #define ZEND_USER_OPCODE_RETURN     1 /* exit from executor (return from function) */
     254             : #define ZEND_USER_OPCODE_DISPATCH   2 /* call original opcode handler */
     255             : #define ZEND_USER_OPCODE_ENTER      3 /* enter into new op_array without recursion */
     256             : #define ZEND_USER_OPCODE_LEAVE      4 /* return to calling op_array within the same executor */
     257             : 
     258             : #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
     259             : 
     260             : ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler);
     261             : ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
     262             : 
     263             : /* former zend_execute_locks.h */
     264             : typedef struct _zend_free_op {
     265             :         zval *var;
     266             : /*      int   is_var; */
     267             : } zend_free_op;
     268             : 
     269             : 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 TSRMLS_DC);
     270             : 
     271             : ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
     272             : 
     273             : ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC);
     274             : void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC);
     275             : 
     276             : #define CACHED_PTR(num) \
     277             :         EX(run_time_cache)[(num)]
     278             : 
     279             : #define CACHE_PTR(num, ptr) do { \
     280             :                 EX(run_time_cache)[(num)] = (ptr); \
     281             :         } while (0)
     282             : 
     283             : #define CACHED_POLYMORPHIC_PTR(num, ce) \
     284             :         ((EX(run_time_cache)[(num)] == (ce)) ? \
     285             :                 EX(run_time_cache)[(num) + 1] : \
     286             :                 NULL)
     287             : 
     288             : #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
     289             :                 EX(run_time_cache)[(num)] = (ce); \
     290             :                 EX(run_time_cache)[(num) + 1] = (ptr); \
     291             :         } while (0)
     292             : 
     293             : #define CACHED_PTR_EX(slot) \
     294             :         (slot)[0]
     295             : 
     296             : #define CACHE_PTR_EX(slot, ptr) do { \
     297             :                 (slot)[0] = (ptr); \
     298             :         } while (0)
     299             : 
     300             : #define CACHED_POLYMORPHIC_PTR_EX(slot, ce) \
     301             :         (((slot)[0] == (ce)) ? (slot)[1] : NULL)
     302             : 
     303             : #define CACHE_POLYMORPHIC_PTR_EX(slot, ce, ptr) do { \
     304             :                 (slot)[0] = (ce); \
     305             :                 (slot)[1] = (ptr); \
     306             :         } while (0)
     307             : 
     308             : END_EXTERN_C()
     309             : 
     310             : #endif /* ZEND_EXECUTE_H */
     311             : 
     312             : /*
     313             :  * Local variables:
     314             :  * tab-width: 4
     315             :  * c-basic-offset: 4
     316             :  * indent-tabs-mode: t
     317             :  * End:
     318             :  */

Generated by: LCOV version 1.10

Generated at Thu, 30 Oct 2014 07:41:27 +0000 (6 hours ago)

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