mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Improve performance by inlining zend_ptr_stack_n_push(). var_args can
usually not be inlined by compilers.
This commit is contained in:
parent
18896d510d
commit
138ef9a43e
5 changed files with 45 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -140,7 +140,6 @@ void zend_debug_alloc_output(char *format, ...);
|
|||
#define full_mem_check(silent)
|
||||
#endif
|
||||
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue