Skip to content

Commit 2403a58

Browse files
committed
MFH: better fix for #48409 , #48428 , #48228
1 parent 083ed5b commit 2403a58

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
@@ -192,6 +192,12 @@ char *alloca ();
192192
# define ZEND_FASTCALL
193193
#endif
194194

195+
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3400
196+
#else
197+
# define __restrict__
198+
#endif
199+
#define restrict __restrict__
200+
195201
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
196202
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
197203
# 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
@@ -2288,9 +2288,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
22882288
EG(called_scope) = EX(called_scope);
22892289
}
22902290

2291-
EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack));
2292-
EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack));
2293-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
2291+
zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc));
22942292
EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC);
22952293

22962294
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
@@ -4298,8 +4296,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
42984296
zval_ptr_dtor(&EX(object));
42994297
}
43004298
EX(called_scope) = DECODE_CTOR(EX(called_scope));
4301-
EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack));
4302-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
4299+
zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc));
43034300
}
43044301

43054302
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
@@ -290,9 +290,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
290290
EG(called_scope) = EX(called_scope);
291291
}
292292

293-
EX(called_scope) = zend_ptr_stack_pop(&EG(arg_types_stack));
294-
EX(current_object) = zend_ptr_stack_pop(&EG(arg_types_stack));
295-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
293+
zend_ptr_stack_3_pop(&EG(arg_types_stack), (zend_alias*)&EX(called_scope), (zend_alias*)&EX(current_object), (zend_alias*)&EX(fbc));
296294
EX(function_state).arguments = zend_vm_stack_push_args(opline->extended_value TSRMLS_CC);
297295

298296
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
@@ -638,8 +636,7 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER
638636
zval_ptr_dtor(&EX(object));
639637
}
640638
EX(called_scope) = DECODE_CTOR(EX(called_scope));
641-
EX(object) = zend_ptr_stack_pop(&EG(arg_types_stack));
642-
EX(fbc) = zend_ptr_stack_pop(&EG(arg_types_stack));
639+
zend_ptr_stack_2_pop(&EG(arg_types_stack), (zend_alias*)&EX(object), (zend_alias*)&EX(fbc));
643640
}
644641

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

0 commit comments

Comments
 (0)