diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-01-10 05:15:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-01-10 05:15:52 +0000 |
commit | e4876be5f5c5524ea742527100e36c5095181b28 (patch) | |
tree | c910fc6515e88a22e58ae52d5a5d7f80e0cfc982 /libgo/go/runtime/panic.go | |
parent | fe9e1702687db062ad2f13939177e1c5f68c8e05 (diff) | |
download | gcc-e4876be5f5c5524ea742527100e36c5095181b28.zip gcc-e4876be5f5c5524ea742527100e36c5095181b28.tar.gz gcc-e4876be5f5c5524ea742527100e36c5095181b28.tar.bz2 |
runtime: noescape some functions/variables
This is in preparation of turning on escape analysis for the
runtime.
- In gccgo, systemstack is implemented with mcall, which is not
go:noescape. Wrap the closure in noescape so the escape analysis
does not think it escapes.
- Mark some C functions go:noescape. They do not leak arguments.
- Use noescape function to make a few local variables' addresses
not escape. The escape analysis cannot figure out because they
are assigned to pointer indirections.
Reviewed-on: https://go-review.googlesource.com/86244
From-SVN: r256418
Diffstat (limited to 'libgo/go/runtime/panic.go')
-rw-r--r-- | libgo/go/runtime/panic.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index 5cc325f..b2deb6e 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -201,7 +201,7 @@ func deferreturn(frame *bool) { // The gc compiler does this using assembler // code in jmpdefer. var fn func(unsafe.Pointer) - *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn)) + *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) fn(d.arg) } @@ -264,7 +264,7 @@ func checkdefer(frame *bool) { var p _panic p.isforeign = true p.link = gp._panic - gp._panic = &p + gp._panic = (*_panic)(noescape(unsafe.Pointer(&p))) for { d := gp._defer if d == nil || d.frame != frame || d.pfn == 0 { @@ -275,7 +275,7 @@ func checkdefer(frame *bool) { gp._defer = d.link var fn func(unsafe.Pointer) - *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn)) + *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) fn(d.arg) freedefer(d) @@ -368,7 +368,7 @@ func Goexit() { d.pfn = 0 var fn func(unsafe.Pointer) - *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn)) + *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) fn(d.arg) if gp._defer != d { @@ -491,7 +491,7 @@ func gopanic(e interface{}) { d._panic = p var fn func(unsafe.Pointer) - *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(unsafe.Pointer(&pfn)) + *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) fn(d.arg) if gp._defer != d { |