diff options
author | Cherry Zhang <cherryyz@google.com> | 2021-04-02 13:24:35 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2021-04-23 21:05:39 +0000 |
commit | 142151697397235ba5f30a7a660ed8a159adce0b (patch) | |
tree | eb10ad530ae354ba5304cc4e1ce28f26b12f9399 /src/runtime/proc.go | |
parent | 691e1b84c11d038060807f9c79107996ca2f19ae (diff) | |
download | go-142151697397235ba5f30a7a660ed8a159adce0b.tar.gz go-142151697397235ba5f30a7a660ed8a159adce0b.zip |
cmd/compile, internal/abi: add FuncPCABIxxx intrinsics
When ABI wrappers are used, there are cases where in Go code we
need the PC of the defined function instead of the ABI wrapper.
Currently we work around this by define such functions as
ABIInternal, even if they do not actually follow the internal ABI.
This CL introduces internal/abi.FuncPCABIxxx functions as compiler
intrinsics, which return the underlying defined function's entry
PC if the argument is a direct reference of a function of the
expected ABI, and reject it if it is of a different ABI.
As a proof of concept, change runtime.goexit back to ABI0 and use
internal/abi.FuncPCABI0 to retrieve its PC.
Updates #44065.
Change-Id: I02286f0f9d99e6a3090f9e8169dbafc6804a2da6
Reviewed-on: https://go-review.googlesource.com/c/go/+/304232
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r-- | src/runtime/proc.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 2f9818d9f1..1b1b5769ff 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -5,6 +5,7 @@ package runtime import ( + "internal/abi" "internal/cpu" "internal/goexperiment" "runtime/internal/atomic" @@ -2022,7 +2023,7 @@ func oneNewExtraM() { // the goroutine stack ends. mp := allocm(nil, nil, -1) gp := malg(4096) - gp.sched.pc = funcPC(goexit) + sys.PCQuantum + gp.sched.pc = abi.FuncPCABI0(goexit) + sys.PCQuantum gp.sched.sp = gp.stack.hi gp.sched.sp -= 4 * sys.PtrSize // extra space in case of reads slightly beyond frame gp.sched.lr = 0 @@ -4310,7 +4311,7 @@ func newproc1(fn *funcval, argp unsafe.Pointer, narg int32, callergp *g, callerp memclrNoHeapPointers(unsafe.Pointer(&newg.sched), unsafe.Sizeof(newg.sched)) newg.sched.sp = sp newg.stktopsp = sp - newg.sched.pc = funcPC(goexit) + sys.PCQuantum // +PCQuantum so that previous instruction is in same function + newg.sched.pc = abi.FuncPCABI0(goexit) + sys.PCQuantum // +PCQuantum so that previous instruction is in same function newg.sched.g = guintptr(unsafe.Pointer(newg)) gostartcallfn(&newg.sched, fn) newg.gopc = callerpc |