]> granicus.if.org Git - php/commitdiff
Introduce a zval-specific cache - 5-15% speed improvement
authorZeev Suraski <zeev@php.net>
Sun, 26 Dec 1999 21:56:59 +0000 (21:56 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 26 Dec 1999 21:56:59 +0000 (21:56 +0000)
Zend/zend.h
Zend/zend_API.h
Zend/zend_alloc.c
Zend/zend_compile.c
Zend/zend_execute.c
Zend/zend_globals.h
Zend/zend_operators.c

index d99fae9cc995af37f8063deea13d6f961a8ff504..b066b47e12f32f0abf20e97a43cfb032be636163 100644 (file)
@@ -284,10 +284,6 @@ END_EXTERN_C()
 
 #define INIT_ZVAL(z) z = zval_used_for_init;
 
-#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval))
-
-#define FREE_ZVAL(z) efree(z)
-
 #define ALLOC_INIT_ZVAL(zp)                                            \
        ALLOC_ZVAL(zp);         \
        INIT_ZVAL(*zp);
index 070bb09fccf156091ea5374486c669e2ae97957c..46054a8fd7aa1e175b590ecf9622543c1e2b0fb7 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "modules.h"
 #include "zend_list.h"
+#include "zend_zval_alloc.h"
 
 
 #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
index 7bcb8d1ef320a6b1a13f1ff38f92dd73d6e13714..a47afae1924c3413ac49801d28f2c04cf5991bb0 100644 (file)
@@ -23,6 +23,7 @@
 #include "zend.h"
 #include "zend_alloc.h"
 #include "zend_globals.h"
+#include "zend_zval_alloc.h"
 #ifdef HAVE_SIGNAL_H
 # include <signal.h>
 #endif
@@ -31,7 +32,7 @@
 #endif
 
 #ifndef ZTS
-static zend_alloc_globals alloc_globals;
+zend_alloc_globals alloc_globals;
 #endif
 
 
@@ -321,6 +322,10 @@ ZEND_API void start_memory_manager(ALS_D)
        AG(memory_exhausted)=0;
 #endif
 
+#if ZEND_DEBUG
+       AG(zval_list_head) = NULL;
+#endif
+
        memset(AG(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned char));
 }
 
@@ -330,9 +335,21 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
        zend_mem_header *p, *t;
 #if ZEND_DEBUG
        int had_leaks=0;
+#else
+       zend_zval_list_entry *zval_list_entry, *next_zval_list_entry;
 #endif
        ALS_FETCH();
 
+#if !ZEND_DEBUG
+       zval_list_entry = AG(zval_list_head);
+       while (zval_list_entry) {
+               next_zval_list_entry = zval_list_entry->next;
+               efree(zval_list_entry);
+               zval_list_entry = next_zval_list_entry;
+       }
+       AG(zval_list_head) = NULL;
+#endif
+
        p=AG(head);
        t=AG(head);
        while (t) {
index 38be21fe3febb631630bbf8b771bbc105d188af2..64872a1d0d4b89308e62a057d097859c01bf09d4 100644 (file)
@@ -25,6 +25,7 @@
 #include "zend_API.h"
 #include "zend_variables.h"
 #include "zend_operators.h"
+#include "zend_zval_alloc.h"
 
 
 ZEND_API zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
index 8a1bf5a74fc790d0cfe6b17397dd7088af61faf1..eb23e33826d61999d56d6c32b9126b95a45961ed 100644 (file)
@@ -30,6 +30,7 @@
 #include "zend_operators.h"
 #include "zend_constants.h"
 #include "zend_extensions.h"
+#include "zend_zval_alloc.h"
 
 #if defined(HAVE_ALLOCA) && defined(HAVE_ALLOCA_H)
 # include <alloca.h>
index cae5a753d14fa71b66e846111aa414aec213f8db..5a08c11a825870514ee30dc275709556449c20b4 100644 (file)
@@ -179,6 +179,9 @@ struct _zend_alloc_globals {
        zend_mem_header *phead;         /* persistent list */
        void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES];
        unsigned char cache_count[MAX_CACHED_MEMORY];
+#if !ZEND_DEBUG
+       void *zval_list_head;
+#endif
 
 #if MEMORY_LIMIT
        unsigned int memory_limit;
index 6256155f3e3cf5e0db3560a621320c8bcc690a6d..894d929d00a1879e38e251263c5bbd5b13c07662 100644 (file)
@@ -29,6 +29,7 @@
 #include "zend_variables.h"
 #include "zend_globals.h"
 #include "zend_list.h"
+#include "zend_zval_alloc.h"
 
 #if WITH_BCMATH
 #include "functions/number.h"