Commit graph

19485 commits

Author SHA1 Message Date
Josh Bleecher Snyder 03c0f3fea9 cmd/gc: alias more variables during register allocation
This is joint work with Daniel Morsing.

In order for the register allocator to alias two variables, they must have the same width, stack offset, and etype. Code generation was altering a variable's etype in a few places. This prevented the variable from being moved to a register, which in turn prevented peephole optimization. This failure to alias was very common, with almost 23,000 instances just running make.bash.

This phenomenon was not visible in the register allocation debug output because the variables that failed to alias had the same name. The debugging-only change to bits.c fixes this by printing the variable number with its name.

This CL fixes the source of all etype mismatches for 6g, all but one case for 8g, and depressingly few cases for 5g. (I believe that extending CL 6819083 to 5g is a prerequisite.) Fixing the remaining cases in 8g and 5g is work for the future.

The etype mismatch fixes are:

* [gc] Slicing changed the type of the base pointer into a uintptr in order to perform arithmetic on it. Instead, support addition directly on pointers.

* [*g] OSPTR was giving type uintptr to slice base pointers; undo that. This arose, for example, while compiling copy(dst, src).

* [8g] 64 bit float conversion was assigning int64 type during codegen, overwriting the existing uint64 type.

Note that some etype mismatches are appropriate, such as a struct with a single field or an array with a single element.

With these fixes, the number of registerizations that occur while running make.bash for 6g increases ~10%. Hello world binary size shrinks ~1.5%. Running all benchmarks in the standard library show performance improvements ranging from nominal to substantive (>10%); a full comparison using 6g on my laptop is available at https://gist.github.com/josharian/8f9b5beb46667c272064. The microbenchmarks must be taken with a grain of salt; see issue 7920. The few benchmarks that show real regressions are likely due to issue 7920. I manually examined the generated code for the top few regressions and none had any assembly output changes. The few benchmarks that show extraordinary improvements are likely also due to issue 7920.

Performance results from 8g appear similar to 6g.

5g shows no performance improvements. This is not surprising, given the discussion above.

Update #7316

LGTM=rsc
R=rsc, daniel.morsing, bradfitz
CC=dave, golang-codereviews
https://golang.org/cl/91850043
2014-05-12 17:10:36 -04:00
Russ Cox 2497c430d8 cmd/go: detect import cycle caused by test code
The runtime was detecting the cycle already,
but we can give a better error without even
building the binary.

Fixes #7789.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96290043
2014-05-12 16:52:55 -04:00
Ian Lance Taylor 02cc45aded cmd/go: link SWIG objects directly rather than using a shared library
This change requires using SWIG version 3.0 or later.  Earlier
versions of SWIG do not generate the pragmas required to use
the external linker.

Fixes #7155.
Fixes #7156.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/97120046
2014-05-12 12:43:51 -07:00
Russ Cox f078711b41 cmd/gc: fix escape analysis for slice of array
Fixes #7931.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100390044
2014-05-12 14:45:05 -04:00
Fabrizio Milo 7e8bc474db net/http: fix flaky test
Prevent idle transport on race condition.

Fixes #7847

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96230044
2014-05-12 09:37:36 -07:00
Brad Fitzpatrick fb392867ae A+C: Fabrizio Milo (individual CLA)
Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/100390045
2014-05-12 09:33:48 -07:00
Russ Cox 9b976f5f03 cmd/gc: record line number for auto-generated wrappers as <autogenerated>:1
Before we used line 1 of the first source file.
This should be clearer.

Fixes #4388.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92250044
2014-05-12 11:59:55 -04:00
Brad Fitzpatrick c91aea6c31 undo CL 92210044 / 5cb21eee2d35
<enter reason for undo>

««« original CL description
net: make use of SO_LINGER_SEC on darwin

Fixes #7971.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92210044
»»»

TBR=iant
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/96220049
2014-05-12 08:48:19 -07:00
Mikio Hara 900d49bf17 net: make use of SO_LINGER_SEC on darwin
Fixes #7971.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92210044
2014-05-13 00:38:36 +09:00
Russ Cox f409681925 cmd/go: better error for install of 'test-only' package
Fixes #7915.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96210044
2014-05-12 11:04:28 -04:00
Russ Cox ee7bb07a53 runtime: add copy of math.sqrt for use by arm softfloat
If it's not used (such as on other systems or if softfloat
is disabled) the linker will discard it.

The alternative is to teach cmd/go that every binary
depends on math implicitly on arm. I started down that
path but it's too scary. If we're going to get dependencies
right we should get dependencies right.

Fixes #6994.

LGTM=bradfitz, dave
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/95290043
2014-05-12 10:55:33 -04:00
Alex Brainman 20aa947c56 cmd/objdump: works with windows pe executables now
Most code is copy from addr2line change 01dd67e5827f

Update #7406
Fixes #7937

LGTM=iant
R=golang-codereviews, iant, 0intro
CC=golang-codereviews
https://golang.org/cl/95090044
2014-05-12 17:00:57 +10:00
Péter Surányi 176041e4c6 unicode: fix doc typo
LGTM=robert.hencke, iant
R=golang-codereviews, robert.hencke, iant
CC=golang-codereviews
https://golang.org/cl/96230043
2014-05-11 22:06:00 -07:00
Alex Brainman 2a7ab1616f cmd/nm: do not write to GOROOT testdata directories during TestNM
LGTM=bradfitz
R=bradfitz, 0intro
CC=golang-codereviews
https://golang.org/cl/95280043
2014-05-12 09:26:05 +10:00
David Crawshaw 82ca308743 net/rpc: do not leak client socket on closed connection
Fixes #6897.

LGTM=bradfitz
R=golang-codereviews, bradfitz, r, rsc
CC=golang-codereviews
https://golang.org/cl/91230045
2014-05-11 14:46:44 -07:00
Brad Fitzpatrick 91a576eb0f C: add another email address for David Crawshaw
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/99180043
2014-05-11 14:46:29 -07:00
Dmitri Shuralyov 4118665775 cmd/go: simplify code, reduce allocations.
This is a trivial change to make use of an existing `nl` byte slice
containing a single '\n' character. It's already declared and
used in another place in this file, so it might as well be used
in the other location instead of
a new slice literal. There should be no change in behavior,
aside from potentially less allocations.

This is my first CL, so I wanted to use a simple, hopefully non-controversial,
minor improvement to get more comfortable with golang contribution process.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97280043
2014-05-10 18:06:58 -07:00
Robert Hencke d6a1fb0b0c cmd/go: remove merge markers
LGTM=minux.ma
R=cespare, rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/96210043
2014-05-10 13:41:05 -04:00
Shenghou Ma 8dfd5184ab cmd/addr2line: accept optional "0x" prefix for addresses.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/91250043
2014-05-10 13:35:40 -04:00
Brad Fitzpatrick b600de755d undo CL 100330043 / e4248ed0037c
<enter reason for undo>

««« original CL description
runtime/race: fix the link for the race detector.

LGTM=bradfitz
R=golang-dev, bradfitz
CC=golang-codereviews
https://golang.org/cl/100330043

»»»

TBR=minux
R=minux.ma
CC=golang-codereviews
https://golang.org/cl/96200044
2014-05-09 17:31:35 -07:00
Bill Neubauer 42c9eaaa49 runtime/race: fix the link for the race detector.
LGTM=bradfitz
R=golang-dev, bradfitz
CC=golang-codereviews
https://golang.org/cl/100330043
2014-05-09 16:33:23 -07:00
Keith Randall 711d1ad7ee runtime: be a lot more lenient on smhasher avalanche test.
Fixes #7943

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98170043
2014-05-09 15:50:57 -07:00
Ian Lance Taylor e3eee85b0d net/url: correct documentation of Values.Add
Fixes #7816.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98160043
2014-05-09 15:49:21 -07:00
Rui Ueyama cdabca325e bytes: fix typos
LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/94240045
2014-05-10 07:13:42 +09:00
ChaiShushan aed9762638 test/bench/shootout: support windows
1. fix executable extension (a.out -> a.exe).
2. fix pthread build error on mingw
3. if depends lib messing, skip the test

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100210043
2014-05-09 14:34:50 -07:00
Ian Lance Taylor c00804c55c encoding/binary: document that Read requires exported struct fields
Add a test for the current behaviour.

Fixes #7482.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/95160043
2014-05-09 14:19:21 -07:00
Russ Cox 0f52fdbf7b cmd/go: accept build flags in clean and list
list has been adding them one at a time haphazardly
(race and tags were there and documented; compiler
was there and undocumented).

clean -i needs -compiler in order to clean the
installed targets for alternate compilers.

Fixes #7302.

While we're here, tweak the language in the 'go get' docs
about build flags.

Fixes #7807.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/99130043
2014-05-09 16:32:38 -04:00
Russ Cox 2182d5786b math/cmplx: specify which square root Sqrt returns
Fixes #7851.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93200043
2014-05-09 16:04:03 -04:00
Russ Cox e5c105033a cmd/gc: disable link-time copying of un-Go-initialized globals
If you write:

        var x = 3

then the compiler arranges for x to be initialized in the linker
with an actual 3 from the data segment, rather than putting
x in the bss and emitting init-time "x = 3" assignment code.

If you write:

        var y = x
        var x = 3

then the compiler is clever and treats this the same as if
the code said 'y = 3': they both end up in the data segment
with no init-time assignments.

If you write

        var y = x
        var x int

then the compiler was treating this the same as if the
code said 'x = 0', making both x and y zero and avoiding
any init-time assignment.

This copying optimization to avoid init-time assignment of y
is incorrect if 'var x int' doesn't mean 'x = 0' but instead means
'x is initialized in C or assembly code'. The program ends up
with 'y = 0' instead of 'y = the value specified for x in that other code'.

Disable the propagation if there is no initializer for x.

This comes up in some uses of cgo, because cgo generates
Go globals that are initialized in accompanying C files.

Fixes #7665.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93200044
2014-05-09 16:03:44 -04:00
Russ Cox 3e8ed96c63 crypto/aes: fix overrun in assembly encrypt/decrypt
Fixes #7928.

LGTM=bradfitz
R=golang-codereviews
CC=agl, bradfitz, golang-codereviews
https://golang.org/cl/91320043
2014-05-09 15:40:55 -04:00
Russ Cox c99dce2b05 cmd/gc: fix ... escape analysis bug
If the ... element type contained no pointers,
then the escape analysis did not track the ... itself.
This manifested in an escaping ...byte being treated
as non-escaping.

Fixes #7934.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100310043
2014-05-09 15:40:45 -04:00
Josh Bleecher Snyder 1848d71445 cmd/gc: don't give credit for NOPs during register allocation
The register allocator decides which variables should be placed into registers by charging for each load/store and crediting for each use, and then selecting an allocation with minimal cost. NOPs will be eliminated, however, so using a variable in a NOP should not generate credit.

Issue 7867 arises from attempted registerization of multi-word variables because they are used in NOPs. By not crediting for that use, they will no longer be considered for registerization.

This fix could theoretically lead to better register allocation, but NOPs are rare relative to other instructions.

Fixes #7867.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/94810044
2014-05-09 09:55:17 -07:00
Robert Hencke 52961b902f cmd/go: mark regexp as dependency of testmain
Fixes #6844.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/97840043
2014-05-09 12:19:00 -04:00
Russ Cox 21e75b3251 testing: write profiles on failure
Fixes #7901.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/90930044
2014-05-09 12:18:50 -04:00
Mikio Hara f40f0b26b6 net: drop flakey TestDialFailPDLeak
TestDialFailPDLeak was created for testing runtime-integrated netwrok
poller stuff and used during Go 1.2 development cycle. Unfortunately
it's still flakey because it depends on MemStats of runtime, not
pollcache directly, and MemStats accounts and revises its own stats
occasionally.

For now the codepaths related to runtime-intergrated network poller
are pretty stable, so removing this test case never suffers us.

Fixes #6553.

LGTM=josharian, iant
R=iant, josharian
CC=golang-codereviews
https://golang.org/cl/98080043
2014-05-09 09:38:29 +09:00
Keith Randall 65c63dc4aa runtime: write memory profile statistics to the heap dump.
LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/97010043
2014-05-08 08:35:49 -07:00
Stephen McQuay 1c2cc125fb encoding/json: add example for Indent, clarify the docs.
There was confusion in the behavior of json.Indent; This change
attempts to clarify the behavior by providing a bit more verbiage
to the documentation as well as provide an example function.

Fixes #7821.

LGTM=robert.hencke, adg
R=golang-codereviews, minux.ma, bradfitz, aram, robert.hencke, r, adg
CC=golang-codereviews
https://golang.org/cl/97840044
2014-05-08 16:52:36 +10:00
Shenghou Ma 5139293986 cmd/objdump: actually accept hex address without "0x" prefix.
Fixes #7936.

LGTM=alex.brainman, bradfitz, iant
R=golang-codereviews, alex.brainman, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/100060043
2014-05-08 01:25:56 -04:00
Shenghou Ma f5a4d241cd doc/install.html: update wrt to OS and compiler support.
Update #7188
Fixes #7894.

LGTM=alex.brainman, bradfitz, r
R=golang-codereviews, alex.brainman, mikioh.mikioh, gobot, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/95870043
2014-05-08 01:25:28 -04:00
Keith Randall 51b72d94de runtime: use duff zero and copy to initialize memory
benchmark                 old ns/op     new ns/op     delta
BenchmarkCopyFat512       1307          329           -74.83%
BenchmarkCopyFat256       666           169           -74.62%
BenchmarkCopyFat1024      2617          671           -74.36%
BenchmarkCopyFat128       343           89.0          -74.05%
BenchmarkCopyFat64        182           48.9          -73.13%
BenchmarkCopyFat32        103           28.8          -72.04%
BenchmarkClearFat128      102           46.6          -54.31%
BenchmarkClearFat512      344           167           -51.45%
BenchmarkClearFat64       50.5          26.5          -47.52%
BenchmarkClearFat256      147           87.2          -40.68%
BenchmarkClearFat32       22.7          16.4          -27.75%
BenchmarkClearFat1024     511           662           +29.55%

Fixes #7624

LGTM=rsc
R=golang-codereviews, khr, bradfitz, josharian, dave, rsc
CC=golang-codereviews
https://golang.org/cl/92760044
2014-05-07 13:17:10 -07:00
Brad Fitzpatrick ce6b75dab6 database/sql: fix accounting of open connections
Existing test TestMaxOpenConns was failing occasionally, especially
with higher values of GOMAXPROCS.

Fixes #7532

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95130043
2014-05-07 11:54:29 -07:00
Robert Griesemer 97aa90d251 spec: several clarifications to language on channels
- A channel may be used between any number of goroutines,
  not just two.
- Replace "passing a value" (which is not further defined)
  by "sending and receiving a value".
- Made syntax production more symmetric.
- Talk about unbuffered channels before buffered channels.
- Clarify what the comma,ok receive values mean (issue 7785).

Not a language change.

Fixes #7785.

LGTM=rsc, r, iant
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/94030045
2014-05-07 10:40:39 -07:00
Robert Griesemer dbe5f88804 spec: remove evaluation order inconsistency
This is a clarification of what happens already.
Not a language change.

Fixes #7137.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/96000044
2014-05-07 08:50:52 -07:00
Robert Griesemer 6f3b84a757 spec: clarify type properties
If the underlying type of a type T is a boolean, numeric,
or string type, then T is also a boolean, numeric, or
string type, respectively.

Not a language change.

Fixes #7551.

LGTM=iant, rsc, robert.hencke, r
R=r, rsc, iant, ken, robert.hencke
CC=golang-codereviews
https://golang.org/cl/100130044
2014-05-07 08:42:08 -07:00
Dmitriy Vyukov acb03b8028 runtime: optimize markspan
Increases throughput by 2x on a memory hungry program on 8-node NUMA machine.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100230043
2014-05-07 19:32:34 +04:00
Dmitriy Vyukov 2e1ddeb136 doc: replace absolute links to golang.org with relative links
Currently tip.golang.org leads to golang.org and
local godoc also leads to golang.org (when you don't have internet connectivity).

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/100200043
2014-05-07 18:49:13 +04:00
Dmitriy Vyukov c0bf96e6b1 runtime: fix bug in cpu profiler
Number of lost samples was overcounted (never reset).
Also remove unused variable (it's trivial to restore it for debugging if needed).

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, rsc
https://golang.org/cl/96060043
2014-05-07 18:48:14 +04:00
David Crawshaw 8bc1bfb6bf net/mail: propagate unsupported charset error
Fixes #6807.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95060043
2014-05-07 05:58:36 -04:00
Alex Brainman 5d25189d80 race.bash,race.bat: unset GOROOT_FINAL during tests
Just like run.* scripts do.
Fixes race build.

LGTM=dave, dvyukov
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/98980043
2014-05-07 16:34:21 +10:00
Nigel Tao 77e0f060e3 C: Patrick Riley (Google CLA)
LGTM=iant
R=dsymonds, iant
CC=golang-codereviews, pfr
https://golang.org/cl/98970045
2014-05-06 22:08:46 -04:00