Skip to content

Commit 07f2ac9

Browse files
committed
better fix for #48409 , #48428 , #48228
1 parent 5904ee8 commit 07f2ac9

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

Zend/zend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ char *alloca ();
193193
# define ZEND_FASTCALL
194194
#endif
195195

196+
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400
197+
#else
198+
# define __restrict__
199+
#endif
200+
#define restrict __restrict__
201+
196202
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
197203
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
198204
# define ALLOCA_FLAG(name) \

Zend/zend_ptr_stack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ static inline void zend_ptr_stack_2_push(zend_ptr_stack *stack, void *a, void *b
8181
#undef ZEND_PTR_STACK_NUM_ARGS
8282
}
8383

84-
static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void **b, void **c)
84+
static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, zend_alias *restrict a, zend_alias *restrict b, zend_alias *restrict c)
8585
{
8686
*a = *(--stack->top_element);
8787
*b = *(--stack->top_element);
8888
*c = *(--stack->top_element);
8989
stack->top -= 3;
9090
}
9191

92-
static inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, void **a, void **b)
92+
static inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, zend_alias *restrict a, zend_alias *restrict b)
9393
{
9494
*a = *(--stack->top_element);
9595
*b = *(--stack->top_element);

Zend/zend_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ typedef long zend_intptr_t;
5050
typedef unsigned long zend_uintptr_t;
5151
#endif
5252

53+
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400
54+
typedef void* __attribute__((__may_alias__)) zend_alias;
55+
#else
56+
typedef void* zend_alias;
57+
#endif
58+
5359
typedef unsigned int zend_object_handle;
5460
typedef struct _zend_object_handlers zend_object_handlers;
5561

Zend/zend_vm_def.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,9 +2362,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
23622362
EG(called_scope) = EX(called_scope);
23632363
}
23642364

2365-
EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack));
2366-
EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack));
2367-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
2365+
zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc));
23682366
EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC);
23692367

23702368
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
@@ -4490,8 +4488,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
44904488
zval_ptr_dtor(&EX(object));
44914489
}
44924490
EX(called_scope) = DECODE_CTOR(EX(called_scope));
4493-
EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack));
4494-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
4491+
zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc));
44954492
}
44964493

44974494
for (i=0; i<EX(op_array)->last_brk_cont; i++) {

Zend/zend_vm_execute.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
298298
EG(called_scope) = EX(called_scope);
299299
}
300300

301-
EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack));
302-
EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack));
303-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
301+
zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc));
304302
EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC);
305303

306304
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
646644
zval_ptr_dtor(&EX(object));
647645
}
648646
EX(called_scope) = DECODE_CTOR(EX(called_scope));
649-
EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack));
650-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
647+
zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc));
651648
}
652649

653650
for (i=0; i<EX(op_array)->last_brk_cont; i++) {

0 commit comments

Comments
 (0)