Skip to content

Commit cc5dc00

Browse files
committed
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: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 05051b5 commit cc5dc00

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/cmd/compile/internal/gc/inl_test.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"bufio"
99
"internal/testenv"
1010
"io"
11+
"math/bits"
1112
"os/exec"
1213
"regexp"
1314
"runtime"
@@ -127,16 +128,16 @@ func TestIntendedInlining(t *testing.T) {
127128
"reflect": {
128129
"Value.CanAddr",
129130
"Value.CanSet",
131+
"Value.CanInterface",
130132
"Value.IsValid",
133+
"Value.pointer",
131134
"add",
132135
"align",
133136
"flag.kind",
134137
"flag.ro",
135138

136-
// TODO: these use panic, need mid-stack
137-
// inlining
138-
// "Value.CanInterface",
139-
// "Value.pointer",
139+
// TODO: these use panic, which gets their budgets
140+
// slightly over the limit
140141
// "flag.mustBe",
141142
// "flag.mustBeAssignable",
142143
// "flag.mustBeExported",
@@ -163,12 +164,27 @@ func TestIntendedInlining(t *testing.T) {
163164
want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Ctz32")
164165
want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Bswap32")
165166
}
166-
switch runtime.GOARCH {
167-
case "amd64", "amd64p32", "arm64", "mips64", "mips64le", "ppc64", "ppc64le", "s390x":
167+
if bits.UintSize == 64 {
168168
// rotl_31 is only defined on 64-bit architectures
169169
want["runtime"] = append(want["runtime"], "rotl_31")
170170
}
171171

172+
switch runtime.GOARCH {
173+
case "nacl", "386", "wasm", "arm":
174+
default:
175+
// TODO(mvdan): As explained in /test/inline_sync.go, some
176+
// architectures don't have atomic intrinsics, so these go over
177+
// the inlining budget. Move back to the main table once that
178+
// problem is solved.
179+
want["sync"] = []string{
180+
"(*Mutex).Lock",
181+
"(*Mutex).Unlock",
182+
"(*RWMutex).RLock",
183+
"(*RWMutex).RUnlock",
184+
"(*Once).Do",
185+
}
186+
}
187+
172188
// Functions that must actually be inlined; they must have actual callers.
173189
must := map[string]bool{
174190
"compress/flate.byLiteral.Len": true,

0 commit comments

Comments
 (0)