From: Ian Lance Taylor Date: Wed, 7 Feb 2018 22:04:55 +0000 (+0000) Subject: runtime: don't call funcPC from a function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1a2d8b1b51ee77499ccf8ed3b4b49ca5307ddb4;p=gcc.git runtime: don't call funcPC from a function The escape analysis support is not yet good enough to avoid escaping the argument to funcPC. This causes unnecessary and often harmful memory allocation. E.g., (*cpuProfile).addExtra can be called from a signal handler, and it must not allocate memory. Move the calls to funcPC to use variables instead. This was done in the original migration to using funcPC, but was not done for newer code. In one case, in signal handling code, use getSigtramp. Reviewed-on: https://go-review.googlesource.com/92735 From-SVN: r257463 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 81e11d1946f..f1a43770690 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -5fe998e4a18cc1dbbd4869be5c8202bda55adb33 +cdc28627b7abfd73f5d552813db8eb4293b823b0 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/cpuprof.go b/libgo/go/runtime/cpuprof.go index 91cdf2b5594..b1a7c3bcd1b 100644 --- a/libgo/go/runtime/cpuprof.go +++ b/libgo/go/runtime/cpuprof.go @@ -156,8 +156,8 @@ func (p *cpuProfile) addExtra() { if p.lostExtra > 0 { hdr := [1]uint64{p.lostExtra} lostStk := [2]uintptr{ - funcPC(_LostExternalCode) + sys.PCQuantum, - funcPC(_ExternalCode) + sys.PCQuantum, + _LostExternalCodePC + sys.PCQuantum, + _ExternalCodePC + sys.PCQuantum, } cpuprof.log.write(nil, 0, hdr[:], lostStk[:]) p.lostExtra = 0 @@ -167,8 +167,8 @@ func (p *cpuProfile) addExtra() { func (p *cpuProfile) addLostAtomic64(count uint64) { hdr := [1]uint64{count} lostStk := [2]uintptr{ - funcPC(_LostSIGPROFDuringAtomic64) + sys.PCQuantum, - funcPC(_System) + sys.PCQuantum, + _LostSIGPROFDuringAtomic64PC + sys.PCQuantum, + _SystemPC + sys.PCQuantum, } cpuprof.log.write(nil, 0, hdr[:], lostStk[:]) } diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index 2972daa059f..edf41405c1c 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -3369,7 +3369,9 @@ var lostAtomic64Count uint64 var _SystemPC = funcPC(_System) var _ExternalCodePC = funcPC(_ExternalCode) +var _LostExternalCodePC = funcPC(_LostExternalCode) var _GCPC = funcPC(_GC) +var _LostSIGPROFDuringAtomic64PC = funcPC(_LostSIGPROFDuringAtomic64) // Called if we receive a SIGPROF signal. // Called by the signal handler, may run during STW. @@ -3469,7 +3471,7 @@ func sigprofNonGoPC(pc uintptr) { if prof.hz != 0 { stk := []uintptr{ pc, - funcPC(_ExternalCode) + sys.PCQuantum, + _ExternalCodePC + sys.PCQuantum, } cpuprof.addNonGo(stk) } diff --git a/libgo/go/runtime/signal_unix.go b/libgo/go/runtime/signal_unix.go index 02d53488807..a8f77fa9bcf 100644 --- a/libgo/go/runtime/signal_unix.go +++ b/libgo/go/runtime/signal_unix.go @@ -245,7 +245,7 @@ func setProcessCPUProfiler(hz int32) { // Enable the Go signal handler if not enabled. if atomic.Cas(&handlingSig[_SIGPROF], 0, 1) { atomic.Storeuintptr(&fwdSig[_SIGPROF], getsig(_SIGPROF)) - setsig(_SIGPROF, funcPC(sighandler)) + setsig(_SIGPROF, getSigtramp()) } } else { // If the Go signal handler should be disabled by default,