]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: update TestIntendedInlining
authorDaniel Martí <mvdan@mvdan.cc>
Sat, 9 Mar 2019 17:48:23 +0000 (17:48 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Sat, 9 Mar 2019 18:39:22 +0000 (18:39 +0000)
Value.CanInterface and Value.pointer are now inlinable, since we have a
limited form of mid-stack inlining. Their calls to panic were preventing
that in previous Go releases. The other three methods still go over
budget, so update that comment.

In recent commits, sync.Once.Do and multiple lock/unlock methods have
also been made inlinable, so add those as well. They have standalone
tests like test/inline_sync.go already, but it's best if the funcs are
in this global test table too. They aren't inlinable on every platform
yet, though.

Finally, use math/bits.UintSize to check if GOARCH is 64-bit, now that
we can.

Change-Id: I65cc681b77015f7746dba3126637e236dcd494e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/166461
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/inl_test.go

index c29c1755f369bfdb8192ac56e7d68c6d07910bd6..1ad6ca342155cf018ae9d9017ecdff2f4626fdfb 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bufio"
        "internal/testenv"
        "io"
+       "math/bits"
        "os/exec"
        "regexp"
        "runtime"
@@ -127,16 +128,16 @@ func TestIntendedInlining(t *testing.T) {
                "reflect": {
                        "Value.CanAddr",
                        "Value.CanSet",
+                       "Value.CanInterface",
                        "Value.IsValid",
+                       "Value.pointer",
                        "add",
                        "align",
                        "flag.kind",
                        "flag.ro",
 
-                       // TODO: these use panic, need mid-stack
-                       // inlining
-                       // "Value.CanInterface",
-                       // "Value.pointer",
+                       // TODO: these use panic, which gets their budgets
+                       // slightly over the limit
                        // "flag.mustBe",
                        // "flag.mustBeAssignable",
                        // "flag.mustBeExported",
@@ -163,12 +164,27 @@ func TestIntendedInlining(t *testing.T) {
                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":
+       if bits.UintSize == 64 {
                // rotl_31 is only defined on 64-bit architectures
                want["runtime"] = append(want["runtime"], "rotl_31")
        }
 
+       switch runtime.GOARCH {
+       case "nacl", "386", "wasm", "arm":
+       default:
+               // TODO(mvdan): As explained in /test/inline_sync.go, some
+               // architectures don't have atomic intrinsics, so these go over
+               // the inlining budget. Move back to the main table once that
+               // problem is solved.
+               want["sync"] = []string{
+                       "(*Mutex).Lock",
+                       "(*Mutex).Unlock",
+                       "(*RWMutex).RLock",
+                       "(*RWMutex).RUnlock",
+                       "(*Once).Do",
+               }
+       }
+
        // Functions that must actually be inlined; they must have actual callers.
        must := map[string]bool{
                "compress/flate.byLiteral.Len":  true,