aboutsummaryrefslogtreecommitdiff
path: root/test/escape_slice.go
AgeCommit message (Collapse)Author
2020-09-12cmd/compile: use clearer error message for stuct literalCuong Manh Le
This CL changes "T literal.M" error message to "T{...}.M". It's clearer expression and focusing user on actual issue. Updates #38745 Change-Id: I84b455a86742f37e0bde5bf390aa02984eecc3c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/253677 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-03-31cmd/compile: make isSmallMakeSlice checks slice cap onlyCuong Manh Le
If slice cap is not set, it will be equal to slice len. So isSmallMakeSlice only needs to check whether slice cap is constant. While at it, also add test to make sure panicmakeslicecap is called when make slice contains invalid non-constant len. For this benchmark: func BenchmarkMakeSliceNonConstantLen(b *testing.B) { len := 1 for i := 0; i < b.N; i++ { s := make([]int, len, 2) _ = s } } Result compare with parent: name old time/op new time/op delta MakeSliceNonConstantLen-12 18.4ns ± 1% 0.2ns ± 2% -98.66% (p=0.008 n=5+5) Fixes #37975 Change-Id: I4bc926361bc2ffeab4cfaa888ef0a30cbc3b80e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/226278 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2019-04-02cmd/compile: skip escape analysis diagnostics for OADDRMatthew Dempsky
For most nodes (e.g., OPTRLIT, OMAKESLICE, OCONVIFACE), escape analysis prints "escapes to heap" or "does not escape" to indicate whether that node's allocation can be heap or stack allocated. These messages are also emitted for OADDR, even though OADDR does not actually allocate anything itself. Moreover, it's redundant because escape analysis already prints "moved to heap" diagnostics when an OADDR node like "&x" causes x to require heap allocation. Because OADDR nodes don't allocate memory, my escape analysis rewrite doesn't naturally emit the "escapes to heap" / "does not escape" diagnostics for them. It's also non-trivial to replicate the exact semantics esc.go uses for OADDR. Since there are so many of these messages, I'm disabling them in this CL by themselves. I modified esc.go to suppress the Warnl calls without any other behavior changes, and then used a shell script to automatically remove any ERROR messages mentioned by run.go in "missing error" or "no match for" lines. Fixes #16300. Updates #23109. Change-Id: I3993e2743c3ff83ccd0893f4e73b366ff8871a57 Reviewed-on: https://go-review.googlesource.com/c/go/+/170319 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2016-05-02all: make copyright headers consistent with one space after periodEmmanuel Odeke
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-18cmd/internal/gc: extend escape analysis to pointers in slicesDavid Chase
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>
2015-03-28test: add tests for escape analysis of slicesDmitry Vyukov
False positives (var incorrectly escapes) are marked with BAD. Change-Id: I9e9a3f71b060520103bcf289829a2efdf6f2b517 Reviewed-on: https://go-review.googlesource.com/5298 Reviewed-by: Keith Randall <khr@golang.org>