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

22854 Commits

Author SHA1 Message Date
Shenghou Ma
a175fa3bc3 cmd/asm/internal/asm: parse arm64 register pairs for LDP/STP
Add test, and while we're at here, also add a test for ARM.

Fixes #10343.

Change-Id: Ic914df8233d4f1f495e2cc0743fbd37b7671bc91
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8472
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-08 05:22:41 +00:00
Robert Griesemer
35599e281b go/types: enable disabled test
Change-Id: I58de76c49de6e43befb30b2bf677934e7952b5ab
Reviewed-on: https://go-review.googlesource.com/8610
Reviewed-by: Rob Pike <r@golang.org>
2015-04-08 04:57:16 +00:00
Robert Griesemer
b2a1fb74f4 cmd/api: update api checker to use go/types from std repo
The old code checked out a specific version of go/types from the
x/tools repo. With go/types being part of the std repo, this is
not necessary anymore.

Also, for the same reason, the api tool is now built like any
other regular command. There's no need to build it for each run.
Removed the respective +build tags.

Change-Id: I5088e4867223d676957084c24651ec05452ac495
Reviewed-on: https://go-review.googlesource.com/8564
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-08 04:09:34 +00:00
Robert Griesemer
5a97747c40 go/types: skip failing tests (fix build)
Temporary work-around so we can start using go/types in the std repo.

Change-Id: I661465af791171b01cd23abf34dcb7eea6e26173
Reviewed-on: https://go-review.googlesource.com/8594
Reviewed-by: Rob Pike <r@golang.org>
2015-04-08 03:45:49 +00:00
Robert Griesemer
254964074f go/types, go/exact: "vendor" go/types into std repo
This is a first step towards moving go/types from the tools
repo into the std repo. The files were brought over via the
added src/go/types.bash script for reproducability. The
script can be removed once all dependencies on go/types
have moved to the std repo go/types.

The script moved packages as follows:

- x/tools/go/types => go/types (type-checker)
- x/tools/go/exact => go/exact (constants)
- x/tools/go/gcimporter => go/types/internal/gcimporter

The gcimporter is needed to be able to run tests. go/types
should probably have some factory function to provide an
appropriate importer.

Some of the go/types tests fail for a handful of platforms
(windows and nacl). In order to keep this change "clean"
from manual changes, the next change will disable those
tests for now so we can move forward.

Change-Id: I448d8f7faa39ad2e04811911b699f7682627c224
Reviewed-on: https://go-review.googlesource.com/8530
Reviewed-by: Rob Pike <r@golang.org>
2015-04-08 03:40:04 +00:00
Nigel Tao
0def13ac3f image/color: have CMYK.RGBA work in 16-bit color, per the Color interface.
Change-Id: I3621527c924a43724032f80a072505c60d929ab3
Reviewed-on: https://go-review.googlesource.com/8180
Reviewed-by: Rob Pike <r@golang.org>
2015-04-08 03:39:11 +00:00
Alex Brainman
32e75bace0 all: fix race when allocating buffer for some windows syscalls
Fixes #9753

Change-Id: I6c641ed7ef4f687a108e7d937ab4b9c24d5baf5d
Reviewed-on: https://go-review.googlesource.com/4940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-08 02:06:31 +00:00
Robert Griesemer
2f16ddc580 doc: update go1.5.txt (gc constant arithmetic now based on math/big)
Change-Id: Iff943d15e83e7db1f3c77f509a60e00ee2041d69
Reviewed-on: https://go-review.googlesource.com/8592
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-07 23:22:12 +00:00
Robert Griesemer
bb418a59f8 cmd/internal/gc: use approx. float formatting in error messages
For very out-of-range floating-point constants (1e100000000),
precise formatting of the offending value for error messages
is not needed and potentially extremely slow.

This change resurrects an adjusted variant of the original code
which uses float64 formatting in the common case (in-range values),
and a fast manual approximation for out-of-range values.

Change-Id: I2f6e53040929b8bf924dac4bb27c4d811ede48e2
Reviewed-on: https://go-review.googlesource.com/8470
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-07 23:01:01 +00:00
Michael Hudson-Doyle
b643684feb cmd/go: re-run mkdoc.sh
Adds $DOLLAR to doc.go

Change-Id: Ia0ccdd9b5292010297ae95debab4acf50d3c4d9c
Reviewed-on: https://go-review.googlesource.com/8600
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 22:44:27 +00:00
ALTree
e21154fe31 math/big: fix Exp when exponent is 1
Fixed bug that caused Exp(x, y, m) ( i.e. x**y (mod m) ) to return x
instead of x (mod m) when y == 1. See issue page on github for more
details.

Added test case

Fixes #9826

Change-Id: Ibabb58275a20c4231c9474199b7f1c10e54241ce
Reviewed-on: https://go-review.googlesource.com/8409
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-07 21:04:09 +00:00
Rob Pike
0c8fe3463f encoding/gob: more cleanups handling slice length
Fix the other places the slice length was being believed, and refactor
the code to use a single function to unify the check.

Fixes #10273.

Change-Id: Ia62b25203fbe87c95d71a70ebc1db8d202eaa4a4
Reviewed-on: https://go-review.googlesource.com/8511
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07 17:48:03 +00:00
Dave Cheney
d3252a2db9 cmd/internal/gc: fix race build (again)
Add OGETG to the list of ignored operations.

We don't instrument the runtime package, but calls to runtime.getg
can appear in other packages, for example, after inlining
runtime.LockOSThread.

Change-Id: I8d6e91f1f3c8fd1302b596bdead42d588c059911
Reviewed-on: https://go-review.googlesource.com/8553
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-04-07 16:38:57 +00:00
Dave Cheney
d6b4069852 cmd/internal/gc: fix race build
Add special case for OGETG which should never be instrumented.

Change-Id: I7d082abb8608537f82b03362b687baf2a1d809dc
Reviewed-on: https://go-review.googlesource.com/8551
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-04-07 15:44:34 +00:00
Russ Cox
92c826b1b2 cmd/internal/gc: inline runtime.getg
This more closely restores what the old C runtime did.
(In C, g was an 'extern register' with the same effective
implementation as in this CL.)

On a late 2012 MacBookPro10,2, best of 5 old vs best of 5 new:

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              4981312777     4463426605     -10.40%
BenchmarkFannkuch11                3046495712     3006819428     -1.30%
BenchmarkFmtFprintfEmpty           89.3           79.8           -10.64%
BenchmarkFmtFprintfString          284            262            -7.75%
BenchmarkFmtFprintfInt             282            262            -7.09%
BenchmarkFmtFprintfIntInt          480            448            -6.67%
BenchmarkFmtFprintfPrefixedInt     382            358            -6.28%
BenchmarkFmtFprintfFloat           529            486            -8.13%
BenchmarkFmtManyArgs               1849           1773           -4.11%
BenchmarkGobDecode                 12835963       11794385       -8.11%
BenchmarkGobEncode                 10527170       10288422       -2.27%
BenchmarkGzip                      436109569      438422516      +0.53%
BenchmarkGunzip                    110121663      109843648      -0.25%
BenchmarkHTTPClientServer          81930          85446          +4.29%
BenchmarkJSONEncode                24638574       24280603       -1.45%
BenchmarkJSONDecode                93022423       85753546       -7.81%
BenchmarkMandelbrot200             4703899        4735407        +0.67%
BenchmarkGoParse                   5319853        5086843        -4.38%
BenchmarkRegexpMatchEasy0_32       151            151            +0.00%
BenchmarkRegexpMatchEasy0_1K       452            453            +0.22%
BenchmarkRegexpMatchEasy1_32       131            132            +0.76%
BenchmarkRegexpMatchEasy1_1K       761            722            -5.12%
BenchmarkRegexpMatchMedium_32      228            224            -1.75%
BenchmarkRegexpMatchMedium_1K      63751          64296          +0.85%
BenchmarkRegexpMatchHard_32        3188           3238           +1.57%
BenchmarkRegexpMatchHard_1K        95396          96756          +1.43%
BenchmarkRevcomp                   661587262      687107364      +3.86%
BenchmarkTemplate                  108312598      104008540      -3.97%
BenchmarkTimeParse                 453            459            +1.32%
BenchmarkTimeFormat                475            441            -7.16%

The garbage benchmark from the benchmarks subrepo gets 2.6% faster as well.

Change-Id: I320aeda332db81012688b26ffab23f6581c59cfa
Reviewed-on: https://go-review.googlesource.com/8460
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-04-07 14:26:47 +00:00
Mikio Hara
8e95654ac8 net/url: allow Parse, ParseRequestURI to parse ipv6 zone identifiers in URIs
Using IPv6 link-local addresses to make connections between on-link
nodes is useful for small distributed applications but it requires zone
identifiers to distinguish a correct IP link. It's the same for
transports using URI for destination discovery such as HTTP, WebSocket.

This change allows Parse, ParseRequestURI functions and String method of
URL to parse/return a literal IPv6 address followed by a zone identifier
within a URI as described in RFC 6874.

Fixes #6530.

Change-Id: I2936ea65c1446994770cf2ee2c28a1c73faaa0ca
Reviewed-on: https://go-review.googlesource.com/2431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07 14:24:23 +00:00
kortschak
aaa092cfd7 encoding/gob: make method doc string match method name
Change-Id: I6859bd9c9dba30fc5eeb9bbc1de90af67984944c
Reviewed-on: https://go-review.googlesource.com/8526
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07 13:35:41 +00:00
Mikio Hara
5a83f06c21 net: deflake dual IP stack tests
This change deflakes TestDialerDualStackFDLeak, TestDialerDualStack,
TestResolve{TCP,UDP,IP}Addr by removing external dependencies.

Fixes #8764.

Change-Id: I5cca0a93776cf05652e0e6a4a4ff4af392ccb885
Reviewed-on: https://go-review.googlesource.com/8485
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 13:32:28 +00:00
Alex Brainman
f8bcebe47c Revert "misc/cgo/testso: add test for fixed issue 4339"
This reverts commit 9fa9f966e9.

The change has broken darwin and netbsd builders. It needs to be tested properly.

Change-Id: Id9e2d30caa8764c362c9f33890015dfc1aae0dab
Reviewed-on: https://go-review.googlesource.com/8527
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-04-07 11:50:28 +00:00
Brad Fitzpatrick
827a8a56c6 doc: add mime/quotedprintable to go1.5.txt
Change-Id: Iace8941c947253b1141f4194c5d2010c420ec220
Reviewed-on: https://go-review.googlesource.com/8540
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07 10:00:01 +00:00
Jiong Du
cce127a75f database/sql: close connection if db.numOpen > db.maxOpen
Bug Description:
When reduce db.maxOpen via db.SetMaxOpenConns, the unnecssary
connections won't been released until all other connections are free.

Fixes #9453

Change-Id: I9afb2e4b184139b31029ae53d7f5fd1fdb8d8d7e
Reviewed-on: https://go-review.googlesource.com/2200
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07 09:27:26 +00:00
Alex Brainman
b40421f32c cmd/dist: add misc/cgo/test with -linkmode=auto
Change-Id: I5939524f75f8fbbd67bd54b7c9e4b8c162337e9d
Reviewed-on: https://go-review.googlesource.com/8525
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-07 07:07:12 +00:00
Alex Brainman
9fa9f966e9 misc/cgo/testso: add test for fixed issue 4339
Update #4339.

Change-Id: Ic1a7535562b8b824ba166777725f7ba5b9623d77
Reviewed-on: https://go-review.googlesource.com/8523
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-07 06:25:33 +00:00
Mikio Hara
f077505d9a net: fix tester goroutine leakage in tests
This change tries to stop various tester goroutines at the end of each
scope for avoiding interference between test cases including benchmarks.
Not yet finished completely but enough to land upcoming changes to Dial
functions. The rest will be fixed later.

Change-Id: Ic38b8681a3a2ddbcd69ba3696f24a61d418a0346
Reviewed-on: https://go-review.googlesource.com/8398
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 03:26:03 +00:00
Josh Bleecher Snyder
75883bae28 cmd/internal/gc: convert yet more Node fields to bools
Convert Embedded, Method, and Colas to bools.

I believe that this is the last of the Node fields
that can be trivially converted to bools.

No functional changes. Passes toolstash -cmp.

Change-Id: I81962ee47866596341fc60d24d6959c20cd7fc1c
Reviewed-on: https://go-review.googlesource.com/8440
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-07 03:10:30 +00:00
Mikio Hara
be4c38ed34 net: move testHookSetKeepAlive into hook.go
Change-Id: I1f2d4e3b0351a7a47c3a6073833a17dbc0c7b05c
Reviewed-on: https://go-review.googlesource.com/8520
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 03:02:10 +00:00
Mikio Hara
35b3db253c net: add lookup IP hook for testing
This change adds testHookLookIP to enable to inject DNS name to IP
address mappings for Happ{y,yish,ier} Eyeballs dial testing.

Change-Id: I8ac04a594e1e2bd77909528df0552889914a7790
Reviewed-on: https://go-review.googlesource.com/8399
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 02:34:42 +00:00
Michael Hudson-Doyle
bec4481dd3 cmd/internal/ld: remove extraneous parentheses
Ian complained about these in a review and then submitted the change
before I could fix them.

Change-Id: I23d890db2f3648ed1003ed3d13e7247435b913e5
Reviewed-on: https://go-review.googlesource.com/8480
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 01:40:40 +00:00
Josh Bleecher Snyder
5451fff475 doc/progs: rewrite test driver in Go
The tests in doc/progs appear to have been originally written
for use with the old test driver. At some later point,
they acquired their own test driver.
Both ran tests in serial.

This CL rewrites the current test driver in Go,
runs tests concurrently, and cleans up
historical artifacts from the old drivers.

The primary motivation is to speed up all.bash.
On my laptop, using tip, this CL reduces doc/progs test
wall time from 26s to 7s. The savings will remain
even when the compiler gets faster. Using Go 1.4,
this CL reduces test wall time from 15s to 4s.

Change-Id: Iae945a8490222beee76e8a2118a0d7956092f543
Reviewed-on: https://go-review.googlesource.com/8410
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-07 00:41:59 +00:00
Michael Hudson-Doyle
ad49c7bb62 cmd/internal/obj: remove dead fields and code
A quick pass through link.go, mostly removing fields that are not
used on the "creating a single object file" side of the fence.

Change-Id: I35ba41378c2c418f7df2f2f88dce65bc64a1a45d
Reviewed-on: https://go-review.googlesource.com/7672
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-07 00:27:59 +00:00
Matthew Dempsky
e7d9f81645 cmd/internal/gc, cmd/yacc: implement "expecting" syntax error messages
Bison includes suggestions about what tokens are expected in the
current state when there's only four or fewer of them.  For example:

  syntax error: unexpected literal 2.01, expecting semicolon or newline or }

This CL adds the same functionality to cmd/yacc, which fully restores
the previous error message behavior from Go 1.4.

Updates #9968.

Change-Id: I2c1a1677c6d829a829d812c05e8813aa8829d09c
Reviewed-on: https://go-review.googlesource.com/8494
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-07 00:18:02 +00:00
Josh Bleecher Snyder
ee54d57101 doc/go1.5.txt: add Reader.Size to bytes and strings
Change-Id: Idd42e0f5c6ed55be2e153ac83022439e5272c1a7
Reviewed-on: https://go-review.googlesource.com/8444
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-06 23:21:50 +00:00
David Crawshaw
ede863c673 runtime: add _rt0_arm_android_lib
At the moment this function does nothing, runtime initialization is
still done in android.c:init_go_runtime.

Fixes #10358

Change-Id: I1d762383ba61efcbcf0bbc7c77895f5c1dbf8968
Reviewed-on: https://go-review.googlesource.com/8510
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 22:54:52 +00:00
Rob Pike
e449b5705b encoding/gob: change panic into error for corrupt input
decBuffer.Drop is called using data provided by the user, don't
panic if it's bogus.

Fixes #10272.

Change-Id: I913ae9c3c45cef509f2b8eb02d1efa87fbd52afa
Reviewed-on: https://go-review.googlesource.com/8496
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-06 21:40:03 +00:00
Austin Clements
8c3fc088fb runtime: report marked heap size in gctrace
When the gctrace GODEBUG option is enabled, it will now report three
heap sizes: the heap size at the beginning of the GC cycle, the heap
size at the end of the GC cycle before sweeping, and marked heap size,
which is the amount of heap that will be retained until the next GC
cycle.

Change-Id: Ie13f8a6d5c609bc9cc47c7555960ab55b37b5f1c
Reviewed-on: https://go-review.googlesource.com/8430
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-06 21:28:23 +00:00
Austin Clements
6d12b1780e runtime: make next_gc be heap size to trigger GC at
In the STW collector, next_gc was both the heap size to trigger GC at
as well as the goal heap size.

Early in the concurrent collector's development, next_gc was the goal
heap size, but was also used as the heap size to trigger GC at. This
meant we always overshot the goal because of allocation during
concurrent GC.

Currently, next_gc is still the goal heap size, but we trigger
concurrent GC at 7/8*GOGC heap growth. This complicates
shouldtriggergc, but was necessary because of the incremental
maintenance of next_gc.

Now we simply compute next_gc for the next cycle during mark
termination. Hence, it's now easy to take the simpler route and
redefine next_gc as the heap size at which the next GC triggers. We
can directly compute this with the 7/8 backoff during mark termination
and shouldtriggergc can simply test if the live heap size has grown
over the next_gc trigger.

This will also simplify later changes once we start setting next_gc in
more sophisticated ways.

Change-Id: I872be4ae06b4f7a0d7f7967360a054bd36b90eea
Reviewed-on: https://go-review.googlesource.com/8420
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-06 21:28:18 +00:00
Austin Clements
d7e0ad4b82 runtime: introduce heap_live; replace use of heap_alloc in GC
Currently there are two main consumers of memstats.heap_alloc:
updatememstats (aka ReadMemStats) and shouldtriggergc.

updatememstats recomputes heap_alloc from the ground up, so we don't
need to keep heap_alloc up to date for it. shouldtriggergc wants to
know how many bytes were marked by the previous GC plus how many bytes
have been allocated since then, but this *isn't* what heap_alloc
tracks. heap_alloc also includes objects that are not marked and
haven't yet been swept.

Introduce a new memstat called heap_live that actually tracks what
shouldtriggergc wants to know and stop keeping heap_alloc up to date.

Unlike heap_alloc, heap_live follows a simple sawtooth that drops
during each mark termination and increases monotonically between GCs.
heap_alloc, on the other hand, has much more complicated behavior: it
may drop during sweep termination, slowly decreases from background
sweeping between GCs, is roughly unaffected by allocation as long as
there are unswept spans (because we sweep and allocate at the same
rate), and may go up after background sweeping is done depending on
the GC trigger.

heap_live simplifies computing next_gc and using it to figure out when
to trigger garbage collection. Currently, we guess next_gc at the end
of a cycle and update it as we sweep and get a better idea of how much
heap was marked. Now, since we're directly tracking how much heap is
marked, we can directly compute next_gc.

This also corrects bugs that could cause us to trigger GC early.
Currently, in any case where sweep termination actually finds spans to
sweep, heap_alloc is an overestimation of live heap, so we'll trigger
GC too early. heap_live, on the other hand, is unaffected by sweeping.

Change-Id: I1f96807b6ed60d4156e8173a8e68745ffc742388
Reviewed-on: https://go-review.googlesource.com/8389
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-06 21:28:13 +00:00
Austin Clements
50a66562a0 runtime: track heap bytes marked by GC
This tracks the number of heap bytes marked by a GC cycle. We'll use
this information to precisely trigger the next GC cycle.

Currently this aggregates the work counter in gcWork and dispose
atomically aggregates this into a global work counter. dispose happens
relatively infrequently, so the contention on the global counter
should be low. If this turns out to be an issue, we can reduce the
number of disposes, and if it's still a problem, we can switch to
per-P counters.

Change-Id: I1bc377cb2e802ef61c2968602b63146d52e7f5db
Reviewed-on: https://go-review.googlesource.com/8388
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-06 21:28:07 +00:00
Rob Pike
dfc9e264d1 cmd/asm/internal/asm: fix comment in ppc64.go
It referred to the wrong architecture.

Fixes #10355.

Change-Id: I5b9d31c9f04f3106b93f94fa68c848b2518b128e
Reviewed-on: https://go-review.googlesource.com/8495
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-04-06 18:23:13 +00:00
Robert Griesemer
da5ebecc6e cmd/internal/gc/big: update vendored version of math/big
This fixes the formerly extremely slow conversion of floating-point
constants with large exponents (e.g., "const c = 1e1000000000" could
stall the machine).

Change-Id: I36e02158e3334d32b18743ec0c259fec77baa74f
Reviewed-on: https://go-review.googlesource.com/8466
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-06 16:35:39 +00:00
Igor Dolzhikov
debe12cfcf net/http, math/big, cmd/internal/gc/big: replaced errors.New(fmt.Sprintf(...)) in favour fmt.Errorf()
Change-Id: I38fc0ab84a374cb9be0234e40665d7cea0e76fc1
Reviewed-on: https://go-review.googlesource.com/8402
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-06 15:40:34 +00:00
Brad Fitzpatrick
c264c87335 bytes, strings: add Reader.Size methods
As noted on recently on golang-nuts, there's currently no way to know
the total size of a strings.Reader or bytes.Reader when using ReadAt
on them. Most callers resort to wrapping it in an io.SectionReader to
retain that information.

The SizeReaderAt abstraction (an io.ReaderAt with a Size() int64
method) has proven useful as a way of expressing a concurrency-safe
read-only number of bytes.

As one example, see http://talks.golang.org/2013/oscon-dl.slide#49 and
the rest of that presentation for its use in dl.google.com.

SizeReaderAt is also used in the open source google-api-go-client, and
within Google's internal codebase, where it exists in a public package
created in 2013 with the package comment: "These may migrate to the
standard library after we have enough experience with their feel."

I'm still as happy with the SizeReaderAt abstraction and its
composabilty as I was in 2013, so I'd like to make these two Readers
also be SizeReaderAts.

Fixes #9667

Change-Id: Ie6f145ada419dd116280472d8c029f046d5edf70
Reviewed-on: https://go-review.googlesource.com/3199
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-06 08:53:47 +00:00
Paul Marks
c50a8416c8 net: dialChannel should not treat an expired deadline as noDeadline.
Now, only a zero deadline is interpreted as noDeadline.  Any other time
in the past yields an immediate timeout.

TestConnectDeadlineInThePast already covers this case.  We just need to
un-skip it for plan9, where dialChannel is used.

Change-Id: I995fd1a632c31f8004dac772c3d7c43a2a5853b0
Reviewed-on: https://go-review.googlesource.com/8435
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-04-06 01:03:31 +00:00
Josh Bleecher Snyder
5242d2cef4 bytes: fix comment
The the has been deleted.

Change-Id: I4290105435d4f1fd10c7014f913a3147ddeb3c2b
Reviewed-on: https://go-review.googlesource.com/8469
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-04 02:00:51 +00:00
Matthew Dempsky
2381077786 cmd/yacc: fix default action
Previously, a production rule like

	A: B C D

would cause yacc to check that A and B have the same declared types,
but then it would generate an implicit action of { $$ = $3 } (i.e.,
copy the value from D), even if A and D have different types.

Fixes #10192.

Change-Id: I51cfd7baa0011557141dca33b7af1d892cc6f49e
Reviewed-on: https://go-review.googlesource.com/7780
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-04 00:10:16 +00:00
Adam Langley
7b850ec691 crypto/tls: tidy up a little and add test.
This is a follow on to 28f33b4a which removes one of the boolean flags
and adds a test for the key-driven cipher selection.

Change-Id: If2a400de807eb19110352912a9f467491cc8986c
Reviewed-on: https://go-review.googlesource.com/8428
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Jacob Haven <jacob@cloudflare.com>
2015-04-04 00:06:21 +00:00
Michael Hudson-Doyle
8e9c6431f0 cmd/internal/ld: maintain Ctxt.Etextp when removing dead code
I wrote some code that added a function in gentext() by sticking it
after Ctxt.Etextp and was very confused when this wasn't written out
sometimes. It turned out that Etextp was not updated by deadcode() so
if the last function is not reachable, my new function was never
seen. This changes deadcode() to update Etextp to the last reachable
funtion.

Change-Id: Ib6a3e7c67ccfb8a15826ce9e0ef046732b5e25d2
Reviewed-on: https://go-review.googlesource.com/8233
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-04 00:06:19 +00:00
Robert Griesemer
09b3bf42c7 math/big: compute 10**exp efficiently when converting Floats
Change-Id: Ic2d9fdae43d18255c198ae62376212bdc89b75da
Reviewed-on: https://go-review.googlesource.com/8464
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-04 00:03:16 +00:00
Rob Pike
ea2c94e81e doc/go1.5.txt: bytes.Buffer.Cap, template.Option
Change-Id: I8e2177ffdb4b75e7f3687109311306fc02fcc8e3
Reviewed-on: https://go-review.googlesource.com/8468
Reviewed-by: Rob Pike <r@golang.org>
2015-04-03 23:53:12 +00:00
Cristian Staretu
90554be030 bytes: export Cap method for buffer
Obtaining the actual size of the underlying storage of the buffer can
be very useful in various scenarios. Long running programs which write
and read large amounts of data to buffers might have to recycle
buffers in order to avoid holding onto potentially huge buffers.

For example, a piece of code which buffers a lot of data in a buffer
might need to release the big buffer and start again with a smaller
buffer after it finished processing the huge amount of data.

In cases where pools of bytes.Buffer are used, being able to check the
size of the allocated data can be very useful.

Instead of forking bytes.Buffer or writing new code, we can export the
Cap() method.

Change-Id: I79d4f0a3cff53b9419d82c8122964761e9e38566
Reviewed-on: https://go-review.googlesource.com/8342
Reviewed-by: Rob Pike <r@golang.org>
2015-04-03 23:50:02 +00:00