public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@golang.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
		"gofrontend-dev@googlegroups.com"
	<gofrontend-dev@googlegroups.com>
Subject: libgo patch committed: Avoid write barriers when calling deferred function
Date: Thu, 22 Jun 2017 14:33:00 -0000	[thread overview]
Message-ID: <CAOyqgcXDnK+TVog1yxMrmyg-GvBAUQ1WNoK3NGxdq-4qXTxxuw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]

Calling a deferred function in libgo currently requires changing from
a uintptr to the function code to a Go function value. That is done by
setting the value of a func local variable using unsafe.Pointer. The
local variable will always be on the stack. Adjust the code that sets
the local variable to avoid generating a write barrier.

A write barrier is never needed here. Also, for deferreturn, we must
avoid write barriers entirely when called from a cgo function; that
requires more than just this, but this is a start.

The test for this is runtime tests that use the go tool; these are not
currently run, but they will be in the future.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1621 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 249558)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-a459f1fdfe0bd365bf2def730e1529052c6487fd
+73b14da15ec731837ce2a45db658142bfbf5fe22
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/panic.go
===================================================================
--- libgo/go/runtime/panic.go	(revision 249558)
+++ libgo/go/runtime/panic.go	(working copy)
@@ -194,7 +194,7 @@ func deferreturn(frame *bool) {
 			// The gc compiler does this using assembler
 			// code in jmpdefer.
 			var fn func(unsafe.Pointer)
-			*(**uintptr)(unsafe.Pointer(&fn)) = &pfn
+			*(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn))
 			fn(d.arg)
 		}
 
@@ -259,7 +259,7 @@ func checkdefer(frame *bool) {
 			gp._defer = d.link
 
 			var fn func(unsafe.Pointer)
-			*(**uintptr)(unsafe.Pointer(&fn)) = &pfn
+			*(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn))
 			fn(d.arg)
 
 			freedefer(d)
@@ -345,7 +345,7 @@ func Goexit() {
 
 		if pfn != 0 {
 			var fn func(unsafe.Pointer)
-			*(**uintptr)(unsafe.Pointer(&fn)) = &pfn
+			*(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn))
 			fn(d.arg)
 		}
 
@@ -446,7 +446,7 @@ func gopanic(e interface{}) {
 
 		if pfn != 0 {
 			var fn func(unsafe.Pointer)
-			*(**uintptr)(unsafe.Pointer(&fn)) = &pfn
+			*(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn))
 			fn(d.arg)
 
 			if p.recovered {

                 reply	other threads:[~2017-06-22 14:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOyqgcXDnK+TVog1yxMrmyg-GvBAUQ1WNoK3NGxdq-4qXTxxuw@mail.gmail.com \
    --to=iant@golang.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).