andi Fri Jul 30 17:00:38 2004 EDT
Modified files:
/ZendEngine2 zend_execute.c zend_execute_API.c zend_ptr_stack.c
zend_ptr_stack.h
Log:
- More ptr_stack optimizations and cleanups
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.661&r2=1.662&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.661 ZendEngine2/zend_execute.c:1.662
--- ZendEngine2/zend_execute.c:1.661 Fri Jul 30 16:16:40 2004
+++ ZendEngine2/zend_execute.c Fri Jul 30 17:00:37 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.661 2004/07/30 20:16:40 andi Exp $ */
+/* $Id: zend_execute.c,v 1.662 2004/07/30 21:00:37 andi Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2646,7 +2646,7 @@
NEXT_OPCODE(); /* Never reached */
}
- zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *)
opline->extended_value, NULL);
+ zend_ptr_stack_2_push(&EG(argument_stack), (void *)
opline->extended_value, NULL);
EX_T(opline->result.u.var).var.ptr_ptr =
&EX_T(opline->result.u.var).var.ptr;
@@ -2790,7 +2790,7 @@
EG(This) = current_this;
EG(scope) = current_scope;
}
- zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope),
&EX(object), &EX(fbc));
+ zend_ptr_stack_3_pop(&EG(arg_types_stack), &EX(calling_scope),
&EX(object), &EX(fbc));
EX(function_state).function = (zend_function *) op_array;
EG(function_state_ptr) = &EX(function_state);
http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.289&r2=1.290&ty=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.289
ZendEngine2/zend_execute_API.c:1.290
--- ZendEngine2/zend_execute_API.c:1.289 Sun Jul 25 03:14:25 2004
+++ ZendEngine2/zend_execute_API.c Fri Jul 30 17:00:37 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.289 2004/07/25 07:14:25 helly Exp $ */
+/* $Id: zend_execute_API.c,v 1.290 2004/07/30 21:00:37 andi Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -781,7 +781,7 @@
fci->param_count = 2;
}
- zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *) (long)
fci->param_count, NULL);
+ zend_ptr_stack_2_push(&EG(argument_stack), (void *) (long)
fci->param_count, NULL);
original_function_state_ptr = EG(function_state_ptr);
EG(function_state_ptr) = &EX(function_state);
http://cvs.php.net/diff.php/ZendEngine2/zend_ptr_stack.c?r1=1.21&r2=1.22&ty=u
Index: ZendEngine2/zend_ptr_stack.c
diff -u ZendEngine2/zend_ptr_stack.c:1.21 ZendEngine2/zend_ptr_stack.c:1.22
--- ZendEngine2/zend_ptr_stack.c:1.21 Thu Jan 8 12:31:48 2004
+++ ZendEngine2/zend_ptr_stack.c Fri Jul 30 17:00:37 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ptr_stack.c,v 1.21 2004/01/08 17:31:48 sniper Exp $ */
+/* $Id: zend_ptr_stack.c,v 1.22 2004/07/30 21:00:37 andi Exp $ */
#include "zend.h"
#include "zend_ptr_stack.h"
@@ -38,12 +38,8 @@
va_list ptr;
void *elem;
- if (stack->top+count > stack->max) { /* we need to allocate
more memory */
- stack->max *= 2;
- stack->max += count;
- stack->elements = (void **) erealloc(stack->elements,
(sizeof(void *) * (stack->max)));
- stack->top_element = stack->elements+stack->top;
- }
+ ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)
+
va_start(ptr, count);
while (count>0) {
elem = va_arg(ptr, void *);
http://cvs.php.net/diff.php/ZendEngine2/zend_ptr_stack.h?r1=1.20&r2=1.21&ty=u
Index: ZendEngine2/zend_ptr_stack.h
diff -u ZendEngine2/zend_ptr_stack.h:1.20 ZendEngine2/zend_ptr_stack.h:1.21
--- ZendEngine2/zend_ptr_stack.h:1.20 Fri Jul 30 16:16:40 2004
+++ ZendEngine2/zend_ptr_stack.h Fri Jul 30 17:00:37 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ptr_stack.h,v 1.20 2004/07/30 20:16:40 andi Exp $ */
+/* $Id: zend_ptr_stack.h,v 1.21 2004/07/30 21:00:37 andi Exp $ */
#ifndef ZEND_PTR_STACK_H
#define ZEND_PTR_STACK_H
@@ -39,7 +39,16 @@
ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void
*));
ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void
*), zend_bool free_elements);
ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack);
+END_EXTERN_C()
+#define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count) \
+ if (stack->top+count > stack->max) {
\
+ /* we need to allocate more memory */
\
+ stack->max *= 2;
\
+ stack->max += count;
\
+ stack->elements = (void **) erealloc(stack->elements,
(sizeof(void *) * (stack->max))); \
+ stack->top_element = stack->elements+stack->top; \
+ }
/* Not doing this with a macro because of the loop unrolling in the
element assignment.
Just using a macro for 3 in the body for readability sake. */
@@ -47,12 +56,7 @@
{
#define ZEND_PTR_STACK_NUM_ARGS 3
- if (stack->top+ZEND_PTR_STACK_NUM_ARGS > stack->max) { /* we
need to allocate more memory */
- stack->max *= 2;
- stack->max += ZEND_PTR_STACK_NUM_ARGS;
- stack->elements = (void **) erealloc(stack->elements,
(sizeof(void *) * (stack->max)));
- stack->top_element = stack->elements+stack->top;
- }
+ ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
stack->top += ZEND_PTR_STACK_NUM_ARGS;
*(stack->top_element++) = a;
@@ -62,31 +66,31 @@
#undef ZEND_PTR_STACK_NUM_ARGS
}
-/*
-ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
+static inline void zend_ptr_stack_2_push(zend_ptr_stack *stack, void *a, void
*b)
{
- va_list ptr;
- void **elem;
-
- va_start(ptr, count);
- while (count>0) {
- elem = va_arg(ptr, void **);
- *elem = *(--stack->top_element);
- stack->top--;
- count--;
- }
- va_end(ptr);
+#define ZEND_PTR_STACK_NUM_ARGS 2
+
+ ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
+
+ stack->top += ZEND_PTR_STACK_NUM_ARGS;
+ *(stack->top_element++) = a;
+ *(stack->top_element++) = b;
+
+#undef ZEND_PTR_STACK_NUM_ARGS
}
-*/
-END_EXTERN_C()
+static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void
**b, void **c)
+{
+ *a = *(--stack->top_element);
+ *b = *(--stack->top_element);
+ *c = *(--stack->top_element);
+ stack->top -= 3;;
+}
static inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)
{
- if (stack->top >= stack->max) { /* we need to allocate more
memory */
- stack->elements = (void **) erealloc(stack->elements,
(sizeof(void *) * (stack->max *= 2 )));
- stack->top_element = stack->elements+stack->top;
- }
+ ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, 1)
+
stack->top++;
*(stack->top_element++) = ptr;
}
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|