diff options
author | David Chase <drchase@google.com> | 2015-05-15 12:19:07 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2015-05-18 15:34:39 +0000 |
commit | a21cf5b6a281df2c3506105cecfbeeda70afca1c (patch) | |
tree | 0f47567dddaaca8cbbf060a99eaa24c519fd5117 /test/escape2.go | |
parent | f0dd002895b48595f6c14f2bf606775289f59d5f (diff) | |
download | go-a21cf5b6a281df2c3506105cecfbeeda70afca1c.tar.gz go-a21cf5b6a281df2c3506105cecfbeeda70afca1c.zip |
cmd/internal/gc: extend escape analysis to pointers in slices
Modified esc.go to allow slice literals (before append)
to be non-escaping. Modified tests to account for changes
in escape behavior and to also test the two cases that
were previously not tested.
Also minor cleanups to debug-printing within esc.go
Allocation stats for running compiler
( cd src/html/template;
for i in {1..5} ; do
go tool 6g -memprofile=testzz.${i}.prof -memprofilerate=1 *.go ;
go tool pprof -alloc_objects -text testzz.${i}.prof ;
done ; )
before about 86k allocations
after about 83k allocations
Fixes #8972
Change-Id: Ib61dd70dc74adb40d6f6fdda6eaa4bf7d83481de
Reviewed-on: https://go-review.googlesource.com/10118
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'test/escape2.go')
-rw-r--r-- | test/escape2.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/escape2.go b/test/escape2.go index cc714711cf..dfc37ed45f 100644 --- a/test/escape2.go +++ b/test/escape2.go @@ -787,7 +787,7 @@ func foo93(c chan *int) *int { // ERROR "foo93 c does not escape$" } // does not leak m -func foo94(m map[*int]*int, b bool) *int { // ERROR "foo94 m does not escape$" +func foo94(m map[*int]*int, b bool) *int { // ERROR "leaking param: m to result ~r2 level=1" for k, v := range m { if b { return k @@ -802,8 +802,8 @@ func foo95(m map[*int]*int, x *int) { // ERROR "foo95 m does not escape$" "leaki m[x] = x } -// does not leak m -func foo96(m []*int) *int { // ERROR "foo96 m does not escape$" +// does not leak m but does leak content +func foo96(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1" return m[0] } @@ -823,7 +823,7 @@ func foo99(m *[1]*int) []*int { // ERROR "leaking param: m to result ~r1 level=0 } // does not leak m -func foo100(m []*int) *int { // ERROR "foo100 m does not escape$" +func foo100(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1" for _, v := range m { return v } @@ -863,8 +863,8 @@ func foo104(x []*int) { // ERROR "foo104 x does not escape$" copy(y, x) } -// does not leak x -func foo105(x []*int) { // ERROR "foo105 x does not escape$" +// does not leak x but does leak content +func foo105(x []*int) { // ERROR "leaking param content: x" _ = append(y, x...) } @@ -894,7 +894,7 @@ func foo110(x *int) *int { // ERROR "leaking param: x$" return m[nil] } -func foo111(x *int) *int { // ERROR "leaking param: x$" +func foo111(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0" m := []*int{x} // ERROR "foo111 \[\]\*int literal does not escape$" return m[0] } |