Browse Source

Introduce a zval-specific cache - 5-15% speed improvement

PHP-4.0.5
Zeev Suraski 26 years ago
parent
commit
aec33aa753
  1. 4
      Zend/zend.h
  2. 1
      Zend/zend_API.h
  3. 19
      Zend/zend_alloc.c
  4. 1
      Zend/zend_compile.c
  5. 1
      Zend/zend_execute.c
  6. 3
      Zend/zend_globals.h
  7. 1
      Zend/zend_operators.c

4
Zend/zend.h

@ -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);

1
Zend/zend_API.h

@ -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)

19
Zend/zend_alloc.c

@ -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) {

1
Zend/zend_compile.c

@ -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, ...);

1
Zend/zend_execute.c

@ -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>

3
Zend/zend_globals.h

@ -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;

1
Zend/zend_operators.c

@ -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"

Loading…
Cancel
Save