aboutsummaryrefslogtreecommitdiff
path: root/test/escape4.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-24 12:19:01 -0500
committerRuss Cox <rsc@golang.org>2015-02-26 17:36:00 +0000
commit77ccb16eb12f461eaea5fdf652a2e929dc154192 (patch)
tree254c4fb61ef0df8da7efe617513e4667f8f3c563 /test/escape4.go
parent5d1828269540fa7ba1dee60ce6b4a938463a696f (diff)
downloadgo-77ccb16eb12f461eaea5fdf652a2e929dc154192.tar.gz
go-77ccb16eb12f461eaea5fdf652a2e929dc154192.zip
cmd/internal/gc: transitive inlining
Inlining refuses to inline bodies containing an actual function call, so that if that call or a child uses runtime.Caller it cannot observe the inlining. However, inlining was also refusing to inline bodies that contained function calls that were themselves inlined away. For example: func f() int { return f1() } func f1() int { return f2() } func f2() int { return 2 } The f2 call in f1 would be inlined, but the f1 call in f would not, because f1's call to f2 blocked the inlining, despite itself eventually being inlined away. Account properly for this kind of transitive inlining and enable. Also bump the inlining budget a bit, so that the runtime's heapBits.next is inlined. This reduces the time for '6g *.go' in html/template by around 12% (!). (For what it's worth, closing Chrome reduces the time by about 17%.) Change-Id: If1aa673bf3e583082dcfb5f223e67355c984bfc1 Reviewed-on: https://go-review.googlesource.com/5952 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'test/escape4.go')
-rw-r--r--test/escape4.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/escape4.go b/test/escape4.go
index 83bc8eb123..248f8a96b9 100644
--- a/test/escape4.go
+++ b/test/escape4.go
@@ -22,11 +22,11 @@ func f1() {
// Escape analysis used to miss inlined code in closures.
- func() { // ERROR "func literal does not escape"
+ func() { // ERROR "func literal does not escape" "can inline f1.func1"
p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
}()
- f = func() { // ERROR "func literal escapes to heap"
+ f = func() { // ERROR "func literal escapes to heap" "can inline f1.func2"
p = alloc(3) // ERROR "inlining call to alloc" "&x escapes to heap" "moved to heap: x"
}
f()
@@ -42,7 +42,7 @@ func f5() *byte {
type T struct {
x [1]byte
}
- t := new(T) // ERROR "new.T. escapes to heap"
+ t := new(T) // ERROR "new.T. escapes to heap"
return &t.x[0] // ERROR "&t.x.0. escapes to heap"
}
@@ -52,6 +52,6 @@ func f6() *byte {
y byte
}
}
- t := new(T) // ERROR "new.T. escapes to heap"
+ t := new(T) // ERROR "new.T. escapes to heap"
return &t.x.y // ERROR "&t.x.y escapes to heap"
}