aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgcmark.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-04-25 16:53:04 -0400
committerAustin Clements <austin@google.com>2018-04-29 00:03:04 +0000
commit0fd427fda70d635a526efc8cf40251718e5a45bf (patch)
tree20658392a3c324f27070274a9499e82697b35f4b /src/runtime/mgcmark.go
parent3c65bb5b90e0ea367775d4c51966260b1e7c4d25 (diff)
downloadgo-0fd427fda70d635a526efc8cf40251718e5a45bf.tar.xz
runtime: use entry stack map at function entry
Currently, when the runtime looks up the stack map for a frame, it uses frame.continpc - 1 unless continpc is the function entry PC, in which case it uses frame.continpc. As a result, if continpc is the function entry point (which happens for deferred frames), it will actually look up the stack map *following* the first instruction. I think, though I am not positive, that this is always okay today because the first instruction of a function can never change the stack map. It's usually not a CALL, so it doesn't have PCDATA. Or, if it is a CALL, it has to have the entry stack map. But we're about to start emitting stack maps at every instruction that changes them, which means the first instruction can have PCDATA (notably, in leaf functions that don't have a prologue). To prepare for this, tweak how the runtime looks up stack map indexes so that if continpc is the function entry point, it directly uses the entry stack map. For #24543. Change-Id: I85aa818041cd26aff416f7b1fba186e9c8ca6568 Reviewed-on: https://go-review.googlesource.com/109349 Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mgcmark.go')
-rw-r--r--src/runtime/mgcmark.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go
index 270fa6cd32..7be2820909 100644
--- a/src/runtime/mgcmark.go
+++ b/src/runtime/mgcmark.go
@@ -801,10 +801,15 @@ func scanframeworker(frame *stkframe, cache *pcvalueCache, gcw *gcWork) {
if _DebugGC > 1 {
print("scanframe ", funcname(f), "\n")
}
+ pcdata := int32(-1)
if targetpc != f.entry {
+ // Back up to the CALL. If we're at the function entry
+ // point, we want to use the entry map (-1), even if
+ // the first instruction of the function changes the
+ // stack map.
targetpc--
+ pcdata = pcdatavalue(f, _PCDATA_StackMapIndex, targetpc, cache)
}
- pcdata := pcdatavalue(f, _PCDATA_StackMapIndex, targetpc, cache)
if pcdata == -1 {
// We do not have a valid pcdata value but there might be a
// stackmap for this function. It is likely that we are looking