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_gc.h (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 3 3 100.0 %
Date: 2014-11-22 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: David Wang <planetbeing@gmail.com>                          |
      16             :    |          Dmitry Stogov <dmitry@zend.com>                             |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #ifndef ZEND_GC_H
      23             : #define ZEND_GC_H
      24             : 
      25             : #ifndef GC_BENCH
      26             : # define GC_BENCH 0
      27             : #endif
      28             : 
      29             : #if GC_BENCH
      30             : # define GC_BENCH_INC(counter) GC_G(counter)++
      31             : # define GC_BENCH_DEC(counter) GC_G(counter)--
      32             : # define GC_BENCH_PEAK(peak, counter) do {              \
      33             :                 if (GC_G(counter) > GC_G(peak)) {            \
      34             :                         GC_G(peak) = GC_G(counter);                     \
      35             :                 }                                                                               \
      36             :         } while (0)
      37             : #else
      38             : # define GC_BENCH_INC(counter)
      39             : # define GC_BENCH_DEC(counter)
      40             : # define GC_BENCH_PEAK(peak, counter)
      41             : #endif
      42             : 
      43             : #define GC_COLOR  0xc000
      44             : 
      45             : #define GC_BLACK  0x0000
      46             : #define GC_WHITE  0x8000
      47             : #define GC_GREY   0x4000
      48             : #define GC_PURPLE 0xc000
      49             : 
      50             : #define GC_ADDRESS(v) \
      51             :         ((v) & ~GC_COLOR)
      52             : #define GC_SET_ADDRESS(v, a) \
      53             :         do {(v) = ((v) & GC_COLOR) | (a);} while (0)
      54             : #define GC_GET_COLOR(v) \
      55             :         (((zend_uintptr_t)(v)) & GC_COLOR)
      56             : #define GC_SET_COLOR(v, c) \
      57             :         do {(v) = ((v) & ~GC_COLOR) | (c);} while (0)
      58             : #define GC_SET_BLACK(v) \
      59             :         do {(v) = (v) & ~GC_COLOR;} while (0)
      60             : #define GC_SET_PURPLE(v) \
      61             :         do {(v) = (v) | GC_COLOR;} while (0)
      62             : 
      63             : #define GC_ZVAL_ADDRESS(v) \
      64             :         GC_ADDRESS(Z_GC_INFO_P(v))
      65             : #define GC_ZVAL_SET_ADDRESS(v, a) \
      66             :         GC_SET_ADDRESS(Z_GC_INFO_P(v), (a))
      67             : #define GC_ZVAL_GET_COLOR(v) \
      68             :         GC_GET_COLOR(Z_GC_INFO_P(v))
      69             : #define GC_ZVAL_SET_COLOR(v, c) \
      70             :         GC_SET_COLOR(Z_GC_INFO_P(v), (c))
      71             : #define GC_ZVAL_SET_BLACK(v) \
      72             :         GC_SET_BLACK(Z_GC_INFO_P(v))
      73             : #define GC_ZVAL_SET_PURPLE(v) \
      74             :         GC_SET_PURPLE(Z_GC_INFO_P(v))
      75             : 
      76             : typedef struct _gc_root_buffer {
      77             :         zend_refcounted          *ref;
      78             :         struct _gc_root_buffer   *next;     /* double-linked list               */
      79             :         struct _gc_root_buffer   *prev;
      80             :         uint32_t                 refcount;
      81             : } gc_root_buffer;
      82             : 
      83             : typedef struct _zend_gc_globals {
      84             :         zend_bool         gc_enabled;
      85             :         zend_bool         gc_active;
      86             :         zend_bool         gc_full;
      87             : 
      88             :         gc_root_buffer   *buf;                          /* preallocated arrays of buffers   */
      89             :         gc_root_buffer    roots;                        /* list of possible roots of cycles */
      90             :         gc_root_buffer   *unused;                       /* list of unused buffers           */
      91             :         gc_root_buffer   *first_unused;         /* pointer to first unused buffer   */
      92             :         gc_root_buffer   *last_unused;          /* pointer to last unused buffer    */
      93             : 
      94             :         gc_root_buffer    to_free;                      /* list to free                     */
      95             :         gc_root_buffer   *next_to_free;
      96             : 
      97             :         uint32_t gc_runs;
      98             :         uint32_t collected;
      99             : 
     100             : #if GC_BENCH
     101             :         uint32_t root_buf_length;
     102             :         uint32_t root_buf_peak;
     103             :         uint32_t zval_possible_root;
     104             :         uint32_t zval_buffered;
     105             :         uint32_t zval_remove_from_buffer;
     106             :         uint32_t zval_marked_grey;
     107             : #endif
     108             : 
     109             : } zend_gc_globals;
     110             : 
     111             : #ifdef ZTS
     112             : BEGIN_EXTERN_C()
     113             : ZEND_API extern int gc_globals_id;
     114             : END_EXTERN_C()
     115             : #define GC_G(v) TSRMG(gc_globals_id, zend_gc_globals *, v)
     116             : #else
     117             : #define GC_G(v) (gc_globals.v)
     118             : extern ZEND_API zend_gc_globals gc_globals;
     119             : #endif
     120             : 
     121             : BEGIN_EXTERN_C()
     122             : ZEND_API int  gc_collect_cycles(TSRMLS_D);
     123             : ZEND_API void gc_possible_root(zend_refcounted *ref TSRMLS_DC);
     124             : ZEND_API void gc_remove_from_buffer(zend_refcounted *ref TSRMLS_DC);
     125             : ZEND_API void gc_globals_ctor(TSRMLS_D);
     126             : ZEND_API void gc_globals_dtor(TSRMLS_D);
     127             : ZEND_API void gc_init(TSRMLS_D);
     128             : ZEND_API void gc_reset(TSRMLS_D);
     129             : END_EXTERN_C()
     130             : 
     131             : #define GC_ZVAL_CHECK_POSSIBLE_ROOT(z) \
     132             :         gc_check_possible_root((z) TSRMLS_CC)
     133             : 
     134             : #define GC_REMOVE_FROM_BUFFER(p) do { \
     135             :                 zend_refcounted *_p = (zend_refcounted*)(p); \
     136             :                 if (GC_ADDRESS(GC_INFO(_p))) { \
     137             :                         gc_remove_from_buffer(_p TSRMLS_CC); \
     138             :                 } \
     139             :         } while (0)
     140             : 
     141             : static zend_always_inline void gc_check_possible_root(zval *z TSRMLS_DC)
     142             : {
     143    11430569 :         ZVAL_DEREF(z);
     144    11430569 :         if (Z_COLLECTABLE_P(z) && UNEXPECTED(!Z_GC_INFO_P(z))) {
     145      658391 :                 gc_possible_root(Z_COUNTED_P(z) TSRMLS_CC);
     146             :         }
     147             : }
     148             : 
     149             : #endif /* ZEND_GC_H */
     150             : 
     151             : /*
     152             :  * Local variables:
     153             :  * tab-width: 4
     154             :  * c-basic-offset: 4
     155             :  * indent-tabs-mode: t
     156             :  * End:
     157             :  */

Generated by: LCOV version 1.10

Generated at Sat, 22 Nov 2014 23:01:09 +0000 (6 days ago)

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