From patchwork Mon Jul 15 21:17:24 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: 1132313 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-505110-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="YGyFxAAh"; 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="hSXdMVev"; 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 45nbwF1CKlz9sBt for ; Tue, 16 Jul 2019 07:17:47 +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=wywSGl/k4/i7HrwLpT4gBt1xn1ASTu0UuV4Qz1tKtPUqpI gju2nfT2mmXMNzLsGSNNX/NKdo1uWhWNTTdCmJkc1r/+tMjwKk+ZU3fgMRhTC2m7 MgUyaX7Fbjusy7LVS3Col4gV66+nhQm4Q2CYD1wEVir6EENsUwRytL3N4TCQY= 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=vmcTxMFoq2d9D5j6QZMKM3wh4OU=; b=YGyFxAAhxaS/9kyR6jIh kQp8lJ1aCu5opO/+eBpxa3FRQkYAsa6q5ZXtA3es1QOUZffEgSGVcYR5K5v0Wuma U8DBKYoM9YPjFXJlCHudJ70zIWabhgGXb7apIhV81H2YlufLPbLuCjSnINREHfcl /r0D34uYBOkq6Ebee5URvtU= Received: (qmail 11254 invoked by alias); 15 Jul 2019 21:17:40 -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 10977 invoked by uid 89); 15 Jul 2019 21:17:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HTo:D*googlegroups.com, H*Ad:D*googlegroups.com, zhang, Zhang X-HELO: mail-lf1-f46.google.com Received: from mail-lf1-f46.google.com (HELO mail-lf1-f46.google.com) (209.85.167.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Jul 2019 21:17:38 +0000 Received: by mail-lf1-f46.google.com with SMTP id c9so12034168lfh.4 for ; Mon, 15 Jul 2019 14:17:38 -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=BUMdaWO/bC4XTO+rWNatgpeOPM6lB3aBQJ6MeMaHGvs=; b=hSXdMVevq05KMSJoS9jZkBNh6bZTa6kwh6lPEYZnCIvheRSRf2XKBsJXEBE6t8A9fK CfzsMbqnS53ghC1v/WNNSGAcggh85VxtpoUjnAvxzcgla/CFkS/3oeP5plrJeMNvQcY3 LemqiMPmkjI6hjF+FA45FeSBt2TMz2QO4gRYQ7IIU7zBh1A+z1ZhbHN7Gvdkdit440zh QaS6tfh+CoL8uA8Ot0UNQ1h5szTMgiSnKXO95Hmpf3XDwVAnZn78wg3dyjLxdEip7WqY pxkZK9VZMEebOk0wgukG7DfwcynlnqMugokcfXVS/nT/7/DWgdrtMQEAydXx7LMINQ7a KZyg== MIME-Version: 1.0 From: Ian Lance Taylor Date: Mon, 15 Jul 2019 14:17:24 -0700 Message-ID: Subject: libgo patch committed: Expose the g variable To: gcc-patches , gofrontend-dev This libgo patch by Cherry Zhang expose the thread-local g variable. Currently, getg is implemented in C, which loads the thread-local g variable. The g variable is declared static in C. This CL exposes the g variable, so it can be accessed from the Go side. This allows the Go compiler to inline getg calls to direct access of g. The actual inlining is not yet implemented in gccgo, because it runs into trouble when the address of the thread-local variable is cached across a function call that changes threads. We will need to develop a mechanism to disable that caching for at least some functions. There doesn't seem to be one currently. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 273494) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -70ceba5e95716653b9f829a457a44a829175d4da +0e51b7e9c03c6f6bc3d06343f2050f17349ccdc3 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/runtime/proc.c =================================================================== --- libgo/runtime/proc.c (revision 273494) +++ libgo/runtime/proc.c (working copy) @@ -65,7 +65,7 @@ static void gscanstack(G*); #define __thread #endif -static __thread G *g; +__thread G *g __asm__(GOSYM_PREFIX "runtime.g"); #ifndef SETCONTEXT_CLOBBERS_TLS @@ -320,7 +320,7 @@ runtime_mcall(FuncVal *fv) if(gp != nil) { #ifdef USING_SPLIT_STACK - __splitstack_getcontext((void*)(&g->stackcontext[0])); + __splitstack_getcontext((void*)(&gp->stackcontext[0])); #else // We have to point to an address on the stack that is // below the saved registers.