From 990c9c6cabad6a083ac67c591a38f73d00850da8 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 5 Oct 2021 11:31:57 -0700 Subject: [PATCH] Revert "runtime: use unsafe.Slice in getStackMap" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This reverts commit golang.org/cl/352953. Reason for revert: unsafe.Slice is considerably slower. Part of this is extra safety checks (good), but most of it is the function call overhead. We should consider open-coding it (#48798). Impact of this change: name old time/op new time/op delta StackCopyWithStkobj-8 12.1ms ± 5% 11.6ms ± 3% -4.03% (p=0.009 n=10+8) Change-Id: Ib2448e3edac25afd8fb55ffbea073b8b11521bde Reviewed-on: https://go-review.googlesource.com/c/go/+/354090 Trust: Josh Bleecher Snyder Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- src/runtime/stack.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/runtime/stack.go b/src/runtime/stack.go index efaa799022..284c6b3b84 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1328,8 +1328,7 @@ func getStackMap(frame *stkframe, cache *pcvalueCache, debug bool) (locals, args if p != nil { n := *(*uintptr)(p) p = add(p, goarch.PtrSize) - r0 := (*stackObjectRecord)(noescape(p)) - objs = unsafe.Slice(r0, int(n)) + *(*slice)(unsafe.Pointer(&objs)) = slice{array: noescape(p), len: int(n), cap: int(n)} // Note: the noescape above is needed to keep // getStackMap from "leaking param content: // frame". That leak propagates up to getgcmask, then -- 2.48.1