Annotation of embedaddon/php/Zend/zend_fast_cache.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | Zend Engine                                                          |
                      4:    +----------------------------------------------------------------------+
                      5:    | Copyright (c) 1998-2012 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: zend_fast_cache.h 321634 2012-01-01 13:15:04Z felipe $ */
                     21: #if 0
                     22: #ifndef ZEND_FAST_CACHE_H
                     23: #define ZEND_FAST_CACHE_H
                     24: 
                     25: #ifndef ZEND_ENABLE_FAST_CACHE
                     26: # if ZEND_DEBUG
                     27: # define ZEND_ENABLE_FAST_CACHE 0
                     28: # else
                     29: # define ZEND_ENABLE_FAST_CACHE 0
                     30: # endif
                     31: #endif
                     32: 
                     33: typedef struct _zend_fast_cache_list_entry {
                     34:        struct _zend_fast_cache_list_entry *next;
                     35: } zend_fast_cache_list_entry;
                     36: 
                     37: #define MAX_FAST_CACHE_TYPES   4
                     38: 
                     39: 
                     40: #define ZVAL_CACHE_LIST                        0
                     41: #define HASHTABLE_CACHE_LIST   1
                     42: 
                     43: #if ZEND_ENABLE_FAST_CACHE
                     44: 
                     45: 
                     46: #include "zend_globals.h"
                     47: #include "zend_globals_macros.h"
                     48: #include "zend_alloc.h"
                     49: 
                     50: 
                     51: #if ZEND_DEBUG
                     52: # define RECORD_ZVAL_CACHE_HIT(fc_type)                AG(fast_cache_stats)[fc_type][1]++;
                     53: # define RECORD_ZVAL_CACHE_MISS(fc_type)       AG(fast_cache_stats)[fc_type][0]++;
                     54: #else
                     55: # define RECORD_ZVAL_CACHE_HIT(fc_type)
                     56: # define RECORD_ZVAL_CACHE_MISS(fc_type)
                     57: #endif
                     58: 
                     59: 
                     60: #define ZEND_FAST_ALLOC(p, type, fc_type)                                                              \
                     61:        {                                                                                                                               \
                     62:                TSRMLS_FETCH();                                                                                         \
                     63:                                                                                                                                        \
                     64:                if (((p) = (type *) AG(fast_cache_list_head)[fc_type])) {       \
                     65:                        AG(fast_cache_list_head)[fc_type] = ((zend_fast_cache_list_entry *) AG(fast_cache_list_head)[fc_type])->next;   \
                     66:                        RECORD_ZVAL_CACHE_HIT(fc_type);                                                 \
                     67:                } else {                                                                                                        \
                     68:                        (p) = (type *) emalloc(sizeof(type));                                   \
                     69:                        RECORD_ZVAL_CACHE_MISS(fc_type);                                                \
                     70:                }                                                                                                                       \
                     71:        }
                     72: 
                     73: 
                     74: #define ZEND_FAST_FREE(p, fc_type)                                                                             \
                     75:        {                                                                                                                               \
                     76:                TSRMLS_FETCH();                                                                                         \
                     77:                                                                                                                                        \
                     78:                ((zend_fast_cache_list_entry *) (p))->next = (zend_fast_cache_list_entry *) AG(fast_cache_list_head)[fc_type];  \
                     79:                AG(fast_cache_list_head)[fc_type] = (zend_fast_cache_list_entry *) (p);                 \
                     80:        }
                     81: 
                     82: #define ZEND_FAST_ALLOC_REL(p, type, fc_type)  \
                     83:        ZEND_FAST_ALLOC(p, type, fc_type)
                     84: 
                     85: #define ZEND_FAST_FREE_REL(p, fc_type) \
                     86:        ZEND_FAST_FREE(p, fc_type)
                     87: 
                     88: 
                     89: #else /* !ZEND_ENABLE_FAST_CACHE */
                     90: 
                     91: #define ZEND_FAST_ALLOC(p, type, fc_type)      \
                     92:        (p) = (type *) emalloc(sizeof(type))
                     93: 
                     94: #define ZEND_FAST_FREE(p, fc_type)     \
                     95:        efree(p)
                     96: 
                     97: #define ZEND_FAST_ALLOC_REL(p, type, fc_type)  \
                     98:        (p) = (type *) emalloc_rel(sizeof(type))
                     99: 
                    100: #define ZEND_FAST_FREE_REL(p, fc_type) \
                    101:        efree_rel(p)
                    102: 
                    103: #endif /* ZEND_ENABLE_FAST_CACHE */
                    104: 
                    105: 
                    106: 
                    107: /* fast cache for zval's */
                    108: #define ALLOC_ZVAL(z)  \
                    109:        ZEND_FAST_ALLOC(z, zval, ZVAL_CACHE_LIST)
                    110: 
                    111: #define FREE_ZVAL(z)   \
                    112:        ZEND_FAST_FREE(z, ZVAL_CACHE_LIST)
                    113: 
                    114: #define ALLOC_ZVAL_REL(z)      \
                    115:        ZEND_FAST_ALLOC_REL(z, zval, ZVAL_CACHE_LIST)
                    116: 
                    117: #define FREE_ZVAL_REL(z)       \
                    118:        ZEND_FAST_FREE_REL(z, ZVAL_CACHE_LIST)
                    119: 
                    120: /* fast cache for HashTables */
                    121: #define ALLOC_HASHTABLE(ht)    \
                    122:        ZEND_FAST_ALLOC(ht, HashTable, HASHTABLE_CACHE_LIST)
                    123: 
                    124: #define FREE_HASHTABLE(ht)     \
                    125:        ZEND_FAST_FREE(ht, HASHTABLE_CACHE_LIST)
                    126: 
                    127: #define ALLOC_HASHTABLE_REL(ht)        \
                    128:        ZEND_FAST_ALLOC_REL(ht, HashTable, HASHTABLE_CACHE_LIST)
                    129: 
                    130: #define FREE_HASHTABLE_REL(ht) \
                    131:        ZEND_FAST_FREE_REL(ht, HASHTABLE_CACHE_LIST)
                    132: 
                    133: #endif /* ZEND_FAST_CACHE_H */
                    134: #endif
                    135: /*
                    136:  * Local variables:
                    137:  * tab-width: 4
                    138:  * c-basic-offset: 4
                    139:  * indent-tabs-mode: t
                    140:  * End:
                    141:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>