From patchwork Wed Jan 5 00:24:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 77553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 392E8B70CD for ; Wed, 5 Jan 2011 11:26:01 +1100 (EST) Received: (qmail 8602 invoked by alias); 5 Jan 2011 00:24:34 -0000 Received: (qmail 8492 invoked by uid 22791); 5 Jan 2011 00:24:31 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Jan 2011 00:24:23 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id p050OKFt025416 for ; Tue, 4 Jan 2011 16:24:20 -0800 Received: from iwn42 (iwn42.prod.google.com [10.241.68.106]) by kpbe18.cbf.corp.google.com with ESMTP id p050O1wQ024834 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Tue, 4 Jan 2011 16:24:19 -0800 Received: by iwn42 with SMTP id 42so17052583iwn.24 for ; Tue, 04 Jan 2011 16:24:18 -0800 (PST) Received: by 10.42.167.8 with SMTP id q8mr8230968icy.405.1294187058850; Tue, 04 Jan 2011 16:24:18 -0800 (PST) Received: from coign.google.com (dhcp-172-22-123-229.mtv.corp.google.com [172.22.123.229]) by mx.google.com with ESMTPS id k42sm1466802ick.20.2011.01.04.16.24.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 Jan 2011 16:24:18 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Use __builtin_unwind_init Date: Tue, 04 Jan 2011 16:24:16 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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)