]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "runtime: use unsafe.Slice in getStackMap"
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 5 Oct 2021 18:31:57 +0000 (11:31 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 5 Oct 2021 20:35:54 +0000 (20:35 +0000)
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>
src/runtime/stack.go

index efaa799022f3f4c6b1109469f3d084a429ed11bb..284c6b3b84614d5f8a81d0e41e527b04349e26e5 100644 (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