From: Arnaud Le Blanc Date: Mon, 1 Jun 2009 15:07:27 +0000 (+0000) Subject: better fix for #48409 , #48428 , #48228 X-Git-Tag: php-5.4.0alpha1~191^2~3432 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07f2ac9f0aa8094c1e72d487163449264d932f47;p=php better fix for #48409 , #48428 , #48228 --- diff --git a/Zend/zend.h b/Zend/zend.h index 3acdcf17dc..8cf757bb46 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -193,6 +193,12 @@ char *alloca (); # define ZEND_FASTCALL #endif +#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400 +#else +# define __restrict__ +#endif +#define restrict __restrict__ + #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN) # define ZEND_ALLOCA_MAX_SIZE (32 * 1024) # define ALLOCA_FLAG(name) \ diff --git a/Zend/zend_ptr_stack.h b/Zend/zend_ptr_stack.h index ffa074608e..7230375c5d 100644 --- a/Zend/zend_ptr_stack.h +++ b/Zend/zend_ptr_stack.h @@ -81,7 +81,7 @@ static inline void zend_ptr_stack_2_push(zend_ptr_stack *stack, void *a, void *b #undef ZEND_PTR_STACK_NUM_ARGS } -static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void **b, void **c) +static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, zend_alias *restrict a, zend_alias *restrict b, zend_alias *restrict c) { *a = *(--stack->top_element); *b = *(--stack->top_element); @@ -89,7 +89,7 @@ static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void ** stack->top -= 3; } -static inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, void **a, void **b) +static inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, zend_alias *restrict a, zend_alias *restrict b) { *a = *(--stack->top_element); *b = *(--stack->top_element); diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 124adf4adf..e3d765529c 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -50,6 +50,12 @@ typedef long zend_intptr_t; typedef unsigned long zend_uintptr_t; #endif +#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400 +typedef void* __attribute__((__may_alias__)) zend_alias; +#else +typedef void* zend_alias; +#endif + typedef unsigned int zend_object_handle; typedef struct _zend_object_handlers zend_object_handlers; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 7f5e364e2d..8909566e2d 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2362,9 +2362,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) EG(called_scope) = EX(called_scope); } - EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack)); + zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc)); EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { @@ -4490,8 +4488,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) zval_ptr_dtor(&EX(object)); } EX(called_scope) = DECODE_CTOR(EX(called_scope)); - EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack)); + zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc)); } for (i=0; ilast_brk_cont; i++) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 742c42c828..9e1d11fb90 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -298,9 +298,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR EG(called_scope) = EX(called_scope); } - EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack)); + zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc)); EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC); if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { @@ -646,8 +644,7 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER zval_ptr_dtor(&EX(object)); } EX(called_scope) = DECODE_CTOR(EX(called_scope)); - EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack)); - EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack)); + zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc)); } for (i=0; ilast_brk_cont; i++) {