]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: allow inlining of stackmapdata
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 1 Apr 2018 19:21:57 +0000 (12:21 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 1 May 2018 19:14:17 +0000 (19:14 +0000)
Also do very minor code cleanup.

name                old time/op  new time/op  delta
StackCopyPtr-8      84.8ms ± 6%  82.9ms ± 5%  -2.19%  (p=0.000 n=95+94)
StackCopy-8         68.4ms ± 5%  65.3ms ± 4%  -4.54%  (p=0.000 n=99+99)
StackCopyNoCache-8   107ms ± 2%   105ms ± 2%  -2.13%  (p=0.000 n=91+95)

Change-Id: I2d85ede48bffada9584d437a08a82212c0da6d00
Reviewed-on: https://go-review.googlesource.com/109001
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/gc/inl_test.go
src/runtime/symtab.go

index 02252878660b79d90608b691513e0e67a56d2aa0..a452f2ad2946a5e17c77f8e4cab2d7a395577391 100644 (file)
@@ -60,6 +60,7 @@ func TestIntendedInlining(t *testing.T) {
                        "releasem",
                        "round",
                        "roundupsize",
+                       "stackmapdata",
                        "stringStructOf",
                        "subtract1",
                        "subtractb",
index 91a8f8eb057a72564cb0604047fc3957c49d5b7c..8d54369d88a3bb566cdd62d19aab88837c545856 100644 (file)
@@ -916,10 +916,13 @@ type stackmap struct {
 
 //go:nowritebarrier
 func stackmapdata(stkmap *stackmap, n int32) bitvector {
-       if n < 0 || n >= stkmap.n {
+       // Check this invariant only when stackDebug is on at all.
+       // The invariant is already checked by many of stackmapdata's callers,
+       // and disabling it by default allows stackmapdata to be inlined.
+       if stackDebug > 0 && (n < 0 || n >= stkmap.n) {
                throw("stackmapdata: index out of range")
        }
-       return bitvector{stkmap.nbit, (*byte)(add(unsafe.Pointer(&stkmap.bytedata), uintptr(n*((stkmap.nbit+7)>>3))))}
+       return bitvector{stkmap.nbit, addb(&stkmap.bytedata[0], uintptr(n*((stkmap.nbit+7)>>3)))}
 }
 
 // inlinedCall is the encoding of entries in the FUNCDATA_InlTree table.