Skip to content

Commit

Permalink
MFH: better fix for #48409 , #48428 , #48228
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Jun 1, 2009
1 parent 083ed5b commit 2403a58
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,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) \
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_ptr_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ 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);
*c = *(--stack->top_element);
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);
Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 2 additions & 5 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -2288,9 +2288,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) {
Expand Down Expand Up @@ -4298,8 +4296,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; i<EX(op_array)->last_brk_cont; i++) {
Expand Down
7 changes: 2 additions & 5 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,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) {
Expand Down Expand Up @@ -638,8 +636,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; i<EX(op_array)->last_brk_cont; i++) {
Expand Down

0 comments on commit 2403a58

Please sign in to comment.