1
0
mirror of https://github.com/golang/go synced 2024-10-04 12:31:21 -06:00
Commit Graph

13837 Commits

Author SHA1 Message Date
Russ Cox
b8be100d35 cmd/gc: silence clang warning
This code is only built when you run 'make' in cmd/gc,
not in all.bash.

R=golang-dev, jsing, iant
CC=golang-dev
https://golang.org/cl/19160043
2013-10-29 11:50:18 -04:00
Russ Cox
7dbbb53f37 debug/dwarf: add DWARF 4 form constants
Some versions of clang generate DWARF 4-format attributes
even when using -gdwarf-2. We don't care much about the
values, but we do need to be able to parse past them.

This fixes a bug in Go 1.2 rc2 reported via private mail using
a near-tip version of clang.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/18460043
2013-10-29 10:36:51 -04:00
Russ Cox
adda33483d cmd/cgo: stop using -fno-eliminate-unused-debug-types
This flag was added in January 2010, in CL 181102, to fix issue 497.
(Numbers were just shorter back then.) The fix was for OS X machines
and the llvm-gcc frontend.

In July 2011 we had to change the way we get enum values, because
there were no flags available to force Xcode's llvm-gcc to include the
enum names and values in DWARF debug output.

We now use clang, not llvm-gcc, on OS X machines.
Earlier versions of clang printed a warning about not knowing the flag.
Newer versions of clang now make that an error.

That is:
 - The flag was added for OS X machines.
 - The flag is no longer necessary on OS X machines.
 - The flag now breaks some OS X machines.

Remove it.

I have run the original program from issue 497 successfully
without the flag on both OS X and Linux machines.

Fixes #6678.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/18850043
2013-10-28 22:21:26 -04:00
Russ Cox
00a757fb74 runtime: relax preemption assertion during stack split
The case can happen when starttheworld is calling acquirep
to get things moving again and acquirep gets preempted.
The stack trace is in golang.org/issue/6644.

It is difficult to build a short test case for this, but
the person who reported issue 6644 confirms that this
solves the problem.

Fixes #6644.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/18740044
2013-10-28 19:40:40 -04:00
Josh Bleecher Snyder
5644774ea5 net: handle single-line non-\n-terminated files correctly in readLine
Fixes #6646.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/15960047
2013-10-28 19:31:25 -04:00
Andrew Gerrand
6ea5687b46 net/url: fix Encode doc comment
Encoded query strings are always sorted by key; the example wasn't.

R=golang-dev, dsymonds, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/16430043
2013-10-25 23:00:22 +03:00
Brad Fitzpatrick
2d6a13997a strings: fix Replacer bug with prefix matches
singleStringReplacer had a bug where if a string was replaced
at the beginning and no output had yet been produced into the
temp buffer before matching ended, an invalid nil check (used
as a proxy for having matched anything) meant it always
returned its input.

Fixes #6659

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/16880043
2013-10-24 15:51:19 -07:00
Matthew Cottingham
17a03d8650 database/sql: link to wiki in package docs
Update #5886

R=golang-dev, kamil.kisiel, adg, r, rsc, dave, arnehormann, bradfitz
CC=golang-dev
https://golang.org/cl/14087043
2013-10-24 10:13:23 -07:00
Russ Cox
c8ddfd9ad1 cmd/cgo: use __typeof__, -w instead of typeof, -Wno-all
Suggested by iant in earlier CL.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/14920052
2013-10-22 18:33:23 -04:00
Shenghou Ma
d220c9957c time: fix ParseDuration overflow when given more than 9 digits on 32-bit arch
Fixes #6617.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/15080043
2013-10-22 18:33:05 -04:00
Russ Cox
089bc25ae2 math: remove unnecessary source file
The routines in this file are dregs from a very early copy of the math API.
There are no Go prototypes and no non-amd64 implementations.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/15750046
2013-10-22 10:37:33 -04:00
Bill Neubauer
72d40a4bd9 go/build: document the go1.2 build tag
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14930046
2013-10-22 16:43:32 +04:00
Adam Langley
7d9acff751 crypto/x509: name constraints should be a disjunction.
The code was requiring that all constraints be met, but it should be
satisfied by meeting *any* of them.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/15570044
2013-10-21 19:01:24 -04:00
Adam Langley
efed6f99d2 crypto/tls: advertise support for RSA+SHA1 in TLS 1.2 handshake.
Despite SHA256 support being required for TLS 1.2 handshakes, some
servers are aborting handshakes that don't offer SHA1 support.

This change adds support for signing TLS 1.2 ServerKeyExchange messages
with SHA1. It does not add support for signing TLS 1.2 client
certificates with SHA1 as that would require the handshake to be
buffered.

Fixes #6618.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/15650043
2013-10-21 16:35:09 -04:00
David Symonds
fae4553a9d net/mail: fix minor doc typo.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/15510043
2013-10-21 17:32:45 +11:00
Shenghou Ma
be1a94b401 cmd/yacc: fix stderr on Windows.
Fixes #6620.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/15330043
2013-10-19 23:07:20 -04:00
Russ Cox
dbe2eacf04 cmd/cgo: fix line number in an error message
Fixes #6563.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14870046
2013-10-18 16:52:44 -04:00
Russ Cox
06ad3b2de1 cmd/cgo: stop using compiler error message text to analyze C names
The old approach to determining whether "name" was a type, constant,
or expression was to compile the C program

        name;

and scan the errors and warnings generated by the compiler.
This requires looking for specific substrings in the errors and warnings,
which ties the implementation to specific compiler versions.
As compilers change their errors or drop warnings, cgo breaks.
This happens slowly but it does happen.
Clang in particular (now required on OS X) has a significant churn rate.

The new approach compiles a slightly more complex program
that is either valid C or not valid C depending on what kind of
thing "name" is. It uses only the presence or absence of an error
message on a particular line, not the error text itself. The program is:

        // error if and only if name is undeclared
        void f1(void) { typeof(name) *x; }

        // error if and only if name is not a type
        void f2(void) { name *x; }

        // error if and only if name is not an integer constant
        void f3(void) { enum { x = (name)*1 }; }

I had not been planning to do this until Go 1.3, because it is a
non-trivial change, but it fixes a real Xcode 5 problem in Go 1.2,
and the new code is easier to understand than the old code.
It should be significantly more robust.

Fixes #6596.
Fixes #6612.

R=golang-dev, r, james, iant
CC=golang-dev
https://golang.org/cl/15070043
2013-10-18 15:56:25 -04:00
Russ Cox
20f99ffa3e cmd/gc: shorten name used for map bucket type
Before:
type.struct { buckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; oldbuckets *struct { overflow *struct { overflow *struct { overflow *struct { overflow *struct { overflow *<...>; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable }; keys [8]string; values [8]*"".RangeTable } }

After:
type.map.bucket[string]*"".RangeTable

This makes debugging maps a little nicer, and it takes up less space in the binary.

R=golang-dev, r
CC=golang-dev, khr
https://golang.org/cl/15110044
2013-10-18 15:56:07 -04:00
Russ Cox
66f49f78a5 net: make sure failed Dial returns nil Conn
Fixes #6614.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14950045
2013-10-18 15:35:45 -04:00
Dmitriy Vyukov
f6329700ae runtime: remove nomemprof
Nomemprof seems to be unneeded now, there is no recursion.
If the recursion will be re-introduced, it will break loudly by deadlocking.
Fixes #6566.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/14695044
2013-10-18 10:45:19 +04:00
Andrew Gerrand
04e95a1a56 api: add go1.2.txt, use in tests
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14860043
2013-10-18 13:36:59 +09:00
Brad Fitzpatrick
f41b43a024 net/url: fix regression when serializing relative URLs
Only add a slash to path if it's a separator between
a host and path.

Fixes #6609

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/14815043
2013-10-17 16:06:40 -07:00
Ian Lance Taylor
88c448ba40 runtime: correct test for when to poll network
Fixes #6610.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/14793043
2013-10-17 11:57:48 -07:00
Ian Lance Taylor
667303f158 runtime: correct parameter name in MCentral_AllocList comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14792043
2013-10-17 11:57:00 -07:00
Russ Cox
4dce7f8575 encoding/xml: accept chains of interfaces and pointers
Fixes #6556.

R=golang-dev, iant, adg
CC=golang-dev
https://golang.org/cl/14747043
2013-10-17 12:13:33 -04:00
Alberto García Hierro
e39eda1366 database/sql: make tests repeatable with -cpu=n,n
New test added in CL 14611045 causes a deadlock when
running the tests with -cpu=n,n because the fakedb
driver always waits when opening a new connection after
running TestConnectionLeak.  Reset its state after.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14780043
2013-10-17 09:02:32 -07:00
Brad Fitzpatrick
e5babeff8a database/sql: fix some test fmt verbs
Found by vet.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14762044
2013-10-16 16:30:39 -07:00
Alberto García Hierro
37db880469 database/sql: Fix connection leak and potential deadlock
CL 10726044 introduced a race condition which causes connections
to be leaked under certain circumstances. If SetMaxOpenConns is
used, the application eventually deadlocks. Otherwise, the number
of open connections just keep growing indefinitely.

Fixes #6593

R=golang-dev, bradfitz, tad.glines, bketelsen
CC=golang-dev
https://golang.org/cl/14611045
2013-10-16 09:22:57 -07:00
Alberto García Hierro
478f4b6754 database/sql: fix double decrement of numOpen count; test for connection leaks
Add a check at the end of every test to make sure
there are no leaked connections after running a test.

Avoid incorrectly decrementing the number of open connections
when the driver connection ends up it a bad state (numOpen was
decremented twice).

Prevent leaking a Rows struct (which ends up leaking a
connection) in Row.Scan() when a *RawBytes destination is
improperly used.

Close the Rows struct in TestRowsColumns.

Update #6593

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/14642044
2013-10-16 09:17:25 -07:00
Shenghou Ma
4d38d1260e cmd/cgo: simpler fix for issue 6506.
Replaces CL 14682044.
Fixes #6506.

R=rsc, iant, dave
CC=golang-dev
https://golang.org/cl/14717043
2013-10-15 21:35:52 -04:00
Russ Cox
5feb15508e cmd/cgo: print the builtin prolog after the per-file preamble
The preamble may want to #define some special symbols
and then #include <sys/types.h> itself. The builtin prolog
also #includes <sys/types.h>, which would break such a
preamble (because the second #include will be a no-op).

The use of sys/types.h in the builtin prolog is new since Go 1.1,
so this should preserve the semantics of more existing cgo
code than we would otherwise.

It also fixes src/pkg/syscall/mkall.sh's use of go tool cgo -godefs
on some Linux systems.

Thanks to fullung@ for identifying the problem.

Fixes #6558.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14684044
2013-10-15 15:00:48 -04:00
Alex Brainman
9aee98def8 undo CL 14231047 / 2f4c2dde2756
undone because the change slows down profile collection
significantly and unpredictable at times (see comments
at https://golang.org/cl/14231047 for details)

««« original CL description
runtime: collect profiles even while on g0 stack

Fixes #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14231047
»»»

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14535046
2013-10-15 14:37:43 -04:00
Russ Cox
043ace1213 cmd/cgo: fix Xcode 5 incompatibility for #defined expressions
Ensure that clang always exits with a non-zero status by
giving it something that it always warns about (the statement "1;").

Fixes #6128.

R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/14702043
2013-10-15 14:34:46 -04:00
Russ Cox
56aeec31c6 cmd/cgo: work around bug in clang debug info for builtins like memset
Fixes #6506.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14682044
2013-10-15 12:46:14 -04:00
Alex Brainman
9a420b79d7 runtime/pprof: disable flaky TestGoroutineSwitch on windows
Update #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14604043
2013-10-15 13:00:06 +11:00
Keith Randall
2acb80b5e5 cmd/gc: fix comment about performing indexing at compile time.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14441070
2013-10-14 14:26:52 -07:00
Michael Piatek
21e6b90d36 net/http: skip content-type sniffing if the header is explicitly unset.
Fixes #5953

R=dsymonds, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/14434044
2013-10-15 08:22:04 +11:00
Ian Lance Taylor
c78d67fb86 debug/dwarf: report the value of an unrecognized attribute format
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/14669045
2013-10-14 10:53:55 -07:00
Shenghou Ma
89ebc28b58 cmd/api: make it work even when cgo is disabled
make use of $USER or %USERNAME% to determine the current user.
Fixes #6578.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/14649043
2013-10-14 00:18:46 -04:00
Ian Lance Taylor
5b2f626159 go/build: add GOOS and GOARCH to name of gccgo pkg directory
This matches the behaviour of builder.includeArgs in
cmd/go/build.go.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14535048
2013-10-11 16:17:45 -07:00
Ian Lance Taylor
96648e0195 go/build: fix test if built with CGO_ENABLED=0
Fixes #6567.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14502060
2013-10-11 15:55:50 -07:00
Shenghou Ma
7dba510c7b cmd/gc: re-word some error messages
Fixes #6557.

R=golang-dev, rsc, tracey.brendan
CC=golang-dev
https://golang.org/cl/14432053
2013-10-10 22:43:34 -04:00
Ian Lance Taylor
649fc255a9 net: fix TestDialFailPDLeak to work when GOMAXPROCS is large
Fixes #6553.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14526048
2013-10-09 13:52:29 -07:00
Keith Randall
139cc96a57 runtime: markfreed's error reports should be prefixed with "markfreed", not "markallocated".
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14441055
2013-10-09 13:28:47 -07:00
Ian Lance Taylor
c774e90208 cmd/go: add any .c/.cc files to the SWIG shared library
Also add the action's object directory to the list of
directories we use to find SWIG shared libraries.

Fixes #6521.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14369043
2013-10-09 10:35:46 -07:00
Ian Lance Taylor
cb30917387 runtime/cgo: mark callback functions as NOSPLIT
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14448044
2013-10-09 08:44:47 -07:00
Russ Cox
0965459bd9 debug/dwarf: handle surprising clang encoding
Fixes a bug in cgo on OS X using clang.
See golang.org/issue/6472 for details.

Fixes #6472.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14575043
2013-10-09 11:08:22 -04:00
Ian Lance Taylor
7bbe0163c7 net: fix typo in failure message in test
R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14582043
2013-10-09 06:44:11 -07:00
Russ Cox
8ba6deb1ec compress/flate: fix infinite loop on malformed data
Test using compress/gzip, because that's how the
data arrived.

Fixes #6550.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14441051
2013-10-09 08:37:06 -04:00
Rob Pike
daa61d1eb3 encoding/gob: add examples
Also tweak the package document, putting in section headings and
adding a sentence about intended use.

Fixes #4925.

R=golang-dev, iant, adg, ugorji
CC=golang-dev
https://golang.org/cl/14519044
2013-10-08 13:13:40 -07:00
Carl Shapiro
254dc5fdbe cmd/go, runtime: express armv5t architecture constraint differently
Instead of adding an -march=armv5t flag to the gcc command
line, the same effect is obtained with an ".arch armv5t"
pseudo op in the assembly file that uses armv5t instructions.

R=golang-dev, iant, dave
CC=golang-dev
https://golang.org/cl/14511044
2013-10-08 10:40:51 -07:00
Rob Pike
9795882704 math: the trig functions work in radians; document that
Fixes #6543
6543 is also a fine NGC object.

R=golang-dev, dsymonds, kamil.kisiel, minux.ma
CC=golang-dev
https://golang.org/cl/14515044
2013-10-07 16:32:47 -07:00
Joel Sing
fc1bea321d os/user: fix user lookups on dragonfly
Like FreeBSD, DragonFly does not provide a sysconf value for
_SC_GETPW_R_SIZE_MAX.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14469043
2013-10-07 09:21:33 -07:00
Joel Sing
fba015ecb4 os/user: enable tests on all supported platforms
All of the currently supported platforms have a working user
implementation and do not use stubs. As a result, enable the tests
on all platforms rather than whitelisting.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/14454044
2013-10-07 09:12:17 -07:00
Joel Sing
932428a1ed os/signal: make test logs reflect reality
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14470043
2013-10-07 09:04:20 -07:00
Keith Randall
869368a528 runtime: fix bug in maps at the intersection of iterators, growing, and NaN keys
If an iterator is started while a map is in the middle of a grow,
and the map has NaN keys, then those keys might get returned by
the iterator more than once.  This fix makes the evacuation decision
deterministic and repeatable for NaN keys so each one gets returned
only once.

R=golang-dev, r, khr, iant
CC=golang-dev
https://golang.org/cl/14367043
2013-10-04 13:54:03 -07:00
Keith Randall
15baf6b4ac runtime: remove 3 unused declarations.
R=golang-dev, cshapiro, iant
CC=golang-dev
https://golang.org/cl/14405043
2013-10-04 13:22:20 -07:00
Ian Lance Taylor
ef4e12a4ba reflect: test using a MakeFunc value in a couple of different ways
The gccgo implementation mishandled calling Interface on a
value created by MakeFunc.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14401043
2013-10-04 13:12:50 -07:00
Alex Brainman
4207897dcc runtime: collect profiles even while on g0 stack
Fixes #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14231047
2013-10-04 13:53:34 +10:00
Ian Lance Taylor
e59db90bfb reflect: add a test that gccgo mishandled
Failure occurred when using reflect.Call to pass a func value
following a non-pointer value.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14186043
2013-10-03 13:23:02 -07:00
Robert Hencke
a51b8cf870 gofmt: explain why lower bounds aren't automatically simplified
Full credit goes to gri and rsc for their explanations.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14229043
2013-10-03 10:55:17 -07:00
Rob Pike
c4579635cf sync/atomic: explain how to subtract an unsigned constant
Explain for those unfamiliar with twos-complement arithmetic how to
implement negation of signed positive constant.
Fixes #6408.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14267044
2013-10-03 10:40:42 -07:00
Russ Cox
01479b6c4a go/doc: update ToHTML doc comment
Update #5429

R=golang-dev, r, dan.kortschak
CC=golang-dev
https://golang.org/cl/14293043
2013-10-03 09:49:12 -04:00
Russ Cox
408238e20b runtime: change default stack segment size to 8 kB
Changing from 4 kB to 8 kB brings significant improvement
on a variety of the Go 1 benchmarks, on both amd64
and 386 systems.

Significant runtime reductions:

          amd64  386
GoParse    -14%  -1%
GobDecode  -12% -20%
GobEncode  -64%  -1%
JSONDecode  -9%  -4%
JSONEncode -15%  -5%
Template   -17% -14%

In the longer term, khr's new stacks will avoid needing to
make this decision at all, but for Go 1.2 this is a reasonable
stopgap that makes performance significantly better.

Demand paging should mean that if the second 4 kB is not
used, it will not be brought into memory, so the change
should not adversely affect resident set size.
The same argument could justify bumping as high as 64 kB
on 64-bit machines, but there are diminishing returns
after 8 kB, and using 8 kB limits the possible unintended
memory overheads we are not aware of.

Benchmark graphs at
http://swtch.com/~rsc/gostackamd64.html
http://swtch.com/~rsc/gostack386.html

Full data at
http://swtch.com/~rsc/gostack.zip

R=golang-dev, khr, dave, bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/14317043
2013-10-03 09:19:10 -04:00
Dave Day
0a033a18ad cmd/gc: support -installsuffix in the compiler and builder
Add the -installsuffix flag to gc and {5,6,8}l, which overrides -race
for the suffix if both are supplied.
Pass this flag from the go tool for build and install.

R=rsc
CC=golang-dev
https://golang.org/cl/14246044
2013-10-03 13:48:47 +10:00
Russ Cox
94a6511b7f net: use original argument in lookup error
Fixes #6324.

R=golang-dev, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13280049
2013-10-02 22:09:54 -04:00
Russ Cox
e0867738fc cmd/go: document relative imports
Fixes #3524.

R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/14296043
2013-10-02 21:42:23 -04:00
Russ Cox
95d85d90d8 crypto/tls: document ConnectionState fields
Fixes #6456.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14289043
2013-10-02 21:40:01 -04:00
Russ Cox
4216203bcf runtime: remove syscall.NewCallbackCDecl on Windows
It is not possible to use (there is no declaration in package syscall),
and no one seems to care.

Alex Brainman may bring this back properly for Go 1.3.

Fixes #6338.

R=golang-dev, r, alex.brainman
CC=golang-dev
https://golang.org/cl/14287043
2013-10-02 21:39:45 -04:00
Josh Bleecher Snyder
0857045818 encoding/json: add an example for RawMessage
RawMessage is useful and mildly non-obvious.
Given the frequency with which RawMessage questions
show up on golang-nuts, and get answered with an example,
I suspect adding an example to the docs might help.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14190044
2013-10-03 08:52:18 +10:00
Russ Cox
1b0bffa973 net/http: be clear that HTTPS is supported
Fixes #6443.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14231045
2013-10-02 13:21:15 -04:00
Russ Cox
5f853d7d94 runtime: fix finalizer test on amd64
Not scanning the stack by frames means we are reintroducing
a few false positives into the collection. Run the finalizer registration
in its own goroutine so that stack is guaranteed to be out of
consideration in a later collection.

This is working around a regression from yesterday's tip, but
it's not a regression from Go 1.1.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/14290043
2013-10-02 12:30:49 -04:00
Rémy Oudompheng
8d6bc666fb cmd/gc: qualified embedded fields with owner package.
R=rsc
CC=golang-dev
https://golang.org/cl/14188044
2013-10-02 12:27:33 -04:00
Frithjof Schulze
4d7c63558c crypto/tls: Update reference to the TLS 1.2 RFC.
Ticket 13740047 updated the documented TLS version to 1.2.
This also updates the RFC refered to.

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/14029043
2013-10-02 12:09:13 -04:00
Russ Cox
c3dadca977 runtime: do not scan stack by frames during garbage collection
Walking the stack by frames is ~3x more expensive
than not, and since it didn't end up being precise,
there is not enough benefit to outweigh the cost.

This is the conservative choice: this CL makes the
stack scanning behavior the same as it was in Go 1.1.

Add benchmarks to package runtime so that we have
them when we re-enable this feature during the
Go 1.3 development.

benchmark                     old ns/op    new ns/op    delta
BenchmarkGoroutineSelect        3194909      1272092  -60.18%
BenchmarkGoroutineBlocking      3120282       866366  -72.23%
BenchmarkGoroutineForRange      3256179       939902  -71.13%
BenchmarkGoroutineIdle          2005571       482982  -75.92%

The Go 1 benchmarks, just to add more data.
As far as I can tell the changes are mainly noise.

benchmark                         old ns/op    new ns/op    delta
BenchmarkBinaryTree17            4409403046   4414734932   +0.12%
BenchmarkFannkuch11              3407708965   3378306120   -0.86%
BenchmarkFmtFprintfEmpty                100           99   -0.60%
BenchmarkFmtFprintfString               242          239   -1.24%
BenchmarkFmtFprintfInt                  204          206   +0.98%
BenchmarkFmtFprintfIntInt               320          316   -1.25%
BenchmarkFmtFprintfPrefixedInt          295          299   +1.36%
BenchmarkFmtFprintfFloat                442          435   -1.58%
BenchmarkFmtManyArgs                   1246         1216   -2.41%
BenchmarkGobDecode                 10186951     10051210   -1.33%
BenchmarkGobEncode                 16504381     16445650   -0.36%
BenchmarkGzip                     447030885    447056865   +0.01%
BenchmarkGunzip                   111056154    111696305   +0.58%
BenchmarkHTTPClientServer             89973        93040   +3.41%
BenchmarkJSONEncode                28174182     27933893   -0.85%
BenchmarkJSONDecode               106353777    110443817   +3.85%
BenchmarkMandelbrot200              4822289      4806083   -0.34%
BenchmarkGoParse                    6102436      6142734   +0.66%
BenchmarkRegexpMatchEasy0_32            133          132   -0.75%
BenchmarkRegexpMatchEasy0_1K            372          373   +0.27%
BenchmarkRegexpMatchEasy1_32            113          111   -1.77%
BenchmarkRegexpMatchEasy1_1K            964          940   -2.49%
BenchmarkRegexpMatchMedium_32           202          205   +1.49%
BenchmarkRegexpMatchMedium_1K         68862        68858   -0.01%
BenchmarkRegexpMatchHard_32            3480         3407   -2.10%
BenchmarkRegexpMatchHard_1K          108255       112614   +4.03%
BenchmarkRevcomp                  751393035    743929976   -0.99%
BenchmarkTemplate                 139637041    135402220   -3.03%
BenchmarkTimeParse                      479          475   -0.84%
BenchmarkTimeFormat                     460          466   +1.30%

benchmark                          old MB/s     new MB/s  speedup
BenchmarkGobDecode                    75.34        76.36    1.01x
BenchmarkGobEncode                    46.50        46.67    1.00x
BenchmarkGzip                         43.41        43.41    1.00x
BenchmarkGunzip                      174.73       173.73    0.99x
BenchmarkJSONEncode                   68.87        69.47    1.01x
BenchmarkJSONDecode                   18.25        17.57    0.96x
BenchmarkGoParse                       9.49         9.43    0.99x
BenchmarkRegexpMatchEasy0_32         239.58       241.74    1.01x
BenchmarkRegexpMatchEasy0_1K        2749.74      2738.00    1.00x
BenchmarkRegexpMatchEasy1_32         282.49       286.32    1.01x
BenchmarkRegexpMatchEasy1_1K        1062.00      1088.96    1.03x
BenchmarkRegexpMatchMedium_32          4.93         4.86    0.99x
BenchmarkRegexpMatchMedium_1K         14.87        14.87    1.00x
BenchmarkRegexpMatchHard_32            9.19         9.39    1.02x
BenchmarkRegexpMatchHard_1K            9.46         9.09    0.96x
BenchmarkRevcomp                     338.26       341.65    1.01x
BenchmarkTemplate                     13.90        14.33    1.03x

Fixes #6482.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/14257043
2013-10-02 11:59:53 -04:00
Shenghou Ma
6b188ef57a cmd/dist, build: support building statically linked toolchain
Added a new $GO_DISTFLAGS to make.bash, and while we're here,
added mention $CXX in make.bash (CL 13704044).

Fixes #6448.
Update #3564
We can pass GO_DISTFLAGS=-s from misc/dist to make.bash so that
it will build a statically linked toolchain.
(Note: OS X doesn't have the concept of static linking, so don't
pass GO_DISTFLAGS=-s for OS X builds)

R=adg, rsc, iant
CC=golang-dev
https://golang.org/cl/13887043
2013-10-01 23:44:20 -04:00
Dave Day
57f69710d5 cmd/go: use -installsuffix to determine the includes directory list
Currently, the directories generaed by includeArgs can have the "_race"
suffix added if invoked with -race flag, but ignores -installsuffix if
set.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/14174043
2013-10-01 20:44:57 -04:00
Carl Shapiro
7a480a8c9b undo CL 14154043 / 3e485428767e
««« original CL description
encoding/gob: do not hide pointer argument for the garbage collector

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14154043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/14165043
2013-09-30 16:02:12 -07:00
Carl Shapiro
6ffd70e7f0 encoding/gob: do not hide pointer argument for the garbage collector
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14154043
2013-09-30 15:54:21 -07:00
Dave Cheney
cdb33231b2 race.bash, race.bat: build a race enabled cmd/cgo before trying to use it
Fixes #5537.

To avoid `go install -v race std` replacing cmd/cgo with a race enabled version and another package trying to build a cgo enabled package, always build cmd/cgo race enabled before doing the rest of the build.

R=remyoudompheng, rsc, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/14071044
2013-09-29 10:34:41 +10:00
Robin Eklind
9bd1f49e37 syscall: Fix one issue detected by vet.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/14038044
2013-09-28 11:06:50 +10:00
Kamil Kisiel
48da6754e2 encoding/json: Tweak documentation for Encoder.Encode.
The documentation for the Encoder type calls it a stream,
not a connection.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14015044
2013-09-27 15:38:39 +10:00
Carl Shapiro
0ab8f2d287 reflect: expose reflect.call argument slice to the garbage collector
The argument slice was kept hidden from the garbage collector
by destroying its referent in an unsafe.Pointer to uintptr
conversion.  This change preserves the unsafe.Pointer referent
and only performs an unsafe.Pointer to uintptr conversions
within expressions that construct new unsafe.Pointer values.

R=golang-dev, khr, rsc
CC=golang-dev
https://golang.org/cl/14008043
2013-09-26 21:59:13 -07:00
Rob Pike
fa7791e922 all: fix some mistakes found by go tool vet .
R=golang-dev, iant, adg
CC=golang-dev
https://golang.org/cl/14000043
2013-09-27 10:09:15 +10:00
Adam Langley
f752484c74 crypto/tls: don't select TLS 1.2 cipher suites in prior versions.
AES-GCM cipher suites are only defined for TLS 1.2, although there's
nothing really version specific about them. However, development
versions of NSS (meaning Firefox and Chrome) have an issue where
they'll advertise TLS 1.2-only cipher suites in a TLS 1.1 ClientHello
but then balk when the server selects one.

This change causes Go clients not to advertise TLS 1.2 cipher suites
unless TLS 1.2 is being used, and prevents servers from selecting them
unless TLS 1.2 has been negotiated.

https://code.google.com/p/chromium/issues/detail?id=297151
https://bugzilla.mozilla.org/show_bug.cgi?id=919677

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13573047
2013-09-26 17:09:56 -04:00
Dave Cheney
649a2a9be5 runtime, syscall: update freebsd/arm calling convention to match EABI
Fixes #6451.

There is still some breakages unrelated to the syscall change.

[root@beaglebone ~/go/src]# /root/go/pkg/tool/freebsd_arm/go_bootstrap version
go version devel freebsd/arm
a std@beaglebone ~/go/src]# /root/go/pkg/tool/freebsd_arm/go_bootstrap install -
fatal error: mark - finalizer inconsistency

runtime stack:
runtime.throw(0x3e80ac)
        /root/go/src/pkg/runtime/panic.c:464 +0x5c
addfinroots(0x2)
        /root/go/src/pkg/runtime/mgc0.c:1501 +0x74
runtime.walkfintab(0x6c200)
        /root/go/src/pkg/runtime/mfinal.c:216 +0xa0
addroots()
        /root/go/src/pkg/runtime/mgc0.c:1561 +0x188
gc(0x50632f78)
        /root/go/src/pkg/runtime/mgc0.c:2098 +0x19c
mgc(0x306170a0)
        /root/go/src/pkg/runtime/mgc0.c:2049 +0x30
runtime.mcall(0x3e97b0)
        /root/go/src/pkg/runtime/asm_arm.s:165 +0x3c

goroutine 1 [garbage collection]:
runtime.gc(0x0)
        /root/go/src/pkg/runtime/mgc0.c:2020 +0x1a0 fp=0x50632f80
runtime.mallocgc(0x680, 0x1b1971, 0x1)
        /root/go/src/pkg/runtime/malloc.goc:143 +0x210 fp=0x50632fbc
----- stack segment boundary -----
cnew(0x1b1970, 0x640, 0x1)
        /root/go/src/pkg/runtime/malloc.goc:718 +0xc4 fp=0x50626110
runtime.cnewarray(0x1b1970, 0x640)
        /root/go/src/pkg/runtime/malloc.goc:731 +0x3c fp=0x50626120
makeslice1(0x1ac6d0, 0x500, 0x640, 0x50626190)
        /root/go/src/pkg/runtime/slice.c:57 +0x50 fp=0x5062612c
growslice1(0x1ac6d0, 0x30714a00, 0x500, 0x500, 0x501, ...)
        /root/go/src/pkg/runtime/slice.c:113 +0x8c fp=0x50626144
runtime.growslice(0x1ac6d0, 0x30714a00, 0x500, 0x500, 0x1, ...)
        /root/go/src/pkg/runtime/slice.c:80 +0x19c fp=0x50626174
go/build.(*importReader).readByte(0x3070d1b0, 0xb384e)
        /root/go/src/pkg/go/build/read.go:43 +0xbc fp=0x506261b4
go/build.(*importReader).peekByte(0x3070d1b0, 0x3070d101, 0x3070d180)
        /root/go/src/pkg/go/build/read.go:89 +0x210 fp=0x506261d0
go/build.readComments(0x203e2560, 0x306f79a8, 0x306f79a8, 0x203e2560, 0x306f79a8, ...)
        /root/go/src/pkg/go/build/read.go:194 +0x84 fp=0x506261f4
go/build.(*Context).matchFile(0x3e9730, 0x306209c0, 0x13, 0x306c42b4, 0x5, ...)
        /root/go/src/pkg/go/build/build.go:812 +0x74c fp=0x5062629c
go/build.(*Context).Import(0x3e9730, 0x1f95c8, 0x1, 0x30620960, 0x13, ...)
        /root/go/src/pkg/go/build/build.go:580 +0xd64 fp=0x506268dc
go/build.(*Context).ImportDir(0x3e9730, 0x30620960, 0x13, 0x0, 0x24d901, ...)
        /root/go/src/pkg/go/build/build.go:397 +0x5c fp=0x50626904
main.func·021(0x30620960, 0x13, 0x203e2200, 0x30680330, 0x0, ...)
        /root/go/src/cmd/go/main.go:521 +0x2cc fp=0x5062696c
path/filepath.walk(0x30620960, 0x13, 0x203e2200, 0x30680330, 0x50626ae8, ...)
        /root/go/src/pkg/path/filepath/path.go:341 +0x5c fp=0x506269d8
path/filepath.walk(0x3067e720, 0x11, 0x203e2200, 0x30680210, 0x50626ae8, ...)
        /root/go/src/pkg/path/filepath/path.go:359 +0x308 fp=0x50626a44
path/filepath.Walk(0x3067e720, 0x11, 0x50626ae8, 0x1f9728, 0x1)
        /root/go/src/pkg/path/filepath/path.go:380 +0xb4 fp=0x50626a68
main.matchPackages(0xbfffedea, 0x3, 0x1b1190, 0x3067e600, 0x10)
        /root/go/src/cmd/go/main.go:530 +0x2c0 fp=0x50626b1c
main.allPackages(0xbfffedea, 0x3, 0x1fadc8, 0x3, 0x1)
        /root/go/src/cmd/go/main.go:474 +0x34 fp=0x50626b70
main.importPathsNoDotExpansion(0x30620018, 0x1, 0x1, 0x0, 0xffffffff, ...)
        /root/go/src/cmd/go/main.go:305 +0x2f8 fp=0x50626c04
main.importPaths(0x30620018, 0x1, 0x1, 0x3, 0x0, ...)
        /root/go/src/cmd/go/main.go:315 +0x44 fp=0x50626c88
main.packagesAndErrors(0x30620018, 0x1, 0x1, 0x50626d60, 0x90f44, ...)
        /root/go/src/cmd/go/pkg.go:798 +0x1bc fp=0x50626d1c
main.packagesForBuild(0x30620018, 0x1, 0x1, 0x53490, 0x0, ...)
        /root/go/src/cmd/go/pkg.go:818 +0x44 fp=0x50626dac
main.runInstall(0x3e46e0, 0x30620018, 0x1, 0x1)
        /root/go/src/cmd/go/build.go:311 +0x48 fp=0x50626e60
main.main()
        /root/go/src/cmd/go/main.go:161 +0x518 fp=0x50626f8c
runtime.main()
        /root/go/src/pkg/runtime/proc.c:222 +0x100 fp=0x50626fc0
runtime.goexit()
        /root/go/src/pkg/runtime/proc.c:1396 fp=0x50626fc0

goroutine 3 [syscall]:
os/signal.loop()
        /root/go/src/pkg/os/signal/signal_unix.go:21 +0x24
created by os/signal.init·1
        /root/go/src/pkg/os/signal/signal_unix.go:27 +0x48

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13824044
2013-09-26 21:35:49 +10:00
Shenghou Ma
752960aa5c cmd/go: "go test -c -test.bench=XX fmt" shouldn't hang
Fixes #6480.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13925043
2013-09-25 16:18:33 -04:00
Ian Lance Taylor
935a826a2f cmd/cgo: fix so that tests pass again when using gccgo
Use the symbol prefixes with the prologue functions when using
gccgo.

Use an & when referring to a function declared as a variable.

Fix the malloc prologue function.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13878043
2013-09-24 18:11:13 -07:00
Rob Pike
e2e9d1d684 html/template: update the Tree field after parsing new templates
After text/template.Parse, all the templates may have changed, so
we need to set them all back to their unescaped state. The code
did this but (mea culpa) forgot to set the Tree field of the html/template
struct.

Since the Tree is reset during escaping, this only matters if an error
arises during escaping and we want to print a message.

Fixes #6459.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13877043
2013-09-25 10:00:09 +10:00
Robert Griesemer
20db0f428a go/ast: add Slice3 field to SliceExpr
If Slice3 is set, the expression is
a 3-index slice expression (2 colons).
Required for type-checking.

Backward-compatible API extension.

R=r, rsc
CC=golang-dev
https://golang.org/cl/13826050
2013-09-24 16:35:35 -07:00
Kamil Kisiel
b0ef6aeff9 math/big: Fix variable name in documentation for *Int.Bytes and BitLen.
R=golang-dev, iant, gri
CC=golang-dev
https://golang.org/cl/13869043
2013-09-24 16:32:23 -07:00
Russ Cox
828a4b9376 sync/atomic: adjust for new runtime.cas64 prototype
R=golang-dev, minux.ma, josharian
CC=golang-dev
https://golang.org/cl/13859043
2013-09-24 15:54:48 -04:00
Russ Cox
5639d2754b cmd/cgo: retain Go pointer passed to C call for duration of call
Fixes #6397.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/13858043
2013-09-24 15:52:48 -04:00
Shenghou Ma
7616c94921 cmd/dist, cmd/go: embed default C++ compiler into cmd/go
Fixes #6426.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/13704044
2013-09-24 00:17:08 -04:00
Alex Brainman
b80ef1ab48 net: re-enable raw socket tests on windows
Since CL 38bf89161a72 raw socket tests are not executed
on windows builders. This change re-enable them again.
It will attempt to run raw socket tests only if user
is permitted to create raw socket by OS.

Fixes #6392

R=golang-dev
CC=golang-dev, mikioh.mikioh, rsc
https://golang.org/cl/13422044
2013-09-24 13:15:49 +10:00
Brad Fitzpatrick
0f3ea75020 encoding/json: don't cache value addressability when building first encoder
newTypeEncoder (called once per type and then cached) was
looking at the first value seen of that type's addressability
and caching the encoder decision.  If the first value seen was
addressable and a future one wasn't, it would panic.

Instead, introduce a new wrapper encoder type that checks
CanAddr at runtime.

Fixes #6458

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13839045
2013-09-23 19:57:19 -07:00
Russ Cox
e8bbbe0886 net: ensure that ResolveTCPAddr(addr.String()) reproduces addr
And same for UDP.

Fixes #6465.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13740048
2013-09-23 22:40:24 -04:00
Albert Strasheim
2be62360b2 net: fix Close of autobind unix listener
Fixes #6455.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/13457058
2013-09-23 22:33:42 -04:00
Andrew Gerrand
2d2ae53119 reflect: update docs; Interface can return a method value
Fixes #6460.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13761046
2013-09-24 10:49:54 +10:00
Russ Cox
d9f034dc9e net/http: accept Content-Range for entire file
Fixes a bug reported privately.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13846043
2013-09-23 17:16:59 -04:00
Russ Cox
3c1ece2cb4 cmd/cgo: update #cgo docs to reflect reality
The syntax accepted is full build constraints, not just
GOOS, GOARCH, and GOOS/GOARCH.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13504048
2013-09-23 16:29:53 -04:00
Russ Cox
05ff4d7a1a runtime/pprof: fix profile parser in test
Fixes #6417.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13843043
2013-09-23 16:05:36 -04:00
Russ Cox
bc2c3388f4 crypto/tls: document that the package supports TLS 1.2
Fixes #6456.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13740047
2013-09-23 16:05:23 -04:00
Russ Cox
0fc9db7944 undo CL 13321048 / 9567c5da6e25
Makes build unnecessarily slower. Will fix the parser instead.

««« original CL description
runtime/pprof: run TestGoroutineSwitch for longer

Short test now takes about 0.5 second here.

Fixes #6417.

The failure was also seen on our builders.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/13321048
»»»

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13720048
2013-09-23 15:58:35 -04:00
Kamil Kisiel
e07b5baf4f reflect: add example for StructTag
Fix a few minor vet quibbles while I'm here.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13235059
2013-09-23 13:19:08 -04:00
Shenghou Ma
60513bf2f4 cmd/ld: fix "_image_base__ not defined" problem for cmd/8l.
Fixes #6431.

Change suggested by kin.wilson.za.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13314048
2013-09-23 13:08:00 -04:00
Péter Surányi
3861cb4388 go/build: add go1.2 build tag
Fixes #6449.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13829044
2013-09-23 18:11:25 +10:00
Rob Pike
3e3ed5d978 fmt: one bad index shouldn't spoil them all
In an indexed verb such as %[3]d, if the index is out of range, don't
skip processing the rest of the verbs. The bug was that the bad
index set a bit for the whole format instead of just the verb.

Ok for 1.2 because this is a bug in a 1.2 feature.

Fixes #6434

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13632058
2013-09-23 16:03:57 +10:00
Dmitry Chestnykh
c2b7fb3902 net/http: send correct time in Date header.
Date header indicated that it contained GMT time,
however it actually sent local time. Fixed by
converting time to UTC.

Also fixes incorrect comment in appendTime().

Regression since CL 9432046.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13386047
2013-09-22 19:53:55 -07:00
Dmitriy Vyukov
3ec600d0ca runtime/race: update runtime to r191161.
Fixes #6305.

R=golang-dev, dave, alex.brainman, r
CC=golang-dev
https://golang.org/cl/13359046
2013-09-22 10:56:06 -07:00
Alex Brainman
521dbbfef3 runtime/pprof: run TestGoroutineSwitch for longer
Short test now takes about 0.5 second here.

Fixes #6417.

The failure was also seen on our builders.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/13321048
2013-09-22 17:31:08 +10:00
Brad Fitzpatrick
afda774e95 cmd/api: always do API check if hg is available
Fixes #6124

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13500046
2013-09-22 08:01:17 +01:00
Russ Cox
0826c04e14 cmd/yacc: report correct line for 'default action causes potential type clash'
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13588044
2013-09-20 16:00:13 -04:00
Russ Cox
5be1821a31 cmd/gc: fix imported and not used error for import .
Fixes issues 6420.

R=ken2
CC=golang-dev
https://golang.org/cl/13703044
2013-09-20 15:25:43 -04:00
Russ Cox
36f8480965 cmd/gc: print expression in 'duplicate case in switch' error
The line number alone does not help when the line is
case '~', '*', '(', ')', '[', ']', '{', '}', '?', ':', ';', ',', '*', '%', '^', '!', '=', '<', '>', '+', '-', '&', '|':

R=ken2
CC=golang-dev
https://golang.org/cl/13431046
2013-09-20 15:15:43 -04:00
Russ Cox
551ada4742 runtime: avoid allocation of internal panic values
If a fault happens in malloc, inevitably the next thing that happens
is a deadlock trying to allocate the panic value that says the fault
happened. Stop doing that, two ways.

First, reject panic in malloc just as we reject panic in garbage collection.

Second, runtime.panicstring was using an error implementation
backed by a Go string, so the interface held an allocated *string.
Since the actual errors are C strings, define a new error
implementation backed by a C char*, which needs no indirection
and therefore no allocation.

This second fix will avoid allocation for errors like nil panic derefs
or division by zero, so it is worth doing even though the first fix
should take care of faults during malloc.

Update #6419

R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/13774043
2013-09-20 15:15:25 -04:00
Shenghou Ma
0d85d5423b cmd/ld: fix "ld -s" to not discard pclntab.
Fixes #6245.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/13751045
2013-09-20 10:04:52 -04:00
David Symonds
318e165238 crypto/x509: update comment on system root cert locations.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13775045
2013-09-20 15:49:26 +10:00
Rémy Oudompheng
381b72a7a3 cmd/gc: cleanup SWITCH nodes after walk.
Keeping pointers from the pre-walk phase confuses
the race detection instrumentation.

Fixes #6418.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/13368057
2013-09-19 09:23:04 +02:00
Shenghou Ma
c742179c49 cmd/ld: handle IMAGE_SYM_CLASS_LABEL symbols.
Was causing "invalid symbol binding" and thus "malformed pe file" error.

R=golang-dev, alex.brainman, adg
CC=golang-dev
https://golang.org/cl/13722050
2013-09-19 02:27:53 -04:00
Shenghou Ma
db71e1557b cmd/go: fix missing __mingw_fprintf symbol for cgo on windows
Fixes #5986.

R=golang-dev, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/13261055
2013-09-19 01:20:02 -04:00
Shenghou Ma
9add729a1f cmd/ld: handle duplicate static symbols in COFF and Mach-O files.
Fixes #5740.

R=iant, rsc, luisbebop
CC=gobot, golang-dev
https://golang.org/cl/10345046
2013-09-18 22:27:25 -04:00
Rob Pike
ba10318607 cmd/go: write the WORK=/tmp/... line to stderr
Unlike the other output from the -x flag, it was going to stdout.
Fixes #6362.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13746044
2013-09-19 11:19:11 +10:00
Thomas Habets
fefa4f2b89 net/http/cgi: use 'https://' for urls if HTTPS is set.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13700044
2013-09-18 10:48:28 +10:00
Dave Cheney
b27e09331c cmd/gc: fix set but not used error
R=rsc, r
CC=golang-dev
https://golang.org/cl/13749044
2013-09-18 10:15:52 +10:00
Ian Lance Taylor
3d3bccc421 cmd/go: add basic docs on calling between Go and C/C++
This is a framework for docs on the subject more than it is
actual docs.

The section header in go/doc.go just says "C", not "C/C++,"
because otherwise godoc doesn't recognize the line as a
section header.

Fixes #5473.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13280050
2013-09-17 17:10:48 -07:00
Robert Griesemer
0d0c748930 encoding/xml: remove dead code
Avoid future 'declared and not used error'.
See also issue 6414.

R=r
CC=golang-dev
https://golang.org/cl/13242058
2013-09-17 15:24:40 -07:00
Ian Lance Taylor
c757020b55 reflect: test method calls on pointers to pointers
Gccgo got this wrong, and evidently nothing else tests it.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13709045
2013-09-17 15:22:42 -07:00
Russ Cox
aa0439ba65 cmd/gc: eliminate redundant &x.Field nil checks
This eliminates ~75% of the nil checks being emitted,
on all architectures. We can do better, but we need
a bit more general support from the compiler, and
I don't want to do that so close to Go 1.2.
What's here is simple but effective and safe.

A few small code generation cleanups were required
to make the analysis consistent on all systems about
which nil checks are omitted, at least in the test.

Fixes #6019.

R=ken2
CC=golang-dev
https://golang.org/cl/13334052
2013-09-17 16:54:22 -04:00
Adam Langley
eef7035ec8 crypto/tls: don't select ECDSA ciphersuites with only an RSA certificate.
47ec7a68b1a2 added support for ECDSA ciphersuites but didn't alter the
cipher suite selection to take that into account. Thus Go servers could
try and select an ECDSA cipher suite while only having an RSA
certificate, leading to connection failures.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13239053
2013-09-17 13:30:36 -04:00
Ian Lance Taylor
acae4d212c cmd/cgo: rearrange and update documentation
In particular document that the Go tool will look for certain
file extensions and compile with them with either the C or the
C++ compiler.

Fixes #6393.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13733043
2013-09-17 07:11:40 -07:00
Josh Bleecher Snyder
eeb758546e text/template/parse, html/template: copy Tree.text during html template clone
The root cause of the panic reported in https://code.google.com/p/go/issues/detail?id=5980
is that parse's Tree.Text wasn't being copied during the clone.

Fix this by adding and using a Copy method for parse.Tree.

Fixes #5980.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12420044
2013-09-17 14:19:44 +10:00
Dave Cheney
8d5ec52e6c cmd/6c, cmd/6g, cmd/cc: fix undefined behavior warnings
Update #5764

Like Tribbles, the more you kill, the more spring up in their place.

R=rsc
CC=golang-dev
https://golang.org/cl/13324049
2013-09-17 13:43:27 +10:00
Carl Shapiro
16d6b6c771 runtime: export PCDATA value reader
This interface is required to use the PCDATA interface
implemented in Go 1.2.  While initially entirely private, the
FUNCDATA side of the interface has been made public.  This
change completes the FUNCDATA/PCDATA interface.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13735043
2013-09-16 19:03:19 -07:00
Rémy Oudompheng
045dbeaf05 cmd/gc, runtime: inline append in frontend.
A new transformation during walk turns append calls
into a combination of growslice and memmove.

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     141          141   +0.00%
BenchmarkAppend1Byte                 18           11  -39.56%
BenchmarkAppend4Bytes                19           10  -42.63%
BenchmarkAppend7Bytes                18           10  -42.16%
BenchmarkAppend8Bytes                18           10  -40.44%
BenchmarkAppend15Bytes               19           11  -41.67%
BenchmarkAppend16Bytes               19           11  -41.97%
BenchmarkAppend32Bytes               23           14  -38.82%
BenchmarkAppendStr1Byte              14           10  -23.78%
BenchmarkAppendStr4Bytes             14           11  -21.13%
BenchmarkAppendStr8Bytes             14           10  -25.17%
BenchmarkAppendStr16Bytes            19           11  -41.45%
BenchmarkAppendStr32Bytes            18           14  -19.44%
BenchmarkAppendSpecialCase           62           63   +1.77%

R=golang-dev, khr, cshapiro, rsc, dave
CC=golang-dev
https://golang.org/cl/12815046
2013-09-16 20:31:21 -04:00
Russ Cox
00061219f0 cmd/nm: make -S listing a bit more accurate
Hide container symbols like text and etext so that
the individual pieces inside are shown instead.
For example, if text and main.init have the same
address, it was a toss-up which name was printed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13722046
2013-09-16 20:27:57 -04:00
Russ Cox
30ecb4cd05 build: disable precise collection of stack frames
The code for call site-specific pointer bitmaps was not ready in time,
but the zeroing required without it is too expensive to use by default.
We will have to wait for precise collection of stack frames until Go 1.3.

The precise collection can be re-enabled by

        GOEXPERIMENT=precisestack ./all.bash

but that will not be the default for a Go 1.2 build.

Fixes #6087.

R=golang-dev, jeremyjackins, dan.kortschak, r
CC=golang-dev
https://golang.org/cl/13677045
2013-09-16 20:26:10 -04:00
Adam Langley
6a1022a094 crypto/tls: fix TLS 1.2 client certificates.
With TLS 1.2, when sending client certificates the code was omitting
the new (in TLS 1.2) signature and hash fields.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13413050
2013-09-16 16:39:42 -04:00
Ian Lance Taylor
5ffc0f8fbb cmd/cgo: remove inaccurate comment
All these features have in fact been implemented.

R=rsc
CC=golang-dev
https://golang.org/cl/13419049
2013-09-16 13:19:32 -07:00
Russ Cox
e9453e0545 cmd/gc: do not report fields when looking for methods
Fixes #6395.

R=ken2
CC=golang-dev
https://golang.org/cl/13470046
2013-09-16 15:55:16 -04:00
Russ Cox
70138a2108 runtime: fix uint64 division on 386
The uint64 divide function calls _mul64x32 to do a 64x32-bit multiply
and then compares the result against the 64-bit numerator.
If the result is bigger than the numerator, must use the slow path.

Unfortunately, the 64x32 produces a 96-bit product, and only the
low 64 bits were being used in the comparison. Return all 96 bits,
the bottom 64 via the original uint64* pointer, and the top 32
as the function's return value.

Fixes 386 build (broken by ARM division tests).

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13722044
2013-09-16 15:11:32 -04:00
Russ Cox
51266761fd cmd/gc: fix divide by zero error in compiler
Fixes #6399.

R=ken2
CC=golang-dev
https://golang.org/cl/13253055
2013-09-16 14:22:37 -04:00
Russ Cox
a70cbf1329 runtime: fix freebsd build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13720044
2013-09-16 14:22:24 -04:00
Russ Cox
d9fdf88f34 net: make all.bat run for ordinary Windows users
This CL is required for all.bat to work out of the box on
my Windows 8 laptop.

These tests either require the firewall to be turned off
or require the user to be in the Administrators group.
I don't know which.

Alex may follow up with a refinement of the test to
allow them to run if the user is in the Administrators
group.

Fixes #6392.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13421049
2013-09-16 14:05:06 -04:00
Russ Cox
647eaed93b cmd/cgo: allow C.malloc(0) always
Because we can, and because it otherwise might crash
the program if we think we're out of memory.

Fixes #6390.

R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/13345048
2013-09-16 14:04:55 -04:00
Russ Cox
b2794a1c2e runtime: make ARM integer div-by-zero traceback-friendly
The implementation of division in the 5 toolchain is a bit too magical.
Hide the magic from the traceback routines.

Also add a test for the results of the software divide routine.

Fixes #5805.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13239052
2013-09-16 14:04:45 -04:00
Russ Cox
555da73c56 runtime, syscall: work around FreeBSD/amd64 kernel bug
The kernel implementation of the fast system call path,
the one invoked by the SYSCALL instruction, is broken for
restarting system calls. A C program demonstrating this is below.

Change the system calls to use INT $0x80 instead, because
that (perhaps slightly slower) system call path actually works.

I filed http://www.freebsd.org/cgi/query-pr.cgi?pr=182161.

The C program demonstrating that it is FreeBSD's fault is below.
It reports the same "Bad address" failures from wait.

#include <sys/time.h>
#include <sys/signal.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

static void handler(int);
static void* looper(void*);

int
main(void)
{
        int i;
        struct sigaction sa;
        pthread_cond_t cond;
        pthread_mutex_t mu;

        memset(&sa, 0, sizeof sa);
        sa.sa_handler = handler;
        sa.sa_flags = SA_RESTART;
        memset(&sa.sa_mask, 0xff, sizeof sa.sa_mask);
        sigaction(SIGCHLD, &sa, 0);

        for(i=0; i<2; i++)
                pthread_create(0, 0, looper, 0);

        pthread_mutex_init(&mu, 0);
        pthread_mutex_lock(&mu);
        pthread_cond_init(&cond, 0);
        for(;;)
                pthread_cond_wait(&cond, &mu);

        return 0;
}

static void
handler(int sig)
{
}

int
mywait4(int pid, int *stat, int options, struct rusage *rusage)
{
        int result;

        asm("movq %%rcx, %%r10; syscall"
                : "=a" (result)
                : "a" (7),
                  "D" (pid),
                  "S" (stat),
                  "d" (options),
                  "c" (rusage));
}

static void*
looper(void *v)
{
        int pid, stat, out;
        struct rusage rusage;

        for(;;) {
                if((pid = fork()) == 0)
                        _exit(0);
                out = mywait4(pid, &stat, 0, &rusage);
                if(out != pid) {
                        printf("wait4 returned %d\n", out);
                }
        }
}

Fixes #6372.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13582047
2013-09-16 14:04:32 -04:00
Rob Pike
29b4de25b3 cmd/go: document that "main" is a reserved import path
Fixes #6312.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13391049
2013-09-16 22:53:12 +10:00
Han-Wen Nienhuys
ab578e12ff net/rpc: log I/O and internal errors only if debugLog is set.
Fixes #6367.

R=rsc, r
CC=golang-dev
https://golang.org/cl/13395047
2013-09-16 16:29:04 +10:00
Rob Pike
2ec53b0705 cmd/nm: put the -S flag in the usage message
The -S flag reports symbol size, but is missing from the usage message.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13660046
2013-09-16 16:13:27 +10:00
Andrew Gerrand
49eeef5927 sort: move example to package level and simplify further
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13634044
2013-09-16 13:02:01 +10:00
Andrew Gerrand
d445b76331 cmd/gofmt: document -s transformations
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13721043
2013-09-16 11:19:39 +10:00
Rob Pike
1fba73de45 encoding/gob: ignore chan and func fields of structures
Previously, fields of type chan or func caused an error.
Now we just treat them like unexported fields and ignore them.
This makes it easier to guarantee long-term compatibilty since
a substructure from another package cannot break gob
encoding by adding a func or chan field.

Fixes #6071

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13693043
2013-09-16 10:26:23 +10:00
Russ Cox
6d68fc8eea runtime: fix CPU profiling on Windows
The test 'gp == m->curg' is not valid on Windows,
because the goroutine being profiled is not from the
current m.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13718043
2013-09-15 12:05:24 -04:00
Russ Cox
aa53b37fa6 go/build: add ctxt.MatchFile
Fixes #6369.

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/13708043
2013-09-15 11:29:47 -04:00
Russ Cox
1385e394cf encoding/xml: document behavior for undefined name space prefixes
Fixes #5626.

R=golang-dev, dominik.honnef
CC=golang-dev
https://golang.org/cl/13702043
2013-09-15 11:29:06 -04:00
Rob Pike
89dacb9cca fmt: %b for complex64 and complex128
Just an oversight they were missing.
Fixes #6387

R=golang-dev, dominik.honnef, rsc
CC=golang-dev
https://golang.org/cl/13715043
2013-09-15 10:45:36 +10:00
Rémy Oudompheng
04c40c97c3 cmd/gc: don't generate algs for internal map types.
Fake types describing the internal structure of hashmaps are
generated for use by precise GC.

Generating hash and eq functions for these fake types slows down
the build and wastes space: the go tool binary size is 13MB
instead of 12MB, and the package size on amd64 is 48.7MB instead
of 45.3MB.

R=golang-dev, daniel.morsing, r, khr, rsc, iant
CC=golang-dev
https://golang.org/cl/13698043
2013-09-14 09:30:36 +02:00
Russ Cox
22e8f82e8d os/exec: add more caveats to StdoutPipe, StderrPipe
(StdinPipe was taken care of by CL 13329043.)

Fixes #6008.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13606046
2013-09-13 15:43:54 -04:00
Russ Cox
439f9397fc runtime: avoid inconsistent goroutine state in profiler
Because profiling signals can arrive at any time, we must
handle the case where a profiling signal arrives halfway
through a goroutine switch. Luckily, although there is much
to think through, very little needs to change.

Fixes #6000.
Fixes #6015.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13421048
2013-09-13 14:19:23 -04:00
Russ Cox
7fb3d8e45e reflect: document FieldByName shortcoming
Fixes #4876.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13701044
2013-09-13 13:56:39 -04:00
Dave Cheney
bd9cd6e30e syscall: add TCIOFLUSH family of constants
Fixes #6355.

zerrors_linux_{386,amd64,arm}.go were regenerated using mkerrors.sh but I opted to add the three TC.*FLUSH lines by hand to keep the diff smaller and avoid problems with the API checker.

I'll check freebsd and darwin, could I ask for help with net/open bsd.

R=mikioh.mikioh, jsing, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/13660043
2013-09-13 15:01:22 +10:00
Russ Cox
3acddba2ec cmd/5l: fix handling of RET.EQ in wrapper function
Keith is too clever for me.

R=ken2
CC=golang-dev, khr
https://golang.org/cl/13272050
2013-09-13 03:50:50 +00:00
Jamie Wilkinson
27cb23ceb1 goyacc: Fix debug printing of the lexed token's ID and name, and add whitespace in the 'stateX saw' message.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13352048
2013-09-13 13:18:02 +10:00
Rob Pike
c842e43ef6 text/template/parse: mostly roll back the error detection for unmatched right delimiters
It's too late to change this behavior: it breaks templates with minimized JavaScript.

Makes me sad because this common error can never be caught: "{foo}}".
Three cheers for compatibility.

(Leave in a fix to a broken test.)

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13689043
2013-09-13 12:44:45 +10:00
Russ Cox
913f1f1557 cmd/go: do not support code.google.com/r/zzz projects
This reverts CL 13261048. I have just learned that these are
no longer supported on code.google.com (that is, it is impossible
to create them), so there is little reason to add support in
Go 1.2.

Update #5408

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/13317046
2013-09-12 21:47:56 -04:00
Russ Cox
3c11dd8ebc encoding/xml: add Encoder.Flush
Fixes #6365.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13627046
2013-09-12 16:54:01 -04:00
Russ Cox
7276c02b41 runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:

Issue 5406 identified an interesting case:
        defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.

[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]

Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.

Bug #2:

The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.

Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.

Fixes #5406.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 14:00:16 -04:00
Josh Bleecher Snyder
1ea0c480dc go/token: rename RemoveLine to MergeLine, improve documentation
This is a follow-up to feedback from gri in
https://golang.org/cl/12837044/. Most of the wording
and naming improvements are lifted shamelessly from him.

R=gri
CC=golang-dev
https://golang.org/cl/13670043
2013-09-12 09:31:07 -07:00
Nicholas Sullivan
4874bc9b76 crypto/x509: allow ECDSA public keys to be marshaled.
The public key serialization from CreateCertificate is factored out to be
used in MarshalPKIXPublicKey.
Testcode with one P224 ECDSA keypair has been added.

R=golang-dev, agl
CC=agl, golang-dev
https://golang.org/cl/13427044
2013-09-12 12:23:34 -04:00
Han-Wen Nienhuys
1e71e74262 net/rpc: document thread safety requirements of codec types.
Fixes #6306.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/13474043
2013-09-12 22:03:53 +10:00
Brad Fitzpatrick
1a819be590 net/http: document ServeMux handling of pattern "/"
Fixes #4799

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/13457047
2013-09-12 11:20:16 +01:00
Rob Pike
caa462137a text/template: catch unmatched right delimiter
It was simply a missing error case: when scanning plain text
outside of an action, a right delimiter should be an error.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13468045
2013-09-12 13:22:56 +10:00
Mikio Hara
fe62a1f1fe net: move mock ICMP into separate file
This is in prepartion for fixing issue 6320.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13611043
2013-09-12 11:59:18 +09:00
Mikio Hara
81737a9a51 net: make TestDialFailPDLeak shorter
Reduces a number of trials but it still can detect memory leak
when we make blunders in runtime-integarted network poller work,
like just forgetting to call runtime_pollClose in code paths.

Also disables the test on windows/386.

R=alex.brainman, r
CC=golang-dev
https://golang.org/cl/13022046
2013-09-12 11:10:25 +09:00
Dave Cheney
e38eddbfe4 cmd/8l: fix 386 builds
Remove set but unused variable.

R=rsc
CC=golang-dev
https://golang.org/cl/13490047
2013-09-12 11:18:34 +10:00
Russ Cox
1a6576db34 cmd/5l, cmd/6l, cmd/8l: refactor stack split code
Pull the stack split generation into its own function.
This will make an upcoming change to fix recover
easier to digest.

R=ken2
CC=golang-dev
https://golang.org/cl/13611044
2013-09-11 20:29:45 -04:00
Russ Cox
bab302dea2 undo CL 13348045 / 43675523c526
There is no reason to do this, and it's more work.

««« original CL description
net: make channel-based semaphore depend on receive, not send

R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045

»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13632047
2013-09-11 20:29:22 -04:00
Russ Cox
7f6a7e22a8 net/http: explain the "1.1" in the default User-Agent
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13263052
2013-09-11 20:28:14 -04:00
Rémy Oudompheng
ff416a3f19 cmd/gc: inline copy in frontend to call memmove directly.
A new node type OSPTR is added to refer to the data pointer of
strings and slices in a simple way during walk(). It will be
useful for future work on simplification of slice arithmetic.

benchmark                  old ns/op    new ns/op    delta
BenchmarkCopy1Byte                 9            8  -13.98%
BenchmarkCopy2Byte                14            8  -40.49%
BenchmarkCopy4Byte                13            8  -35.04%
BenchmarkCopy8Byte                13            8  -37.10%
BenchmarkCopy12Byte               14           12  -15.38%
BenchmarkCopy16Byte               14           12  -17.24%
BenchmarkCopy32Byte               19           14  -27.32%
BenchmarkCopy128Byte              31           26  -15.29%
BenchmarkCopy1024Byte            100           92   -7.50%
BenchmarkCopy1String              10            7  -28.99%
BenchmarkCopy2String              10            7  -28.06%
BenchmarkCopy4String              10            8  -22.69%
BenchmarkCopy8String              10            8  -23.30%
BenchmarkCopy12String             11           11   -5.88%
BenchmarkCopy16String             11           11   -5.08%
BenchmarkCopy32String             15           14   -6.58%
BenchmarkCopy128String            28           25  -10.60%
BenchmarkCopy1024String           95           95   +0.53%

R=golang-dev, bradfitz, cshapiro, dave, daniel.morsing, rsc, khr, khr
CC=golang-dev
https://golang.org/cl/9101048
2013-09-12 00:15:28 +02:00
Russ Cox
6d47de2f40 cmd/5g, cmd/6g, cmd/8g: remove O(n) reset loop in copyprop
Simpler version of CL 13084043.

R=ken2
CC=golang-dev
https://golang.org/cl/13602045
2013-09-11 15:22:11 -04:00
Russ Cox
a0bc379d46 undo CL 13084043 / ef4ee02a5853
There is a cleaner, simpler way.

««« original CL description
cmd/5g, cmd/6g, cmd/8g: faster compilation
Replace linked list walk with memset.
This reduces CPU time taken by 'go install -a std' by ~10%.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.714s	0m14.858s	0m6.138s
0m22.644s	0m14.875s	0m6.120s
0m22.604s	0m14.854s	0m6.081s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13084043
»»»

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/13352049
2013-09-11 15:14:11 -04:00
Russ Cox
8cd6341cf8 cmd/gc: allow x[i:j:k] (and x[:j:k]) into the release
R=ken2
CC=golang-dev
https://golang.org/cl/13512053
2013-09-11 14:55:46 -04:00
Russ Cox
cdc5356c93 cmd/api: fix tool for recent go/build change
Asking about runtime/cgo when CgoEnabled=false now correctly
returns an error from build.Import (specifically, NoGoError), because
there are no buildable Go files in that directory.

The API tool was depending on it returning a package with no Go
files instead. Correct that assumption.

Fixes all.bash on local machines.
(Dashboard appears not to be running the api tool at all.)

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13385046
2013-09-11 14:42:34 -04:00
Russ Cox
6624b70866 undo CL 13632053 / dc7bfe0f022d
It was never going to last.

««« original CL description
cmd/api: break the builds

There is some question about whether the api tool is
running on Windows (see issue 6124), and now I'm
starting to question whether it runs on any of the builders,
since both darwin/amd64 and linux/amd64 are crashing for me
in the api tool due to a recent cgo-related change, and yet
the dashboard is happy.

If the dashboard is still happy after this CL, we have a problem.

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13632053
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13474045
2013-09-11 14:35:08 -04:00
Russ Cox
89a6a8fdb3 cmd/api: break the builds
There is some question about whether the api tool is
running on Windows (see issue 6124), and now I'm
starting to question whether it runs on any of the builders,
since both darwin/amd64 and linux/amd64 are crashing for me
in the api tool due to a recent cgo-related change, and yet
the dashboard is happy.

If the dashboard is still happy after this CL, we have a problem.

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13632053
2013-09-11 14:34:11 -04:00
Russ Cox
ce9ddd0eee runtime: keep args and frame in struct Func
args is useful for printing tracebacks.

frame is not necessary anymore, but we might some day
get back to functions where the frame size does not vary
by program counter, and if so we'll need it. Avoid needing
to introduce a new struct format later by keeping it now.

Fixes #5907.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13632051
2013-09-11 14:18:52 -04:00
Russ Cox
611b182190 go/build: reject directory with only cgo files if cgo not in use
The old test for "no Go files" was p.Name == "", meaning we never
saw a Go package statement. That test fails if there are cgo files
that we parsed (and recorded the package name) but then chose
not to use (because cgo is not available).

Test the actual file lists instead.

Fixes #6078.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13661043
2013-09-11 13:25:30 -04:00
Ian Lance Taylor
fdaf88ea5b cmd/yacc: replace units example with simpler expr example
The units example is nice but is covered by the Lucent
license, which may be a concern for some people making a
commercial source code distribution of Go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13283045
2013-09-11 09:01:47 -07:00
Russ Cox
ab38e2a498 runtime: show m stack during crash on m stack
The various throwing > 0 finish a change started
in a previous CL, which sets throwing = -1 to mean
"don't show the internals". That gets set during the
"all goroutines are asleep - deadlock!" crash, and it
should also be set during any other expected crash
that does not indicate a problem within the runtime.

Most runtime.throw do indicate a problem within the
runtime, however, so we should be able to enumerate
the ones that should be silent. The goroutine sleeping
deadlock is the only one I can think of.

Update #5139

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13662043
2013-09-11 12:00:37 -04:00
Russ Cox
fa4984d535 runtime: show runtime.panic frame in traceback
Otherwise, if panic starts running deferred functions,
the code that panicked appears to be calling those
functions directly, which is not the case and can be
confusing.

For example:

main.Two()
        /Users/rsc/x.go:12 +0x2a
runtime.panic(0x20dc0, 0x2100cc010)
        /Users/rsc/g/go/src/pkg/runtime/panic.c:248 +0x106
main.One()
        /Users/rsc/x.go:8 +0x55

This makes clear(er) that main.Two is being called during
a panic, not as a direct call from main.One.

Fixes #5832.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13302051
2013-09-11 11:59:19 -04:00
Russ Cox
382738af51 net: defend against broken getaddrinfo on Linux
getaddrinfo is supposed to set errno when it returns
EAI_SYSTEM, but sometimes it does not.

Fixes #6232.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13532045
2013-09-11 11:38:56 -04:00
Russ Cox
397ba2cb4a cmd/cgo: replace C.malloc with our own wrapper
This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes #3403.
Fixes #5926.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13413047
2013-09-11 11:30:08 -04:00
Mikio Hara
89b26760d7 net: implement TCP connection setup with fast failover
This CL adds minimal support of Happy Eyeballs-like TCP connection
setup to Dialer API. Happy Eyeballs and derivation techniques are
described in the following:

- Happy Eyeballs: Success with Dual-Stack Hosts
  http://tools.ietf.org/html/rfc6555

- Analysing Dual Stack Behaviour and IPv6 Quality
  http://www.potaroo.net/presentations/2012-04-17-dual-stack-quality.pdf

Usually, the techniques consist of three components below.

- DNS query racers, that run A and AAAA queries in parallel or series
- A short list of destination addresses
- TCP SYN racers, that run IPv4 and IPv6 transport in parallel or series

This CL implements only the latter two. The existing DNS query
component gathers together A and AAAA records in series, so we don't
touch it here. This CL just uses extended resolveInternetAddr and makes
it possible to run multiple Dial racers in parallel.

For example, when the given destination is a DNS name and the name has
multiple address family A and AAAA records, and it happens on the TCP
wildcard network "tcp" with DualStack=true like the following:

(&net.Dialer{DualStack: true}).Dial("tcp", "www.example.com:80")

The function will return a first established connection either TCP over
IPv4 or TCP over IPv6, and close the other connection internally.

Fixes #3610.
Fixes #5267.

Benchmark results on freebsd/amd64 virtual machine, tip vs. tip+12416043:

benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                    50696        52141   +2.85%
BenchmarkTCP4OneShotTimeout             65775        66426   +0.99%
BenchmarkTCP4Persistent                 10986        10457   -4.82%
BenchmarkTCP4PersistentTimeout          11207        10445   -6.80%
BenchmarkTCP6OneShot                    62009        63718   +2.76%
BenchmarkTCP6OneShotTimeout             78351        79138   +1.00%
BenchmarkTCP6Persistent                 14695        14659   -0.24%
BenchmarkTCP6PersistentTimeout          15032        14646   -2.57%
BenchmarkTCP4ConcurrentReadWrite         7215         6217  -13.83%
BenchmarkTCP6ConcurrentReadWrite         7528         7493   -0.46%

benchmark                          old allocs   new allocs    delta
BenchmarkTCP4OneShot                       36           36    0.00%
BenchmarkTCP4OneShotTimeout                36           36    0.00%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                       37           37    0.00%
BenchmarkTCP6OneShotTimeout                37           37    0.00%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

benchmark                           old bytes    new bytes    delta
BenchmarkTCP4OneShot                     2500         2503    0.12%
BenchmarkTCP4OneShotTimeout              2508         2505   -0.12%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                     2713         2707   -0.22%
BenchmarkTCP6OneShotTimeout              2722         2720   -0.07%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

R=golang-dev, bradfitz, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12416043
2013-09-11 10:48:53 -04:00
Russ Cox
e6a49555a7 cmd/go: use pattern to prune file tree walk
For example, if the pattern is m... there is
no need to look in directories not beginning with m.

Fixes #5214.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13253049
2013-09-11 09:57:05 -04:00
Russ Cox
08b26e4104 cmd/cgo: don't say "gcc produced no output" if we ran clang
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13420048
2013-09-11 09:56:51 -04:00
Dave Cheney
3ee0744c06 bytes: additional test coverage
Add coverage for some uncovered bytes methods. The increase in actual coverage is disapointing small.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13651044
2013-09-11 21:20:15 +10:00
Robert Daniel Kortschak
b34ec90e19 cmd/api: make api check directory per-user
Fixes #6353.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/13652043
2013-09-11 10:50:56 +10:00
Russ Cox
b99fdb2a11 cmd/go: report correct directory for 'no version control'
The scan starts at the directory we care about and works
backward to the GOPATH root. The error should say the
original directory name, not the name of the GOPATH root.

Fixes #6175.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13366050
2013-09-10 15:28:29 -04:00
Russ Cox
6034406eae build: more "undefined behavior" fixes
Fixes #5764.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13441051
2013-09-10 14:54:55 -04:00
Russ Cox
80a153dd51 cmd/6l, cmd/8l: fix MOVL MOVQ optab
The entry for LEAL/LEAQ in these optabs was listed as having
two data bytes in the y array. In fact they had and expect no data
bytes. However, the general loop expects to be able to look at at
least one data byte, to make sure it is not 0x0f. So give them each
a single data byte set to 0 (not 0x0f).

Since the MOV instructions have the largest optab cases, this
requires growing the size of the data array.

Clang found this bug because the general o->op[z] == 0x0f
test was using z == 22, which was out of bounds.

In practice the next byte in memory was probably not 0x0f
so it wasn't truly broken. But might as well be clean.

Update #5764

R=ken2
CC=golang-dev
https://golang.org/cl/13241050
2013-09-10 14:53:41 -04:00
Arnaud Ysmal
8edf764fa3 libmach: accept OS X binary generated by external linker
Fixes cpu subtype check when using external linker which sets the CPU_SUBTYPE_LIB64 bit (1<<31).
Fixes #6197.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13248046
2013-09-10 11:50:34 -07:00
Russ Cox
baed067d87 cmd/go: show FAIL for errors during test setup
For example, if an x_test.go file contains a syntax error,
b.test fails with an error message. But it wasn't printing
the same FAIL line that a build failure later would print.
This makes all the test failures that happen (once we
decide to start running tests) consistently say FAIL.

Fixes #4701.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13431044
2013-09-10 14:43:57 -04:00
Russ Cox
627d17cf29 cmd/go: fix go test using package main_test
A package main binary (that is, a command) being installed
does not mean we can skip the build of the package archive
during a test.

Fixes #3417.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13462046
2013-09-10 14:43:35 -04:00
Russ Cox
90f9192886 cmd/go: run benchmarks in sequence
Fixes #5662.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13650043
2013-09-10 14:43:21 -04:00
Russ Cox
6706931a71 go/doc: restore handling of multi-paragraph BUG comments
It was lost when the generic "Notes" support went in.

Had to change the test setup, because it precluded even
being able test multi-line comments, much less multi-paragraph
comments.

Now 'godoc sync/atomic' works correctly again.

Fixes #6135.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13427045
2013-09-10 14:41:20 -04:00
Russ Cox
159c2b7e46 cmd/go: fix error for 'go install x.go' when GOBIN is not set
Fixes #6191.
Fixes #5426.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13234052
2013-09-10 14:41:07 -04:00
Ian Lance Taylor
a547ad6ac0 cmd/go: report real package in errors for go get with wildcard
Fixes #5054.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13609043
2013-09-10 11:27:29 -07:00
Ian Lance Taylor
7f062fa2de cmd/go: build SWIG shared libraries in work directory
Remove test of whether SWIG shared library is older than
sources--should be covered by test of package file anyhow.

Fixes #5739.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13352046
2013-09-10 11:00:26 -07:00
Russ Cox
d5fbad0de8 cmd/go: better error for shadowed directories in GOPATH
Fixes #5774.

R=golang-dev, adg, r, bradfitz
CC=golang-dev
https://golang.org/cl/9164043
2013-09-10 13:17:21 -04:00
Alexis Imperial-Legrand
927b7ac327 runtime: explicit init of runtime-gdb helpers
If using other gdb python scripts loaded before Go's gdb-runtime.py
and that have a different init prototype:
Traceback (most recent call last):
  File "/usr/lib/go/src/pkg/runtime/runtime-gdb.py", line 446, in <module>
    k()
TypeError: __init__() takes exactly 3 arguments (1 given)

The problem is that gdb keeps all python scripts in the same namespace,
so vars() contains them. To avoid that, load helpers one by one.

R=iant, rsc
CC=gobot, golang-dev
https://golang.org/cl/9752044
2013-09-10 13:00:08 -04:00
Russ Cox
7d249ef28f cmd/go: fix build -n output when using swig
$INTBITS will not be defined, of course, but that's the best we can do.

Fixes #5978.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13253048
2013-09-10 12:55:07 -04:00
Russ Cox
7c6db642b0 cmd/go: implement -x correctly for 'go vet', 'go fmt', and so on
Fixes #5676.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13250047
2013-09-10 12:47:52 -04:00
Russ Cox
c971f95c10 go/build: allow $ in cgo LDFLAGS
Fixes #6038.

R=iant
CC=golang-dev
https://golang.org/cl/13649043
2013-09-10 12:47:43 -04:00
Russ Cox
358ae20777 libmach: change three more BGET macro invocations back
Various compilers complain about the macro expansion not
being used. I fixed a few yesterday. More today.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13643044
2013-09-10 12:24:43 -04:00
Keith Randall
4487054751 runtime: clean up / align comment tabbing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13336046
2013-09-10 09:02:22 -07:00
Mikio Hara
02faa939d3 net: remove dreg of obsoleted network poller
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13396051
2013-09-10 20:00:21 +09:00
Alex Brainman
a6149da08a os/exec: change windows LookPath so it works like cmd.exe
Fixes #6224

R=golang-dev, hcwfrichter, bradfitz
CC=golang-dev
https://golang.org/cl/13410045
2013-09-10 14:50:29 +10:00
Russ Cox
5d2c3a687c encoding/json: document actual behavior for Unmarshal into interface{}
Fixes #4900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13400044
2013-09-09 19:11:05 -04:00
Richard Eric Gavaletz
7adb42eee4 container/list: unexpected panic if Next/Prev called outside of list.
Before CL 7065067 calling Next on an element returned either the
next/prev element or nil was returned.  After the CL if an element
was not part of a list e.Next() and e.Prev() will panic.  This CL
returns to the documented behavior, that Next/Prev returns the
next/prev list element or nil.

Fixes #6349.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/13234051
2013-09-09 15:41:36 -07:00
Russ Cox
5dc8c4dbfb path/filepath: fix race with other tests
Bug3486 tried to walk the entire file tree, but other tests might
be creating and removing files in that tree. In particular, package os
creates and removes files in the os directory, and issue 5863
reports failures due to seeing those files appear and then disappear.

Change the test to walk just the test tree, which should not be
changing.

Fixes #5863.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13467045
2013-09-09 16:42:18 -04:00
Russ Cox
10c36fbc9d encoding/xml: fix panic in Marshal
Fixes #6341.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13512048
2013-09-09 16:42:07 -04:00
Russ Cox
1b651556c3 syslog: fix data race on 'crashy' in test function
Fixes #5894.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303051
2013-09-09 16:17:59 -04:00
Russ Cox
87a6d75012 log/syslog: use alternate format for logging to local syslog daemon
Fixes #5803.
Is it correct behavior? Who knows.

R=golang-dev, bradfitz, jgc
CC=golang-dev, jgc
https://golang.org/cl/13248048
2013-09-09 16:17:44 -04:00
Ian Lance Taylor
f0ff63ea64 cmd/go: if there are C++ sources, use g++ as default external linker
This will bring in the C++ standard library without requiring
any special #cgo LDFLAGS options.

When using gccgo, just add -lstdc++ to link line; this should
do no harm if it is not needed.

No tests, since we don't want to assume a C++ compiler.

Update #5629

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13394045
2013-09-09 12:50:49 -07:00
Russ Cox
7d734d9252 build: remove various uses of C undefined behavior
If you thought gcc -ansi -pedantic was pedantic, just wait
until you meet clang -fsanitize=undefined.

I think this addresses all the reported "errors", but we'll
need another run to be sure.

all.bash still passes.

Update #5764

Dave, can you please try again?

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13334049
2013-09-09 15:07:23 -04:00
Russ Cox
6252b41981 runtime: remove OABI check from ARM startup
The code in question is trying to print a nice error message
when a Go EABI binary runs on an OABI machine.
Unfortunately, the only way to do that is to use
ARM Thumb instructions, which we otherwise don't use.

There exist ARM EABI machines that do not support Thumb.
We could run on them if not for this OABI check, so disable it.

Fixes #5685.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13234050
2013-09-09 15:06:05 -04:00
Rémy Oudompheng
9c21ce54dd cmd/6g: handle very wide offsets.
Fixes #6036.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12992043
2013-09-09 20:36:19 +02:00
Russ Cox
0218dfe7eb cmd/gc: allow inlined struct == to mention unsafe.Pointer even in safe mode
Fixes #5578.

R=ken2
CC=golang-dev
https://golang.org/cl/13417044
2013-09-09 13:11:41 -04:00
Russ Cox
5b04d67091 cmd/cgo: record full source path to input .go files
Fixes #5122.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13395046
2013-09-09 13:04:14 -04:00
Russ Cox
933d7129c0 cmd/gc: squelch spurious "invalid recursive type" error
R=ken2
CC=golang-dev
https://golang.org/cl/13512047
2013-09-09 13:03:59 -04:00
Russ Cox
903c2fda18 cmd/gc: diagnose '_ = nil' better
Fixes #6004.

R=ken2
CC=golang-dev
https://golang.org/cl/13616044
2013-09-09 12:49:39 -04:00
Russ Cox
85195e2ccf cmd/gc: more detail in import conflict error message
Cannot happen when using the go command, but help
people running commands by hand or with other tools.

Fixes #5888.

R=ken2
CC=golang-dev
https://golang.org/cl/13324048
2013-09-09 12:30:53 -04:00
Russ Cox
8d530f2472 cmd/gc: show package name in 'imported and not used' error
Fixes #5957.

R=ken2
CC=golang-dev
https://golang.org/cl/13250046
2013-09-09 12:21:09 -04:00
Russ Cox
a7d8b35aac cmd/gc: fix 'internal error: typename ideal bool'
Fixes #6298.

R=ken2
CC=golang-dev
https://golang.org/cl/13624043
2013-09-09 12:00:16 -04:00
Joel Sing
3b089179c4 runtime: unbreak build on dragonfly
Update dragonfly memory functions to work with new memory statistics.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13615043
2013-09-09 08:48:06 -07:00
Alex Brainman
5f75314e18 time: allow more time for TestOverflowRuntimeTimer to succeed
Attempting to fix windows gobuilders

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13507044
2013-09-09 15:50:11 +10:00
Dominik Honnef
a789ae9e8e compress/flate: small documentation fix
R=golang-dev, adg
CC=bradfitz, golang-dev, remyoudompheng
https://golang.org/cl/13568045
2013-09-09 09:37:05 +10:00
Robert Daniel Kortschak
c01945afc9 sort: fix up example expected output formatting
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13426046
2013-09-08 13:21:03 +10:00
Andriy Lytvynov
467122ce0b sort: add a simpler sort.Interface example
Existing example renamed to Example_sortWrapper.
Fixes #6335.

R=golang-dev, rsc, taj.khattra, r
CC=golang-dev
https://golang.org/cl/13586043
2013-09-08 11:17:23 +10:00
Keith Randall
78338d8c66 runtime: Smhasher tests of our map hash function.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13436045
2013-09-06 16:23:46 -07:00
Brad Fitzpatrick
da7a51d16b net: don't error when marshalling nil IP addresses
See https://code.google.com/p/go/issues/detail?id=6339#c3

Fixes #6339

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13553044
2013-09-06 15:29:09 -07:00
Ehren Kret
3b6b53f493 compress/flate: prevent panic when reinitializing huffmanDecoder with bad input
The huffmanDecoder struct appears to be intented for reuse by calling init a
second time with a second sequence of code lengths. Unfortunately, it can
currently panic if the second sequence of code lengths has a minimum value
greater than 10 due to failure to reinitialize the links table.

This change prevents the panic by resetting the huffmanDecoder struct back to
the struct's zero value at the beginning of the init method if the
huffmanDecoder is being reused (determined by checking if min has been set to a
non-zero value).

Fixes #6255.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13230043
2013-09-06 15:09:42 -07:00
Dmitriy Vyukov
a33ef8d11b runtime: account for all sys memory in MemStats
Currently lots of sys allocations are not accounted in any of XxxSys,
including GC bitmap, spans table, GC roots blocks, GC finalizer blocks,
iface table, netpoll descriptors and more. Up to ~20% can unaccounted.
This change introduces 2 new stats: GCSys and OtherSys for GC metadata
and all other misc allocations, respectively.
Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation
functions require the stat for accounting, so that it's impossible to miss something.
Also fix updating of mcache_sys/inuse, they were not updated after deallocation.

test/bench/garbage/parser before:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14204928
MCacheSys	16384
BuckHashSys	1439992

after:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14188544
MCacheSys	16384
BuckHashSys	3194304
GCSys		39198688
OtherSys	3129656

Fixes #5799.

R=rsc, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/12946043
2013-09-06 16:55:40 -04:00
Alex Brainman
52f15df9e2 cmd/go: rename go.exe if cannot delete it during clean
Fixes #6179

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12916047
2013-09-06 16:55:35 -04:00
Rémy Oudompheng
c929ac5f7e cmd/gc: add missing typecheck for walk-generated constants.
Fixes #6131.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/12800045
2013-09-06 16:55:30 -04:00
Marco Hennings
4e998d71c9 archive/tar: fix a case where USTAR-split is not working correctly.
For some long filenames the USTAR-split code does not work
correctly. It is wrongly assumed that the path would not be too long,
but it is.

The user visible result was that a filename was split, but it still
caused an error.

The cause was a wrongly calculated nlen. In addition I noticed that
at this place it is also seems necessary to check if the prefix will
fit in the 155 chars available for the prefix.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13300046
2013-09-06 16:49:38 -04:00
Andriy Lytvynov
fb25a61872 sort: fix Example_sortMultiKeys
Old example referenced global var from multiSorter.Sort and ignored it's argument.
Changed one of example calls to actually pass slice to sort.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13551044
2013-09-06 16:49:34 -04:00
Russ Cox
af2a3193af cmd/5g, cmd/6g, cmd/8g: simplify for loop in bitmap generation
Lucio De Re reports that the more complex
loop miscompiles on Plan 9.

R=ken2
CC=golang-dev
https://golang.org/cl/13602043
2013-09-06 16:49:11 -04:00
Josh Bleecher Snyder
08925ce6ee cmd/gofmt: sort more, remove some duplicate imports
* Sort imports by import path, then import name, then comment. Currently, gofmt sorts only by import path.
* If two imports have the same import path and import name, and one of them has no comment, remove the import with no comment. (See the discussion at issue 4414.)

Based on @rsc's https://golang.org/cl/7231070/

Fixes #4414.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12837044
2013-09-06 16:25:15 -04:00
Russ Cox
e1ac15743b cmd/gc: remove "send used as value" hint
This message was helpful for pre-Go 1 users updating to Go 1.
That time is past. Now the message is confusing because it
depends on knowing what pre-Go 1 looked like.

Update #4697.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13335051
2013-09-06 15:47:52 -04:00
Anthony Martin
3548ab5ebb runtime: handle timer overflow in tsleep
Make sure we never pass a timer into timerproc with
a negative duration since it will cause other timers
to never expire.

Fixes #5321.

R=golang-dev, minux.ma, remyoudompheng, mikioh.mikioh, r, bradfitz, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/9035047
2013-09-06 15:47:39 -04:00
Brad Fitzpatrick
8a70b50b1f cmd/api: include constant values
Update #5935

R=golang-dev, rsc, iant, dave
CC=golang-dev
https://golang.org/cl/13261050
2013-09-06 12:01:01 -07:00
Brad Fitzpatrick
da50221e8e reflect: unexport BUCKETSIZE, MAXKEYSIZE, MAXVALSIZE
But keep their case for ease of searching.

They were added recently. We don't want them part of go1.2's API.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13569044
2013-09-06 12:00:42 -07:00
Brad Fitzpatrick
c327e82ddb crypto/rand: make Read use io.ReadFull
Fixes #6084

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/13523044
2013-09-06 12:00:27 -07:00
Kamil Kisiel
a3834a2e8a net: Fix inaccurate docs for AcceptTCP and AcceptUnix.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13592043
2013-09-06 12:00:03 -07:00
Lucio De Re
fd7ddad160 cmd/dist: Plan 9 build needs an additional include path
cmd/cc: bv.c imports libc.h twice

When using the Plan 9 compiler, the invocation

        #include <../ld/textflag.h>

works for the toolchain, but not for the MACH library.

Module cmd/cc/bv.c includes libc.h and "cc.h", which in
turn also includes libc.h.  In the Plan 9 context, this
causes a number of duplicate definitions.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/13303047
2013-09-06 16:15:44 +10:00
Rob Pike
6833d1b436 cmd/go: don't leave test binary around for coverage
It's not needed to analyze coverage data.
Fixes #6120

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13343050
2013-09-06 15:54:26 +10:00
Rob Pike
46f96079df undo CL 13004046 / 5db14b33d6ef
Flushing after every token negates the point of buffering. A different approach is required.

««« original CL description
encoding/xml: flush buffer after encoding token

R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046

»»»

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/13515043
2013-09-06 07:54:43 +10:00
Ian Lance Taylor
28bbc6c27a cmd/ld: emit relocations for .debug_frame in external link mode
This should have been part of revision 16731:cdedb129e020, but
I missed it.  This fixes printing local variables when doing
an external link.

No test because we aren't doing any debug info testing yet.

Fixes #5719.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13464046
2013-09-05 12:55:21 -07:00
Rémy Oudompheng
86c0cf10cb compress/zlib: add Reset method to Writer.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13171046
2013-09-05 21:50:47 +02:00
Rémy Oudompheng
780f5b714d reflect: do not cache trivial values in DeepEqual.
DeepEqual caches addresses of compared values
each time it visits addressable values. This is
more expensive than actually comparing them in
the common case of large slices of bytes or integers.

Also add a fast path for slices with identical
underlying array.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13000044
2013-09-05 21:37:07 +02:00
Ian Lance Taylor
f2380a81d7 cmd/dist: don't print misleading warning when using GOROOT_FINAL
Fixes #5240.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13546044
2013-09-04 17:02:08 -07:00
Brad Fitzpatrick
fca660892d compress/flate: use bytes.NewReader instead of NewBuffer in test
Also, report allocations in benchmark.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13410044
2013-09-04 15:31:46 -07:00
Rob Pike
80f39f7b73 html/template: export the parse.Tree for the escaped template
The underlying parse tree is visible in text/template, so it should be visible here.
Done by copying the underlying *parse.Tree up to the top level of the struct, and then making sure it's kept up to date.
Fixes #6318.

R=mikesamuel
CC=golang-dev
https://golang.org/cl/13479044
2013-09-05 08:23:11 +10:00
Aulus Egnatius Varialus
2b44b36487 cgo: enable cgo on dragonfly
Enable cgo for dragonfly/386 and dragonfly/amd64.

R=golang-dev, jsing, iant, bradfitz
CC=golang-dev
https://golang.org/cl/13247046
2013-09-04 15:19:21 -07:00
Ian Lance Taylor
d011f0aa89 cmd/ld: don't allocate unused garbage space in pclntab file table
Fixes #6319.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13539043
2013-09-04 13:26:49 -07:00
Ian Lance Taylor
97d6a1e130 cmd/cgo: document command line options
Also remove incorrect statement that cgo does not support
gccgo.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13511043
2013-09-03 21:23:52 -07:00
Ian Lance Taylor
f68c23e2bb cmd/cgo: don't let #cgo directives mess up line numbering
Fixes #5272.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13498046
2013-09-03 21:15:15 -07:00
Rob Pike
0ba7ffe289 text/template: allow eq to take more than two arguments
Based on an old suggestion by rsc, it compares the second
and following arguments to the first.

Unfortunately the code cannot be as pretty as rsc's original
because it doesn't require identical types.

R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/13509046
2013-09-04 13:42:22 +10:00
Mikio Hara
54b2a83d9a net/http: remove dreg of obsoleted network poller
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13261049
2013-09-04 10:04:12 +09:00
Brad Fitzpatrick
8272c14f7e net/http: sniff less
We were reading 1024 bytes but only using 512.

Fixes #6311

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13289047
2013-09-03 09:11:25 -07:00
Mikio Hara
c576bcbad5 net: fix TestFirstFavoriteAddr failure on single IP stack kernel
Update #3610
Update #5267
Update #5707

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13465043
2013-09-02 16:44:51 +09:00
Keith Randall
23f9751e83 runtime: clean up map code. Remove hashmap.h.
Use cnew/cnewarray instead of mallocgc.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13396045
2013-08-31 14:09:34 -07:00
Joel Sing
fd0af9b56c cmd/8l: add support for dragonfly/386
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13328045
2013-08-31 09:33:38 -07:00
Joel Sing
465ba6b78c runtime, syscall: add support for dragonfly/386
Add runtime and syscall support for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13237051
2013-08-31 09:32:07 -07:00
Joel Sing
f6f02a69ae syscall: z* files for dragonfly/386
Add generated z* files for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303046
2013-08-31 09:29:38 -07:00
Keith Randall
fb376021be runtime: record type information for hashtable internal structures.
Remove all hashtable-specific GC code.

Fixes bug 6119.

R=cshapiro, dvyukov, khr
CC=golang-dev
https://golang.org/cl/13078044
2013-08-31 09:09:50 -07:00
Joel Sing
d0206101c8 cmd/5l,cmd/6l,cmd/8l: fix dragonflydynld path
R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13225043
2013-08-31 22:02:21 +10:00
Mikio Hara
29de03adf3 net: keep lookup IP stuff close
Also flattens import declaration.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/13373046
2013-08-31 16:29:50 +09:00
Mikio Hara
7c59c8bdee net: make resolveInternetAddr return a list of addresses
This CL makes resolveInternetAddr return a list of addresses that
contain a pair of different address family IP addresses if possible,
but doesn't contain any API behavioral changes yet. A simple IP
address selection mechanism for Resolve{TCP,UDP,IP}Addr and Dial API
still prefers IPv4.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13374043
2013-08-31 10:28:49 +09:00
Brad Fitzpatrick
db12f9d4e4 compress/gzip: add Writer.Reset
compress/flate is https://golang.org/cl/12953048
compress/zlib is https://golang.org/cl/13171046

Update #6138

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13435043
2013-08-30 11:41:12 -07:00
Tad Glines
41c5d8d85f database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added separate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-30 09:27:33 -07:00
Adam Langley
87404c9887 crypto/x509: expose arbitary X.509 extensions.
This change allows people who want to parse or set odd X.509 extensions
to do so without having to add support for them all to the package.

I tried to make it so that only a single member: Extensions would be
needed. However, that would mean detecting when the caller had altered
the contents of it so that parsing and marshaling a certificate
wouldn't ignore all changes to the other members. This ended up being
messy, thus the current design where there are two members: one for
reading and another for writing.

As crypto/x509 adds support for more extensions in the future, the raw
extensions will still be in Extensions for older code that expects it
there. Also, future extensions will be overridden by any raw extensions
added to ExtraExtensions by code that was written before support was
added.

R=golang-dev, r
CC=golang-dev, jpsugar
https://golang.org/cl/12056043
2013-08-30 10:14:45 -04:00
Dmitriy Vyukov
79dca0327e libbio, all cmd: consistently use BGETC/BPUTC instead of Bgetc/Bputc
Also introduce BGET2/4, BPUT2/4 as they are widely used.
Slightly improve BGETC/BPUTC implementation.
This gives ~5% CPU time improvement on go install -a -p1 std.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.999s	0m15.841s	0m5.889s
0m22.845s	0m15.808s	0m5.850s
0m22.889s	0m15.832s	0m5.848s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12745047
2013-08-30 15:46:12 +04:00
Nigel Tao
2df3d80037 go/build: fix deps_test for Plan 9's os/user dependencies and to
include the new image/color/palette package.

R=r
CC=golang-dev
https://golang.org/cl/13314044
2013-08-30 17:12:42 +10:00
Nigel Tao
aeb8b45866 image/color/palette: move Plan9Palette and WebSafePalette out of the
image/color package into their own package. They require some non-
trivial init-time code (interface conversions, currently 40KiB of text)
that would otherwise burden any Go program that imported image/color.

R=r
CC=golang-dev
https://golang.org/cl/13256046
2013-08-30 16:03:16 +10:00
Mikio Hara
20692c22d7 net: add addrList
This CL adds a new type addrList that will carry a short list of IP
addresses to dial helper functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13241046
2013-08-30 09:28:26 +09:00
Brad Fitzpatrick
9456adb36b undo CL 10726044 / c9bea548fb6f
Breaks build, and has a race.

««« original CL description
database/sql: add SetMaxOpenConns

Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044

»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13252046
2013-08-29 17:26:00 -07:00
Tad Glines
4572e48483 database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-29 17:20:39 -07:00
Mikio Hara
3c6558ad90 net: add netaddr interface
This CL adds the netaddr interface that will carry a single network
endpoint address or a short list of IP addresses to dial helper
functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13368044
2013-08-30 09:09:45 +09:00
Keith Randall
32b770b2c0 runtime: jump to badmcall instead of calling it.
This replaces the mcall frame with the badmcall frame instead of
leaving the mcall frame on the stack and adding the badmcall frame.
Because mcall is no longer on the stack, traceback will now report what
called mcall, which is what we would like to see in this situation.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13012044
2013-08-29 15:53:34 -07:00
Brad Fitzpatrick
90351506d4 regexp/syntax: optimize EmptyOpContext
Minor. Saw this in a profile at few percent of CPU and was
curious what it was. Improves overall regexp benchmarks
anywhere from 0 to 3%, but they're a pain to run. You need to
run them in isolation for long runs to get stable numbers.

benchmark                  old ns/op    new ns/op    delta
BenchmarkEmptyOpContext          537          473  -11.92%

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13407043
2013-08-29 14:31:10 -07:00
Adam Langley
2fe9a5a3e8 crypto/tls: support AES-GCM.
AES-GCM is the only current TLS ciphersuite that doesn't have
cryptographic weaknesses (RC4), nor major construction issues (CBC mode
ciphers) and has some deployment (i.e. not-CCM).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13249044
2013-08-29 17:18:59 -04:00
Brad Fitzpatrick
c4aa9c5c4e regexp: fix a benchmark case
I noticed that this one benchmark in particular was very
noisy.  Looking into it, I saw that the table was wrong
and inconsistent with the lines above and below.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13393045
2013-08-29 13:55:30 -07:00
Shenghou Ma
716a409b90 net/http: redirect handlers from mux.Handler() shouldn't clear the query string
R=bradfitz, alberto.garcia.hierro, rsc, adg
CC=golang-dev
https://golang.org/cl/7099045
2013-08-29 13:55:12 -07:00
Carl Shapiro
c51152f438 runtime: check bitmap word for allocated bit in markonly
When searching for an allocated bit, flushptrbuf would search
backward in the bitmap word containing the bit of pointer
being looked-up before searching the span.  This extra check
was not replicated in markonly which, instead, after not
finding an allocated bit for a pointer would directly look in
the span.

Using statistics generated from godoc, before this change span
lookups were, on average, more common than word lookups.  It
was common for markonly to consult spans for one third of its
pointer lookups.  With this change in place, what were
previously span lookups are overwhelmingly become by the word
lookups making the total number of span lookups a relatively
small fraction of the whole.

This change also introduces some statistics gathering about
lookups guarded by the CollectStats enum.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/13311043
2013-08-29 13:52:38 -07:00
Keith Randall
ed467db6d8 cmd/cc,runtime: change preprocessor to expand macros inside of
#pragma textflag and #pragma dataflag directives.
Update dataflag directives to use symbols instead of integer constants.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13310043
2013-08-29 12:36:59 -07:00
Rémy Oudompheng
f5f0e40e80 compress/flate: implement Reset method on Writer.
Fixes #6138.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12953048
2013-08-29 21:09:23 +02:00