diff options
| author | Todd Neal <todd@tneal.org> | 2015-10-29 21:45:19 -0500 |
|---|---|---|
| committer | Todd Neal <todd@tneal.org> | 2015-11-03 02:01:34 +0000 |
| commit | e3e0122ae269027bfd2e2db1dbf106883ad5a8a7 (patch) | |
| tree | c3313e876d4d10a4b340f0886305fb5cc60932d3 /src/runtime | |
| parent | ebafc80ebaa8d7e67ba72642eed67c0adfc0c0c3 (diff) | |
| download | go-e3e0122ae269027bfd2e2db1dbf106883ad5a8a7.tar.xz | |
test: use go:noinline consistently
Replace various implementations of inlining prevention with
"go:noinline"
Change-Id: Iac90895c3a62d6f4b7a6c72e11e165d15a0abfa4
Reviewed-on: https://go-review.googlesource.com/16510
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/gc_test.go | 6 | ||||
| -rw-r--r-- | src/runtime/pprof/mprof_test.go | 15 | ||||
| -rw-r--r-- | src/runtime/race/testdata/mop_test.go | 8 | ||||
| -rw-r--r-- | src/runtime/race/testdata/regression_test.go | 9 |
4 files changed, 13 insertions, 25 deletions
diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go index 61bbc14945..ce61059e85 100644 --- a/src/runtime/gc_test.go +++ b/src/runtime/gc_test.go @@ -511,9 +511,11 @@ func TestAssertE2T2Liveness(t *testing.T) { testIfaceEqual(io.EOF) } +var a bool + +//go:noinline func testIfaceEqual(x interface{}) { if x == "abc" { - // Prevent inlining - panic("") + a = true } } diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go index ebf53dd66b..d14fb5888e 100644 --- a/src/runtime/pprof/mprof_test.go +++ b/src/runtime/pprof/mprof_test.go @@ -22,11 +22,8 @@ func allocateTransient1M() { } } +//go:noinline func allocateTransient2M() { - // prevent inlining - if memSink == nil { - panic("bad") - } memSink = make([]byte, 2<<20) } @@ -76,18 +73,18 @@ func TestMemoryProfiler(t *testing.T) { tests := []string{ fmt.Sprintf(`%v: %v \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof_test\.allocatePersistent1K\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:43 -# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:66 +# 0x[0-9,a-f]+ runtime/pprof_test\.allocatePersistent1K\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:40 +# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test\.go:63 `, 32*memoryProfilerRun, 1024*memoryProfilerRun, 32*memoryProfilerRun, 1024*memoryProfilerRun), fmt.Sprintf(`0: 0 \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ # 0x[0-9,a-f]+ runtime/pprof_test\.allocateTransient1M\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:21 -# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:64 +# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:61 `, (1<<10)*memoryProfilerRun, (1<<20)*memoryProfilerRun), fmt.Sprintf(`0: 0 \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ -# 0x[0-9,a-f]+ runtime/pprof_test\.allocateTransient2M\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:30 -# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:65 +# 0x[0-9,a-f]+ runtime/pprof_test\.allocateTransient2M\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:27 +# 0x[0-9,a-f]+ runtime/pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/runtime/pprof/mprof_test.go:62 `, memoryProfilerRun, (2<<20)*memoryProfilerRun), } diff --git a/src/runtime/race/testdata/mop_test.go b/src/runtime/race/testdata/mop_test.go index d7cbc98f95..c96acb9021 100644 --- a/src/runtime/race/testdata/mop_test.go +++ b/src/runtime/race/testdata/mop_test.go @@ -1356,14 +1356,8 @@ type InterImpl struct { x, y int } +//go:noinline func (p InterImpl) Foo(x int) { - // prevent inlining - z := 42 - x = 85 - y := x / z - z = y * z - x = z * y - _, _, _ = x, y, z } type InterImpl2 InterImpl diff --git a/src/runtime/race/testdata/regression_test.go b/src/runtime/race/testdata/regression_test.go index d461269d98..6a7802fb02 100644 --- a/src/runtime/race/testdata/regression_test.go +++ b/src/runtime/race/testdata/regression_test.go @@ -65,10 +65,8 @@ type Image struct { min, max Rect } +//go:noinline func NewImage() Image { - var pleaseDoNotInlineMe stack - pleaseDoNotInlineMe.push(1) - _ = pleaseDoNotInlineMe.pop() return Image{} } @@ -113,11 +111,8 @@ type RpcChan struct { var makeChanCalls int +//go:noinline func makeChan() *RpcChan { - var pleaseDoNotInlineMe stack - pleaseDoNotInlineMe.push(1) - _ = pleaseDoNotInlineMe.pop() - makeChanCalls++ c := &RpcChan{make(chan bool, 1)} c.c <- true |
