cvs: ZendEngine2 / zend_alloc.c zend_alloc.h zend_execute.c zend_fast_cache.h zend_ptr_stack.h
| From: | Andi Gutmans | Date: | Fri, 30 Jul 2004 20:16:40 +0000 |
| Subject: | cvs: ZendEngine2 / zend_alloc.c zend_alloc.h zend_execute.c zend_fast_cache.h zend_ptr_stack.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2828@lists.php.net to get a copy of this message | ||
andi Fri Jul 30 16:16:40 2004 EDT
Modified files:
/ZendEngine2 zend_alloc.c zend_alloc.h zend_execute.c
zend_fast_cache.h zend_ptr_stack.h
Log:
- Improve performance by inlining zend_ptr_stack_n_push(). var_args can
usually not be inlined by compilers.
http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.c?r1=1.139&r2=1.140&ty=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.139 ZendEngine2/zend_alloc.c:1.140
--- ZendEngine2/zend_alloc.c:1.139 Tue Jul 20 17:55:57 2004
+++ ZendEngine2/zend_alloc.c Fri Jul 30 16:16:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.c,v 1.139 2004/07/20 21:55:57 moriyoshi Exp $ */
+/* $Id: zend_alloc.c,v 1.140 2004/07/30 20:16:40 andi Exp $ */
#include "zend.h"
#include "zend_alloc.h"
@@ -799,7 +799,6 @@
zend_debug_alloc_output("------------------------------------------------\n");
}
#endif
-
/*
* Local variables:
http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.h?r1=1.55&r2=1.56&ty=u
Index: ZendEngine2/zend_alloc.h
diff -u ZendEngine2/zend_alloc.h:1.55 ZendEngine2/zend_alloc.h:1.56
--- ZendEngine2/zend_alloc.h:1.55 Tue Jul 20 17:55:57 2004
+++ ZendEngine2/zend_alloc.h Fri Jul 30 16:16:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.h,v 1.55 2004/07/20 21:55:57 moriyoshi Exp $ */
+/* $Id: zend_alloc.h,v 1.56 2004/07/30 20:16:40 andi Exp $ */
#ifndef ZEND_ALLOC_H
#define ZEND_ALLOC_H
@@ -139,7 +139,6 @@
#define mem_block_check(type, ptr, silent)
#define full_mem_check(silent)
#endif
-
END_EXTERN_C()
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.660&r2=1.661&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.660 ZendEngine2/zend_execute.c:1.661
--- ZendEngine2/zend_execute.c:1.660 Thu Jul 29 13:45:30 2004
+++ ZendEngine2/zend_execute.c Fri Jul 30 16:16:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.660 2004/07/29 17:45:30 pollita Exp $ */
+/* $Id: zend_execute.c,v 1.661 2004/07/30 20:16:40 andi Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2451,7 +2451,7 @@
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 @@
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 @@
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 @@
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 @@
{
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);
http://cvs.php.net/diff.php/ZendEngine2/zend_fast_cache.h?r1=1.19&r2=1.20&ty=u
Index: ZendEngine2/zend_fast_cache.h
diff -u ZendEngine2/zend_fast_cache.h:1.19 ZendEngine2/zend_fast_cache.h:1.20
--- ZendEngine2/zend_fast_cache.h:1.19 Thu Jan 8 12:31:47 2004
+++ ZendEngine2/zend_fast_cache.h Fri Jul 30 16:16:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_fast_cache.h,v 1.19 2004/01/08 17:31:47 sniper Exp $ */
+/* $Id: zend_fast_cache.h,v 1.20 2004/07/30 20:16:40 andi Exp $ */
#ifndef ZEND_FAST_CACHE_H
#define ZEND_FAST_CACHE_H
@@ -101,7 +101,6 @@
efree_rel(p)
#endif /* ZEND_ENABLE_FAST_CACHE */
-
http://cvs.php.net/diff.php/ZendEngine2/zend_ptr_stack.h?r1=1.19&r2=1.20&ty=u
Index: ZendEngine2/zend_ptr_stack.h
diff -u ZendEngine2/zend_ptr_stack.h:1.19 ZendEngine2/zend_ptr_stack.h:1.20
--- ZendEngine2/zend_ptr_stack.h:1.19 Wed Feb 18 17:44:40 2004
+++ ZendEngine2/zend_ptr_stack.h Fri Jul 30 16:16:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ptr_stack.h,v 1.19 2004/02/18 22:44:40 hholzgra Exp $ */
+/* $Id: zend_ptr_stack.h,v 1.20 2004/07/30 20:16:40 andi Exp $ */
#ifndef ZEND_PTR_STACK_H
#define ZEND_PTR_STACK_H
@@ -39,6 +39,46 @@
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)