aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-06-22 14:33:13 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-22 14:33:13 +0000
commitc8a47c4877889b42afc5e3804c0fc575770564f2 (patch)
treecd867e8bbd31844fdb91beae7951b4a13cc9ceb6 /libgo
parentb92e4dff0a767a4e39dac6a012e381816ee5937a (diff)
downloadgcc-c8a47c4877889b42afc5e3804c0fc575770564f2.zip
gcc-c8a47c4877889b42afc5e3804c0fc575770564f2.tar.gz
gcc-c8a47c4877889b42afc5e3804c0fc575770564f2.tar.bz2
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 From-SVN: r249559
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/panic.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go
index bbd34b4..de3c79f 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 {