From f47c38245ff6976c5d1fc27a79f239bba00fc333 Mon Sep 17 00:00:00 2001 From: Breno Leitao Date: Mon, 16 Dec 2019 01:05:21 +0000 Subject: gc.h: Add SET_MACHINE_STACK_END specific for Powerpc64 (#1767) Currently we are not able to grab the correct end/top of the stack on powerpc64 due to the fact that it uses the fallback function. The fallback function does not return the correct top of the stack because it adds a new frame and the returned top of the stack contains this frame overhead that could be something around 112 bytes on Powerpc64. This patch simply gets the correct top of the stack pointer, which is always on r1 register according to both ABI v1 and ABI v2 (Little endian). Signed-off-by: Breno Leitao --- gc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gc.h b/gc.h index 7c7f0efd1b..cf794fa514 100644 --- a/gc.h +++ b/gc.h @@ -6,6 +6,8 @@ #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p))) #elif defined(__i386) && defined(__GNUC__) #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p))) +#elif defined(__powerpc64__) && defined(__GNUC__) +#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p))) #else NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p) -- cgit v1.2.3