Commit cc5dc001 authored by Daniel Martí's avatar Daniel Martí

cmd/compile: update TestIntendedInlining

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 05051b56
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment