From 0fd427fda70d635a526efc8cf40251718e5a45bf Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 25 Apr 2018 16:53:04 -0400 Subject: 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 --- src/runtime/stack.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 63a286bf59..2d10ac8381 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -625,10 +625,11 @@ func adjustframe(frame *stkframe, arg unsafe.Pointer) bool { // have full GC info for it (because it is written in asm). return true } + pcdata := int32(-1) // Use the entry map at function entry if targetpc != f.entry { targetpc-- + pcdata = pcdatavalue(f, _PCDATA_StackMapIndex, targetpc, &adjinfo.cache) } - pcdata := pcdatavalue(f, _PCDATA_StackMapIndex, targetpc, &adjinfo.cache) if pcdata == -1 { pcdata = 0 // in prologue } -- cgit v1.3