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

17804 Commits

Author SHA1 Message Date
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
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
Shenghou Ma
764c751ae5 math, cmd/internal/gc, cmd/7g: enable SQRT inlining, add assembly implementation
benchmark                 old ns/op     new ns/op     delta
BenchmarkSqrt             474           16.5          -96.52%
BenchmarkSqrtIndirect     476           38.1          -92.00%
BenchmarkSqrtGo           484           483           -0.21%

Change-Id: I5ad0132feda0d3275a884523b9e79d83db4fc726
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8465
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-03 23:48:00 +00:00
Shenghou Ma
8b2503d5f5 cmd/internal/gc: fix race build
Change-Id: Iab3f5538c135a21e071789e2c7b445b0a04a2ad0
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8461
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 23:45:37 +00:00
Rob Pike
4e5ac45ec5 text/template: provide a mechanism for options
Add one option, which is the motivating example, a way to control
what happens when a map is indexed with a key that is not in the map.
Rather than do something specific for that case, we provide a simple
general option mechanism to avoid adding API if something else
comes up. This general approach also makes it easy for html/template
to track (and adapt, should that become important).

New method: Option(option string...). The option strings are key=value
pairs or just simple strings (no =).

New option:

 missingkey: Control the behavior during execution if a map is
 indexed with a key that is not present in the map.
	"missingkey=default" or "missingkey=invalid"
		The default behavior: Do nothing and continue execution.
		If printed, the result of the index operation is the string
		"<no value>".
	"missingkey=zero"
		The operation returns the zero value for the map type's element.
	"missingkey=error"
		Execution stops immediately with an error.

Fixes #6288.

Change-Id: Id811e2b99dc05aff324d517faac113ef3c25293a
Reviewed-on: https://go-review.googlesource.com/8462
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-03 23:40:59 +00:00
Matthew Dempsky
4f2a73011f cmd/internal/gc, cmd/yacc: restore remaining custom error messages
This CL extends cmd/yacc to expose a yyErrorVerbose variable that
changes the error messages from just "syntax error" to "syntax error:
unexpected ${tokname}".

It also moves the yyToknames table generation to after rules have been
processed so that entries can be generated for tokens that aren't
mentioned in the preamble (e.g., '.' in the case of go.y).

Lastly, it restores gc's old code for applying yytfix to yyToknames,
except that substituting "LLITERAL" with litbuf happens in Yyerror.

Fixes #9968.

Change-Id: Icec188d11fdabc1dae31b8a471c35b5c7f6deec7
Reviewed-on: https://go-review.googlesource.com/8432
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-03 23:40:40 +00:00
Matthew Dempsky
0c9f3e4972 cmd/internal/gc: destutter array initializers
Aside from removing the superfluous comment near syms, this diff is
entirely mechanically generated via Emacs's query-replace-regexp to
replace "^\tstruct {\n[^}]*}" with "\t".

Change-Id: Ide7e4b5995f6a121b3f57415e033933ac5c7431a
Reviewed-on: https://go-review.googlesource.com/8427
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-03 19:07:41 +00:00
Josh Bleecher Snyder
c45f4b7145 iostest.bash: warn if GOARCH is not correct
Fixes #10334

Change-Id: I468230870ca2afc691ce879707dac34e513e1b9e
Reviewed-on: https://go-review.googlesource.com/8442
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-03 18:51:42 +00:00
David Crawshaw
ca0adeddd5 cmd/7g: reserve registers R26 to R32
These registers are not available for programs to use. Prior to this
change, the compiler would crash attempting to use ZR as a general
purpose register. Other programs would compile but on execution would
overwrite the G register and cause havoc.

Fixes linux/arm64 build.
Fixes #10304
Fixes #10320

Change-Id: I5cf51d3b77cfe3db7dd6377324950cafb02f8d8b
Reviewed-on: https://go-review.googlesource.com/8456
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-03 18:25:09 +00:00
Robert Griesemer
a51d5f27e8 cmd/internal/gc: use 512 bits (rather than 464) for multi-precision arithmetic
The original implementation used 16 int "words" but only 29 bits per word
for a total of 16*29 = 464 bits, with a space consumption of 16*64 = 1024
bits on a 64 bit machine. Switching to 512 bits increases precision while
still using (in the worst case) half the amount of memory per mp value on
a 64 bit machine.

Also: Decreased permitted number of least-significant mantissa bits which
may be incorrect when considering if a precise floating-point constant is
an integer from 29 to 16 bits.

Change-Id: Iee9287056f0e9aa4f06ceac0724ff4674f710c53
Reviewed-on: https://go-review.googlesource.com/8429
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-03 17:13:07 +00:00
Josh Bleecher Snyder
14bbab4758 cmd/internal/gc/big: gofmt vendored code
Change-Id: I035e6f1cd159644db5eeef83056b9c34c401e60f
Reviewed-on: https://go-review.googlesource.com/8441
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-03 17:05:57 +00:00
Russ Cox
92dba0d278 cmd/internal/gc: use hardware instruction for math.Sqrt (amd64/arm)
I first prototyped this change in Sept 2011, and I discarded it
because it made no difference in the obvious benchmark loop.
It still makes no difference in the obvious benchmark loop,
but in a less obvious one, doing some extra computation
around the calls to Sqrt, not making the call does have a
significant effect.

benchmark                 old ns/op     new ns/op     delta
BenchmarkSqrt             4.56          4.57          +0.22%
BenchmarkSqrtIndirect     4.56          4.56          +0.00%
BenchmarkSqrtGo           69.4          69.4          +0.00%
BenchmarkSqrtPrime        4417          3647          -17.43%

This is a warmup for using hardware expansions for some
calls to 1-line assembly routines in the runtime (for example getg).

Change-Id: Ie66be23f8c09d0f7dc4ddd7ca8a93cfce28f55a4
Reviewed-on: https://go-review.googlesource.com/8356
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 16:13:36 +00:00
Russ Cox
90c0fefe51 cmd/internal/obj/x86: remove NOP that crept into framepointer fix
Followup to CL 7728.

Change-Id: Ibb0fed7816aab459a94720b139a7737fad65bea2
Reviewed-on: https://go-review.googlesource.com/8425
Reviewed-by: Austin Clements <austin@google.com>
2015-04-03 16:13:30 +00:00
Shenghou Ma
13f749486d cmd/7g: FCMPS/FCMPD also should be RegRead instead of RightRead
No test cases yet, but I found this while double checking the
proginfo table.

Change-Id: Ib59675c117c676c1298bcab8765ca6a8fd234de8
Reviewed-on: https://go-review.googlesource.com/8431
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-04-03 09:10:18 +00:00
Ian Lance Taylor
32dbe07621 runtime: fix arm, arm64, ppc64 builds (I hope)
I guess we need more builders.

Change-Id: I309e3df7608b9eef9339196fdc50dedf5f9422e4
Reviewed-on: https://go-review.googlesource.com/8434
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-03 05:18:31 +00:00
Mikio Hara
21ed40c8cb net: deflake TestDialGoogle, TestResolveDialGoogle
This change makes use of the socktest package instead of the non-thread
safe variable syscall.SocketDisableIPv6 for simulating unreachable
external networks.

Also adds -ipv4 flag, -ipv6 flag already exists, as a control knob for
testing on each of IPv4-only, IPv6-only and dual IP stack kernels.

Fixes #7687.

Change-Id: I82002007fd526e8cf4de207f935e721df049a22f
Reviewed-on: https://go-review.googlesource.com/8390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 01:50:30 +00:00
Srdjan Petrovic
e8694c8196 runtime: initialize shared library at library-load time
This is Part 2 of the change, see Part 1 here: in https://go-review.googlesource.com/#/c/7692/

Suggested by iant@, we use the library initialization entry point to:
    - create a new OS thread and run the "regular" runtime init stack on
      that thread
    - return immediately from the main (i.e., loader) thread
    - at the first CGO invocation, we wait for the runtime initialization
      to complete.

The above mechanism is implemented only on linux_amd64.  Next step is to
support it on linux_arm.  Other platforms don't yet support shared library
compiling/linking, but we intend to use the same strategy there as well.

Change-Id: Ib2c81b1b83bee837134084b75a3beecfb8de6bf4
Reviewed-on: https://go-review.googlesource.com/8094
Run-TryBot: Srdjan Petrovic <spetrovic@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 01:24:51 +00:00
Mikio Hara
167562f652 net: deflake TestDialTimeoutFDLeak
This change makes TestDialTimeoutFDLeak work on almost all the supported
platforms.

Updates #4384.

Change-Id: I3608f438003003f9b7cfa17c9e5fe7077700fd60
Reviewed-on: https://go-review.googlesource.com/8392
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 00:48:47 +00:00
Jacob H. Haven
88399b2e46 crypto/x509: Fix parsing bug in uncommon CSR Attributes.
A CSR containing challengePassword or unstructuredName Attributes
(included in default OpenSSL prompts) would break ASN.1 parsing.
This updates the parsing structures to allow but then ignore these
fields.

See this CFSSL issue: https://github.com/cloudflare/cfssl/issues/115

Change-Id: I26a3bf1794589d27e6e763da88ae32276f0170c7
Reviewed-on: https://go-review.googlesource.com/8160
Reviewed-by: Adam Langley <agl@golang.org>
2015-04-03 00:28:30 +00:00
Mikio Hara
3a9024b498 net: move init function into net.go
It's a single, package-wide init function specified for the net package.

Change-Id: Id5894d65e1a92297cc16803cc5e4d4eef0b4b099
Reviewed-on: https://go-review.googlesource.com/8391
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-03 00:23:23 +00:00
Austin Clements
f244a1471d runtime: add cumulative GC CPU % to gctrace line
This tracks both total CPU time used by GC and the total time
available to all Ps since the beginning of the program and uses this
to derive a cumulative CPU usage percent for the gctrace line.

Change-Id: Ica85372b8dd45f7621909b325d5ac713a9b0d015
Reviewed-on: https://go-review.googlesource.com/8350
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 23:37:13 +00:00
Austin Clements
24ee948269 runtime: update gctrace line for new garbage collector
GODEBUG=gctrace=1 turns on a per-GC cycle trace line. The current line
is left over from the STW garbage collector and includes a lot of
information that is no longer meaningful for the concurrent GC and
doesn't include a lot of information that is important.

Replace this line with a new line designed for the new garbage
collector.

This new line is focused more on helping the user understand the
impact of the garbage collector on their program and less on telling
us, the runtime developers, everything that's happening inside
GC. It's designed to fit in 80 columns and intentionally omit some
potentially useful things that were in the old line. We might want a
"verbose" mode that adds information for us.

We'll be able to further simplify the line once we eliminate the STW
around enabling the write barrier. Then we'll have just one STW phase,
one concurrent phase, and one more STW phase, so we'll be able to
reduce the number of times from five to three.

Change-Id: Icc30939fe4576fb4491b4eac811649395727aa2a
Reviewed-on: https://go-review.googlesource.com/8208
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 23:37:06 +00:00
Jacob H. Haven
28f33b4a70 crypto/tls: make use of crypto.Signer and crypto.Decrypter
This change replaces all direct ECDSA/RSA sign and decrypt operations
with calls through the crypto.Signer and crypto.Decrypter interfaces.

This is a follow-up to https://go-review.googlesource.com/#/c/3900/
which added crypto.Decrypter and implemented it for RSA.

Change-Id: Ie0f3928448b285f329efcd3a93ca3fd5e3b3e42d
Reviewed-on: https://go-review.googlesource.com/7804
Reviewed-by: Adam Langley <agl@golang.org>
2015-04-02 23:19:57 +00:00
Robert Griesemer
5750b7118f cmd/internal/gc: move fix and flt functions into respective files (cleanups)
Also:
- introduce Mpprec (remove old constants)
- no semantic changes

Change-Id: Ie0e77e8e09bd68e09bcf8747a3d875270e736081
Reviewed-on: https://go-review.googlesource.com/8171
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 23:10:38 +00:00
Robert Griesemer
5bb89eb009 cmd/internal/gc: use big.Float to represent Mpflt bits
All multi-precision arithmetic is now based on math/big.

- passes all.bash
- added test cases for fixed bugs

Fixes #7740.
Fixes #6866.

Change-Id: I67268b91766970ced3b928260053ccdce8753d58
Reviewed-on: https://go-review.googlesource.com/7912
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 22:49:47 +00:00
Robert Griesemer
4da157a723 cmd/dist, cmd/internal/gc: switch gc from math/big to vendored math/big
Change-Id: Iab9a1f814acd53d5707bfcd6c3f9616c79fa7789
Reviewed-on: https://go-review.googlesource.com/7858
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 22:23:14 +00:00
Robert Griesemer
dec685921d cmd/internal/gc/big: updated vendored version of math/big (fix build)
Change-Id: I04c2bd18a47cc775c78d074fe521cef2b0d6e7f0
Reviewed-on: https://go-review.googlesource.com/8426
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-02 22:05:22 +00:00
Matthew Dempsky
398bf9d5a0 cmd/internal/gc, cmd/yacc: restore custom syntax error messages
This restores go.errors from before 3af0d79 along with a fixed up
version of the bisonerrors AWK script, translated to Go.

However, this means Yyerror needs access to the yacc parser's state,
which is currently private.  To workaround that, add a "state"
accessor method like the Lookahead method added in c7fa3c6.

Update issue #9968.

Change-Id: Ib868789e92fdb7d135442120a392457923e50121
Reviewed-on: https://go-review.googlesource.com/7270
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-02 21:56:24 +00:00
Robert Griesemer
e5a0d6399e cmd/internal/gc/big: vendored math/big for use by gc
This is vendored copy of the pure-Go version of math/big.
To update, run vendor.bash in place.

This will permit the use of the new big.Float functionality in
gc (which is not available in 1.4, the version used for bootstrapping).

Change-Id: I4dcdea875d54710005ca3fdea2e0e30422b1b46d
Reviewed-on: https://go-review.googlesource.com/7857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 21:27:23 +00:00
Matthew Dempsky
a1bb3030c8 cmd/yacc: generate arrays instead of slices where possible
Yacc generates a bunch of global variables of the form

    var yyFoo = []int{...}

where yyFoo is never subsequently modified to point to a different
slice.  Since these variables are implicitly compiled as

    var yyFoo = ([...]int{...})[:]

anyway, by simply converting them all to

    var yyFoo = [...]int{...}

we save sizeof(sliceStruct) bytes of data memory for each variable and
also make len(yyFoo) into compile-time constant expressions, which
shaves some bytes off text size:

    $ size 6g.before 6g.after
       text	   data	    bss	    dec	    hex	filename
    4598019	 605968	 342700	5546687	 54a2bf	6g.before
    4597810	 605552	 342700	5546062	 54a04e	6g.after

Change-Id: I53c7aa6efdb2d52738013e9d337a59afbfcb2494
Reviewed-on: https://go-review.googlesource.com/7520
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 21:05:43 +00:00
Dave Cheney
01d005c616 cmd/8g, cmd/internal/gc: clean up GO386 handling
This change cleans up some of the uglyness introduced in 8fc73a39ef
by moving the gc.Use_sse into the gc.Arch struct and adjusting its
zero value to be more useful.

Change-Id: I26ff5d9ac57b3f25e936519e443de6583cdafa56
Reviewed-on: https://go-review.googlesource.com/7994
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 20:44:20 +00:00
David Crawshaw
33448d963c cmd/7g: fix ACMP entry in progtable
On arm64, CMP $foo, R is encoded as from=$foo, reg=R, not as from=$foo,
to=R. The progtable entry for ACMP incorrectly described the latter
form. Because of this, the registerizer was not accounting the registers
used in CMP instructions and was incorrectly re-assigning those registers.

This was an old problem, but it only became apparent after b115c35
(cmd/internal/gc: move cgen, regalloc, et al to portable code). Previous
to this commit, the compiler used a slightly larger register set for the
temps than it used for register variables. Since it had plenty registers
dedicated to temps, the registers used in CMP instruction never clashed
with registers assigned to register variables.

Fixes #10253

Change-Id: Iedf4bd882bd59440dff310ac0f81e0f53d80d7ed
Reviewed-on: https://go-review.googlesource.com/8387
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-02 20:18:28 +00:00
Robert Griesemer
bb298754ab math/big: implement missing special cases for binary operations
Change-Id: I9fc12b1a9b1554523e08839c1ff46c8668217ba1
Reviewed-on: https://go-review.googlesource.com/8381
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-02 17:05:09 +00:00
Michael Schaller
d6dff636ea cmd/go: print SWIG warnings
Fixes #9053

Change-Id: I7b9af3647800671f065c366a6adf9278e64ebec9
Reviewed-on: https://go-review.googlesource.com/8400
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-02 16:37:48 +00:00
Austin Clements
822a24b602 runtime: remove checkgc code from hashmap
Currently hashmap is riddled with code that attempts to force a GC on
the next allocation if checkgc is set. This no longer works as
originally intended with the concurrent collector, and is apparently
no longer used anyway.

Remove checkgc.

Change-Id: Ia6c17c405fa8821dc2e6af28d506c1133ab1ca0c
Reviewed-on: https://go-review.googlesource.com/8355
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-02 15:28:56 +00:00
Austin Clements
6134caf1f9 runtime: improve MemStats comments
This tries to clarify that Alloc and HeapAlloc are tied to how much
freeing has been done by the sweeper.

Change-Id: Id8320074bd75de791f39ec01bac99afe28052d02
Reviewed-on: https://go-review.googlesource.com/8354
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-04-02 15:28:50 +00:00
Mikio Hara
52c84c34fd net: move test flags into main_test.go
Also updates the comments on test flags.

Change-Id: I8dbd90270e08728ab309ab88a3030e0f8e547175
Reviewed-on: https://go-review.googlesource.com/8394
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-02 09:07:24 +00:00
Robert Griesemer
bd09279c3f go/ast: fix ast.Inspect doc string
Fixes #10243.

Change-Id: I06ac53628980853faecbf1a57ff71b88098d65f2
Reviewed-on: https://go-review.googlesource.com/8382
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-02 03:51:22 +00:00
Josh Bleecher Snyder
ad3600945a runtime: auto-generate duff routines
This makes it easier to experiment with alternative implementations.

While we're here, update the comments.

No functional changes. Passes toolstash -cmp.

Change-Id: I428535754908f0fdd7cc36c214ddb6e1e60f376e
Reviewed-on: https://go-review.googlesource.com/8310
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-02 02:37:59 +00:00
Josh Bleecher Snyder
102b80652f cmd/internal/gc: make class uint8 throughout
This prevents conversion noise.

No functional changes. Passes toolstash -cmp.

Change-Id: I238adf28680f875217827931a689ce7f19a9b371
Reviewed-on: https://go-review.googlesource.com/8164
Reviewed-by: David Chase <drchase@google.com>
2015-04-02 02:16:49 +00:00
Mikio Hara
8b0e38ffb4 net: deflake TestDialTimeout
This change makes TestDialTimeout work on almost all the supported
platforms.

Updates #3016.
Updates #3307.
Updates #3867.
Updates #5380.
Updates #5349.

Change-Id: Iacf0ebea23cdd8f6c0333d70c667a5a5f5eb0ed2
Reviewed-on: https://go-review.googlesource.com/8220
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-02 01:04:49 +00:00
Mikio Hara
93553dd216 net: fix data race in benchmarks
Fixes #10307.

Change-Id: If70f36a6f1c4e465a47a0bc4d38b318424111106
Reviewed-on: https://go-review.googlesource.com/8330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-01 22:02:41 +00:00
David Symonds
9b696be08b go/scanner: Simplify ErrorList.Sort implementation.
It functions exactly the same, but this is the more common
style for these kinds of multi-key comparison functions,
and is more regular.

Change-Id: I46630948f893bcc96c05eb3d36eb82e1d97a6fa0
Reviewed-on: https://go-review.googlesource.com/8358
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-01 21:32:47 +00:00
Robert Griesemer
919a6fbeab math/big: faster Int.Binomial(n, k) for k > n/2
benchmark             old ns/op     new ns/op     delta
BenchmarkBinomial     478664        4410          -99.08%

Fixes #10084.

Change-Id: Ib75034428e32c79c9a660ae9f9bd396afc6a7f11
Reviewed-on: https://go-review.googlesource.com/8351
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-01 19:35:35 +00:00
Josh Bleecher Snyder
3ed9e4ca3c cmd/internal/gc: unembed Node.Func
This is a follow-up to CL 7360.

It was generated with eg and gofmt -r.

The only manual changes are the unembedding in syntax.go
and backporting changes from y.go to go.y.

Passes toolstash -cmp.

Change-Id: I3d6d06ecb659809a4bc8592395d5b9a18967218e
Reviewed-on: https://go-review.googlesource.com/8053
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-01 18:21:22 +00:00
Josh Bleecher Snyder
57279ba752 cmd/internal/gc: separate func-only Node fields
Nodes dominate gc's memory usage, but many fields are only used
for a subset of kinds of nodes. This change pulls out fields
used only for func-like Nodes. This reduces the size of the
Node struct on a 64-bit machine from 504 bytes to 416 bytes (-17%).

Compiling the runtime, 1.5% of nodes have a non-nil Func.
In html/template, 2.7% of nodes have a non-nil Func.

This change introduces an extra alloc and associated GC overhead
when Func is non-nil. However, when Func is nil, as it almost
always is, it spares the garbage collector scanning some Node fields.
Empirically, this change appears to be roughly neutral with regard to GC.

To keep the diff readable, this CL uses an embedded Func field.
A subsequent CL will unembed the field.

Passes toolstash -cmp.

Change-Id: Ide86aa954b097fb8e6154f0811d3691497477004
Reviewed-on: https://go-review.googlesource.com/7360
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-01 18:00:20 +00:00
Jan Mercl
9fd87bd501 go/scanner: Stabilize (*ErrorList).Sort
This change stabilizes the result of Sort when the error list contains
multiple items for same position. To stabilize the result, newly also
the Msg field is considered.

The motivation is to avoid diffs of sorted scanner.ErrorList output
in repository tracked logs like:

-testdata/foo.go:19:44: "bar"
 testdata/foo.go:19:44: "qux"
+testdata/foo.go:19:44: "bar"

The change was approved at [0] before submitting.

As a side effect, one file in go/parser/testdata must be updated as
well. For this file the parser produces two different errors:

testdata/issue3106.src:22:5: expected ';', found 'if'
testdata/issue3106.src:22:5: expected operand, found 'if'

Before comparing the actual and expected errors, the former are
filtered to keep only one error per source line[1]. With the new
(*ErrorList).Less the outcome is the other error than before which is
kept after the call to RemoveMultiplies.

[0]: https://groups.google.com/d/msg/golang-nuts/5ChC0XiIwlU/rol_yb2gTj4J
[1]:
9d0239771a/src/go/parser/error_test.go (L160)

Change-Id: Ib72c98a891cdeef34705c22dfbeb0408dcdfddf8
Reviewed-on: https://go-review.googlesource.com/8340
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-01 17:39:57 +00:00
Sebastien Binet
9a3ee2d217 cmd/gofmt, go/format: refactor common pieces into internal/format
cmd/gofmt and go/format had 3 functions (parse, format and isSpace)
that had to be kept in-sync.

This CL extracts these 3 functions and refactors them into a new
internal/format package.
This CL is just code reorganization with no behavior nor semantic
change.

Change-Id: I593f24e9d3cadbbd9559a67e3b1d2ff190b4fd90
Reviewed-on: https://go-review.googlesource.com/6760
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-01 17:35:26 +00:00
Josh Bleecher Snyder
b09925b31d cmd/5g etc: merge simple case expressions onto fewer lines
The c2go translation left a lot of case expressions on separate lines.
Merge expressions onto single lines subject to these constraints:

* Max 4 clauses, all literals or names
* Don't move expressions with comments

The change was created by running http://play.golang.org/p/yHajs72h-g:

$ mergecase cmd/internal/{ld,gc,obj}/*.go cmd/internal/obj/*/*.go

Passes toolstash -cmp.

Change-Id: Iba41b390d302e5486e5dc6ba7599a92270676556
Reviewed-on: https://go-review.googlesource.com/7593
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-01 17:27:22 +00:00
Preetam Jinka
2c20eda1d8 compress/flate: fix typo in comment
Change-Id: I32ec2d8cb838fb850b3779726cf347dac21dff68
Reviewed-on: https://go-review.googlesource.com/8322
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-01 16:48:04 +00:00
Josh Bleecher Snyder
94410c794e cmd/gc: teach componentgen about string constants
This makes it cheaper to copy string literals.
This happens just about anywhere that they are used.

Example:

func f() string {
	return "f"
}

Using 6g, compiler output before:

"".f t=1 size=32 value=0 args=0x10 locals=0x0
	0x0000 00000 (p.go:3)	TEXT	"".f+0(SB),4,$0-16
	0x0000 00000 (p.go:3)	FUNCDATA	$0,gclocals·d64e51a4c4bfeaa840e480961ec6b0b3+0(SB)
	0x0000 00000 (p.go:3)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (p.go:4)	LEAQ	go.string."f"+0(SB),BX
	0x0007 00007 (p.go:4)	MOVQ	(BX),BP
	0x000a 00010 (p.go:4)	MOVQ	BP,"".~r0+8(FP)
	0x000f 00015 (p.go:4)	MOVQ	8(BX),BP
	0x0013 00019 (p.go:4)	MOVQ	BP,"".~r0+16(FP)
	0x0018 00024 (p.go:4)	RET	,

After:

"".f t=1 size=32 value=0 args=0x10 locals=0x0
	0x0000 00000 (p.go:3)	TEXT	"".f+0(SB),4,$0-16
	0x0000 00000 (p.go:3)	FUNCDATA	$0,gclocals·d64e51a4c4bfeaa840e480961ec6b0b3+0(SB)
	0x0000 00000 (p.go:3)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (p.go:4)	MOVQ	$go.string."f"+16(SB),BX
	0x0007 00007 (p.go:4)	MOVQ	BX,"".~r0+8(FP)
	0x000c 00012 (p.go:4)	MOVQ	$1,"".~r0+16(FP)
	0x0015 00021 (p.go:4)	RET	,

The leading MOVQ here will be converted into a LEAQ by the linker,
but there is still a net reduction of two MOVQs.

Before:

TEXT main.f(SB)
        p.go:4  0x2000  488d1d49500500  LEAQ 0x55049(IP), BX
        p.go:4  0x2007  488b2b          MOVQ 0(BX), BP
        p.go:4  0x200a  48896c2408      MOVQ BP, 0x8(SP)
        p.go:4  0x200f  488b6b08        MOVQ 0x8(BX), BP
        p.go:4  0x2013  48896c2410      MOVQ BP, 0x10(SP)
        p.go:4  0x2018  c3              RET

After:

TEXT main.f(SB)
        p.go:4  0x2000  488d1dd94c0500          LEAQ 0x54cd9(IP), BX
        p.go:4  0x2007  48895c2408              MOVQ BX, 0x8(SP)
        p.go:4  0x200c  48c744241001000000      MOVQ $0x1, 0x10(SP)
        p.go:4  0x2015  c3                      RET

The performance improvement is small but widespread.

As a nice small example, net/url's sole benchmark using 6g:

benchmark           old ns/op     new ns/op     delta
BenchmarkString     16372         16118         -1.55%

And with 8g:

benchmark           old ns/op     new ns/op     delta
BenchmarkString     22034         21709         -1.47%

Change-Id: I4ce202ee7dbd4057be869e2faaaa638c28a1fff0
Reviewed-on: https://go-review.googlesource.com/2587
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-01 16:32:20 +00:00
Andrei Korzhevskii
297c1d297f database/sql: provide stats on number of open connections to the database.
This change provides a convenient way to monitor database connection pool.

Change-Id: I4b3757855b43f3b254acf9312e2a16e2f87840d0
Reviewed-on: https://go-review.googlesource.com/7950
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-01 15:24:53 +00:00
Dave Cheney
9d0239771a cmd/go: always link external test packages first when using gccgo
This CL is an amagamation of several fixes Canonical have made on their
fork of the cmd/go tool (packaged as gccgo-go.deb on Ubuntu 14.04+).

Additionally this CL brings gccgoToolchain.ldi() up to date with the version
that will ship in gccgo-5.0. As gccgo is most likely to be used with its
own version of the go tool that it supples it makes good sense that the libgo
version should dictate the contents of gccgotoolchain.ld()

Please see https://codereview.appspot.com/222890043/ for more details on the
issues fixed.

Change-Id: Icf7deb43f8e80b424757f1673e6bca7a0aa2a1ac
Reviewed-on: https://go-review.googlesource.com/8250
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-01 09:10:59 +00:00
Evan Phoenix
9c0375277c text/scanner: Fix EOF reporting on strange Readers
Currently, scanner uses -1 to represent 2 different states:

1. I haven't yet scanned anything, call it "Beginning of File"
2. I've reached the end of the input, ie EOF

The result of this behavior is that calling Peek() when next()
has detected the end of the input and set s.ch to scanner.EOF,
is that Peek() things "oh, s.ch is < 0, which to me means that
I haven't scanned any next yet, let me try and clear the BOM
marker."

When this behavior is run on a typical IO, next() will issue
a Read and get (0, io.EOF) back for the second time without
blocking and Peek() will return scanner.EOF.

The bug comes into play when, inside a terminal, hitting Control-D.
This causes the terminal to return a EOF condition to the reader
but it does not actually close the fd.

So, combining these 2 situations, we arrive at the bug:

What is expected: hitting Control-D in a terminal will make Peek()
return scanner.EOF instantly.

What actually happens:

0. Code waiting in Next()
1. User hits Control-D
2. fd returns EOF condition
3. EOF bubbles it's way out to line 249 in scanner.go
4. next() returns scanner.EOF
5. Next() saves the scanner.EOF to s.ch and returns the previous value
6. Peek() runs, sees s.ch < 0, mistakenly thinks it hasn't run yet and
   tries to read the BOM marker.
7. next() sees the buffer is empty and tries to fill it again, blocking
   on line 249.

The fix is simple: use a different code to indicate that no data
has been scanned.

Change-Id: Iee8f4da5881682c4d4c36b93b9bf397ac5798179
Reviewed-on: https://go-review.googlesource.com/7913
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-04-01 03:39:22 +00:00
Martin Möhrmann
15e66f9d01 fmt: improve test coverage of %x and %X format variations for strings
The tests in the basic string section are now covering more code paths
for encoding a string into the hexadecimal representation of its bytes.

Changed the basic string and basic bytes tests so that they mirror each other.

Change-Id: Ib5dc7b33876769965f9aba2ac270040abc4b2451
Reviewed-on: https://go-review.googlesource.com/2611
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-01 00:55:30 +00:00
Mikio Hara
29d1f3b85c net: add socket system call hooks for testing
This change adds socket system call hooks to existing test cases for
simulating a bit complicated network conditions to help making timeout
and dual IP stack test cases work more properly in followup changes.

Also test cases print debugging information in non-short mode like the
following:

Leaked goroutines:
net.TestWriteTimeout.func2(0xc20802a5a0, 0xc20801d000, 0x1000, 0x1000, 0xc2081d2ae0)
	/go/src/net/timeout_test.go:170 +0x98
created by net.TestWriteTimeout
	/go/src/net/timeout_test.go:173 +0x745
net.runDatagramPacketConnServer(0xc2080730e0, 0x2bd270, 0x3, 0x2c1770, 0xb, 0xc2081d2ba0, 0xc2081d2c00)
	/go/src/net/server_test.go:398 +0x667
created by net.TestTimeoutUDP
	/go/src/net/timeout_test.go:247 +0xc9
	(snip)

Leaked sockets:
3: {Cookie:615726511685632 Err:<nil> SocketErr:0}
5: {Cookie:7934075906097152 Err:<nil> SocketErr:0}

Socket statistical information:
{Family:1 Type:805306370 Protocol:0 Opened:17 Accepted:0 Connected:5 Closed:17}
{Family:2 Type:805306369 Protocol:0 Opened:450 Accepted:234 Connected:279 Closed:636}
{Family:1 Type:805306369 Protocol:0 Opened:11 Accepted:5 Connected:5 Closed:16}
{Family:28 Type:805306369 Protocol:0 Opened:95 Accepted:22 Connected:16 Closed:116}
{Family:2 Type:805306370 Protocol:0 Opened:84 Accepted:0 Connected:34 Closed:83}
{Family:28 Type:805306370 Protocol:0 Opened:52 Accepted:0 Connected:4 Closed:52}

Change-Id: I0e84be59a0699bc31245c78e2249423459b8cdda
Reviewed-on: https://go-review.googlesource.com/6390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-31 23:07:42 +00:00
Robert Griesemer
fa85a7206d math/big: remove NaN support - just not worth it
NaNs make the API more complicated for no real good reasons.
There are few operations that produce NaNs with IEEE arithmetic,
there's no need to copy the behavior. It's easy to test for these
scenarios and avoid them (on the other hand, it's not easy to test
for overflow or underflow, so we want to keep +/-Inf).

Also:
- renamed IsNeg -> Signbit (clearer, especially for x == -0)
- removed IsZero           (Sign() == 0 is sufficient and efficient)
- removed IsFinite         (now same as !IsInf)

Change-Id: I3f3b4445c325d9bbb1bf46ce2e298a6aeb498e07
Reviewed-on: https://go-review.googlesource.com/8280
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-03-31 23:05:31 +00:00
Michael Hudson-Doyle
67426a8a9e runtime, cmd/internal/ld: change runtime to use a single linker symbol
In preparation for being able to run a go program that has code
in several objects, this changes from having several linker
symbols used by the runtime into having one linker symbol that
points at a structure containing the needed data.  Multiple
object support will construct a linked list of such structures.

A follow up will initialize the slices in the themoduledata
structure directly from the linker but I was aiming for a minimal
diff for now.

Change-Id: I613cce35309801cf265a1d5ae5aaca8d689c5cbf
Reviewed-on: https://go-review.googlesource.com/7441
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-31 22:45:07 +00:00
Michael Hudson-Doyle
0de359da30 cmd/internal/gc: directly produce importpath of package being compiled
Relying on an importing package being linked at the same time as the
imported package does not work in the shared library world.

This also lets us remove some obscure code from the linker.

Change-Id: I57cd5447b42a1a6129b02951d44efffb10cf64be
Reviewed-on: https://go-review.googlesource.com/7797
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-31 20:31:55 +00:00
Robert Griesemer
8d267b9b59 math/big: fixed Float.Float64, implemented Float.Float32
- fix bounds checks for exponent range of denormalized numbers
- use correct rounding precision for denormalized numbers
- added extra tests

Change-Id: I6be56399afd0d9a603300a2e44b5539e08d6f592
Reviewed-on: https://go-review.googlesource.com/8096
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-03-31 19:36:55 +00:00
Alex Brainman
34ee744d00 crypto/x509: use syscall.GetVersion instead of internal/syscall/windows.GetVersion
cl8167 introduced internal/syscall/windows.GetVersion, but we already
have that function in syscall.GetVersion. Use that instead.
Also revert all internal/syscall/windows cl8167 changes.

Change-Id: I512a5bf4b3b696e93aaf69e9e8b7df7022670ec0
Reviewed-on: https://go-review.googlesource.com/8302
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-31 08:11:24 +00:00
Austin Clements
a2f3d73fee runtime: improve comment about non-preemption during GC work
Currently, gcDrainN is documented saying that it must be run on the
system stack. In fact, the problem and solution here are somewhat
subtler. First, it doesn't have to happen on the system stack, it just
has to be non-stoppable (that is, non-preemptible). Second, this isn't
specific to gcDrainN (though gcDrainN is perhaps the most surprising
instance); it's general to anything that uses the gcWork structure.

Move the comment to gcWork and generalize it.

Change-Id: I5277b5abb070e47f8d783bc15a310b379c6adc22
Reviewed-on: https://go-review.googlesource.com/8247
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-31 01:05:38 +00:00
Austin Clements
a4374c1de1 runtime: fix another out of date comment in GC
gcDrain used to be passed a *workbuf to start draining from, but now
it takes a gcWork, which hides whether or not there's an initial
workbuf. Update the comment to match this.

Change-Id: I976b58e5bfebc451cfd4fa75e770113067b5cc07
Reviewed-on: https://go-review.googlesource.com/8246
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-31 01:05:31 +00:00
John Potocny
6262192cd0 strings: Add benchmark test for trim function
The strings.Trim function and variants allocate memory on the heap when creating a function to pass into TrimFunc.
Add a benchmark to document the behavior; an issue will be submitted to address this behavior in the compiler if possible.

Change-Id: I8b66721f077951f7e7b8cf3cf346fac27a9b68c0
Reviewed-on: https://go-review.googlesource.com/8200
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-31 00:40:55 +00:00
Lee Packham
c45751e8a5 runtime: allow pointers to strings to be printed
Being able to printer pointers to strings means one will able to output
the result of things like the flag library and other components that use
string pointers.

While here, adjusted the tests for gdb to test original string pretty
printing as well as pointers to them. It was doing it via the map before
but for completeness this ensures it's tested as a unit.

Change-Id: I4926547ae4fa6c85ef74301e7d96d49ba4a7b0c6
Reviewed-on: https://go-review.googlesource.com/8217
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-30 23:59:24 +00:00
Rob Pike
6ca91d264f cmd/internal/obj/arm64: delete needless closure in for claus
A residue of the automatic translation, this closure is easily rewritten
to a simpler, smaller, and faster construct.

Discovered while analyzing #10269, which I still plan to fix.

Change-Id: I76b12290280d81880c446b4cf75da633a94482d4
Reviewed-on: https://go-review.googlesource.com/8270
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-30 22:36:43 +00:00
Michael Hudson-Doyle
f78dc1dac1 runtime: rename ·main·f to ·mainPC to avoid duplicate symbol
runtime·main·f is normalized by the linker to runtime.main.f, as is
the compiler-generated symbol runtime.main·f.  Change the former to
runtime·mainPC instead.

Fixes issue #9934

Change-Id: I656a6fa6422d45385fa2cc55bd036c6affa1abfe
Reviewed-on: https://go-review.googlesource.com/8234
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-30 18:52:14 +00:00
Michael Hudson-Doyle
b8417854c3 cmd/internal/ld: handle TLS and imported symbols more regularly
For shared libraries we need to be more flexible in how these symbols
are handled (e.g. sometimes tlsg needs to be global, or you can get
a SDYNIMPORT symbol that has .Hide == true) so handling these cases
in genasmsym makes everything much more regular.

Even ignoring shared libraries, I think this is a bit cleaner.

Change-Id: If5beb093a261e79f4496183226e1765ee7aa6717
Reviewed-on: https://go-review.googlesource.com/8230
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-30 18:14:51 +00:00
David Crawshaw
dd95244d4b iostest.bash: build script for iOS
In the spirit of nacltest.bash and androidtest.bash. Sets up the
exec script and reboots the device.

The reboot helps make sure previous runs do not interfere with the
current run. It is reasonably easy for a bad program, e.g. one with
a corrupt stack, to get the device stuck.

Change-Id: I61317527741c45a70c390fe21adc4895510fc79f
Reviewed-on: https://go-review.googlesource.com/8242
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-30 16:54:01 +00:00
David Chase
ffe7fbf33b cmd/internal/gc: convert some comment text from C to Go syntax
Change-Id: Icbc42bcff5a3eabe9f43cff7fcc126141e209ded
Reviewed-on: https://go-review.googlesource.com/8203
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-30 16:12:00 +00:00
David Chase
2270133981 cmd/gc: allocate backing storage for non-escaping interfaces on stack
Extend escape analysis to convT2E and conT2I. If the interface value
does not escape supply runtime with a stack buffer for the object copy.

This is a straight port from .c to .go of Dmitry's patch

Change-Id: Ic315dd50d144d94dd3324227099c116be5ca70b6
Reviewed-on: https://go-review.googlesource.com/8201
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-03-30 16:11:22 +00:00
Daniel Theophanes
cf7461caed crypto/x509: skip SHA2 system verify test if not supported.
Windows XP SP2 and Windows 2003 do not support SHA2.

Change-Id: Ica5faed040e9ced8b79fe78d512586e0e8788b3f
Reviewed-on: https://go-review.googlesource.com/8167
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-30 15:58:08 +00:00
Austin Clements
9e6f7aac28 runtime: make "write barriers are not allowed" comments more precise
Currently, various functions are marked with the comment

  // May run without a P, so write barriers are not allowed.

However, "running without a P" is ambiguous. We intended these to mean
that m.p may be nil (which is the condition checked by the write
barrier). The comment could also be taken to mean that a
stop-the-world may happen, which is not the case for these functions
because they run in situations where there is in fact a function on
the stack holding a P locally, it just isn't in m.p.

Change these comments to state precisely what we mean, that m.p may be
nil.

Change-Id: I4a4a1d26aebd455e5067540e13b9f96a7482146c
Reviewed-on: https://go-review.googlesource.com/8209
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-30 15:13:53 +00:00
Alexandre Cesaro
fa3ad1ebb5 mime/quotedprintable: add binary mode to the writer
Change-Id: Id82c3111d7571263208ced3d011ad80f3fe55984
Reviewed-on: https://go-review.googlesource.com/7892
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-30 12:49:19 +00:00
Aaron Jacobs
09b7f4f12a io: clarify the behavior of PipeWriter.CloseWithError(nil).
The previous wording implied that reads would return no error, rather
than EOF. It's convenient for users to know that Close() is equivalent
to CloseWithError(nil) because it can remove a branch from their error
handling code where they want to close the pipe in the appropriate way.
For example:

    6e9a8cec0a/gcs/bucket.go (L637-L643)

Change-Id: I618bffe556eb518011e7ba5cdce1eb0ff536350e
Reviewed-on: https://go-review.googlesource.com/8152
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-30 09:43:11 +00:00
Brad Fitzpatrick
b86f393167 mime: tighten up and simplify tests
Don't test so much at once.

Fixes #10278

Change-Id: I32a9cb81a3cffecc7ce4f83c35a4b589bcd3a9f7
Reviewed-on: https://go-review.googlesource.com/8213
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-30 09:12:03 +00:00
Daniel Theophanes
77f4571f71 runtime: do not use AddVectoredContinueHandler on Windows XP/2003.
When Windows Error Reporting dialog is disabled on amd64
Windows XP or 2003, the continue handler does not fire. Newer
versions work correctly regardless of WER.

Fixes #10162

Change-Id: I84ea36ee188b34d1421a8db6231223cf61b4111b
Reviewed-on: https://go-review.googlesource.com/8165
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-30 03:37:55 +00:00
Dmitry Vyukov
ca98dd773a runtime/pprof: fix data race in test
rp.Close happened concurrently with rp.Read. Order them.

Fixes #10280

Change-Id: I7b083bcc336d15396c4e42fc4654ba34fad4a4cc
Reviewed-on: https://go-review.googlesource.com/8211
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-03-29 12:24:16 +00:00
Dmitry Vyukov
edcc062bdc test: add tests for escape analysis of interface conversions
The false positives (var incorrectly escapes) are marked with BAD.

Change-Id: If64fabb6ea96de44a1177d9ab12e2ccc579fe0c4
Reviewed-on: https://go-review.googlesource.com/5294
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 16:15:27 +00:00
Dmitry Vyukov
c61d86af72 os: give race detector chance to override Exit(0)
Racy tests do not fail currently, they do os.Exit(0).
So if you run go test without -v, you won't even notice.
This was probably introduced with testing.TestMain.

Racy programs do not have the right to finish successfully.

Change-Id: Id133d7424f03d90d438bc3478528683dd02b8846
Reviewed-on: https://go-review.googlesource.com/4371
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-28 12:42:37 +00:00
Mikio Hara
7b2b45e544 net: simplify test helpers
This change consolidates test helpers that test platform capabilities.
testNetwork, testAddress and testListenArgs report whether given
ariguments are testable on the current platform configuration to
mitigate to receive weird test results.

Change-Id: Ie1ed568a1f9cc50f3155945ea01562904bc2c389
Reviewed-on: https://go-review.googlesource.com/8076
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-28 08:21:10 +00:00
Srdjan Petrovic
71756355dc cmd/go: add -asmflags build flag
We need this in order to pass the "-shared" flag to the assembler.

Change-Id: I9c15cfe4d32c1e5e8cae1b9b2c924cfd77923b55
Reviewed-on: https://go-review.googlesource.com/7694
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-27 22:52:48 +00:00
Srdjan Petrovic
8da54a4eec cmd: linker changes for shared library initialization
Suggested by iant@, this change:
  - looks for a symbol _rt0_<GOARCH>_<GOOS>_lib,
  - if the symbol is present, adds a new entry into the .init_array ELF
    section that points to the symbol.

The end-effect is that the symbol _rt0_<GOARCH>_<GOOS>_lib will be
invoked as soon as the (ELF) shared library is loaded, which will in turn
initialize the runtime. (To be implemented.)

Change-Id: I99911a180215a6df18f8a18483d12b9b497b48f4
Reviewed-on: https://go-review.googlesource.com/7692
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-27 22:52:10 +00:00
Jeremy Schlatter
ff1f3a11e4 math/big: fix copy-paste mistake in int_test.go
Change-Id: If986ed2cf94efba92763d00a3182047c05d6f805
Reviewed-on: https://go-review.googlesource.com/8133
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-27 21:02:31 +00:00
Jeremy Schlatter
4ec7e76a74 cmd/go: small code reorganization
covermode is not passed to 6.out, so it should not be grouped
with the flags that are. Move it to the "local" section.

Change-Id: Id487898962e7ab7adf98b0854c2f1802116bec11
Reviewed-on: https://go-review.googlesource.com/8132
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-27 21:02:11 +00:00
Hyang-Ah Hana Kim
39bc78845b runtime/pprof: fix TestCPUProfileWithFork for GOOS=android.
1) Large allocation in this test caused crash. This was not
detected by builder because builder runs tests with -test.short.

2) The command "go" for forking doesn't exist in some platforms
including android. This change uses the test binary itself which
is guaranteed to exist.

This change also adds logging of the total samples collected in
TestCPUProfileMultithreaded test that is flaky in android-arm
builder.

Change-Id: I225c6b7877d811edef8b25e7eb00559450640c42
Reviewed-on: https://go-review.googlesource.com/8131
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-27 18:07:06 +00:00
Brad Fitzpatrick
dde5b56c91 syscall: apply the errno allocation fix to other operating systems
The previously-submitted https://go-review.googlesource.com/#/c/6701
didn't include dragonfly, freebsd, nacl, netbsd, openbsd, or solaris.
(or things like darwin/arm or ppc64 or arm64)

So do them all.

Note I had to copy the function into tables_nacl.go. I found that
preferable to creating a new file just to have suitable build
tags. It's likely this function will be mirrored to plan9 and windows
later too, each of the 4 with their own policy of which error values
are common.

The corresponding x/sys CL for this CL is https://golang.org/cl/8190
but it excludes nacl (not in x/sys) and solaris (already broken).

Update Issue #8859

Change-Id: I91902615692b29b69c905edd9e126a26337294f6
Reviewed-on: https://go-review.googlesource.com/8192
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-27 16:58:02 +00:00
Nick Cooper
ec56bad1fc mime: add ExtensionByType method
Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
Reviewed-on: https://go-review.googlesource.com/7444
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-27 16:24:07 +00:00
Brad Fitzpatrick
8047093e5b net: reenable a previously skipped test
Update #8859

Change-Id: I5b0005b308e83954a495f06d27b7d8d30e813820
Reviewed-on: https://go-review.googlesource.com/8193
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-27 16:15:56 +00:00
Dmitry Vyukov
6b85090139 testing/quick: fix comment
There is no top-level Values function.

Change-Id: I3ea2eea0b5f77f3e1a3f75d1a6472507ef2888bb
Reviewed-on: https://go-review.googlesource.com/8196
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-27 13:00:53 +00:00
Brad Fitzpatrick
6bf00075ad syscall: don't allocate when boxing common Errno values into errors
Fixes #8859

Change-Id: If8098e6edad1f83dc35fa84f4431689e8ee97678
Reviewed-on: https://go-review.googlesource.com/6701
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-27 06:47:27 +00:00
Nigel Tao
180fbb16c4 image/draw: fix golden test for YCbCr.RGBA change.
The previous change was
https://go-review.googlesource.com/#/c/8073/

Change-Id: I0c48502d1ba90fb5d41c5e66346a8e7f4ee87ce7
Reviewed-on: https://go-review.googlesource.com/8151
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-03-27 00:30:14 +00:00
Nigel Tao
2f34e606fa image/color: have YCbCr.RGBA work in 16-bit color, per the Color
interface.

Change-Id: Ie025753df08ae93e7a5095a3426aff15fa2016fd
Reviewed-on: https://go-review.googlesource.com/8073
Reviewed-by: Rob Pike <r@golang.org>
2015-03-26 22:30:55 +00:00
Austin Clements
392336f94e runtime: disallow write barriers in handoffp and callees
handoffp by definition runs without a P, so it's not allowed to have
write barriers. It doesn't have any right now, but mark it
nowritebarrier to disallow any creeping in in the future. handoffp in
turns calls startm, newm, and newosproc, all of which are "below Go"
and make sense to run without a P, so disallow write barriers in these
as well.

For most functions, we've done this because they may race with
stoptheworld() and hence must not have write barriers. For these
functions, it's a little different: the world can't stop while we're
in handoffp, so this race isn't present. But we implement this
restriction with a somewhat broader rule that you can't have a write
barrier without a P. We like this rule because it's simple and means
that our write barriers can depend on there being a P, even though
this rule is actually a little broader than necessary. Hence, even
though there's no danger of the race in these functions, we want to
adhere to the broader rule.

Change-Id: Ie22319c30eea37d703eb52f5c7ca5da872030b88
Reviewed-on: https://go-review.googlesource.com/8130
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-26 20:38:59 +00:00
Shenghou Ma
400f58a010 runtime: don't trigger write barrier in newosproc for nacl
This should fix the intermittent calling write barrier with mp.p == nil
failures on the nacl/386 builder.

Change-Id: I34aef5ca75ccd2939e6a6ad3f5dacec64903074e
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7973
Reviewed-by: Austin Clements <austin@google.com>
2015-03-26 19:58:14 +00:00
Rob Pike
8537ccdd7f time: add a thorough example for time.Format
People will still not look at it, but at least we will have a stronger defense.

Change-Id: Ieea6a3d42d06e1067e424e35b87dbcb01c9523cb
Reviewed-on: https://go-review.googlesource.com/7859
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-26 18:44:42 +00:00
Ian Lance Taylor
28074d5baa syscall: change Dup,Dup2,Dup3 to use Syscall, not RawSyscall
This avoids hanging when a Go program uses a FUSE filesystem and the
dup system call has to close a file descriptor.  When dup uses
RawSyscall then the goroutine calling dup will occupy a scheduler slot
(a p structure) during the call, and may block waiting for some other
goroutine to respond to the close call on the FUSE filesystem.
Changing to Syscall avoids the problem.  This makes Dup a tiny bit
slower but is quite unlikely to make a difference for any real
programs.

Fixes #10202.

Change-Id: If6490a8f9b3c9cfed6acbfb4bfd1eaeac62ced17
Reviewed-on: https://go-review.googlesource.com/8095
Reviewed-by: Rob Pike <r@golang.org>
2015-03-26 17:29:08 +00:00
Austin Clements
ec2c7e6659 runtime: use uintXX instead of *byte for si_addr on Darwin
Currently, Darwin's siginfo type uses *byte for the si_addr
field. This results in unwanted write barriers in set_sigaddr. It's
also pointless since it never points to anything real and the get/set
methods return/take uintXX and cast it from/to the pointer.

All other arches use a uint type for this field. Change Darwin to
match. This simplifies the get/set methods and eliminates the unwanted
write barriers.

Change-Id: Ifdb5646d35e1f2f6808b87a3d59745ec9718add1
Reviewed-on: https://go-review.googlesource.com/8086
Reviewed-by: Austin Clements <austin@google.com>
2015-03-26 16:20:32 +00:00
Austin Clements
9b0ea6aa27 runtime: remove write barrier on G in sighandler
sighandler may run during a stop-the-world without a P, so it's not
allowed to have write barriers. Fix the G write to disable the write
barrier (this is safe because the G is reachable from allgs) and mark
the function nowritebarrier.

Change-Id: I907f05d3829e24eeb15fa4d020598af36710e87e
Reviewed-on: https://go-review.googlesource.com/8020
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-26 15:26:29 +00:00
Ian Lance Taylor
222f371118 syscall: regenerate zsyscall_darwin_arm.go
This is mostly straightforward but it does introduce an odd change to
Fchflags and adds the Mlock related functions.  These changes look
correct to me but I don't know why they weren't in the original file.

Change-Id: I1a01e075566d327a78b77e7354c9fb85b6ad1f22
Reviewed-on: https://go-review.googlesource.com/8062
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-26 14:52:01 +00:00
David Crawshaw
e9d9d0befc runtime, runtime/cgo: make needextram a bool
Also invert it, which means it no longer needs to cross the cgo
package boundary.

Change-Id: I393cd073bda02b591a55d6bc6b8bb94970ea71cd
Reviewed-on: https://go-review.googlesource.com/8082
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-26 11:12:25 +00:00
Rob Pike
f338d94285 cmd/go: add $DOLLAR to the predefined variables for go generate
Without some hook like this, it's impossible to get a $ into the generate
command, which is necessary if you're trying to do some shell scripting
or regular expressions.

We could use backslash escaping but that's already tricky enough
because the strings are processed as Go strings. Using $ like this
means we need no more mechanism, just a predefined variable.

We may need to revisit this but I hope we can avoid new quoting rules.

Change-Id: Ieb478c8cc767a866765282472239ed3c1e5669a8
Reviewed-on: https://go-review.googlesource.com/8091
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-26 00:18:51 +00:00
Dave Cheney
e2543ef62c runtime: add runtime.cmpstring and bytes.Compare
Update #10007

Implement runtime.cmpstring and bytes.Compare in asm for arm.

benchmark                                old ns/op     new ns/op     delta
BenchmarkCompareBytesEqual               254           91.4          -64.02%
BenchmarkCompareBytesToNil               41.5          37.6          -9.40%
BenchmarkCompareBytesEmpty               40.7          37.6          -7.62%
BenchmarkCompareBytesIdentical           255           96.3          -62.24%
BenchmarkCompareBytesSameLength          125           60.9          -51.28%
BenchmarkCompareBytesDifferentLength     133           60.9          -54.21%
BenchmarkCompareBytesBigUnaligned        17985879      5669706       -68.48%
BenchmarkCompareBytesBig                 17097634      4926798       -71.18%
BenchmarkCompareBytesBigIdentical        16861941      4389206       -73.97%

benchmark                             old MB/s     new MB/s     speedup
BenchmarkCompareBytesBigUnaligned     58.30        184.95       3.17x
BenchmarkCompareBytesBig              61.33        212.83       3.47x
BenchmarkCompareBytesBigIdentical     62.19        238.90       3.84x

This is a collaboration between Josh Bleecher Snyder and myself.

Change-Id: Ib3944b8c410d0e12135c2ba9459bfe131df48edd
Reviewed-on: https://go-review.googlesource.com/8010
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-25 22:46:39 +00:00
Nigel Tao
a3a193c018 image/internal/imageutil: inline the color.YCbCrToRGB calls.
The image/draw benchmark:
benchmark          old ns/op     new ns/op     delta
BenchmarkYCbCr     1198605       978647        -18.35%

Change-Id: Iacfc21e6f641ecb05adc00b3aec0048f1f43d265
Reviewed-on: https://go-review.googlesource.com/7952
Reviewed-by: Rob Pike <r@golang.org>
2015-03-25 21:01:57 +00:00
Matt Bostock
f279cadfa4 crypto/tls: Correct minimum version in comment
Commit 604fa4d5 made TLS 1.0 the default minimum version. This commit
amends a comment to reflect that.

This is where the default is used in the absence of an explicit version
being set:
edadffa2f3/src/crypto/tls/common.go (L391-L393)

Change-Id: I8f1117ecdddc85bb1cc76a6834026505a380b793
Reviewed-on: https://go-review.googlesource.com/5525
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2015-03-25 12:53:36 +00:00
Alex Brainman
2420926a8a runtime: remove obsolete comment
We do not use SEH to handle Windows exception anymore.

Change-Id: I0ac807a0fed7a5b4c745454246764c524460472b
Reviewed-on: https://go-review.googlesource.com/8071
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-25 02:55:56 +00:00
Shenghou Ma
003dccfac4 runtime, syscall: use the new get_random_bytes syscall for NaCl
The SecureRandom named service was removed in
https://codereview.chromium.org/550523002. And the new syscall
was introduced in https://codereview.chromium.org/537543003.

Accepting this will remove the support for older version of
sel_ldr. I've confirmed that both pepper_40 and current
pepper_canary have this syscall.

After this change, we need sel_ldr from pepper_39 or above to
work.

Fixes #9261

Change-Id: I096973593aa302ade61f259a3a71ebc7c1a57913
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1755
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-25 02:07:09 +00:00
Hyang-Ah (Hana) Kim
41d58c3739 os/exec: post-process lsof output on Android.
lsof is used to inspect the open file desciptors in exec_test.go.
In order to limit the output of lsof to the tested process, the tests use
lsof with the -p option, but the version of lsof in android seems to ignore
it. This change adds a post-processing step to filter out irrelevant entries.

Fixes golang/go#10206.

Change-Id: Ia789b8f5e1e9b95c7b55deac92d0d1fbf3ee74fb
Reviewed-on: https://go-review.googlesource.com/8025
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-25 00:34:37 +00:00
Mikio Hara
4d54f27b35 net/internal/socktest: new package
Package socktest provides utilities for socket testing.

This package allows test cases in the net package to simulate
complicated network conditions such as that a destination address is
resolvable/discoverable but is not routable/reachable at network layer.
Those conditions are required for testing functionality of timeout,
multiple address families.

Change-Id: Idbe32bcc3319b41b0cecac3d058014a93e13288b
Reviewed-on: https://go-review.googlesource.com/6090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-25 00:13:46 +00:00
Shenghou Ma
16d8b411b2 nacltest.bash: reduce test time by using bootstrapping Go to build fstest_nacl.go
One full round of make.bash is saved with this change.

Change-Id: I8ad1442e9e1255b9abe14dbfec4c903d897d6015
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-24 23:58:14 +00:00
Shenghou Ma
89f4fd3fd0 cmd/6g: fix build for nacl/amd64p32
Change-Id: I3de78f321c99f8f850a304f7d34c85d0fe254c0e
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7975
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 23:57:50 +00:00
Shenghou Ma
1c26176b67 net/url: fix docs for URL.String
Fixes #10227.

Change-Id: I64d5522e76da5a717e3c4169405e5ef35d6c262e
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-24 23:56:43 +00:00
Alexandre Cesaro
cf68fac7e7 mime/quotedprintable: accept badly encoded bytes
RFC 2045 says:
    An "=" followed by two hexadecimal digits, one or both
    of which are lowercase letters in "abcdef", is formally
    illegal. A robust implementation might choose to
    recognize them as the corresponding uppercase letters.

    https://tools.ietf.org/html/rfc2045#page-22

Change-Id: Ibb4b1e4b8bf4fa65ff895ba486a931d90308bf70
Reviewed-on: https://go-review.googlesource.com/7891
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-24 22:35:58 +00:00
Dave Cheney
8fc73a39ef cmd/8g, cmd/internal/gc: fix GO386=387 build
Adjust Thearch.FREG_MIN/MAX when using non sse2 mode in 8g.

Also, gc.Use_sse is treated as a bool, so make it a bool.

Change-Id: I840411605344bb31c32f492b3e6729166c084f0c
Reviewed-on: https://go-review.googlesource.com/7993
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
2015-03-24 21:57:54 +00:00
Robert Griesemer
2c4cf2f6f2 math/big: fix known bug in Float.Float64
- handle exponent over- and underflow
- handle denormalized numbers
- added test cases

Change-Id: I1bbb9904b0c104f54696944e1f57559881f6eeeb
Reviewed-on: https://go-review.googlesource.com/7982
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-03-24 20:34:14 +00:00
Brad Fitzpatrick
0e55f201d6 cmd/dist: add test to usage message's list of commands
Change-Id: Id1edbed38c94e7c1c13a0200c44edf2b9ae5f087
Reviewed-on: https://go-review.googlesource.com/8040
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-24 20:22:23 +00:00
Aram Hăvărneanu
41f9c430f3 runtime, syscall: fix Solaris exec tests
Also fixes a long-existing problem in the fork/exec path.

Change-Id: Idec40b1cee0cfb1625fe107db3eafdc0d71798f2
Reviewed-on: https://go-review.googlesource.com/8030
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 19:51:21 +00:00
Shenghou Ma
75447d0623 cmd/7g: fix linux/arm64 build
REGRT1 and REGRT2 are also reserved on arm64 for runtime (duffzero
and duffcopy).

Change-Id: If098527a7f29d16f94bdcec05fd55950b9076e35
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7977
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 19:48:02 +00:00
Shenghou Ma
7a88c6465b syscall: use Getpgid to emulate Getpgrp on linux
Fixes newly introduced test on linux/arm64 because linux/arm64 doesn't
have the getpgrp syscall. Getpgid(0) is documented to be equivalent to
Getpgrp.

Change-Id: I8f30f4f8de8c32fe04a29c9c4a9330d4e4e6b46d
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8022
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 19:47:20 +00:00
David Crawshaw
b8caed823b runtime: initialize extra M for cgo during mstart
Previously the extra m needed for cgo callbacks was created on the
first callback. This works for cgo, however the cgocallback mechanism
is also borrowed by badsignal which can run before any cgo calls are
made.

Now we initialize the extra M at runtime startup before any signal
handlers are registered, so badsignal cannot be called until the
extra M is ready.

Updates #10207.

Change-Id: Iddda2c80db6dc52d8b60e2b269670fbaa704c7b3
Reviewed-on: https://go-review.googlesource.com/7978
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-03-24 19:39:46 +00:00
Rick Hudson
546a54bb2e runtime: Remove write barrier on g
There are calls to stdcall when the GC thinks the world is stopped
and stdcall write a *g for the CPU profiler. This produces a write
barrier but the GC is not prepared to deal with write barriers when
it thinks the world is stopped. Since the g is on allg it does not
need a write barrier to keep it alive so eliminate the write barrier.

Change-Id: I937633409a66553d7d292d87d7d58caba1fad0b6
Reviewed-on: https://go-review.googlesource.com/7979
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Rick Hudson <rlh@golang.org>
2015-03-24 16:42:39 +00:00
Alex Brainman
9b69196958 runtime: add TestCgoDLLImports
The test is a simple reproduction of issue 9356.

Update #8948.
Update #9356.

Change-Id: Ia77bc36d12ed0c3c4a8b1214cade8be181c9ad55
Reviewed-on: https://go-review.googlesource.com/7618
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-24 05:39:28 +00:00
Shenghou Ma
59b3424cd9 cmd/go: update PE header magic for files generated by GNU ld
Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e32
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7536
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-24 03:24:16 +00:00
Shenghou Ma
4d59d1fcb1 cmd/dist: enable external linking test for windows/amd64
Fixes #4069.

Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e31
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7535
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-24 03:24:01 +00:00
Shenghou Ma
e7df053977 cmd/internal/ld, cmd/6l: external linking for windows/amd64
Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e30
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7534
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-24 03:23:49 +00:00
Shenghou Ma
484d9399de cmd/dist: enable external linking test for windows/386
Signed-off-by: Shenghou Ma <minux@golang.org>
Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e2f
Reviewed-on: https://go-review.googlesource.com/7284
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-24 03:23:28 +00:00
Shenghou Ma
04642e92ac cmd/internal/ld, cmd/8l: external linking for windows/386
Update #4069: this CL fixes the issue on windows/386.

Signed-off-by: Shenghou Ma <minux@golang.org>
Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e2e
Reviewed-on: https://go-review.googlesource.com/7283
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-24 03:23:16 +00:00
Shenghou Ma
b6ed943bef runtime: use _main instead of main on windows/386
windows/386 also wants underscore prefix for external names.
This CL is in preparation of external linking support.

Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e2d
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7282
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-24 03:23:03 +00:00
Shenghou Ma
6112e6e404 cmd/internal/ld, runtime: record argument size for cgo_dynimport stdcall syscalls
When external linking, we must link to implib provided by mingw, so we must use
properly decorated names for stdcalls.

Because the feature is only used in the runtime, I've designed a new decoration
scheme so that we can use the same decorated name for both 386 and amd64.

A stdcall function named FooEx from bar16.dll which takes 3 parameters will be
imported like this:
	//go:cgo_import_dynamic runtime._FooEx FooEx%3 "bar16.dll"
Depending on the size of uintptr, the linker will later transform it to _FooEx@12
or _FooEx@24.

This is in prepration for the next CL that adds external linking support for
windows/386.

Change-Id: I2d2ea233f976aab3f356f9b508cdd246d5013e2c
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7163
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-24 03:22:26 +00:00
Shenghou Ma
398f56fe22 os/signal: skip TestCtrlBreak on windows/386 temporarily
Update #10215.

Change-Id: Ib588f90279a4ef5461492553d50ad77c742b3560
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7971
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-24 01:38:05 +00:00
Nigel Tao
7180cfa864 image/internal/imageutil: generate subsample-ratio-specific code.
This is in preparation for inlining the color.YCbCrToRGB calls in a
follow-up change.

Change-Id: I30750ace11a8ef6016b3c1e0b4bfdbcc8151f9a5
Reviewed-on: https://go-review.googlesource.com/7951
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 01:01:20 +00:00
Matthew Dempsky
f1878c0d46 debug/dwarf, encoding/asn1, go/ast: fix old comments
The debug/dwarf and encoding/asn1 examples were added in 2009, a few
months before Go added implicit semicolons, and never updated.

The go/ast node types have always been named just "Expr", "Stmt", and
"Decl", so the comments about "ExprNode", "StmtNode", and "DeclNode"
were likely just mistaken because the interface tag methods are
"exprNode", "stmtNode", and "declNode", respectively.

Change-Id: I9d138cc3a16c1a51453da1406914d7b320bf6270
Reviewed-on: https://go-review.googlesource.com/7980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-24 00:09:30 +00:00
Matthew Dempsky
717cb74907 cmd/internal/ld: edit into more idiomatic Go code
Instead of reimplementing chained hash tables, just use maps.

Use bool instead of uint8 for variables only set to 0 or 1.

Fix parsing of `import foo "foo" // indirect` lines.  Previously, this
was treated as an import of package path `"foo" // indirect`, which
could result in the cycle-detection code failing to detect a cycle
because it would be treated as a separate package from `"foo"`.

Also, since there are theoretically multiple quoted forms for a
package path, use strconv.Unquote to normalize them.  Side benefit:
Unquote will complain if any trailing comments sneak back in.

Aside: For most Go archives, Go package data is only present in the
__.PKGDEF member, but unless -u is used, ldpkg is only called on the
_go_.6 member.  Consequently, importcycles is a no-op when -u isn't
used as it has no package data to inspect.

Change-Id: I7076cf91a66726a8d9c5676adfea13c5532001fa
Reviewed-on: https://go-review.googlesource.com/7002
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-24 00:01:40 +00:00
Nigel Tao
b2f29511dd image/internal/imageutil: new package, used by image/draw and image/jpeg.
The imageutil.DrawYCbCr function lives in an internal package because it
is needed by both the image/draw and image/jpeg packages, but it doesn't
seem right for one of those two to depend on the other.

It could eventually go into the image package, but that would require
committing to an API for the rest of Go 1.x.

Change-Id: I7b12555c970d86409365e99eef9360702aaffa30
Reviewed-on: https://go-review.googlesource.com/7925
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-23 23:22:58 +00:00
Sebastien Binet
db454afd23 cmd/go: allow go get with local path
Previously, running 'go get' with a local path would correctly
download the package but fail to install it.
This is because a sticky error - resulting from discovering that the
package needed to be downloaded - was still around.
Theoretically, such sticky errors would be cleared but they weren't
because the map tracking these errors were indexed with the correct
canonical import path of the package (e.g. "ex.com/x/pkg") whereas the
clearing was done with the local path (e.g. "./pkg".)

Always use the canonical import path.

Fixes #9767

Change-Id: Ia0e8a51ac591d4c833d11285da5b767ef7ed8ad2
Reviewed-on: https://go-review.googlesource.com/6266
Reviewed-by: Rob Pike <r@golang.org>
2015-03-23 22:14:17 +00:00
Brad Fitzpatrick
fc9a234d9f regexp: fix link to RE2 syntax
Fixes #10224

Change-Id: I21037379b4667575e51ab0b6b683138c505c3f68
Reviewed-on: https://go-review.googlesource.com/7960
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-23 19:17:52 +00:00
David Crawshaw
9ee6baa82a syscall: disable test that forks on darwin/arm
This test was introduced in cl/5130 and broke the darwin/arm builder.

Also check some errors, which was making the failure hard to decipher.

Change-Id: Ifb1d60b9971782cf8d2e979d83f8a81249d7ee9b
Reviewed-on: https://go-review.googlesource.com/7932
Reviewed-by: Rob Pike <r@golang.org>
2015-03-23 17:17:07 +00:00
Joe Harrison
21e47d831b mime: add "image/svg+xml" type for extension ".svg"
Since there is internal usage of svg files in cmd/trace served via
HTTP, add it to the (small) map of mime types.

MIME type as documented at http://www.w3.org/TR/SVG11/mimereg.html

Change-Id: If14f07cbe2e55d8d68af663f30920a530e2e7974
Reviewed-on: https://go-review.googlesource.com/7942
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-23 16:53:00 +00:00
Michael Matloob
93238623e2 regexp: port RE2's bitstate backtracker to the regexp package
This is a port of RE2's bitstate backtracker, which triggers under
the same conditions that the RE2 backtracker triggers.  However I wasn't
sure how to port over some of the optimizations in the RE2 backtracker,
and there is a ~2% penalty on benchmarks that don't trigger the backtracker.

benchmark                                 old ns/op      new ns/op      delta
BenchmarkLiteral                          312            189            -39.42%
BenchmarkNotLiteral                       4435           3001           -32.33%
BenchmarkMatchClass                       5758           4378           -23.97%
BenchmarkMatchClass_InRange               5385           4084           -24.16%
BenchmarkReplaceAll                       5291           3505           -33.76%
BenchmarkAnchoredLiteralShortNonMatch     190            200            +5.26%
BenchmarkAnchoredLiteralLongNonMatch      189            194            +2.65%
BenchmarkAnchoredShortMatch               479            304            -36.53%
BenchmarkAnchoredLongMatch                478            499            +4.39%
BenchmarkOnePassShortA                    791            798            +0.88%
BenchmarkNotOnePassShortA                 3202           1571           -50.94%
BenchmarkOnePassShortB                    614            633            +3.09%
BenchmarkNotOnePassShortB                 2685           881            -67.19%
BenchmarkOnePassLongPrefix                152            154            +1.32%
BenchmarkOnePassLongNotPrefix             505            533            +5.54%
BenchmarkMatchEasy0_32                    139            171            +23.02%
BenchmarkMatchEasy0_1K                    653            1797           +175.19%
BenchmarkMatchEasy0_32K                   12032          13346          +10.92%
BenchmarkMatchEasy0_1M                    462882         461272         -0.35%
BenchmarkMatchEasy0_32M                   15015339       15365238       +2.33%
BenchmarkMatchEasy1_32                    122            168            +37.70%
BenchmarkMatchEasy1_1K                    3339           2612           -21.77%
BenchmarkMatchEasy1_32K                   72330          71721          -0.84%
BenchmarkMatchEasy1_1M                    2545410        2652284        +4.20%
BenchmarkMatchEasy1_32M                   80072063       82609750       +3.17%
BenchmarkMatchMedium_32                   2359           1980           -16.07%
BenchmarkMatchMedium_1K                   75939          58593          -22.84%
BenchmarkMatchMedium_32K                  2450907        2501106        +2.05%
BenchmarkMatchMedium_1M                   78707697       80174418       +1.86%
BenchmarkMatchMedium_32M                  2535146010     2570896441     +1.41%
BenchmarkMatchHard_32                     4297           2960           -31.11%
BenchmarkMatchHard_1K                     133592         88997          -33.38%
BenchmarkMatchHard_32K                    4240445        4336907        +2.27%
BenchmarkMatchHard_1M                     136187006      139350238      +2.32%
BenchmarkMatchHard_32M                    4350855890     4478537306     +2.93%

benchmark                    old MB/s     new MB/s     speedup
BenchmarkMatchEasy0_32       228.74       186.11       0.81x
BenchmarkMatchEasy0_1K       1565.91      569.64       0.36x
BenchmarkMatchEasy0_32K      2723.31      2455.10      0.90x
BenchmarkMatchEasy0_1M       2265.32      2273.22      1.00x
BenchmarkMatchEasy0_32M      2234.68      2183.79      0.98x
BenchmarkMatchEasy1_32       261.08       190.22       0.73x
BenchmarkMatchEasy1_1K       306.59       391.91       1.28x
BenchmarkMatchEasy1_32K      453.03       456.88       1.01x
BenchmarkMatchEasy1_1M       411.95       395.35       0.96x
BenchmarkMatchEasy1_32M      419.05       406.18       0.97x
BenchmarkMatchMedium_32      13.56        16.16        1.19x
BenchmarkMatchMedium_1K      13.48        17.48        1.30x
BenchmarkMatchMedium_32K     13.37        13.10        0.98x
BenchmarkMatchMedium_1M      13.32        13.08        0.98x
BenchmarkMatchMedium_32M     13.24        13.05        0.99x
BenchmarkMatchHard_32        7.45         10.81        1.45x
BenchmarkMatchHard_1K        7.67         11.51        1.50x
BenchmarkMatchHard_32K       7.73         7.56         0.98x
BenchmarkMatchHard_1M        7.70         7.52         0.98x
BenchmarkMatchHard_32M       7.71         7.49         0.97x

Fixes #4154

Change-Id: Iff7fb9507f0872b320d08afc08679751ed1b28bc
Reviewed-on: https://go-review.googlesource.com/2153
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-23 16:17:42 +00:00
Michael MacInnis
f7befa43a3 syscall: Add Foreground and Pgid to SysProcAttr
On Unix, when placing a child in a new process group, allow that group
to become the foreground process group. Also, allow a child process to
join a specific process group.

When setting the foreground process group, Ctty is used as the file
descriptor of the controlling terminal. Ctty has been added to the BSD
and Solaris SysProcAttr structures and the handling of Setctty changed
to match Linux.

Change-Id: I18d169a6c5ab8a6a90708c4ff52eb4aded50bc8c
Reviewed-on: https://go-review.googlesource.com/5130
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-23 15:35:53 +00:00
David Crawshaw
5bf9249eda net/http: enable segfaulting test on darwin/arm
Issue #10043 was resolved by https://golang.org/cl/7072.
This test now passes.

Change-Id: I7bdef63d9ee4edcede23613a14a2ddce14018f34
Reviewed-on: https://go-review.googlesource.com/7931
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-23 14:27:17 +00:00
Mikio Hara
14082fad9b net: fix TestInterfaces, TestInterfaceAddrs on platforms without loopback interface
Fixes #10214.

Change-Id: If29d26c590eb53d4976e0a6ace0ed33aaf0c3e80
Reviewed-on: https://go-review.googlesource.com/7924
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-23 10:00:34 +00:00
Brad Fitzpatrick
a0fb8f8cce net/http: ignore the Unix epoch time in ServeContent
ServeContent ignored zero time.Time{} values when generating
Last-Modified response headers and checking If-Modified-Since request
headers. Do the same for a time.Time representing the Unix epoch zero
value, as this is a common bogus value. Callers who really want to
send that value (incredibly unlikely) can add a nanosecond to it and
it will be truncated to second granularity anyway.

Fixes #9842

Change-Id: I69f697bfc4017404a92a34e3fe57e2711c1e299d
Reviewed-on: https://go-review.googlesource.com/7915
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-03-23 02:16:56 +00:00
Nigel Tao
25bf792197 image/color: add alpha-premultiplied comment.
Change-Id: I9968f53a8286a0e5ccc197a9b5fae499e2f95326
Reviewed-on: https://go-review.googlesource.com/7790
Reviewed-by: Rob Pike <r@golang.org>
2015-03-21 06:15:57 +00:00