]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make nextFreeFast inlinable
authorIlya Tocar <ilya.tocar@intel.com>
Wed, 20 Sep 2017 18:09:08 +0000 (13:09 -0500)
committerIlya Tocar <ilya.tocar@intel.com>
Wed, 20 Sep 2017 20:27:13 +0000 (20:27 +0000)
https://golang.org/cl/22598 made nextFreeFast inlinable.
But during https://golang.org/cl/63611 it was discovered, that it is no longer inlinable.
Reduce number of statements below inlining threshold to make it inlinable again.
Also update tests, to prevent regressions.
Doesn't reduce readability.

Change-Id: Ia672784dd48ed3b1ab46e390132f1094fe453de5
Reviewed-on: https://go-review.googlesource.com/65030
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/cmd/compile/internal/gc/inl_test.go
src/runtime/malloc.go

index 07e8eea1b882755061672aef7ae0fb2890382976..9f5e3f2a4a11589395e50e5c557031b0958eacdb 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bytes"
        "internal/testenv"
        "os/exec"
+       "runtime"
        "testing"
 )
 
@@ -34,10 +35,6 @@ func TestIntendedInlining(t *testing.T) {
                        "bucketMask",
                        "fastrand",
                        "noescape",
-
-                       // TODO: These were modified at some point to be
-                       // made inlineable, but have since been broken.
-                       // "nextFreeFast",
                },
                "unicode/utf8": {
                        "FullRune",
@@ -47,6 +44,13 @@ func TestIntendedInlining(t *testing.T) {
                },
        }
 
+       if runtime.GOARCH != "386" {
+               // nextFreeFast calls sys.Ctz64, which on 386 is implemented in asm and is not inlinable.
+               // We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386.
+               // So check for it only on non-386 platforms.
+               want["runtime"] = append(want["runtime"], "nextFreeFast")
+       }
+
        m := make(map[string]bool)
        pkgs := make([]string, 0, len(want))
        for pname, fnames := range want {
index 274ab537fcf732d00f453a02d04793b174390c55..d68ebcc5d28bb51d262d4b582c607213c7bebded 100644 (file)
@@ -529,9 +529,8 @@ func nextFreeFast(s *mspan) gclinkptr {
                        }
                        s.allocCache >>= uint(theBit + 1)
                        s.freeindex = freeidx
-                       v := gclinkptr(result*s.elemsize + s.base())
                        s.allocCount++
-                       return v
+                       return gclinkptr(result*s.elemsize + s.base())
                }
        }
        return 0