1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:21:22 -06:00
Commit Graph

5988 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
45ccea71a1 Revert "Revert "cmd/dist: consolidate runtime CPU tests""
This reverts commit 81c2233b4a.

Change-Id: Ie7024f04dba6352ae79ba68d4da5c0c25844cd8c
Reviewed-on: https://go-review.googlesource.com/9397
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-28 02:44:27 +00:00
Russ Cox
2a73559023 cmd/internal/gc: emit typedmemmove write barrier from sgen
Emitting it here instead of rewriting the tree earlier sets us up
to generate an inline check, like we do for single pointers.
But even without the inline check, generating at this level lets
us generate significantly more efficient code, probably due to
having fewer temporaries and less complex high-level code
for the compiler to churn through.

Revcomp is worse, almost certainly due to register pressure.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.0s × (0.99,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.43s × (1.00,1.00)     4.36s × (1.00,1.00)  -1.44%
BenchmarkFmtFprintfEmpty           114ns × (0.95,1.05)      86ns × (0.97,1.06)  -24.12%
BenchmarkFmtFprintfString          468ns × (0.99,1.01)     420ns × (0.99,1.02)  -10.16%
BenchmarkFmtFprintfInt             433ns × (1.00,1.01)     386ns × (0.99,1.02)  -10.74%
BenchmarkFmtFprintfIntInt          748ns × (0.99,1.01)     647ns × (0.99,1.01)  -13.56%
BenchmarkFmtFprintfPrefixedInt     547ns × (0.99,1.01)     499ns × (0.99,1.02)  -8.78%
BenchmarkFmtFprintfFloat           756ns × (1.00,1.01)     689ns × (1.00,1.00)  -8.86%
BenchmarkFmtManyArgs              2.79µs × (1.00,1.01)    2.53µs × (1.00,1.00)  -9.30%
BenchmarkGobDecode                39.6ms × (0.99,1.00)    39.2ms × (0.98,1.01)  -1.07%
BenchmarkGobEncode                37.6ms × (1.00,1.01)    37.5ms × (0.99,1.01)  ~
BenchmarkGzip                      663ms × (0.99,1.02)     660ms × (0.98,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     133µs × (0.99,1.02)  ~
BenchmarkJSONEncode               56.2ms × (0.99,1.01)    54.0ms × (0.98,1.01)  -3.97%
BenchmarkJSONDecode                138ms × (1.00,1.00)     134ms × (0.99,1.02)  -2.70%
BenchmarkMandelbrot200            6.03ms × (1.00,1.01)    6.00ms × (1.00,1.01)  ~
BenchmarkGoParse                  9.82ms × (0.93,1.10)   10.35ms × (0.88,1.11)  ~
BenchmarkRegexpMatchEasy0_32       207ns × (1.00,1.00)     163ns × (0.99,1.01)  -21.26%
BenchmarkRegexpMatchEasy0_1K       581ns × (1.00,1.01)     566ns × (0.99,1.00)  -2.50%
BenchmarkRegexpMatchEasy1_32       185ns × (0.99,1.01)     138ns × (1.00,1.01)  -25.41%
BenchmarkRegexpMatchEasy1_1K       975ns × (1.00,1.01)     892ns × (1.00,1.00)  -8.51%
BenchmarkRegexpMatchMedium_32      328ns × (0.99,1.00)     252ns × (1.00,1.00)  -23.17%
BenchmarkRegexpMatchMedium_1K     88.6µs × (1.00,1.01)    73.0µs × (1.00,1.01)  -17.66%
BenchmarkRegexpMatchHard_32       4.69µs × (0.95,1.03)    3.85µs × (1.00,1.01)  -17.91%
BenchmarkRegexpMatchHard_1K        133µs × (1.00,1.01)     117µs × (1.00,1.00)  -12.34%
BenchmarkRevcomp                   902ms × (0.99,1.05)    1001ms × (0.94,1.01)  +11.04%
BenchmarkTemplate                  174ms × (0.99,1.01)     160ms × (0.99,1.01)  -7.70%
BenchmarkTimeParse                 639ns × (1.00,1.00)     622ns × (1.00,1.00)  -2.66%
BenchmarkTimeFormat                736ns × (1.00,1.01)     736ns × (1.00,1.02)  ~

Change-Id: Ib3bbeb379f5f4819e6f5dcf69bc88a2b7ed41460
Reviewed-on: https://go-review.googlesource.com/9225
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-04-28 01:38:18 +00:00
Russ Cox
653d56075d cmd/internal/gc: inline writeBarrierEnabled check before calling writebarrierptr
I believe the benchmarks that get slower are under register pressure,
and not making the call unconditionally makes the pressure worse,
and the register allocator doesn't do a great job. But part of the point
of this sequence is to get the write barriers out of the way so I can work
on the register allocator, so that's okay.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (1.00,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.43s × (1.00,1.00)     4.43s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           110ns × (1.00,1.06)     114ns × (0.95,1.05)  ~
BenchmarkFmtFprintfString          487ns × (0.99,1.00)     468ns × (0.99,1.01)  -4.00%
BenchmarkFmtFprintfInt             450ns × (0.99,1.00)     433ns × (1.00,1.01)  -3.88%
BenchmarkFmtFprintfIntInt          762ns × (1.00,1.00)     748ns × (0.99,1.01)  -1.84%
BenchmarkFmtFprintfPrefixedInt     584ns × (0.99,1.01)     547ns × (0.99,1.01)  -6.26%
BenchmarkFmtFprintfFloat           738ns × (1.00,1.00)     756ns × (1.00,1.01)  +2.37%
BenchmarkFmtManyArgs              2.80µs × (1.00,1.01)    2.79µs × (1.00,1.01)  ~
BenchmarkGobDecode                39.0ms × (0.99,1.00)    39.6ms × (0.99,1.00)  +1.54%
BenchmarkGobEncode                37.8ms × (0.98,1.01)    37.6ms × (1.00,1.01)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     663ms × (0.99,1.02)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     142ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               56.3ms × (0.99,1.01)    56.2ms × (0.99,1.01)  ~
BenchmarkJSONDecode                138ms × (0.99,1.01)     138ms × (1.00,1.00)  ~
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.03ms × (1.00,1.01)  +0.23%
BenchmarkGoParse                  10.2ms × (0.87,1.05)     9.8ms × (0.93,1.10)  ~
BenchmarkRegexpMatchEasy0_32       208ns × (1.00,1.00)     207ns × (1.00,1.00)  ~
BenchmarkRegexpMatchEasy0_1K       588ns × (1.00,1.00)     581ns × (1.00,1.01)  -1.27%
BenchmarkRegexpMatchEasy1_32       182ns × (0.99,1.01)     185ns × (0.99,1.01)  +1.65%
BenchmarkRegexpMatchEasy1_1K       986ns × (1.00,1.01)     975ns × (1.00,1.01)  -1.17%
BenchmarkRegexpMatchMedium_32      323ns × (1.00,1.01)     328ns × (0.99,1.00)  +1.55%
BenchmarkRegexpMatchMedium_1K     89.9µs × (1.00,1.00)    88.6µs × (1.00,1.01)  -1.38%
BenchmarkRegexpMatchHard_32       4.72µs × (0.95,1.01)    4.69µs × (0.95,1.03)  ~
BenchmarkRegexpMatchHard_1K        133µs × (1.00,1.01)     133µs × (1.00,1.01)  ~
BenchmarkRevcomp                   900ms × (1.00,1.05)     902ms × (0.99,1.05)  ~
BenchmarkTemplate                  168ms × (0.99,1.01)     174ms × (0.99,1.01)  +3.30%
BenchmarkTimeParse                 637ns × (1.00,1.00)     639ns × (1.00,1.00)  +0.31%
BenchmarkTimeFormat                738ns × (1.00,1.00)     736ns × (1.00,1.01)  ~

Change-Id: I03ce152852edec404538f6c20eb650fac82e2aa2
Reviewed-on: https://go-review.googlesource.com/9224
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:38:06 +00:00
Russ Cox
2050f57141 runtime: change unused argument in fat write barriers from pointer to scalar
The argument is unused, only present for alignment of the
following argument. The compiler today always passes a zero
but I'd rather not write anything there during the call sequence,
so mark it as a scalar so the garbage collector won't look at it.

As expected, no significant performance change.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (0.99,1.00)     17.9s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.35s × (1.00,1.00)     4.35s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           120ns × (0.94,1.05)     120ns × (0.93,1.06)  ~
BenchmarkFmtFprintfString          477ns × (1.00,1.00)     479ns × (0.99,1.00)  ~
BenchmarkFmtFprintfInt             450ns × (0.99,1.01)     452ns × (0.99,1.02)  ~
BenchmarkFmtFprintfIntInt          765ns × (0.99,1.01)     766ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     569ns × (0.99,1.01)     576ns × (0.98,1.01)  ~
BenchmarkFmtFprintfFloat           728ns × (1.00,1.00)     730ns × (1.00,1.01)  ~
BenchmarkFmtManyArgs              2.82µs × (0.99,1.01)    2.84µs × (0.99,1.00)  ~
BenchmarkGobDecode                39.1ms × (0.99,1.01)    39.3ms × (0.98,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.01)    39.5ms × (0.99,1.01)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     663ms × (1.00,1.01)  ~
BenchmarkGunzip                    143ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          133µs × (0.99,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               57.3ms × (0.99,1.04)    57.4ms × (0.99,1.01)  ~
BenchmarkJSONDecode                139ms × (0.99,1.00)     139ms × (0.99,1.00)  ~
BenchmarkMandelbrot200            6.02ms × (1.00,1.00)    6.03ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.72ms × (0.92,1.11)   10.31ms × (0.89,1.14)  ~
BenchmarkRegexpMatchEasy0_32       209ns × (1.00,1.01)     209ns × (1.00,1.00)  ~
BenchmarkRegexpMatchEasy0_1K       592ns × (0.99,1.00)     591ns × (0.99,1.00)  ~
BenchmarkRegexpMatchEasy1_32       183ns × (0.98,1.01)     184ns × (0.99,1.02)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.01)    1.01µs × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_32      330ns × (1.00,1.00)     330ns × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_1K     92.4µs × (1.00,1.00)    92.6µs × (1.00,1.00)  ~
BenchmarkRegexpMatchHard_32       4.77µs × (0.95,1.01)    4.80µs × (0.95,1.00)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.00)     136µs × (1.00,1.00)  ~
BenchmarkRevcomp                   906ms × (0.99,1.05)     900ms × (0.99,1.04)  ~
BenchmarkTemplate                  171ms × (0.99,1.01)     172ms × (1.00,1.00)  ~
BenchmarkTimeParse                 638ns × (1.00,1.00)     637ns × (1.00,1.00)  ~
BenchmarkTimeFormat                745ns × (0.99,1.02)     744ns × (1.00,1.01)  ~

Change-Id: I0aeac5dc7adfd75e2223e3aabfedc7818d339f9b
Reviewed-on: https://go-review.googlesource.com/9320
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:45 +00:00
Russ Cox
6c328efc4c cmd/internal/gc: accept comma-separated list of name=value for -d
This should obviously have no performance impact.
Listing numbers just as a sanity check for the benchmark
comparison program: it should (and does) find nothing
to report.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.0s × (0.99,1.01)     17.9s × (0.99,1.00)  ~
BenchmarkFannkuch11                4.36s × (1.00,1.00)     4.35s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           120ns × (0.99,1.06)     120ns × (0.94,1.05)  ~
BenchmarkFmtFprintfString          480ns × (0.99,1.01)     477ns × (1.00,1.00)  ~
BenchmarkFmtFprintfInt             451ns × (0.99,1.01)     450ns × (0.99,1.01)  ~
BenchmarkFmtFprintfIntInt          766ns × (0.99,1.01)     765ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     569ns × (0.99,1.01)     569ns × (0.99,1.01)  ~
BenchmarkFmtFprintfFloat           728ns × (1.00,1.01)     728ns × (1.00,1.00)  ~
BenchmarkFmtManyArgs              2.81µs × (1.00,1.01)    2.82µs × (0.99,1.01)  ~
BenchmarkGobDecode                39.4ms × (0.99,1.01)    39.1ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.00)    39.4ms × (0.99,1.01)  ~
BenchmarkGzip                      660ms × (1.00,1.01)     661ms × (0.99,1.01)  ~
BenchmarkGunzip                    143ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     133µs × (0.99,1.01)  ~
BenchmarkJSONEncode               57.1ms × (0.99,1.01)    57.3ms × (0.99,1.04)  ~
BenchmarkJSONDecode                138ms × (1.00,1.01)     139ms × (0.99,1.00)  ~
BenchmarkMandelbrot200            6.02ms × (1.00,1.00)    6.02ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.79ms × (0.92,1.07)    9.72ms × (0.92,1.11)  ~
BenchmarkRegexpMatchEasy0_32       210ns × (1.00,1.01)     209ns × (1.00,1.01)  ~
BenchmarkRegexpMatchEasy0_1K       593ns × (0.99,1.01)     592ns × (0.99,1.00)  ~
BenchmarkRegexpMatchEasy1_32       182ns × (0.99,1.01)     183ns × (0.98,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.01)    1.01µs × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_32      331ns × (1.00,1.00)     330ns × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_1K     92.6µs × (1.00,1.01)    92.4µs × (1.00,1.00)  ~
BenchmarkRegexpMatchHard_32       4.58µs × (0.99,1.05)    4.77µs × (0.95,1.01)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.01)     136µs × (1.00,1.00)  ~
BenchmarkRevcomp                   900ms × (0.99,1.06)     906ms × (0.99,1.05)  ~
BenchmarkTemplate                  171ms × (1.00,1.01)     171ms × (0.99,1.01)  ~
BenchmarkTimeParse                 637ns × (1.00,1.00)     638ns × (1.00,1.00)  ~
BenchmarkTimeFormat                742ns × (1.00,1.00)     745ns × (0.99,1.02)  ~

Change-Id: I59ec875715cb176bbffa709546370a6a7fc5a75d
Reviewed-on: https://go-review.googlesource.com/9309
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:34 +00:00
Russ Cox
0f0bc0f016 cmd/internal/gc: use MOV R0, R1 instead of LEA 0(R0), R1 in Agen
Minor code generation optimization I've been meaning to do
for a while and noticed while working on the emitted write
barrier code. Using MOV lets the compiler and maybe the
processor do copy propagation.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (0.99,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.42s × (1.00,1.00)     4.36s × (1.00,1.00)  -1.39%
BenchmarkFmtFprintfEmpty           118ns × (0.96,1.02)     120ns × (0.99,1.06)  ~
BenchmarkFmtFprintfString          486ns × (0.99,1.01)     480ns × (0.99,1.01)  -1.34%
BenchmarkFmtFprintfInt             457ns × (0.99,1.01)     451ns × (0.99,1.01)  -1.31%
BenchmarkFmtFprintfIntInt          768ns × (1.00,1.01)     766ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     584ns × (0.99,1.03)     569ns × (0.99,1.01)  -2.57%
BenchmarkFmtFprintfFloat           739ns × (0.99,1.00)     728ns × (1.00,1.01)  -1.49%
BenchmarkFmtManyArgs              2.77µs × (1.00,1.00)    2.81µs × (1.00,1.01)  +1.53%
BenchmarkGobDecode                39.3ms × (0.99,1.01)    39.4ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.00)    39.4ms × (0.99,1.00)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     660ms × (1.00,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     143ms × (1.00,1.00)  +0.20%
BenchmarkHTTPClientServer          133µs × (0.98,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               56.5ms × (0.99,1.01)    57.1ms × (0.99,1.01)  +0.94%
BenchmarkJSONDecode                143ms × (1.00,1.00)     138ms × (1.00,1.01)  -3.22%
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.02ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.63ms × (0.94,1.07)    9.79ms × (0.92,1.07)  ~
BenchmarkRegexpMatchEasy0_32       210ns × (1.00,1.00)     210ns × (1.00,1.01)  ~
BenchmarkRegexpMatchEasy0_1K       596ns × (0.99,1.01)     593ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_32       184ns × (0.99,1.01)     182ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (0.99,1.01)    1.01µs × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_32      327ns × (1.00,1.01)     331ns × (1.00,1.00)  +1.22%
BenchmarkRegexpMatchMedium_1K     93.0µs × (1.00,1.02)    92.6µs × (1.00,1.01)  ~
BenchmarkRegexpMatchHard_32       4.76µs × (0.95,1.01)    4.58µs × (0.99,1.05)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.01)     136µs × (1.00,1.01)  ~
BenchmarkRevcomp                   892ms × (1.00,1.01)     900ms × (0.99,1.06)  ~
BenchmarkTemplate                  175ms × (0.99,1.00)     171ms × (1.00,1.01)  -2.36%
BenchmarkTimeParse                 638ns × (1.00,1.00)     637ns × (1.00,1.00)  ~
BenchmarkTimeFormat                772ns × (1.00,1.00)     742ns × (1.00,1.00)  -3.95%

Change-Id: I6504e310cb9cf48a73d539c478b4dbcacde208b2
Reviewed-on: https://go-review.googlesource.com/9308
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:33 +00:00
Russ Cox
0ad4f8b1f7 cmd/internal/gc: emit write barriers at lower level
This is primarily preparation for inlining, not an optimization by itself,
but it still helps some.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.2s × (0.99,1.01)     17.9s × (0.99,1.01)  -1.57%
BenchmarkFannkuch11                4.44s × (1.00,1.00)     4.42s × (1.00,1.00)  -0.40%
BenchmarkFmtFprintfEmpty           119ns × (0.95,1.02)     118ns × (0.96,1.02)  ~
BenchmarkFmtFprintfString          501ns × (0.99,1.02)     486ns × (0.99,1.01)  -2.89%
BenchmarkFmtFprintfInt             474ns × (0.99,1.00)     457ns × (0.99,1.01)  -3.59%
BenchmarkFmtFprintfIntInt          792ns × (1.00,1.00)     768ns × (1.00,1.01)  -3.03%
BenchmarkFmtFprintfPrefixedInt     574ns × (1.00,1.01)     584ns × (0.99,1.03)  +1.83%
BenchmarkFmtFprintfFloat           749ns × (1.00,1.00)     739ns × (0.99,1.00)  -1.34%
BenchmarkFmtManyArgs              2.94µs × (1.00,1.01)    2.77µs × (1.00,1.00)  -5.76%
BenchmarkGobDecode                39.5ms × (0.99,1.01)    39.3ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (1.00,1.01)    39.4ms × (0.99,1.00)  ~
BenchmarkGzip                      658ms × (1.00,1.01)     661ms × (0.99,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     142ms × (1.00,1.00)  +0.22%
BenchmarkHTTPClientServer          134µs × (0.99,1.01)     133µs × (0.98,1.01)  ~
BenchmarkJSONEncode               57.1ms × (0.99,1.01)    56.5ms × (0.99,1.01)  ~
BenchmarkJSONDecode                141ms × (1.00,1.00)     143ms × (1.00,1.00)  +1.09%
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.01ms × (1.00,1.00)  ~
BenchmarkGoParse                  10.1ms × (0.91,1.09)     9.6ms × (0.94,1.07)  ~
BenchmarkRegexpMatchEasy0_32       207ns × (1.00,1.01)     210ns × (1.00,1.00)  +1.45%
BenchmarkRegexpMatchEasy0_1K       592ns × (0.99,1.00)     596ns × (0.99,1.01)  +0.68%
BenchmarkRegexpMatchEasy1_32       184ns × (0.99,1.01)     184ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.00)    1.01µs × (0.99,1.01)  ~
BenchmarkRegexpMatchMedium_32      327ns × (0.99,1.00)     327ns × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_1K     92.5µs × (1.00,1.00)    93.0µs × (1.00,1.02)  +0.48%
BenchmarkRegexpMatchHard_32       4.79µs × (0.95,1.00)    4.76µs × (0.95,1.01)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.00)     136µs × (1.00,1.01)  ~
BenchmarkRevcomp                   900ms × (0.99,1.01)     892ms × (1.00,1.01)  ~
BenchmarkTemplate                  170ms × (0.99,1.01)     175ms × (0.99,1.00)  +2.95%
BenchmarkTimeParse                 645ns × (1.00,1.00)     638ns × (1.00,1.00)  -1.16%
BenchmarkTimeFormat                740ns × (1.00,1.00)     772ns × (1.00,1.00)  +4.39%

Change-Id: I0be905e32791e0cb70ff01f169c4b309a971d981
Reviewed-on: https://go-review.googlesource.com/9159
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-28 01:37:05 +00:00
Rob Pike
a5de54a870 cmd/go,cmd/doc: add "go doc"
Add the new go doc command to the go command, installed in
the tool directory.

(Still to do: tests)

Fix cmd/dist to remove old "package documentation" code that was
stopping it from including cmd/go/doc.go in the build.

Implement the doc command. Here is the help info from "go help doc":

===
usage: go doc [-u] [package|[package.]symbol[.method]]

Doc accepts at most one argument, indicating either a package, a symbol within a
package, or a method of a symbol.

	go doc
	go doc <pkg>
	go doc <sym>[.<method>]
	go doc [<pkg>].<sym>[.<method>]

Doc interprets the argument to see what it represents, determined by its syntax
and which packages and symbols are present in the source directories of GOROOT and
GOPATH.

The first item in this list that succeeds is the one whose documentation is printed.
For packages, the order of scanning is determined by the file system, however the
GOROOT tree is always scanned before GOPATH.

If there is no package specified or matched, the package in the current directory
is selected, so "go doc" shows the documentation for the current package and
"go doc Foo" shows the documentation for symbol Foo in the current package.

Doc prints the documentation comments associated with the top-level item the
argument identifies (package, type, method) followed by a one-line summary of each
of the first-level items "under" that item (package-level declarations for a
package, methods for a type, etc.)

The package paths must be either a qualified path or a proper suffix of a path
(see examples below). The go tool's usual package mechanism does not apply: package
path elements like . and ...  are not implemented by go doc.

When matching symbols, lower-case letters match either case but upper-case letters
match exactly.

Examples:
	go doc
		Show documentation for current package.
	go doc Foo
		Show documentation for Foo in the current package.
		(Foo starts with a capital letter so it cannot match a package path.)
	go doc json
		Show documentation for the encoding/json package.
	go doc json
		Shorthand for encoding/json assuming only one json package
		is present in the tree.
	go doc json.Number (or go doc json.number)
		Show documentation and method summary for json.Number.
	go doc json.Number.Int64 (or go doc json.number.int64)
		Show documentation for the Int64 method of json.Number.

Flags:
	-u
		Show documentation for unexported as well as exported
		symbols and methods.

===

Still to do:

Tests.
Disambiguation when there is both foo and Foo.
Flag for case-sensitive matching.

Change-Id: I83d409a68688a5445f54297a7e7c745f749b9e66
Reviewed-on: https://go-review.googlesource.com/9227
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-27 23:22:26 +00:00
Josh Bleecher Snyder
00d4a6b35d cmd/internal/gc, cmd/internal/ld: add memprofilerate flag
Also call runtime.GC before exit to ensure
that the profiler picks up all allocations.

Fixes #10537.

Change-Id: Ibfbfc88652ac0ce30a6d1ae392f919df6c1e8126
Reviewed-on: https://go-review.googlesource.com/9261
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-27 22:21:40 +00:00
Josh Bleecher Snyder
81c2233b4a Revert "cmd/dist: consolidate runtime CPU tests"
This reverts commit a9e50a6b35.

Change-Id: I3c5e459f1030e36bc249910facdae12303a44151
Reviewed-on: https://go-review.googlesource.com/9394
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-27 17:56:04 +00:00
Josh Bleecher Snyder
a9e50a6b35 cmd/dist: consolidate runtime CPU tests
Instead of running:

go test -short runtime -cpu=1
go test -short runtime -cpu=2
go test -short runtime -cpu=4

Run just:

go test -short runtime -cpu=1,2,4

This is a return to the Go 1.4.2 behavior.

We lose incremental display of progress and
per-cpu timing information, but we don't have
to recompile and relink the runtime test,
which is slow.

This cuts about 10s off all.bash.

Updates #10571.

Change-Id: I6e8c7149780d47439f8bcfa888e6efc84290c60a
Reviewed-on: https://go-review.googlesource.com/9350
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-04-27 17:36:18 +00:00
Josh Bleecher Snyder
2692f48330 cmd/internal/ld: remove pointless allocs
Reduces allocs linking cmd/go and runtime.test
by ~13%. No functional changes.

The most easily addressed sources of allocations
after this are expandpkg, rdstring, and symbuf
string conversion.

These can be reduced by interning strings,
but that increases the overall memory footprint.

Change-Id: Ifedefc9f2a0403bcc75460d6b139e8408374e058
Reviewed-on: https://go-review.googlesource.com/9391
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-27 17:08:56 +00:00
Håvard Haugen
14a4649fe2 cmd/pprof: handle empty profile gracefully
The command "go tool pprof -top $GOROOT/bin/go /dev/null" now logs that
profile is empty instead of panicking.

Fixes #9207

Change-Id: I3d55c179277cb19ad52c8f24f1aca85db53ee08d
Reviewed-on: https://go-review.googlesource.com/2571
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-26 20:12:17 +00:00
Michael Hudson-Doyle
c20ff36fe2 cmd/internal/ld: R_TLS_LE is fine on Darwin too
Sorry about this.

Fixes #10575

Change-Id: I2de23be68e7d822d182e5a0d6a00c607448d861e
Reviewed-on: https://go-review.googlesource.com/9341
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-26 04:53:51 +00:00
Michael Hudson-Doyle
264858c46e cmd/8l, cmd/internal/ld, cmd/internal/obj/x86: stop incorrectly using the term "inital exec"
The long comment block in obj6.go:progedit talked about the two code sequences
for accessing g as "local exec" and "initial exec", but really they are both forms
of local exec. This stuff is confusing enough without using the wrong words for
things, so rewrite it to talk about 2-instruction and 1-instruction sequences.
Unfortunately the confusion has made it into code, with the R_TLS_IE relocation
now doing double duty as meaning actual initial exec when externally linking and
boring old local exec when linking internally (half of this is my fault). So this
stops using R_TLS_IE in the local exec case. There is a chance this might break
plan9 or windows, but I don't think so. Next step is working out what the heck is
going on on ARM...

Change-Id: I09da4388210cf49dbc99fd25f5172bbe517cee57
Reviewed-on: https://go-review.googlesource.com/9273
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-25 18:13:15 +00:00
Michael Hudson-Doyle
ccc76dba60 cmd/internal/ld: fix R_TLS handling now Xsym is not read from object file
I think this should fix the arm build. A proper fix involves making the handling
of tlsg less fragile, I'll try that tomorrow.

Update #10557

Change-Id: I9b1b666737fb40aebb6f284748509afa8483cce5
Reviewed-on: https://go-review.googlesource.com/9272
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
2015-04-24 20:57:49 +00:00
Rob Pike
b3000b6f6a cmd/go: rename doc.go to alldocs.go in preparation for "go doc"
Also rename and update mkdoc.sh to mkalldocs.sh

Change-Id: Ief3673c22d45624e173fc65ee279cea324da03b5
Reviewed-on: https://go-review.googlesource.com/9226
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-24 18:29:59 +00:00
Hyang-Ah Hana Kim
8566979972 misc/cgo/testcshared: add a c-shared test for android/arm.
- main3.c tests main.main is exported when compiled for GOOS=android.
- wait longer for main2.c (it's slow on android/arm)
- rearranged test.bash

Fixes #10070.

Change-Id: I6e5a98d1c5fae776afa54ecb5da633b59b269316
Reviewed-on: https://go-review.googlesource.com/9296
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-24 16:32:31 +00:00
Michael Hudson-Doyle
029c7bbdfe cmd/internal/gc, cmd/internal/ld, cmd/internal/obj: teach compiler about local symbols
This lets us avoid loading string constants via the GOT and (together with
http://golang.org/cl/9102) results in the fannkuch benchmark having very similar
register usage with -dynlink as without.

Change-Id: Ic3892b399074982b76773c3e547cfbba5dabb6f9
Reviewed-on: https://go-review.googlesource.com/9103
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-24 16:19:41 +00:00
Russ Cox
9406f68e6a cmd/internal/gc: add and test write barrier debug output
We can expand the test cases as we discover problems.
This is some basic tests plus all the things I got wrong
in some recent work.

Change-Id: Id875fcfaf74eb087ae42b441fe47a34c5b8ccb39
Reviewed-on: https://go-review.googlesource.com/9158
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-04-24 14:39:49 +00:00
Shenghou Ma
7579867fec cmd/dist: allow $GO_TEST_TIMEOUT_SCALE to override timeoutScale
Some machines are so slow that even with the default timeoutScale,
they still timeout some tests. For example, currently some linux/arm
builders and the openbsd/arm builder are timing out the runtime
test and CL 8397 was proposed to skip some tests on openbsd/arm
to fix the build.

Instead of increasing timeoutScale or skipping tests, this CL
introduces an environment variable $GO_TEST_TIMEOUT_SCALE that
could be set to manually set a larger timeoutScale for those
machines/builders.

Fixes #10314.

Change-Id: I16c9a9eb980d6a63309e4cacd79eee2fe05769ee
Reviewed-on: https://go-review.googlesource.com/9223
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-24 05:45:36 +00:00
Srdjan Petrovic
5c8fbc6f1e runtime: signal forwarding
Forward signals to signal handlers installed before Go installs its own,
under certain circumstances.  In particular, as iant@ suggests, signals are
forwarded iff:
   (1) a non-SIG_DFL signal handler existed before Go, and
   (2) signal is synchronous (i.e., one of SIGSEGV, SIGBUS, SIGFPE), and
   	(3a) signal occured on a non-Go thread, or
   	(3b) signal occurred on a Go thread but in CGo code.

Supported only on Linux, for now.

Change-Id: I403219ee47b26cf65da819fb86cf1ec04d3e25f5
Reviewed-on: https://go-review.googlesource.com/8712
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-24 05:19:39 +00:00
Josh Bleecher Snyder
04829a4138 cmd/9g, etc: remove // fallthrough comments
They are vestiges of the c2go transition.

Change-Id: I22672e40373ef77d7a0bf69cfff8017e46353055
Reviewed-on: https://go-review.googlesource.com/9265
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-23 23:46:19 +00:00
Josh Bleecher Snyder
c231228085 cmd/internal/gc: remove /*untyped*/ comments
They are vestiges of the c2go translation.

Change-Id: I9a10536f5986b751a35cc7d84b5ba69ae0c2ede7
Reviewed-on: https://go-review.googlesource.com/9262
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-23 01:21:44 +00:00
Michael Hudson-Doyle
68f5570032 cmd/link, cmd/internal/goobj: update constants, regenerate testdata
The constants in cmd/internal/goobj had gone stale (we had three copies of
these constants, working on reducing that was what got me to noticing this).

Some of the changes to link.hello.darwin.amd64 are the change from absolute
to %rip-relative addressing, a change which happened quite a while ago...

Depends on http://golang.org/cl/9113.

Fixes #10501.

Change-Id: Iaa1511f458a32228c2df2ccd0076bb9ae212a035
Reviewed-on: https://go-review.googlesource.com/9105
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-22 20:32:16 +00:00
Michael Hudson-Doyle
91318dc76c cmd/go: refactor creation of top-level actions for -buildmode=shared
Change-Id: I429402dd91243cd9415b054ee17bfebccc68ed57
Reviewed-on: https://go-review.googlesource.com/9197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-22 19:28:03 +00:00
Michael Hudson-Doyle
7820d27049 cmd/internal/gc, cmd/internal/ld: fixes for global vars of types from other modules
To make the gcprog for global data containing variables of types defined in other shared
libraries, we need to know a lot about those types. So read the value of any symbol with
a name starting with "type.". If a type uses a mask, the name of the symbol defining the
mask unfortunately cannot be predicted from the type name so I have to keep track of the
addresses of every such symbol and associate them with the type symbols after the fact.

I'm not very happy about this change, but something like this is needed and this is as
pleasant as I know how to make it.

Change-Id: I408d831b08b3b31e0610688c41367b23998e975c
Reviewed-on: https://go-review.googlesource.com/8334
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-22 19:07:34 +00:00
Michael Hudson-Doyle
ac1cdd13e0 cmd/5g, etc, cmd/internal/gc, cmd/internal/obj, etc: coalesce bool2int implementations
There were 10 implementations of the trivial bool2int function, 9 of which
were the only thing in their file.  Remove all of them in favor of one in
cmd/internal/obj.

Change-Id: I9c51d30716239df51186860b9842a5e9b27264d3
Reviewed-on: https://go-review.googlesource.com/9230
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-22 18:50:07 +00:00
Ian Lance Taylor
af161c577c cmd/go: depend on runtime/cgo if external linking mode is forced
In external linking mode, the linker automatically imports
runtime/cgo.  When the user uses non-standard compilation options,
they have to know to run go install runtime/cgo.  When the go tool
adds non-standard compilation options itself, we can't force the user
to do that.  So add the dependency ourselves.

Bad news: we don't currently have a clean way to know whether we are
going to use external linking mode.  This CL duplicates logic split
between cmd/6l and cmd/internal/ld.

Good news: adding an unnecessary dependency on runtime/cgo does no
real harm.  We aren't going to force the linker to pull it in, we're
just going to build it so that its available if the linker wants it.

Change-Id: Ide676339d4e8b1c3d9792884a2cea921abb281b7
Reviewed-on: https://go-review.googlesource.com/9115
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-21 17:35:33 +00:00
Josh Bleecher Snyder
873483c682 cmd/internal/obj: reuse the varint encoding buffer
This reduces the number of allocations in the compiler
while building the stdlib by 15.66%.

No functional changes. Passes toolstash -cmp.

Change-Id: Ia21b37134a8906a4e23d53fdc15235b4aa7bbb34
Reviewed-on: https://go-review.googlesource.com/9085
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-21 17:20:52 +00:00
Michael Hudson-Doyle
0088ddc3a0 cmd/6l, cmd/internal/ld, cmd/internal/obj: remove Xsym/Xadd from compiler's Reloc
They don't really make any sense on this side of the compiler/linker divide.

Some of the code touching these fields was the support for R_TLS when
thechar=='6' which turns out to be dead and so I just removed all of that.

Change-Id: I4e265613c4e7fcc30a965fffb7fd5f45017f06f3
Reviewed-on: https://go-review.googlesource.com/9107
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 03:00:19 +00:00
Michael Hudson-Doyle
f9bc9a7a2e cmd/internal/ld: set moduledatasize correctly when -linkshared
Change-Id: I1ea4175466c9113c1f41b012ba8266ee2b06e3a3
Reviewed-on: https://go-review.googlesource.com/8522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:21:38 +00:00
Michael Hudson-Doyle
8a3132dd5e cmd/6g: let the compiler use R15 when it is not needed for GOT indirection
Thanks to Russ for the hints.

Change-Id: Ie35a71d432b9d68bd30c7a364b4dce1bd3db806e
Reviewed-on: https://go-review.googlesource.com/9102
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:20:15 +00:00
Brad Fitzpatrick
88c08b06b9 cmd/internal: C->Go printf cleanup
Change-Id: I1cf94377c613fb51ae77f4fe1e3439268b1606a9
Reviewed-on: https://go-review.googlesource.com/9161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 22:36:59 +00:00
Matthew Dempsky
e7ffafdb6e cmd/internal/obj: remove useless Trimpath field and fix users
http://golang.org/cl/7623 refactored how line history works and
introduced a new TrimPathPrefix field to replace the existing Trimpath
field, but never removed the latter or updated its users.

Fixes #10503.

Change-Id: Ief90a55b6cef2e8062b59856a4c7dcc0df01d3f2
Reviewed-on: https://go-review.googlesource.com/9113
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2015-04-20 20:46:06 +00:00
Russ Cox
35b1dcc25f cmd/internal/gc: clean up componentgen
This is primarily about making the code clearer, but as part of the cleanup
componentgen is now much more consistent about what it does and does
not attempt.

The new limit is to 8 move instructions.

The old limit was either 3 or 4 small things but in the details it was
quite inconsistent: ints, interfaces, strings, and slices all counted as small;
it handled a struct containing two ints, but not a struct containing a struct
containing two ints; it handled slices and interfaces and a struct containing
a slice but not a struct containing an interface; and so on.

The new code runs at about the same speed as the old code if limited to 4 moves,
but that's much more restrictive when the pieces are strings or interfaces.
With the limit raised to 8 moves, this CL is sometimes a significant improvement:

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              4361174290     4362870005     +0.04%
BenchmarkFannkuch11                3008201483     2974408533     -1.12%
BenchmarkFmtFprintfEmpty           79.0           79.5           +0.63%
BenchmarkFmtFprintfString          281            261            -7.12%
BenchmarkFmtFprintfInt             264            262            -0.76%
BenchmarkFmtFprintfIntInt          447            443            -0.89%
BenchmarkFmtFprintfPrefixedInt     354            361            +1.98%
BenchmarkFmtFprintfFloat           500            452            -9.60%
BenchmarkFmtManyArgs               1688           1693           +0.30%
BenchmarkGobDecode                 11718456       11741179       +0.19%
BenchmarkGobEncode                 10144620       10161627       +0.17%
BenchmarkGzip                      437631642      435271877      -0.54%
BenchmarkGunzip                    109468858      110173606      +0.64%
BenchmarkHTTPClientServer          76248          75362          -1.16%
BenchmarkJSONEncode                24160474       23753091       -1.69%
BenchmarkJSONDecode                84470041       82902026       -1.86%
BenchmarkMandelbrot200             4676857        4687040        +0.22%
BenchmarkGoParse                   4954602        4923965        -0.62%
BenchmarkRegexpMatchEasy0_32       151            151            +0.00%
BenchmarkRegexpMatchEasy0_1K       450            452            +0.44%
BenchmarkRegexpMatchEasy1_32       131            130            -0.76%
BenchmarkRegexpMatchEasy1_1K       713            695            -2.52%
BenchmarkRegexpMatchMedium_32      227            218            -3.96%
BenchmarkRegexpMatchMedium_1K      63911          62966          -1.48%
BenchmarkRegexpMatchHard_32        3163           3026           -4.33%
BenchmarkRegexpMatchHard_1K        93985          90266          -3.96%
BenchmarkRevcomp                   650697093      649211600      -0.23%
BenchmarkTemplate                  107049170      106804076      -0.23%
BenchmarkTimeParse                 448            452            +0.89%
BenchmarkTimeFormat                468            460            -1.71%

Change-Id: I08563133883e88bb9db9e9e4dee438a5af2787da
Reviewed-on: https://go-review.googlesource.com/9004
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 20:26:57 +00:00
Matthew Dempsky
c776592a4f cmd/internal/ld: prefer constants from cmd/internal/obj
The majority of this CL was prepared via scripted invocations of
`gofmt -w -r "$SYM -> obj.$SYM" cmd/internal/ld/*.go` and `gofmt -w -r
"ld.$SYM -> obj.$SYM" cmd/?l/*.go`.

Because of issue #7417, that was followed by repeatedly running an AWK
script to identify lines that differed other than whitespace changes
or "ld." or "obj." prefixes and manually restoring comments.

Finally, the redundant constants from cmd/internal/ld/link.go were
removed, and "goimports -w" was used to cleanup import lines.

Passes rsc.io/toolstash/buildall, even when modified to also build cmd.

Fixes #10055.

Change-Id: Icd5dbe819a3b6520ce883748e60017dc8e9a2e85
Reviewed-on: https://go-review.googlesource.com/9112
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 20:05:13 +00:00
Russ Cox
6e221a9038 cmd/dist: run commands in $GOROOT/src not $GOROOT when possible
The go command prints paths in errors relative to its current directory.
Since all.bash and run.bash are run in $GOROOT/src, prefer to run
the go command, so that the relative paths are correct.

Before this CL, running all.bash in $GOROOT/src:

	##### Testing race detector
	# net/http
	src/net/http/transport.go:1257: cannot take the address of <node EFACE>

This is wrong (or at least less useful) because there is no $GOROOT/src/src/net/http directory.

Change-Id: I0c0d52c22830d79b3715f51a6329a3d33de52a72
Reviewed-on: https://go-review.googlesource.com/9157
Reviewed-by: Rob Pike <r@golang.org>
2015-04-20 19:54:01 +00:00
Brad Fitzpatrick
a13cf8c104 cmd/internal/obj: manual C->Go cleanups
Change-Id: I5964fc55157dc1df7be400dfa0df591d6163e25e
Reviewed-on: https://go-review.googlesource.com/9084
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 16:54:22 +00:00
David Crawshaw
3f4de49d0a cmd/dist: enable c-archive test on darwin/arm64
Turns out all the necessary pieces have already been submitted.

Change-Id: I19c8d614cd756821ce400ca7a338029002780b18
Reviewed-on: https://go-review.googlesource.com/9076
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:56:56 +00:00
David Crawshaw
98f610fe09 misc/cgo/testcarchive: enable test on darwin/arm
Change-Id: I0d3f9841500e0a41f1c427244869bf3736a31e18
Reviewed-on: https://go-review.googlesource.com/9075
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:16:16 +00:00
Hyang-Ah Hana Kim
983a490ee9 cmd/dist: include misc/cgo/testcshared test for linux/amd64
Change-Id: Ia2c0c617df523482ba1a25b7492267eb80f0819a
Reviewed-on: https://go-review.googlesource.com/9033
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 02:27:43 +00:00
Michael Hudson-Doyle
b92a0a8969 cmd/internal/gc, cmd/go: fix value of importpath symbol
In https://golang.org/cl/7797 I attempted to use myimportpath to set the value
of the go.importpath.$foo. symbol for the module being compiled, but I messed
it up and only set the name (which the linker rewrites anyway). This lead to
the importpath for the module being compiled being "". This was hard to notice,
because all modules that import another define the importpath for their
imported modules correctly -- but main is not imported, and this meant that the
reflect module saw all fields of all types defined in the main module as
exported.

The fix is to do what I meant to do the first time, add a test and change the
go tool to compile main packages with -p main and not -p
command-line-arguments.

Fixes #10332

Change-Id: I5fc6e9b1dc2b26f058641e382f9a56a526eca291
Reviewed-on: https://go-review.googlesource.com/8481
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-19 20:14:59 +00:00
Josh Bleecher Snyder
951f74c4d0 cmd/...: fix vet issues and cull dead code
Change-Id: Ied0eab872950793b34dd2268055b29c702b07e99
Reviewed-on: https://go-review.googlesource.com/9081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-18 01:47:28 +00:00
Matthew Dempsky
93402383ea cmd/cgo: more robust detection of clang
Fixes #10453.

Change-Id: I77470279865d4c954df615d6594c69edf68c28ca
Reviewed-on: https://go-review.googlesource.com/9090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 01:11:44 +00:00
Brad Fitzpatrick
05efc18c20 cmd/6g, etc: cleanup, moving code out of near-empty gg.go files
Clear out gg.go files, and move things into consistent places between
the cmd/?g directories.

Change-Id: I81e04180613b806e0bfbb88519e66111ce9f74a3
Reviewed-on: https://go-review.googlesource.com/9080
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 00:11:23 +00:00
David Crawshaw
7816a096d9 cmd/internal/ld: replace Diag;Errorexit with Exitf
I have left the Diag calls in place where I believe Ctxt.Cursym != nil
which means this CL is not the improvement I had hoped for. However
it is now safe to call Exitf whereever you are in the linker, which
makes it easier to reason about some code.

Change-Id: I8261e761ca9719f7d216e2747314adfe464e3337
Reviewed-on: https://go-review.googlesource.com/8668
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-17 22:50:25 +00:00
Rob Pike
9c3bf097c8 cmd/go: add $GOLINE to generate
Also use os.Expand for variable substitution so ${x}y works.

Fixes #9960.

Change-Id: Ic8239b2e737d1f41910dde8ee9524ac48907cb03
Reviewed-on: https://go-review.googlesource.com/9007
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:33:01 +00:00
Josh Bleecher Snyder
13cb62c764 cmd/internal/gc, cmd/6g: generate boolean values without jumps
Use SETcc instructions instead of Jcc to generate boolean values.
This generates shorter, jump-free code, which may in turn enable other
peephole optimizations.

For example, given

func f(i, j int) bool {
	return i == j
}

Before

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	JEQ	21
	0x000f 00015 (x.go:4)	MOVB	$0, "".~r2+24(FP)
	0x0014 00020 (x.go:4)	RET
	0x0015 00021 (x.go:4)	MOVB	$1, "".~r2+24(FP)
	0x001a 00026 (x.go:4)	JMP	20

After

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	SETEQ	"".~r2+24(FP)
	0x0012 00018 (x.go:4)	RET

regexp benchmarks, best of 12 runs:

benchmark                                 old ns/op      new ns/op      delta
BenchmarkNotOnePassShortB                 782            733            -6.27%
BenchmarkLiteral                          180            171            -5.00%
BenchmarkNotLiteral                       2855           2721           -4.69%
BenchmarkMatchHard_32                     2672           2557           -4.30%
BenchmarkMatchHard_1K                     80182          76732          -4.30%
BenchmarkMatchEasy1_32M                   76440180       73304748       -4.10%
BenchmarkMatchEasy1_32K                   68798          66350          -3.56%
BenchmarkAnchoredLongMatch                482            465            -3.53%
BenchmarkMatchEasy1_1M                    2373042        2292692        -3.39%
BenchmarkReplaceAll                       2776           2690           -3.10%
BenchmarkNotOnePassShortA                 1397           1360           -2.65%
BenchmarkMatchClass_InRange               3842           3742           -2.60%
BenchmarkMatchEasy0_32                    125            122            -2.40%
BenchmarkMatchEasy0_32K                   11414          11164          -2.19%
BenchmarkMatchEasy0_1K                    668            654            -2.10%
BenchmarkAnchoredShortMatch               260            255            -1.92%
BenchmarkAnchoredLiteralShortNonMatch     164            161            -1.83%
BenchmarkOnePassShortB                    623            612            -1.77%
BenchmarkOnePassShortA                    801            788            -1.62%
BenchmarkMatchClass                       4094           4033           -1.49%
BenchmarkMatchEasy0_32M                   14078800       13890704       -1.34%
BenchmarkMatchHard_32K                    4095844        4045820        -1.22%
BenchmarkMatchEasy1_1K                    1663           1643           -1.20%
BenchmarkMatchHard_1M                     131261708      129708215      -1.18%
BenchmarkMatchHard_32M                    4210112412     4169292003     -0.97%
BenchmarkMatchMedium_32K                  2460752        2438611        -0.90%
BenchmarkMatchEasy0_1M                    422914         419672         -0.77%
BenchmarkMatchMedium_1M                   78581121       78040160       -0.69%
BenchmarkMatchMedium_32M                  2515287278     2498464906     -0.67%
BenchmarkMatchMedium_32                   1754           1746           -0.46%
BenchmarkMatchMedium_1K                   52105          52106          +0.00%
BenchmarkAnchoredLiteralLongNonMatch      185            185            +0.00%
BenchmarkMatchEasy1_32                    107            107            +0.00%
BenchmarkOnePassLongNotPrefix             505            505            +0.00%
BenchmarkOnePassLongPrefix                147            147            +0.00%

The godoc binary is ~0.12% smaller after this CL.

Updates #5729.

toolstash -cmp passes for all architectures other than amd64 and amd64p32.

Other architectures can be done in follow-up CLs.

Change-Id: I0e167e259274b722958567fc0af83a17ca002da7
Reviewed-on: https://go-review.googlesource.com/2284
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:12:18 +00:00
Ian Lance Taylor
9c1868d06d runtime: add -buildmode=c-archive/c-shared support for linux/386
Change-Id: I87147ca6bb53e3121cc4245449c519509f107638
Reviewed-on: https://go-review.googlesource.com/9009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 19:31:37 +00:00