]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add more runtime funcs to inline test
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 22 Sep 2017 11:21:36 +0000 (12:21 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 22 Sep 2017 17:19:01 +0000 (17:19 +0000)
This is based from a list that Keith Randall provided in mid-2016. These
are all funcs that, at the time, were important and small enough that
they should be clearly inlined.

The runtime has changed a bit since then. Ctz16 and Ctz8 were removed,
so don't add them. stringtoslicebytetmp was moved to the backend, so
it's no longer a Go function. And itabhash was moved to itabHashFunc.

The only other outlier is adjustctxt, which is not inlineable at the
moment. I've added a TODO and will address it myself in a separate
commit.

While at it, error if any funcs in the input table are duplicated.
They're never useful and typos could lead to unintentionally thinking a
function is inlineable when it actually isn't.

And, since the lists are getting long, start sorting alphabetically.

Finally, rotl_31 is only defined on 64-bit architectures, and the added
runtime/internal/sys funcs are assembly on 386 and thus non-inlineable
in that case.

Updates #21851.

Change-Id: Ib99ab53d777860270e8fd4aefc41adb448f13662
Reviewed-on: https://go-review.googlesource.com/65351
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/inl_test.go

index 03dbd13b0698763bf4ceceddc10006ad7325583a..cbcd96a7b96257431c1d037cdb37f5170340f84c 100644 (file)
@@ -29,16 +29,39 @@ func TestIntendedInlining(t *testing.T) {
        // be inlined.
        want := map[string][]string{
                "runtime": {
-                       "tophash",
                        "add",
                        "addb",
-                       "subtractb",
-                       "(*bmap).keys",
-                       "bucketShift",
+                       "adjustpanics",
+                       "adjustpointer",
                        "bucketMask",
+                       "bucketShift",
+                       "chanbuf",
+                       "deferArgs",
+                       "deferclass",
+                       "evacuated",
+                       "fastlog2",
                        "fastrand",
+                       "float64bits",
+                       "getm",
+                       "isDirectIface",
+                       "itabHashFunc",
+                       "maxSliceCap",
                        "noescape",
+                       "readUnaligned32",
+                       "readUnaligned64",
+                       "round",
+                       "roundupsize",
+                       "stringStructOf",
+                       "subtractb",
+                       "tophash",
+                       "totaldefersize",
+                       "(*bmap).keys",
+                       "(*bmap).overflow",
+                       "(*waitq).enqueue",
+
+                       //"adjustctxt", TODO(mvdan): fix and re-enable
                },
+               "runtime/internal/sys": {},
                "unicode/utf8": {
                        "FullRune",
                        "FullRuneInString",
@@ -52,6 +75,16 @@ func TestIntendedInlining(t *testing.T) {
                // 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")
+               // As explained above, Ctz64 and Ctz32 are not Go code on 386.
+               // The same applies to Bswap32.
+               want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz64")
+               want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz32")
+               want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Bswap32")
+       }
+       switch runtime.GOARCH {
+       case "amd64", "amd64p32", "arm64", "mips64", "mips64le", "ppc64", "ppc64le", "s390x":
+               // rotl_31 is only defined on 64-bit architectures
+               want["runtime"] = append(want["runtime"], "rotl_31")
        }
 
        notInlinedReason := make(map[string]string)
@@ -59,7 +92,11 @@ func TestIntendedInlining(t *testing.T) {
        for pname, fnames := range want {
                pkgs = append(pkgs, pname)
                for _, fname := range fnames {
-                       notInlinedReason[pname+"."+fname] = "unknown reason"
+                       fullName := pname + "." + fname
+                       if _, ok := notInlinedReason[fullName]; ok {
+                               t.Errorf("duplicate func: %s", fullName)
+                       }
+                       notInlinedReason[fullName] = "unknown reason"
                }
        }