From a9d5ea650b39ed144ea32a41fb551c038fb48f0c Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 28 Sep 2021 17:42:05 -0700 Subject: [PATCH] runtime: use unsafe.Slice in getStackMap It's not less code, but it is clearer code. Change-Id: I32239baf92487a56900a4edd8a2593014f37d093 Reviewed-on: https://go-review.googlesource.com/c/go/+/352953 Trust: Josh Bleecher Snyder Trust: Brad Fitzpatrick Run-TryBot: Josh Bleecher Snyder Reviewed-by: Brad Fitzpatrick --- src/runtime/stack.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 22fff73947..0946e6975a 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1327,7 +1327,8 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args if p != nil { n := *(*uintptr)(p) p = add(p, goarch.PtrSize) - *(*slice)(unsafe.Pointer(&objs)) = slice{array: noescape(p), len: int(n), cap: int(n)} + r0 := (*stackObjectRecord)(noescape(p)) + objs = unsafe.Slice(r0, int(n)) // Note: the noescape above is needed to keep // getStackMap from "leaking param content: // frame". That leak propagates up to getgcmask, then