diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-22 14:33:13 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-06-22 14:33:13 +0000 |
commit | 6348b51714d83b5d1424e16740bca5a4376136a5 (patch) | |
tree | cd867e8bbd31844fdb91beae7951b4a13cc9ceb6 | |
parent | 1163d33351b01a0d98e5aea272fce98c0ee90551 (diff) | |
download | gcc-6348b51714d83b5d1424e16740bca5a4376136a5.tar.gz |
runtime: avoid write barriers when calling deferred function
Calling a deferred function 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.
Reviewed-on: https://go-review.googlesource.com/46455
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249559 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | libgo/go/runtime/panic.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 8ce40175bb3..a8dba3608d0 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index bbd34b40131..de3c79fe6bf 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -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 { |