1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:54:39 -07:00

Revert "runtime: use unsafe.Slice in getStackMap"

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 <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2021-10-05 11:31:57 -07:00
parent 113b52979f
commit 990c9c6cab

View File

@ -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