From dbf442b1b2c28b77db288121ee3a7bc669cdc768 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 13 Aug 2022 21:39:56 -0400 Subject: runtime: replace stkframe.arglen/argmap with methods Currently, stkframe.arglen and stkframe.argmap are populated by gentraceback under a particular set of circumstances. But because they can be constructed from other fields in stkframe, they don't need to be computed eagerly at all. They're also rather misleading, as they're only part of computing the actual argument map and most callers should be using getStackMap, which does the rest of the work. This CL drops these fields from stkframe. It shifts the functions that used to compute them, getArgInfoFast and getArgInfo, into corresponding methods stkframe.argBytes and stkframe.argMapInternal. argBytes is expected to be used by callers that need to know only the argument frame size, while argMapInternal is used only by argBytes and getStackMap. We also move some of the logic from getStackMap into argMapInternal because the previous split of responsibilities didn't make much sense. This lets us return just a bitvector from argMapInternal, rather than both a bitvector, which carries a size, and an "actually use this size". The getArgInfoFast function was inlined before (and inl_test checked this). We drop that requirement from stkframe.argBytes because the uses of this have shifted and now it's only called from heap dumping (which never happens) and conservative stack frame scanning (which very, very rarely happens). There will be a few follow-up clean-up CLs. For #54466. This is a nice clean-up on its own, but it also serves to remove pointers from the traceback state that would eventually become troublesome write barriers once we stack-rip gentraceback. Change-Id: I107f98ed8e7b00185c081de425bbf24af02a4163 Reviewed-on: https://go-review.googlesource.com/c/go/+/424514 Run-TryBot: Austin Clements Auto-Submit: Austin Clements Reviewed-by: Michael Pratt Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot --- src/runtime/runtime2.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 4e67fd6e44..fe9b770b44 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -1027,13 +1027,11 @@ type stkframe struct { // This is the PC to use to look up GC liveness for this frame. continpc uintptr - lr uintptr // program counter at caller aka link register - sp uintptr // stack pointer at pc - fp uintptr // stack pointer at caller aka frame pointer - varp uintptr // top of local variables - argp uintptr // pointer to function arguments - arglen uintptr // number of bytes at argp - argmap *bitvector // force use of this argmap + lr uintptr // program counter at caller aka link register + sp uintptr // stack pointer at pc + fp uintptr // stack pointer at caller aka frame pointer + varp uintptr // top of local variables + argp uintptr // pointer to function arguments } // ancestorInfo records details of where a goroutine was started. -- cgit v1.3