From patchwork Mon Jun 3 23:04:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1109550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502260-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NxblBdBO"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.b="gPpExylC"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45HrH83Spgz9s4Y for ; Tue, 4 Jun 2019 09:04:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=Zb0abpcGYjJP8yLK4UAyO7szssAZNMOI0erUozvwauuz04 DXQVStSBfAyo96aKvuGUY9+V9T+dnX0c5C3C9NFcKkf4sSdYkAoc65sLE+cn0R0Y WK9qjvHlnzqicqAYvucU3vLKkxRg1RzmPy1nPwXWX7vKq7Dc0WaRziUirWWls= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=eGIFyq8+rSTauVrLf2BnPfMX+wY=; b=NxblBdBO9Ed8i8fIAIfY aIOchc/cnxIEqwOHeANVUEalW5Qq52P+ptFN0Jb+h8ZAajxxQq6Q2bisCNt/rwxm GWpvT/jujKo1z6QnNBTGMjQOVN7F8oC7IqfeHcMh+wP+EgjYjdzDFoVWb+1auxLs KC0Wf3rfMh0mHq/+c6fW2m8= Received: (qmail 97261 invoked by alias); 3 Jun 2019 23:04:45 -0000 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 Received: (qmail 97253 invoked by uid 89); 3 Jun 2019 23:04:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=permit X-HELO: mail-lj1-f171.google.com Received: from mail-lj1-f171.google.com (HELO mail-lj1-f171.google.com) (209.85.208.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 23:04:43 +0000 Received: by mail-lj1-f171.google.com with SMTP id s21so7198684lji.8 for ; Mon, 03 Jun 2019 16:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=gvtQ3Orz4HSqNgvtfCarVRz+pgyGpIhtfIRf3WoZblU=; b=gPpExylCaF9bCrV379Zg/eiblG7kILwuKsSPrtLPKsqaXHBtPsasi/OqpLRib4dLrK 7h4qGcMHAXKGw4S2fDGfGv8c9ZIEb8JGBqq91QquMu8mKdyV+cxR1fcqM5+GTCfCsqxj U8PPpekS7bs4g747CGLuKB7JZv0fjEAKXHCd9sFeyuqmzwNcUyDDOWPP6YkSE4m1pgD/ tfZF67SNgynMJVwMz5otYcA0zkD8PpskZN7ahxhCd80qDsMr7k9lNGMgIO+XJbivN2b+ o2jdene84NDJpDsc6nNOU4rNopM5nyWq4z1SitTbYocnJChmfW23o75BKRhms5vyun+B WPrw== MIME-Version: 1.0 From: Ian Lance Taylor Date: Mon, 3 Jun 2019 16:04:30 -0700 Message-ID: Subject: Go patch committed: Permit inlining references to global variables To: gcc-patches , gofrontend-dev This patch to the Go frontend permits inlining references to global variables. This requires tracking all references to unexported variables, so that we can make them global symbols in the object file, and can export them so that other compilations can see the right definition for their own inline bodies. This introduces a syntax for referencing names defined in other packages: a prefix, where NN is the package index. This will need to be added to gccgoimporter, but I didn't do it yet since it isn't yet possible to create an object for which gccgoimporter will see a prefix. This increases the number of inlinable functions in the standard library from 181 to 215, adding functions like context.Background.f Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 271883) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -2e623bff8a5855bb6268c69bb04eb37cac8f2dc2 +95784e8eec75cfeb2363fb22b51085380e564af9 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/stubs.go =================================================================== --- libgo/go/runtime/stubs.go (revision 271669) +++ libgo/go/runtime/stubs.go (working copy) @@ -310,13 +310,6 @@ func errno() int func entersyscall() func entersyscallblock() -// For gccgo to call from C code, so that the C code and the Go code -// can share the memstats variable for now. -//go:linkname getMstats runtime.getMstats -func getMstats() *mstats { - return &memstats -} - // Get signal trampoline, written in C. func getSigtramp() uintptr @@ -338,48 +331,12 @@ func dumpregs(*_siginfo_t, unsafe.Pointe // Implemented in C for gccgo. func setRandomNumber(uint32) -// Temporary for gccgo until we port proc.go. -//go:linkname getsched runtime.getsched -func getsched() *schedt { - return &sched -} - -// Temporary for gccgo until we port proc.go. -//go:linkname getCgoHasExtraM runtime.getCgoHasExtraM -func getCgoHasExtraM() *bool { - return &cgoHasExtraM -} - -// Temporary for gccgo until we port proc.go. -//go:linkname getAllP runtime.getAllP -func getAllP() **p { - return &allp[0] -} - -// Temporary for gccgo until we port proc.go. +// Called by gccgo's proc.c. //go:linkname allocg runtime.allocg func allocg() *g { return new(g) } -// Temporary for gccgo until we port the garbage collector. -//go:linkname getallglen runtime.getallglen -func getallglen() uintptr { - return allglen -} - -// Temporary for gccgo until we port the garbage collector. -//go:linkname getallg runtime.getallg -func getallg(i int) *g { - return allgs[i] -} - -// Temporary for gccgo until we port the garbage collector. -//go:linkname getallm runtime.getallm -func getallm() *m { - return allm -} - // Throw and rethrow an exception. func throwException() func rethrowException() @@ -388,13 +345,6 @@ func rethrowException() // used by the stack unwinder. func unwindExceptionSize() uintptr -// Temporary for gccgo until C code no longer needs it. -//go:nosplit -//go:linkname getPanicking runtime.getPanicking -func getPanicking() uint32 { - return panicking -} - // Called by C code to set the number of CPUs. //go:linkname setncpu runtime.setncpu func setncpu(n int32) { @@ -409,18 +359,6 @@ func setpagesize(s uintptr) { } } -// Called by C code during library initialization. -//go:linkname runtime_m0 runtime.runtime_m0 -func runtime_m0() *m { - return &m0 -} - -// Temporary for gccgo until we port mgc.go. -//go:linkname runtime_g0 runtime.runtime_g0 -func runtime_g0() *g { - return &g0 -} - const uintptrMask = 1<<(8*sys.PtrSize) - 1 type bitvector struct { Index: libgo/runtime/go-libmain.c =================================================================== --- libgo/runtime/go-libmain.c (revision 271669) +++ libgo/runtime/go-libmain.c (working copy) @@ -230,7 +230,6 @@ gostart (void *arg) runtime_args (a->argc, (byte **) a->argv); setncpu (getproccount ()); setpagesize (getpagesize ()); - runtime_sched = runtime_getsched(); runtime_schedinit (); __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); Index: libgo/runtime/go-main.c =================================================================== --- libgo/runtime/go-main.c (revision 271669) +++ libgo/runtime/go-main.c (working copy) @@ -54,7 +54,6 @@ main (int argc, char **argv) runtime_args (argc, (byte **) argv); setncpu (getproccount ()); setpagesize (getpagesize ()); - runtime_sched = runtime_getsched(); runtime_schedinit (); __go_go ((uintptr)(runtime_main), NULL); runtime_mstart (runtime_m ()); Index: libgo/runtime/proc.c =================================================================== --- libgo/runtime/proc.c (revision 271818) +++ libgo/runtime/proc.c (working copy) @@ -378,8 +378,6 @@ runtime_mcall(FuncVal *fv) extern G* allocg(void) __asm__ (GOSYM_PREFIX "runtime.allocg"); -Sched* runtime_sched; - bool runtime_isarchive; extern void kickoff(void) @@ -888,11 +886,3 @@ resetNewG(G *newg, void **sp, uintptr *s newg->gcnextsp2 = (uintptr)(newg->gcinitialsp2); #endif } - -// Return whether we are waiting for a GC. This gc toolchain uses -// preemption instead. -bool -runtime_gcwaiting(void) -{ - return runtime_sched->gcwaiting; -} Index: libgo/runtime/runtime.h =================================================================== --- libgo/runtime/runtime.h (revision 271823) +++ libgo/runtime/runtime.h (working copy) @@ -115,11 +115,6 @@ extern M* runtime_m(void); extern G* runtime_g(void) __asm__(GOSYM_PREFIX "runtime.getg"); -extern M* runtime_m0(void) - __asm__(GOSYM_PREFIX "runtime.runtime_m0"); -extern G* runtime_g0(void) - __asm__(GOSYM_PREFIX "runtime.runtime_g0"); - enum { true = 1, @@ -196,15 +191,6 @@ void runtime_hashinit(void); */ extern uintptr* runtime_getZerobase(void) __asm__(GOSYM_PREFIX "runtime.getZerobase"); -extern G* runtime_getallg(intgo) - __asm__(GOSYM_PREFIX "runtime.getallg"); -extern uintptr runtime_getallglen(void) - __asm__(GOSYM_PREFIX "runtime.getallglen"); -extern M* runtime_getallm(void) - __asm__(GOSYM_PREFIX "runtime.getallm"); -extern Sched* runtime_sched; -extern uint32 runtime_panicking(void) - __asm__ (GOSYM_PREFIX "runtime.getPanicking"); extern bool runtime_isstarted; extern bool runtime_isarchive; @@ -447,7 +433,6 @@ int32 getproccount(void); #define PREFETCH(p) __builtin_prefetch(p) -bool runtime_gcwaiting(void); void runtime_badsignal(int); Defer* runtime_newdefer(void); void runtime_freedefer(Defer*);