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 <leitao@debian.org>
This commit is contained in:
Breno Leitao 2019-12-16 01:05:21 +00:00 committed by 卜部昌平
parent e8c62836a6
commit f47c38245f
1 changed files with 2 additions and 0 deletions

2
gc.h
View File

@ -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)