From: Cuong Manh Le Date: Sun, 8 May 2022 16:26:28 +0000 (+0700) Subject: runtime: use unsafe.Slice in getStackMap X-Git-Tag: go1.19beta1~310 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4388faf9646bd4df0b0c3a5b781281d5b7948ce4;p=gostls13.git runtime: use unsafe.Slice in getStackMap CL 362934 added open code for unsafe.Slice, so using it now no longer negatively impacts the performance. Updates #48798 Change-Id: Ifbabe8bc1cc4349c5bcd11586a11fc99bcb388b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/404974 Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Knyszek Reviewed-by: Matthew Dempsky Run-TryBot: Cuong Manh Le TryBot-Result: Gopher Robot --- diff --git a/src/runtime/stack.go b/src/runtime/stack.go index b7df231722..3a22dcd552 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -1346,7 +1346,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