2017-09-13 15:04:16 +02:00
|
|
|
// Copyright 2017 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package gc
|
|
|
|
|
|
|
|
|
|
import (
|
2017-09-14 15:51:18 +01:00
|
|
|
"bufio"
|
2017-09-13 15:04:16 +02:00
|
|
|
"internal/testenv"
|
2017-09-14 15:51:18 +01:00
|
|
|
"io"
|
2017-09-13 15:04:16 +02:00
|
|
|
"os/exec"
|
2017-09-14 15:51:18 +01:00
|
|
|
"regexp"
|
2017-09-20 13:09:08 -05:00
|
|
|
"runtime"
|
2017-09-14 15:51:18 +01:00
|
|
|
"strings"
|
2017-09-13 15:04:16 +02:00
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TestIntendedInlining tests that specific runtime functions are inlined.
|
|
|
|
|
// This allows refactoring for code clarity and re-use without fear that
|
|
|
|
|
// changes to the compiler will cause silent performance regressions.
|
|
|
|
|
func TestIntendedInlining(t *testing.T) {
|
|
|
|
|
if testing.Short() && testenv.Builder() == "" {
|
|
|
|
|
t.Skip("skipping in short mode")
|
|
|
|
|
}
|
|
|
|
|
testenv.MustHaveGoRun(t)
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
2017-09-13 21:03:20 +02:00
|
|
|
// want is the list of function names (by package) that should
|
2019-02-22 15:53:52 +00:00
|
|
|
// be inlinable. If they have no callers in their packages, they
|
2018-09-17 14:08:03 -05:00
|
|
|
// might not actually be inlined anywhere.
|
2017-09-13 21:03:20 +02:00
|
|
|
want := map[string][]string{
|
|
|
|
|
"runtime": {
|
2017-09-23 12:22:10 +01:00
|
|
|
// TODO(mvdan): enable these once mid-stack
|
|
|
|
|
// inlining is available
|
|
|
|
|
// "adjustctxt",
|
|
|
|
|
|
2017-09-13 21:03:20 +02:00
|
|
|
"add",
|
2017-09-23 21:44:18 +01:00
|
|
|
"acquirem",
|
|
|
|
|
"add1",
|
2017-09-13 21:03:20 +02:00
|
|
|
"addb",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"adjustpanics",
|
|
|
|
|
"adjustpointer",
|
2017-09-13 21:03:20 +02:00
|
|
|
"bucketMask",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"bucketShift",
|
|
|
|
|
"chanbuf",
|
|
|
|
|
"deferArgs",
|
|
|
|
|
"deferclass",
|
|
|
|
|
"evacuated",
|
|
|
|
|
"fastlog2",
|
2017-09-13 21:03:20 +02:00
|
|
|
"fastrand",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"float64bits",
|
2017-09-23 21:44:18 +01:00
|
|
|
"funcPC",
|
2018-03-30 22:54:00 -07:00
|
|
|
"getArgInfoFast",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"getm",
|
|
|
|
|
"isDirectIface",
|
|
|
|
|
"itabHashFunc",
|
2017-09-13 21:03:20 +02:00
|
|
|
"noescape",
|
runtime: reduce linear search through pcvalue cache
This change introduces two optimizations together,
one for recursive and one for non-recursive stacks.
For recursive stacks, we introduce the new entry
at the beginning of the cache, so it can be found first.
This adds an extra read and write.
While we're here, switch from fastrandn, which does a multiply,
to fastrand % n, which does a shift.
For non-recursive stacks, split the cache from [16]pcvalueCacheEnt
into [2][8]pcvalueCacheEnt, and add a very cheap associative lookup.
name old time/op new time/op delta
StackCopyPtr-8 118ms ± 1% 106ms ± 2% -9.56% (p=0.000 n=17+18)
StackCopy-8 95.8ms ± 1% 87.0ms ± 3% -9.11% (p=0.000 n=19+20)
StackCopyNoCache-8 135ms ± 2% 139ms ± 1% +3.06% (p=0.000 n=19+18)
During make.bash, the association function used has this return distribution:
percent count return value
53.23% 678797 1
46.74% 596094 0
It is definitely not perfect, but it is pretty good,
and that's all we need.
Change-Id: I2cabb1d26b99c5111bc28f427016a2a5e6c620fd
Reviewed-on: https://go-review.googlesource.com/c/110564
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-04-01 16:39:34 -07:00
|
|
|
"pcvalueCacheKey",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"readUnaligned32",
|
|
|
|
|
"readUnaligned64",
|
2017-09-23 21:44:18 +01:00
|
|
|
"releasem",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"round",
|
|
|
|
|
"roundupsize",
|
2018-04-01 12:21:57 -07:00
|
|
|
"stackmapdata",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"stringStructOf",
|
2017-09-23 21:44:18 +01:00
|
|
|
"subtract1",
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"subtractb",
|
|
|
|
|
"tophash",
|
|
|
|
|
"totaldefersize",
|
|
|
|
|
"(*bmap).keys",
|
|
|
|
|
"(*bmap).overflow",
|
|
|
|
|
"(*waitq).enqueue",
|
2017-09-23 21:44:18 +01:00
|
|
|
|
|
|
|
|
// GC-related ones
|
|
|
|
|
"cgoInRange",
|
|
|
|
|
"gclinkptr.ptr",
|
|
|
|
|
"guintptr.ptr",
|
|
|
|
|
"heapBits.bits",
|
|
|
|
|
"heapBits.isPointer",
|
|
|
|
|
"heapBits.morePointers",
|
|
|
|
|
"heapBits.next",
|
|
|
|
|
"heapBitsForAddr",
|
|
|
|
|
"markBits.isMarked",
|
|
|
|
|
"muintptr.ptr",
|
|
|
|
|
"puintptr.ptr",
|
2018-02-16 17:45:21 -05:00
|
|
|
"spanOf",
|
2017-09-23 21:44:18 +01:00
|
|
|
"spanOfUnchecked",
|
2018-11-19 10:37:14 -05:00
|
|
|
//"(*gcWork).putFast", // TODO(austin): For debugging #27993
|
2017-09-23 21:44:18 +01:00
|
|
|
"(*gcWork).tryGetFast",
|
|
|
|
|
"(*guintptr).set",
|
|
|
|
|
"(*markBits).advance",
|
|
|
|
|
"(*mspan).allocBitsForIndex",
|
|
|
|
|
"(*mspan).base",
|
|
|
|
|
"(*mspan).markBitsForBase",
|
|
|
|
|
"(*mspan).markBitsForIndex",
|
|
|
|
|
"(*muintptr).set",
|
|
|
|
|
"(*puintptr).set",
|
2017-09-13 21:03:20 +02:00
|
|
|
},
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
"runtime/internal/sys": {},
|
2018-01-27 11:55:34 +01:00
|
|
|
"runtime/internal/math": {
|
|
|
|
|
"MulUintptr",
|
|
|
|
|
},
|
2017-09-24 17:55:19 +01:00
|
|
|
"bytes": {
|
|
|
|
|
"(*Buffer).Bytes",
|
|
|
|
|
"(*Buffer).Cap",
|
|
|
|
|
"(*Buffer).Len",
|
2018-12-01 16:28:27 +00:00
|
|
|
"(*Buffer).Grow",
|
2017-09-24 17:55:19 +01:00
|
|
|
"(*Buffer).Next",
|
|
|
|
|
"(*Buffer).Read",
|
|
|
|
|
"(*Buffer).ReadByte",
|
|
|
|
|
"(*Buffer).Reset",
|
|
|
|
|
"(*Buffer).String",
|
|
|
|
|
"(*Buffer).UnreadByte",
|
|
|
|
|
"(*Buffer).tryGrowByReslice",
|
|
|
|
|
},
|
2018-09-17 14:08:03 -05:00
|
|
|
"compress/flate": {
|
|
|
|
|
"byLiteral.Len",
|
|
|
|
|
"byLiteral.Less",
|
|
|
|
|
"byLiteral.Swap",
|
|
|
|
|
},
|
2017-09-13 21:03:20 +02:00
|
|
|
"unicode/utf8": {
|
|
|
|
|
"FullRune",
|
|
|
|
|
"FullRuneInString",
|
|
|
|
|
"RuneLen",
|
|
|
|
|
"ValidRune",
|
|
|
|
|
},
|
2017-09-28 20:44:21 +01:00
|
|
|
"reflect": {
|
|
|
|
|
"Value.CanAddr",
|
|
|
|
|
"Value.CanSet",
|
|
|
|
|
"Value.IsValid",
|
|
|
|
|
"add",
|
|
|
|
|
"align",
|
|
|
|
|
"flag.kind",
|
|
|
|
|
"flag.ro",
|
|
|
|
|
|
|
|
|
|
// TODO: these use panic, need mid-stack
|
|
|
|
|
// inlining
|
|
|
|
|
// "Value.CanInterface",
|
|
|
|
|
// "Value.pointer",
|
|
|
|
|
// "flag.mustBe",
|
|
|
|
|
// "flag.mustBeAssignable",
|
|
|
|
|
// "flag.mustBeExported",
|
|
|
|
|
},
|
2017-09-22 15:15:23 -05:00
|
|
|
"regexp": {
|
|
|
|
|
"(*bitState).push",
|
|
|
|
|
},
|
2018-03-06 09:07:34 +03:00
|
|
|
"math/big": {
|
|
|
|
|
"bigEndianWord",
|
|
|
|
|
},
|
2017-09-13 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 10:53:48 -04:00
|
|
|
if runtime.GOARCH != "386" && runtime.GOARCH != "mips64" && runtime.GOARCH != "mips64le" {
|
2017-09-20 13:09:08 -05:00
|
|
|
// 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.
|
2017-10-20 10:53:48 -04:00
|
|
|
// On MIPS64x, Ctz64 is not intrinsified and causes nextFreeFast too expensive to inline
|
|
|
|
|
// (Issue 22239).
|
2017-09-20 13:09:08 -05:00
|
|
|
want["runtime"] = append(want["runtime"], "nextFreeFast")
|
2017-10-20 10:53:48 -04:00
|
|
|
}
|
|
|
|
|
if runtime.GOARCH != "386" {
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
// 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")
|
2017-09-20 13:09:08 -05:00
|
|
|
}
|
|
|
|
|
|
2018-09-17 14:08:03 -05:00
|
|
|
// Functions that must actually be inlined; they must have actual callers.
|
|
|
|
|
must := map[string]bool{
|
|
|
|
|
"compress/flate.byLiteral.Len": true,
|
|
|
|
|
"compress/flate.byLiteral.Less": true,
|
|
|
|
|
"compress/flate.byLiteral.Swap": true,
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 15:51:18 +01:00
|
|
|
notInlinedReason := make(map[string]string)
|
2017-09-13 21:03:20 +02:00
|
|
|
pkgs := make([]string, 0, len(want))
|
|
|
|
|
for pname, fnames := range want {
|
|
|
|
|
pkgs = append(pkgs, pname)
|
|
|
|
|
for _, fname := range fnames {
|
cmd/compile: add more runtime funcs to inline test
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>
2017-09-22 12:21:36 +01:00
|
|
|
fullName := pname + "." + fname
|
|
|
|
|
if _, ok := notInlinedReason[fullName]; ok {
|
|
|
|
|
t.Errorf("duplicate func: %s", fullName)
|
|
|
|
|
}
|
|
|
|
|
notInlinedReason[fullName] = "unknown reason"
|
2017-09-13 21:03:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 10:58:58 -05:00
|
|
|
args := append([]string{"build", "-a", "-gcflags=all=-m -m"}, pkgs...)
|
2017-09-13 21:03:20 +02:00
|
|
|
cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), args...))
|
2017-09-14 15:51:18 +01:00
|
|
|
pr, pw := io.Pipe()
|
|
|
|
|
cmd.Stdout = pw
|
|
|
|
|
cmd.Stderr = pw
|
|
|
|
|
cmdErr := make(chan error, 1)
|
|
|
|
|
go func() {
|
|
|
|
|
cmdErr <- cmd.Run()
|
|
|
|
|
pw.Close()
|
|
|
|
|
}()
|
|
|
|
|
scanner := bufio.NewScanner(pr)
|
2017-09-13 21:03:20 +02:00
|
|
|
curPkg := ""
|
2017-09-14 15:51:18 +01:00
|
|
|
canInline := regexp.MustCompile(`: can inline ([^ ]*)`)
|
2018-09-17 14:08:03 -05:00
|
|
|
haveInlined := regexp.MustCompile(`: inlining call to ([^ ]*)`)
|
2017-09-14 15:51:18 +01:00
|
|
|
cannotInline := regexp.MustCompile(`: cannot inline ([^ ]*): (.*)`)
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
line := scanner.Text()
|
|
|
|
|
if strings.HasPrefix(line, "# ") {
|
|
|
|
|
curPkg = line[2:]
|
|
|
|
|
continue
|
|
|
|
|
}
|
2018-09-17 14:08:03 -05:00
|
|
|
if m := haveInlined.FindStringSubmatch(line); m != nil {
|
2017-09-14 15:51:18 +01:00
|
|
|
fname := m[1]
|
|
|
|
|
delete(notInlinedReason, curPkg+"."+fname)
|
|
|
|
|
continue
|
2017-09-13 21:03:20 +02:00
|
|
|
}
|
2018-09-17 14:08:03 -05:00
|
|
|
if m := canInline.FindStringSubmatch(line); m != nil {
|
|
|
|
|
fname := m[1]
|
|
|
|
|
fullname := curPkg + "." + fname
|
2019-02-22 15:53:52 +00:00
|
|
|
// If function must be inlined somewhere, being inlinable is not enough
|
2018-09-17 14:08:03 -05:00
|
|
|
if _, ok := must[fullname]; !ok {
|
|
|
|
|
delete(notInlinedReason, fullname)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-14 15:51:18 +01:00
|
|
|
if m := cannotInline.FindStringSubmatch(line); m != nil {
|
|
|
|
|
fname, reason := m[1], m[2]
|
|
|
|
|
fullName := curPkg + "." + fname
|
|
|
|
|
if _, ok := notInlinedReason[fullName]; ok {
|
|
|
|
|
// cmd/compile gave us a reason why
|
|
|
|
|
notInlinedReason[fullName] = reason
|
|
|
|
|
}
|
2017-09-13 15:04:16 +02:00
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-14 15:51:18 +01:00
|
|
|
if err := <-cmdErr; err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
for fullName, reason := range notInlinedReason {
|
|
|
|
|
t.Errorf("%s was not inlined: %s", fullName, reason)
|
2017-09-13 15:04:16 +02:00
|
|
|
}
|
|
|
|
|
}
|