summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2004-07-30 20:16:40 +0000
committerAndi Gutmans <andi@php.net>2004-07-30 20:16:40 +0000
commit138ef9a43e9320a412a40908a8733f66aa4858c7 (patch)
tree23aea6b16bac80664ba7e17076cc6883640fce5a
parent18896d510d04ea4b0dcc9f6afac3acf7999822b5 (diff)
downloadphp-git-138ef9a43e9320a412a40908a8733f66aa4858c7.tar.gz
- Improve performance by inlining zend_ptr_stack_n_push(). var_args can
usually not be inlined by compilers.
-rw-r--r--Zend/zend_alloc.c1
-rw-r--r--Zend/zend_alloc.h1
-rw-r--r--Zend/zend_execute.c10
-rw-r--r--Zend/zend_fast_cache.h1
-rw-r--r--Zend/zend_ptr_stack.h40
5 files changed, 45 insertions, 8 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index b234bc8203..aa152fb7eb 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -800,7 +800,6 @@ ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D
}
#endif
-
/*
* Local variables:
* tab-width: 4
diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h
index 1cc09385bd..3934a383a6 100644
--- a/Zend/zend_alloc.h
+++ b/Zend/zend_alloc.h
@@ -140,7 +140,6 @@ void zend_debug_alloc_output(char *format, ...);
#define full_mem_check(silent)
#endif
-
END_EXTERN_C()
#endif
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 093cd0812e..9b78925491 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -2451,7 +2451,7 @@ int zend_fetch_class_handler(ZEND_OPCODE_HANDLER_ARGS)
int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS)
{
- zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
+ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope));
if (opline->op1.op_type == IS_VAR) {
SELECTIVE_PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr, &opline->op1);
@@ -2481,7 +2481,7 @@ int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
char *function_name_strval;
int function_name_strlen;
- zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
+ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope));
function_name = get_zval_ptr(&opline->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
@@ -2542,7 +2542,7 @@ int zend_init_static_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
zval *function_name;
zend_class_entry *ce;
- zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
+ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope));
ce = EX_T(opline->op1.u.var).class_entry;
if(opline->op2.op_type != IS_UNUSED) {
@@ -2597,7 +2597,7 @@ int zend_init_fcall_by_name_handler(ZEND_OPCODE_HANDLER_ARGS)
char *function_name_strval, *lcname;
int function_name_strlen;
- zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
+ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope));
is_const = (opline->op2.op_type == IS_CONST);
@@ -2818,7 +2818,7 @@ int zend_do_fcall_handler(ZEND_OPCODE_HANDLER_ARGS)
{
zval *fname = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R);
- zend_ptr_stack_n_push(&EG(arg_types_stack), 3, EX(fbc), EX(object), EX(calling_scope));
+ zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope));
if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) {
zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val);
diff --git a/Zend/zend_fast_cache.h b/Zend/zend_fast_cache.h
index 2d5011e713..0ed3c0279d 100644
--- a/Zend/zend_fast_cache.h
+++ b/Zend/zend_fast_cache.h
@@ -104,7 +104,6 @@ typedef struct _zend_fast_cache_list_entry {
-
/* fast cache for zval's */
#define ALLOC_ZVAL(z) \
ZEND_FAST_ALLOC(z, zval, ZVAL_CACHE_LIST)
diff --git a/Zend/zend_ptr_stack.h b/Zend/zend_ptr_stack.h
index 4a77b024eb..d94be35257 100644
--- a/Zend/zend_ptr_stack.h
+++ b/Zend/zend_ptr_stack.h
@@ -39,6 +39,46 @@ ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack);
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);
+
+
+/* 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. */
+static inline void zend_ptr_stack_3_push(zend_ptr_stack *stack, void *a, void *b, void *c)
+{
+#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;
+ }
+
+ stack->top += ZEND_PTR_STACK_NUM_ARGS;
+ *(stack->top_element++) = a;
+ *(stack->top_element++) = b;
+ *(stack->top_element++) = c;
+
+#undef ZEND_PTR_STACK_NUM_ARGS
+}
+
+/*
+ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
+{
+ 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);
+}
+*/
+
END_EXTERN_C()
static inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)