- 10 Mar, 2016 8 commits
-
-
Matthew Dempsky authored
Change-Id: I93b4821254c9b0a3cebd912f447ed58f20adeb58 Reviewed-on: https://go-review.googlesource.com/19937Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
Matthew Dempsky authored
Fixes #13337. Change-Id: Ie74d00390111796619150287d3f7a147750ab456 Reviewed-on: https://go-review.googlesource.com/19932Reviewed-by: Ian Lance Taylor <iant@golang.org>
-
Matthew Dempsky authored
Change-Id: Ice3aa807169f4fec85745a3991b1084a9f85c1b5 Reviewed-on: https://go-review.googlesource.com/20499 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-
Matthew Dempsky authored
Accessing the n'th field of a struct is fairly common, and in particular accessing the 0'th field of the receiver parameter list is very common. Add helper methods for both of these tasks and update code to make use of them. Change-Id: I81f551fecdca306b3800636caebcd0dc106f2ed7 Reviewed-on: https://go-review.googlesource.com/20498 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dave Cheney <dave@cheney.net>
-
Matthew Dempsky authored
Also, more lazy variable declarations, and make Dijkstra happy by replacing "goto loop" with a for loop. Change-Id: Idf2cd779a92eb3f33bd3394e12c9a0be72002ff4 Reviewed-on: https://go-review.googlesource.com/20496Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-
Dave Cheney authored
Follow up to CL 20494 addressing Type.Copy and a few other tiny cleanups. Change-Id: I3d0913a9f50a22ac2fd802858b1a94c15c5cb1bc Reviewed-on: https://go-review.googlesource.com/20501 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-
Matthew Dempsky authored
Better documentation. Change parameter types from **Type and int to just *Type and bool. Make use of short var declarations. Change-Id: I909846ba0df65cd2bc05ee145b72d60e881588bd Reviewed-on: https://go-review.googlesource.com/20495Reviewed-by: Dave Cheney <dave@cheney.net>
-
Matthew Dempsky authored
This should is preparatory cleanup to make it easier to use separate types to represent each kind of Go type, rather than a single omnibus Type struct with heavily overloaded fields. Also, add TODO comments marking assignments that change an existing Type's kind, as they need to be removed before we can factor Type. Change-Id: If4b551fdea4ae045b10b1a3de2ee98f5cf32a517 Reviewed-on: https://go-review.googlesource.com/20494Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
- 09 Mar, 2016 26 commits
-
-
Andrew Gerrand authored
Change-Id: I142a9f97303e3bfbd9522fd061530c0a91305389 Reviewed-on: https://go-review.googlesource.com/20500Reviewed-by: Minux Ma <minux@golang.org>
-
Josh Bleecher Snyder authored
With this, the start and end of geneq and genhash are parallel. This removes a few rare nilchecks from generated hash functions, but nothing to write home about. Change-Id: I3b4836111d04daa6f6834a579bbec374a3f42c70 Reviewed-on: https://go-review.googlesource.com/20456 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
-
Ian Lance Taylor authored
Mix in several other minor cleanups, including adding some new methods to Nodes: Index, Addr, SetIndex, SetNodes. Passes toolstash -cmp. Update #14473. Change-Id: I8bd4ae3fde7c5e20ba66e7dd1654fbc70c3ddeb8 Reviewed-on: https://go-review.googlesource.com/20491Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
David Crawshaw authored
Today the linker keeps all methods of reachable types. This is necessary if a program uses reflect.Value.Call. But while use of reflection is widespread in Go for encoders and decoders, using it to call a method is rare. This CL looks for the use of reflect.Value.Call in a program, and if it is absent, adopts a (reasonably conservative) method pruning strategy as part of dead code elimination. Any method that is directly called is kept, and any method that matches a used interface's method signature is kept. Whether or not a method body is kept is determined by the relocation from its receiver's *rtype to its *rtype. A small change in the compiler marks these relocations as R_METHOD so they can be easily collected and manipulated by the linker. As a bonus, this technique removes the text segment of methods that have been inlined. Looking at the output of building cmd/objdump with -ldflags=-v=2 shows that inlined methods like runtime.(*traceAllocBlockPtr).ptr are removed from the program. Relatively little work is necessary to do this. Linking two examples, jujud and cmd/objdump show no more than +2% link time. Binaries that do not use reflect.Call.Value drop 4 - 20% in size: addr2line: -793KB (18%) asm: -346KB (8%) cgo: -490KB (10%) compile: -564KB (4%) dist: -736KB (17%) fix: -404KB (12%) link: -328KB (7%) nm: -827KB (19%) objdump: -712KB (16%) pack: -327KB (14%) yacc: -350KB (10%) Binaries that do use reflect.Call.Value see a modest size decrease of 2 - 6% thanks to pruning of unexported methods: api: -151KB (3%) cover: -222KB (4%) doc: -106KB (2.5%) pprof: -314KB (3%) trace: -357KB (4%) vet: -187KB (2.7%) jujud: -4.4MB (5.8%) cmd/go: -384KB (3.4%) The trivial Hello example program goes from 2MB to 1.68MB: package main import "fmt" func main() { fmt.Println("Hello, 世界") } Method pruning also helps when building small binaries with "-ldflags=-s -w". The above program goes from 1.43MB to 1.2MB. Unfortunately the linker can only tell if reflect.Value.Call has been statically linked, not if it is dynamically used. And while use is rare, it is linked into a very common standard library package, text/template. The result is programs like cmd/go, which don't use reflect.Value.Call, see limited benefit from this CL. If binary size is important enough it may be possible to address this in future work. For #6853. Change-Id: Iabe90e210e813b08c3f8fd605f841f0458973396 Reviewed-on: https://go-review.googlesource.com/20483Reviewed-by: Russ Cox <rsc@golang.org>
-
Brad Fitzpatrick authored
Introduced in https://golang.org/cl/20462 Change-Id: I6c55f87228f0980058a10f204b57ead7594e3492 Reviewed-on: https://go-review.googlesource.com/20490Reviewed-by: Andrew Gerrand <adg@golang.org>
-
Brad Fitzpatrick authored
Drops cmd/binary size from 14.41 MiB to 11.42 MiB. Before: text data bss dec hex filename 8121210 3521696 737960 12380866 bceac2 ../pkg/tool/linux_amd64/compile bradfitz@dev-bradfitz-debian2:~/go/src$ ls -l ../pkg/tool/linux_amd64/compile -rwxr-xr-x 1 bradfitz bradfitz 15111272 Mar 8 23:32 ../pkg/tool/linux_amd64/compile a2afc0 51312 R html.statictmp_0085 6753f0 56592 T cmd/internal/obj/x86.doasm 625480 58080 T cmd/compile/internal/gc.typecheck1 f34c40 65688 D runtime.trace be0a20 133552 D cmd/compile/internal/ppc64.varianttable c013e0 265856 D cmd/compile/internal/arm.progtable c42260 417280 D cmd/compile/internal/amd64.progtable ca8060 417280 D cmd/compile/internal/x86.progtable f44ce0 500640 D cmd/internal/obj/arm64.oprange d0de60 534208 D cmd/compile/internal/ppc64.progtable d90520 667520 D cmd/compile/internal/arm64.progtable e334a0 790368 D cmd/compile/internal/mips64.progtable a3e8c0 1579362 r runtime.pclntab After: text data bss dec hex filename 8128226 375954 246432 8750612 858614 ../pkg/tool/linux_amd64/compile -rwxr-xr-x 1 bradfitz bradfitz 11971432 Mar 8 23:35 ../pkg/tool/linux_amd64/compile 6436d0 43936 T cmd/compile/internal/gc.walkexpr c13ca0 45056 D cmd/compile/internal/ssa.opcodeTable 5d8ea0 50256 T cmd/compile/internal/gc.(*state).expr 818c50 50448 T cmd/compile/internal/ssa.rewriteValueAMD64_OpMove a2d0e0 51312 R html.statictmp_0085 6753d0 56592 T cmd/internal/obj/x86.doasm 625460 58080 T cmd/compile/internal/gc.typecheck1 c38fe0 65688 D runtime.trace a409e0 1578810 r runtime.pclntab Fixes #14703 Change-Id: I2177596d5c7fd67db0a3c423cd90801cf52adb12 Reviewed-on: https://go-review.googlesource.com/20450Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Martin Möhrmann authored
Uses a switch statement for direct format function selection similar to other types verb handling in fmt. Applies padding also to nil pointers formatted with %v. Guards against "slice bounds out of range" panic in TestSprintf when a pointer test results in a formatted string s that is shorter than the index i the pointer should appear in. Adds more and rearranges tests. Fixes #14712 Fixes #14714 Change-Id: Iaf5ae37b7e6ba7d27d528d199f2b2eb9d5829b8c Reviewed-on: https://go-review.googlesource.com/20371 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
-
Alexandru Moșoi authored
Fixes #14721 Change-Id: Id1d5a819e5c242b91a37c4e464ed3f00c691aff5 Reviewed-on: https://go-review.googlesource.com/20482Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Matthew Dempsky authored
Change-Id: I5365b94b815bfb4795db643415c2df51fc815ea1 Reviewed-on: https://go-review.googlesource.com/20459 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dave Cheney <dave@cheney.net>
-
Richard Miller authored
On Plan 9, there's no "kill all threads" system call, so exit is done by sending a "go: exit" note to each OS process. If concurrent GC occurs during this loop, deadlock sometimes results. Prevent this by incrementing m.locks before sending notes. Change-Id: I31aa15134ff6e42d9a82f9f8a308620b3ad1b1b1 Reviewed-on: https://go-review.googlesource.com/20477Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Richard Miller authored
This prevents a fatal "missing stackmap" error if garbage collection occurs during exit. Also annotate argument sizes for "go vet". Change-Id: I2473e0ef6aef8f26d0bbeaee9bd8f8a52eaaf941 Reviewed-on: https://go-review.googlesource.com/20476Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
Alexandru Moșoi authored
* Move lowering into a separate pass. * SliceLen/SliceCap is now available to various intermediate passes which use useful for bounds checking. * Add a second opt pass to handle the new opportunities Decreases the code size of binaries in pkg/tool/linux_amd64 by ~45K. Updates #14564 #14606 Change-Id: I5b2bd6202181c50623a3585fbf15c0d6db6d4685 Reviewed-on: https://go-review.googlesource.com/20172 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
-
Matthew Dempsky authored
It's only used once, so just make the caller responsible for iterating both the receiver and input params. Change-Id: Icb34f3f0cf96e80fbe27f3f49d12eddc26599b92 Reviewed-on: https://go-review.googlesource.com/20454Reviewed-by: Dave Cheney <dave@cheney.net>
-
Ingo Oeser authored
so the code is more readable. Also use n[i] = val instead of n = append(n, val), because this avoids a function call to append. NOTE: compiles, but I had trouble running toolstash -cmp and need sleep now. @Ian this might save you some grunt work :-) Change-Id: I2a4c70396c58905f7d5aabf83f3020f11dea0e89 Reviewed-on: https://go-review.googlesource.com/20430Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Nigel Tao authored
This helps follow-up CLs ensure that the encoding's core computation does not allocate. It is a separate CL because it has a non-trivial effect on the benchmark numbers, even if it's purely an accounting change and not a change to the underlying performance: BenchmarkEncodeDigitsSpeed1e4-4 5.65 19.31 3.42x BenchmarkEncodeDigitsSpeed1e5-4 17.23 26.79 1.55x BenchmarkEncodeDigitsSpeed1e6-4 26.85 27.51 1.02x BenchmarkEncodeDigitsDefault1e4-4 4.41 13.21 3.00x BenchmarkEncodeDigitsDefault1e5-4 5.64 6.28 1.11x BenchmarkEncodeDigitsDefault1e6-4 5.54 5.65 1.02x BenchmarkEncodeDigitsCompress1e4-4 4.31 13.15 3.05x BenchmarkEncodeDigitsCompress1e5-4 5.52 5.91 1.07x BenchmarkEncodeDigitsCompress1e6-4 5.38 5.63 1.05x BenchmarkEncodeTwainSpeed1e4-4 5.45 19.06 3.50x BenchmarkEncodeTwainSpeed1e5-4 17.30 29.25 1.69x BenchmarkEncodeTwainSpeed1e6-4 28.06 30.86 1.10x BenchmarkEncodeTwainDefault1e4-4 4.06 12.36 3.04x BenchmarkEncodeTwainDefault1e5-4 6.15 7.62 1.24x BenchmarkEncodeTwainDefault1e6-4 6.84 6.99 1.02x BenchmarkEncodeTwainCompress1e4-4 4.06 12.27 3.02x BenchmarkEncodeTwainCompress1e5-4 5.29 5.92 1.12x BenchmarkEncodeTwainCompress1e6-4 5.24 5.29 1.01x Change-Id: I7d32866b7e2d478b0154332c1edeefe339af9a28 Reviewed-on: https://go-review.googlesource.com/20467Reviewed-by: David Symonds <dsymonds@golang.org>
-
Brady Catherman authored
Adds a type of output to Examples that allows tests to have unordered output. This is intended to help clarify when the output of a command will produce a fixed return, but that return might not be in an constant order. Examples where this is useful would be documenting the rand.Perm() call, or perhaps the (os.File).Readdir(), both of which can not guarantee order, but can guarantee the elements of the output. Fixes #10149 Change-Id: Iaf0cf1580b686afebd79718ed67ea744f5ed9fc5 Reviewed-on: https://go-review.googlesource.com/19280Reviewed-by: Andrew Gerrand <adg@golang.org>
-
Shenghou Ma authored
Change-Id: Ia22f681b0e90876ec87363c50c6a284db050f649 Reviewed-on: https://go-review.googlesource.com/19793Reviewed-by: Andrew Gerrand <adg@golang.org>
-
Josh Bleecher Snyder authored
Passes toolstash -cmp. Change-Id: I6ec2143a30c1f2c15f8ec74422c954ed6b9b1a0f Reviewed-on: https://go-review.googlesource.com/20452Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-
Matthew Dempsky authored
Suggested by Dave Cheney in golang.org/cl/20405. Change-Id: I581c11ae80034cb6ebef3de976e8ae9484472322 Reviewed-on: https://go-review.googlesource.com/20453Reviewed-by: Dave Cheney <dave@cheney.net> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Ian Lance Taylor authored
This CL was automatically generated using a special-purpose AST rewriting tool, followed by manual editing to put some comments back in the right places and fix some bad line breaks. The result is not perfect but it's a big step toward getting back to sanity, and because it was automatically generated there is a decent chance that it is correct. Passes toolstash -cmp. Update #14473. Change-Id: I01c09078a6d78e2b008bc304d744b79469a38d3d Reviewed-on: https://go-review.googlesource.com/20440Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
Matthew Dempsky authored
More idiomatic naming (in particular, matches the naming used for go/types.Signature). Also, convert more code to use these methods and/or IterFields. (Still more to go; only made a quick pass for low hanging fruit.) Passes toolstash -cmp. Change-Id: I61831bfb1ec2cd50d4c7efc6062bca4e0dcf267b Reviewed-on: https://go-review.googlesource.com/20451Reviewed-by: Ian Lance Taylor <iant@golang.org>
-
David Crawshaw authored
Alternative to golang.org/cl/19852. This memory layout doesn't have an easy type representation, but it is noticeably smaller than the current funcType, and saves significant extra space. Some notes on the layout are in reflect/type.go: // A *rtype for each in and out parameter is stored in an array that // directly follows the funcType (and possibly its uncommonType). So // a function type with one method, one input, and one output is: // // struct { // funcType // uncommonType // [2]*rtype // [0] is in, [1] is out // uncommonTypeSliceContents // } There are three arbitrary limits introduced by this CL: 1. No more than 65535 function input parameters. 2. No more than 32767 function output parameters. 3. reflect.FuncOf is limited to 128 parameters. I don't think these are limits in practice, but are worth noting. Reduces godoc binary size by 2.4%, 330KB. For #6853. Change-Id: I225c0a0516ebdbe92d41dfdf43f716da42dfe347 Reviewed-on: https://go-review.googlesource.com/19916Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Andrew Gerrand authored
Fixes #14662 Change-Id: I8f7d5e8d2dd8dc763e940e061b424427359246e7 Reviewed-on: https://go-review.googlesource.com/20462Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
Andrew Gerrand authored
Change-Id: Iaa23d27043e6a050075b40072e466623418ba977 Reviewed-on: https://go-review.googlesource.com/19878Reviewed-by: Rob Pike <r@golang.org>
-
Matthew Dempsky authored
Passes toolstash -cmp. Change-Id: I325b02dcc8412ded0dc304d43377c0bdf59c66a8 Reviewed-on: https://go-review.googlesource.com/20405Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Andrew Gerrand authored
Fixes #14687 Change-Id: I51fd8842d35c82db71cc5b28c4c0550871461eb6 Reviewed-on: https://go-review.googlesource.com/20421Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-
- 08 Mar, 2016 6 commits
-
-
David Crawshaw authored
Instead of a pointer on every rtype, use a bit flag to indicate that the contents of uncommonType directly follows the rtype value when it is needed. This requires a bit of juggling in the compiler's rtype encoder. The backing arrays for fields in the rtype are presently encoded directly after the slice header. This packing requires separating the encoding of the uncommonType slice headers from their backing arrays. Reduces binary size of godoc by ~180KB (1.5%). No measurable change in all.bash time. For #6853. Change-Id: I60205948ceb5c0abba76fdf619652da9c465a597 Reviewed-on: https://go-review.googlesource.com/19790Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
David Chase authored
Converting an and-K into a pair of shifts for K that will fit in a one-byte argument is probably not an optimization, and it also interferes with other patterns that we want to see fire, like (<< (AND K)) [for small K] and bounds check elimination for masked indices. Turns out that on Intel, even 32-bit signed immediates beat the shift pair; the size reduction of tool binaries is 0.09% vs 0.07% for only the 8-bit immediates. RLH found this one working on the new/next GC. Change-Id: I2414a8de1dd58d680d18587577fbadb7ff4f67d9 Reviewed-on: https://go-review.googlesource.com/20410Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: David Chase <drchase@google.com>
-
Matthew Dempsky authored
Some cleaned up documentation, but no code changes. Change-Id: I145398bb6d118c626ab3873ef75dbb64ebc286e9 Reviewed-on: https://go-review.googlesource.com/20404 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Brad Fitzpatrick authored
Don't do a substring search to test for a timeout error. Fixes #14722 (maybe) Change-Id: I4e18c749d6fd92c084a1b0b83a805119e1ae5ff2 Reviewed-on: https://go-review.googlesource.com/20403 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-
Alexandru Moșoi authored
* Simplify the nilcheck generated by for _, e := range a {} * No effect on the generated code because these nil checks don't end up in the generated code. * Useful for other analysis, e.g. it'll remove one dependecy on the induction variable. Change-Id: I6ee66ddfdc010ae22aea8dca48163303d93de7a9 Reviewed-on: https://go-review.googlesource.com/20307 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
-
Matthew Dempsky authored
Make more idiomatic with a defer cleanup, which allows declaring variables closer to their first use, rather than up front before the first goto statement. Also, split the legacy code generation code path into a separate genlegacy function, analogous to the new genssa. Passes toolstash -cmp. Change-Id: I86c22838704f6861b75716ae64ba103b0e73b12f Reviewed-on: https://go-review.googlesource.com/20353Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-