From 3fcc6511f6555ca6af5f26ee6313097c42aee9ba Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Tue, 13 Apr 1999 17:03:10 +0000 Subject: [PATCH] * Optimize argument_stack top lookup * Fix a nasty bug in zend_ptr_stack_clean() --- Zend/libzend.dsp | 2 +- Zend/zend_API.c | 6 ++++-- Zend/zend_execute_API.c | 2 +- Zend/zend_ptr_stack.c | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Zend/libzend.dsp b/Zend/libzend.dsp index 9b30d47f10..9dfde8e151 100644 --- a/Zend/libzend.dsp +++ b/Zend/libzend.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /FR /YX /FD /c # ADD BASE RSC /l 0x40d /d "NDEBUG" # ADD RSC /l 0x40d /d "NDEBUG" BSC32=bscmake.exe diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 9a31fc5edc..caf097b01b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -33,7 +33,7 @@ HashTable list_destructors, module_registry; /* this function doesn't check for too many parameters */ int getParameters(int ht, int param_count,...) { - void **p = EG(argument_stack).elements+EG(argument_stack).top-1; + void **p = EG(argument_stack).top_element-1; int arg_count = (ulong) *p; va_list ptr; zval **param, *param_ptr; @@ -57,6 +57,7 @@ int getParameters(int ht, int param_count,...) new_tmp->refcount = 1; new_tmp->is_ref = 0; param_ptr = new_tmp; + ((zval *) *(p-param_count))->refcount--; *(p-param_count) = param_ptr; } *param = param_ptr; @@ -70,7 +71,7 @@ int getParameters(int ht, int param_count,...) int getParametersArray(int ht, int param_count, zval **argument_array) { - void **p = EG(argument_stack).elements+EG(argument_stack).top-1; + void **p = EG(argument_stack).top_element-1; int arg_count = (ulong) *p; zval *param_ptr; ELS_FETCH(); @@ -91,6 +92,7 @@ int getParametersArray(int ht, int param_count, zval **argument_array) new_tmp->refcount = 1; new_tmp->is_ref = 0; param_ptr = new_tmp; + ((zval *) *(p-param_count))->refcount--; *(p-param_count) = param_ptr; } *(argument_array++) = param_ptr; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 728e531a59..e10be7d706 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -466,7 +466,7 @@ ZEND_API inline void zend_ptr_stack_clear_multiple(ELS_D) ZEND_API int zend_ptr_stack_get_arg(int requested_arg, void **data) { - void **p = EG(argument_stack).elements+EG(argument_stack).top-1; + void **p = EG(argument_stack).top_element-1; int arg_count = (ulong) *p; if (requested_arg>arg_count) { diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c index db83c2bd3f..f07f942aa2 100644 --- a/Zend/zend_ptr_stack.c +++ b/Zend/zend_ptr_stack.c @@ -68,6 +68,7 @@ ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *)) { zend_ptr_stack_apply(stack, func); stack->top = 0; + stack->top_element = stack->elements; } -- 2.40.0