Commit Graph

14576 Commits

Author SHA1 Message Date
Robert Griesemer
485673188d spec: type assertions and type switches must be valid
The spec didn't preclude invalid type assertions and
type switches, i.e., cases where a concrete type doesn't
implement the interface type in the assertion in the first
place. Both, the gc and gccgo compiler exclude these cases.
This is documenting the status quo.

Also:
- minor clean up of respective examples
- added sentence about default case in select statements

Fixes #4472.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6869050
2012-12-06 09:17:20 -08:00
Rémy Oudompheng
9146ac14ee cmd/gc: do not overflow parser stack on a long chain of else if.
Fixes #2615.

R=dave, minux.ma, iant, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6847078
2012-12-06 08:09:17 +01:00
Brad Fitzpatrick
53d091c5ff net/http: populate ContentLength in HEAD responses
Also fixes a necessary TODO in the process.

Fixes #4126

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6869053
2012-12-05 22:36:23 -08:00
Rémy Oudompheng
755e13877f cmd/8a: support XMM registers.
R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6884046
2012-12-06 07:27:38 +01:00
Rémy Oudompheng
5cb1ed2189 cmd/6c, cmd/8c: add fixjmp step to regopt.
The fixjmp step eliminates redundant chains of JMP
instructions that are produced by the compiler during
code generation.

It is already implemented in gc, and can be adapted to 6c/8c with
the exception that JMPs refer to destination by pc instead of by
pointer. The algorithm is modified to operate on Regs instead of Progs
for this reason. The pcs are already restored later by regopt.

R=goalng-dev, rsc
CC=golang-dev
https://golang.org/cl/6865046
2012-12-06 07:20:03 +01:00
Dave Cheney
e4d2cd9d0a cmd/5g: fix fixedtests/issue4396b.go test failure on arm5
Add missing file that should have been included in CL 6854063 / 5eac1a2d6fc3

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6891049
2012-12-06 16:52:16 +11:00
Russ Cox
9d2b0e86c8 cmd/ld: skip 0-length write in cwrite
The 0-length part is fine, but some callers that write 0 bytes
also pass nil as the data pointer, and the Plan 9 kernel kills the
process with 'invalid address in sys call' in that case.

R=ken2
CC=golang-dev
https://golang.org/cl/6862051
2012-12-06 00:00:20 -05:00
Ian Lance Taylor
b46d56ae72 test: add some tests where go/defer arg starts with parenthesis
R=gri
CC=golang-dev
https://golang.org/cl/6890047
2012-12-05 20:32:12 -08:00
Rick Arnold
5416e6e916 net: document that File reverts connection to blocking mode.
Fixes #2458.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/6869054
2012-12-05 23:31:35 -05:00
David Symonds
82f2b36e74 vet: be less strict about number of arguments when a ... is present.
R=golang-dev
CC=golang-dev
https://golang.org/cl/6883046
2012-12-06 15:17:31 +11:00
Brad Fitzpatrick
4fb78c3a16 net/http: implement CloseNotifier
Fixes #2510

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6867050
2012-12-05 19:25:43 -08:00
Brad Fitzpatrick
a034fc9855 net/http: fix bug parsing http_proxy lacking a protocol
Per the curl man page, the http_proxy configuration can be
of the form:

   [protocol://]<host>[:port]

And we had a test that <ip>:<port> worked, but if
the host began with a letter, url.Parse parsed the hostname
as the scheme instead, confusing ProxyFromEnvironment.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6875060
2012-12-05 19:08:42 -08:00
Ian Lance Taylor
08918ba438 gc: avoid meaningless constant overflow error for inverted slice range
Used to say:

issue4251.go:12: inverted slice range
issue4251.go:12: constant -1 overflows uint64
issue4251.go:16: inverted slice range
issue4251.go:16: constant -1 overflows uint64
issue4251.go:20: inverted slice range
issue4251.go:20: constant -1 overflows uint64

With this patch, only gives the "inverted slice range" errors.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/6871058
2012-12-05 15:46:45 -08:00
Dave Cheney
54e8d504e8 cmd/5g: use MOVB for fixed array nil check
Fixes #4396.

For fixed arrays larger than the unmapped page, agenr would general a nil check by loading the first word of the array. However there is no requirement for the first element of a byte array to be word aligned, so this check causes a trap on ARMv5 hardware (ARMv6 since relaxed that restriction, but it probably still comes at a cost).

Switching the check to MOVB ensures alignment is not an issue. This check is only invoked in a few places in the code where large fixed arrays are embedded into structs, compress/lzw is the biggest offender, and switching to MOVB has no observable performance penalty.

Thanks to Rémy and Daniel Morsing for helping me debug this on IRC last night.

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6854063
2012-12-06 08:01:33 +11:00
Dave Cheney
9fb96991e6 net: fix data races on deadline vars
Fixes #4434.

This proposal replaces the previous CL 6855110. Due to issue 599, 64-bit atomic operations should probably be avoided, so use a sync.Mutex instead.

Benchmark comparisons against 025b9d070a85 on linux/386:

CL 6855110:

benchmark                        old ns/op    new ns/op    delta
BenchmarkTCPOneShot                 710024       727409   +2.45%
BenchmarkTCPOneShotTimeout          758178       768620   +1.38%
BenchmarkTCPPersistent              223464       228058   +2.06%
BenchmarkTCPPersistentTimeout       234494       242600   +3.46%

This proposal:

benchmark                        old ns/op    new ns/op    delta
BenchmarkTCPOneShot                 710024       718492   +1.19%
BenchmarkTCPOneShotTimeout          758178       748783   -1.24%
BenchmarkTCPPersistent              223464       227628   +1.86%
BenchmarkTCPPersistentTimeout       234494       238321   +1.63%

R=rsc, dvyukov, mikioh.mikioh, alex.brainman, bradfitz
CC=golang-dev, remyoudompheng
https://golang.org/cl/6866050
2012-12-05 15:59:01 +11:00
Alex Brainman
4855c1c145 net: change windows netFD finalizer to behave similar to unix
R=dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6873046
2012-12-05 15:26:18 +11:00
Brad Fitzpatrick
a7c57b05e9 net/http: clarify DefaultTransport docs
Fixes #4281

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6872053
2012-12-04 20:14:58 -08:00
Alex Brainman
87b315a78f net: add missing close socket code
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6868067
2012-12-05 15:13:03 +11:00
Ian Lance Taylor
feb95a802e test: tweak bug273.go to not have constant len < cap when calling make
The current spec says that when calling make, if both len and
cap are constant, it is an error if len > cap.  The gc
compiler does not yet implement that, but when it does this
will need to change.  Changing it now for the benefit of
gccgo.

R=gri
CC=golang-dev
https://golang.org/cl/6867064
2012-12-04 16:51:51 -08:00
Frithjof Schulze
cfc0a59d6e container/heap: Simplify the example.
Using append simplifies the code and makes it work if
the initial capacity of the slice is smaller than the
number of items pushed.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6869060
2012-12-04 14:11:33 -08:00
Robert Griesemer
2cb715a8b3 A+C: adding Frithjof Schulze (individual CLA)
R=bradfitz
CC=golang-dev
https://golang.org/cl/6871060
2012-12-04 14:11:22 -08:00
Robert Griesemer
458632a21a spec: BuiltinCall syntax must permit "..." for append
Also: fix an incorrect link.

Fixes #4479.
Fixes #4456.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6868062
2012-12-04 13:09:02 -08:00
Ian Lance Taylor
76937156ae test: add test for invalid nil == nil
R=gri
CC=golang-dev
https://golang.org/cl/6868059
2012-12-04 11:30:46 -08:00
Brad Fitzpatrick
add1bed735 net/http: clarify that Request.Host may contain a port number
Fixes #4172

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6872055
2012-12-04 07:09:01 -08:00
Mikio Hara
23ca24018a doc: clear execute bit
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6871057
2012-12-04 20:37:19 +09:00
Oling Cat
c2f9be10d4 doc/articles/godoc_documenting_go_code: fix some format issues.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6874056
2012-12-04 17:40:38 +11:00
Alex Brainman
0420eb3b65 net: report Accept error during TestVariousDeadlines1Proc test
R=golang-dev
CC=golang-dev
https://golang.org/cl/6868057
2012-12-04 17:00:19 +11:00
Ian Lance Taylor
dfe2979801 test: add test for unused calls to builtin functions
R=gri
CC=golang-dev
https://golang.org/cl/6871054
2012-12-03 18:49:47 -08:00
Ian Lance Taylor
8990dc8ca0 test: add test for issue 4468 (go/defer expr may not be parenthesized)
R=gri
CC=golang-dev
https://golang.org/cl/6870053
2012-12-03 18:49:14 -08:00
Andrew Gerrand
936a6d2685 A+C: Egon Elbre (individual CLA)
R=golang-dev, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6863055
2012-12-04 10:14:21 +11:00
Robert Griesemer
cc3f21cefe spec: channel operations are restricted by the channel direction
Also:
- 'for' statements with a range clause do not accept send-only
   channels
- '_, _ = range ch' is not equivalent to "_ = range ch" if ch
   is a channel (rewriting the latter to the former leads to
   an invalid range clause).

These clarifications document the status quo.

R=rsc, r, iant, ken
CC=golang-dev
https://golang.org/cl/6874053
2012-12-03 14:23:41 -08:00
Dave Cheney
3167c12eb2 cmd/dist: support building on debian/kFreeBSD
The debian/kFreeBSD project uses the FreeBSD kernel and the debian userspace. From our point of view, this is freebsd not linux as GOOS talks about the kernel syscall interface, not the userspace (although cgo alters that). As debian/kFreeBSD is experimental at this time, I do not think it is worth the effort of duplicating all the freebsd specific code so this is proposal represents a reasonable workaround.

Currently cgo is not supported, make.bash will detect this and disable cgo automatically during the build.

dfc@debian:~/go/src$ uname -a
GNU/kFreeBSD debian 8.1-1-686 #0 Sat Jul 21 17:02:04 UTC 2012 i686 i386 Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz GNU/kFreeBSD
dfc@debian:~/go/src$ ../bin/go version
go version devel +d05272f402ec Sat Dec 01 15:15:14 2012 -0800

Tested with GOOS=freebsd GOARCH=386

R=golang-dev
CC=golang-dev
https://golang.org/cl/6868046
2012-12-04 08:27:30 +11:00
Rémy Oudompheng
b1c4a8efa9 bytes: avoid duplicate malloc/copy in Buffer.ReadString
Twice faster and twice less garbage.

R=golang-dev, dave, daniel.morsing, bradfitz
CC=golang-dev
https://golang.org/cl/6849128
2012-12-03 14:04:18 +01:00
Rémy Oudompheng
bcea0dd1d0 cmd/gc: fix inlining internal error with T.Method calls.
The compiler was confused when inlining a T.Method(f()) call
where f returns multiple values: support for this was marked
as TODO.

Variadic calls are not supported but are not inlined either.
Add a test preventively for that case.

Fixes #4167.

R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6871043
2012-12-03 13:39:40 +01:00
Mikio Hara
19d793a327 net: simplify ListenTCP
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6875044
2012-12-03 20:00:50 +09:00
Luit van Drongelen
882953f62c encoding/gob: Fix typo in doc.go
Exactly how I find minute details like this is beyond me.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6842125
2012-12-01 15:15:14 -08:00
Johan Euphrosine
d7b0f2a524 math/rand: remove noop iteration in Perm
The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.

fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6845121
2012-12-01 14:11:46 -08:00
Brad Fitzpatrick
444b7b53e0 crypto/tls: fix loading keys labeled just "PRIVATE KEY"
Worked in Go 1, broken in f440e65f93fe.

Fixes #4477

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6865043
2012-12-01 11:02:08 -08:00
Rémy Oudompheng
b18a7c7cae net: remove unnecessary Close contention.
Contention profile in BenchmarkTCPOneShot (Core 2 Quad):

Before
Total: 80.285 seconds
44.743  55.7%  55.7%   44.743  55.7% runtime.chanrecv1
31.995  39.9%  95.6%   31.995  39.9% sync.(*Mutex).Lock
 3.547   4.4% 100.0%    3.547   4.4% runtime.chansend1

After
Total: 48.341 seconds
45.810  94.8%  94.8%   45.810  94.8% runtime.chanrecv1
 2.530   5.2% 100.0%    2.530   5.2% runtime.chansend1
 0.001   0.0% 100.0%    0.001   0.0% sync.(*Mutex).Lock

R=golang-dev, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6845119
2012-12-01 09:26:07 +01:00
Mikio Hara
e3e885bb48 net: allow "" as a hint wildcard to Resolve{IP,UDP,TCP}Addr
Also fixes comments on ResolveIPAddr.

Fixes #4476.

R=bradfitz, golang-dev
CC=golang-dev
https://golang.org/cl/6854129
2012-12-01 14:49:54 +09:00
Ian Lance Taylor
0304a48595 test: add a test that caused gccgo to crash
R=golang-dev
CC=golang-dev
https://golang.org/cl/6849129
2012-11-30 14:14:51 -08:00
Anthony Martin
253ed02918 net: update docs and sync API for Plan 9
R=golang-dev, dave, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6674043
2012-11-30 11:41:50 -08:00
Shenghou Ma
279199ebcc cmd/godoc: fix godoc net/http on windows
`godoc net/http` used to complain "/target contains more than one package: http, main"

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6852100
2012-12-01 00:42:50 +08:00
Shenghou Ma
9e30b708a1 all: set GOMAXPROCS to 1 when counting mallocs
also fix an annoying test that relies on $GOROOT be set.
Fixes #3690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6844086
2012-12-01 00:38:01 +08:00
Dave Cheney
5b425cc3ab undo CL 6855110 / 869253ef7009
64bit atomics are broken on 32bit systems. This is issue 599.

linux/arm builders all broke with this change, I am concerned that the other 32bit builders are silently impacted.

««« original CL description
net: fix data races on deadline vars

Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
»»»

R=rsc, mikioh.mikioh, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6852105
2012-11-30 20:02:30 +11:00
Dave Cheney
be0d84e335 net: fix data races on deadline vars
Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
2012-11-30 18:26:51 +11:00
Dmitriy Vyukov
0ce96f9ef4 runtime: better stack traces in race reports
When a race happens inside of runtime (chan, slice, etc),
currently reports contain only user file:line.
If the line contains a complex expression,
it's difficult to figure out where the race exactly.
This change adds one more top frame with exact
runtime function (e.g. runtime.chansend, runtime.mapaccess).

R=golang-dev
CC=golang-dev
https://golang.org/cl/6851125
2012-11-30 10:29:41 +04:00
Dmitriy Vyukov
c3c107f67c cmd/gc: racewalk: collect stack traces in sync and sync/atomic
W/o this change stack traces do not show from where sync.Once()
or atomic.XXX was called.
This change add funcenter/exit instrumentation to sync/sync.atomic
packages.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6854112
2012-11-30 10:27:43 +04:00
Alex Brainman
902af974cb os: check only user attributes in TestStatDirModeExec
Some have their system setup in a particular way,
see http://golang.org/issue/4444#c3.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6851129
2012-11-30 16:10:45 +11:00
Brad Fitzpatrick
9c2f410206 net/http: don't send chunked encoding on 204 responses
RFC 2616: "The 204 response MUST NOT include a message-body,
and thus is always terminated by the first empty line after
the header fields."

Previously we'd trigger chunked encoding by default on
responses, and then when finishing the request we'd write the
chunk trailers, which counted as a message-body.

Fixes #4454

R=golang-dev
CC=golang-dev
https://golang.org/cl/6782139
2012-11-29 18:00:51 -08:00