This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Use __builtin_unwind_init
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 04 Jan 2011 16:24:16 -0800
- Subject: Go patch committed: Use __builtin_unwind_init
The Go runtime library used a hack, SAVE_REGS, to force all callee-saved
registers to be saved on the stack, so that the garbage collector can
see them reliably. Joseph pointed out in a comment in PR 46964 that the
__builtin_unwind_init function does the same thing. This is in fact
what the Boehm garbage collector does. This patch uses the builtin
function rather than the SAVE_REGS hack. This fixes PRs 46959, 46960,
46961, 46962, 46963, and 46964, which are about different targets
failing to define SAVE_REGS. Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r e88088fffdd4 libgo/runtime/go-go.c
--- a/libgo/runtime/go-go.c Tue Jan 04 16:06:33 2011 -0800
+++ b/libgo/runtime/go-go.c Tue Jan 04 16:19:01 2011 -0800
@@ -25,21 +25,6 @@
void **);
#endif
-/* We need to ensure that all callee-saved registers are stored on the
- stack, in case they hold pointers. */
-
-#if defined(__i386__)
- #ifndef __PIC__
- #define SAVE_REGS asm ("" : : : "esi", "edi", "ebx")
- #else
- #define SAVE_REGS asm ("" : : : "esi", "edi")
- #endif
-#elif defined(__x86_64__)
- #define SAVE_REGS asm ("" : : : "r12", "r13", "r14", "r15", "rbp", "rbx")
-#else
- #error must define SAVE_REGS
-#endif
-
/* We stop the threads by sending them the signal GO_SIG_STOP and we
start them by sending them the signal GO_SIG_START. */
@@ -344,7 +329,7 @@
needed if we are called directly, since otherwise we might miss
something that a function somewhere up the call stack is holding
in a register. */
- SAVE_REGS;
+ __builtin_unwind_init ();
stop_for_gc ();
@@ -433,7 +418,7 @@
struct __go_thread_id *p;
/* Make sure all the registers for this thread are on the stack. */
- SAVE_REGS;
+ __builtin_unwind_init ();
me = pthread_self ();
for (p = __go_all_thread_ids; p != NULL; p = p->next)