1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00
Commit Graph

24984 Commits

Author SHA1 Message Date
Joel Sing
82a9d90eda tests/fixedbugs: make test for issue11656 run known instruction
As detailed in #11910, the current implementation attempts to execute an area
of memory with unknown content. If the memory is executable, the result is
unpredictable - instead, make the test deterministic by attempting to execute
an instruction that is known to trigger a trap on the given architecture.

The new implementation is written by iant@ and provided via #11910.

Update issue #11910

Change-Id: Ia698c36e0dd98a9d9d16a701f60f6748c6faf896
Reviewed-on: https://go-review.googlesource.com/15058
Run-TryBot: Joel Sing <jsing@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-28 04:23:33 +00:00
Didier Spezia
b7fa4f27ba net/http/fcgi: fix panic with malformed params record
As stated in FastCGI specifications:

FastCGI transmits a name-value pair as the length of the name,
followed by the length of the value, followed by the name,
followed by the value.

The current implementation trusts the name and value length
provided in the record, leading to a panic if the record
is malformed.

Added an explicit check on the lengths.

Test case and fix suggested by diogin@gmail.com (Jingcheng Zhang)

Fixes #11824

Change-Id: I883a1982ea46465e1fb02e0e02b6a4df9e529ae4
Reviewed-on: https://go-review.googlesource.com/15015
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-27 06:57:03 +00:00
Joel Sing
c4689579c0 cmd/go: Skip note reading test with linkmode external on openbsd/arm
openbsd/arm does not support external linking - skip the note reading test that
uses linkmode external on this platform. While here, cleanup the code and
consistently use t.Skipf for all platforms that cannot run this test.

Change-Id: I64f0d9e038bc4c993c3d843fc069a0b723a924d6
Reviewed-on: https://go-review.googlesource.com/15054
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-27 01:04:59 +00:00
Robert Griesemer
59129c6a93 math/big: remove some string conversions in Int encoding
Change-Id: I1180aa3d30fb8563c8e6ecefeb3296af0a88f5a6
Reviewed-on: https://go-review.googlesource.com/14998
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-25 22:25:52 +00:00
Robert Griesemer
7fa5a11ea1 math/big: move Int/Rat gob/json/xml functionality in separate files
Like int/rat/float conversions, move this functionality into separate
implementation and test files.

No implementation changes besides the move.

Change-Id: If19c45f5a72a57b95cbce2329724693ae5a4807d
Reviewed-on: https://go-review.googlesource.com/14997
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-25 22:25:36 +00:00
Robert Griesemer
e937eeeccd math/big: removed more unnecessary string conversions
- renamed (nat) itoa to utoa (since that's what it is)
- added (nat) itoa that takes a sign parameter; this helps removing a few string copies
- used buffers instead of string+ in Rat conversions

Change-Id: I6b37a6b39557ae311cafdfe5c4a26e9246bde1a9
Reviewed-on: https://go-review.googlesource.com/14995
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-25 22:25:12 +00:00
Robert Griesemer
8d701f092d math/big: implement Int.Text, Int.Append
This makes the Int conversion routines match the respective strconv
and big.Float conversion routines.

Change-Id: I5cfcda1632ee52fe87c5bb75892bdda76cc3af15
Reviewed-on: https://go-review.googlesource.com/14994
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-25 22:24:49 +00:00
Mikio Hara
707b619c3a syscall: fix alignment check for link-layer information on BSD variants
When link-layer information is wrapped with sockaddr_dl, we need to
follow the len field of sockaddr_dl. When link-layer information is
naked, we need to use the length of whole link-layer information.

Fixes #12641.

Change-Id: I4d377f64cbab1760b993fc55c719288616042bbb
Reviewed-on: https://go-review.googlesource.com/14939
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-25 22:00:27 +00:00
Rob Pike
81fada52a6 doc: go1.6.txt: bufio.ErrFinalToken
Change-Id: I2714faa6e8aa7b81a05f0e015b045a57407d808d
Reviewed-on: https://go-review.googlesource.com/14996
Reviewed-by: Rob Pike <r@golang.org>
2015-09-25 21:57:01 +00:00
Rob Pike
ec12754700 bufio: fix scanning with a final empty token.
The Scan function's interface to the split function was not sufficient
to handle an empty final token in a pure function; state was required.
This was ugly.

We introduce a special error value that a split function can return
that signals that this token is OK, but is the last one and scanning
should stop immediately _after_ this token.

The same effect could be achieved using the same trick (a special
error value) and checking for that error after Scan finishes, but it's
a little clumsy. Providing a published sentinel value in bufio is
cleaner and means everyone can use the same trick. The result
is an error-free scan.

Rewrite the test (that was only barely working) to use the value
and be more robust.

Also write a new example showing how to do it.

Fixes #11836

Change-Id: Iaae77d0f95b4a2efa0175ced94d93c66353079e8
Reviewed-on: https://go-review.googlesource.com/14924
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-25 21:46:13 +00:00
Shawn Walker-Salas
dc6df1b070 cmd/go: elide -rpath when not applicable and used via LDFLAGS
Some linker flags should only be applied when performing the final
linking step for a shared library or executable, etc. In other
contexts, they're either invalid, or meaningless to apply (so should
not be specified).

When an external linker is used (either directly by Go or by the
compiler driver used by cgo), -rpath and -rpath-link should only be
specified in the final linking step.  On platforms such as Solaris,
ld(1) will reject its use in any other scenario (such as when linking
relocatable objects).

This change is necessary because Go does not currently offer a way to
specify LDFLAGS based on when they should be applied.

Fixes #12115

Change-Id: If35a18d8eee8ec7ddcca2d4ccd41ab6ffcf93b41
Reviewed-on: https://go-review.googlesource.com/14674
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-25 17:53:00 +00:00
Robert Griesemer
b07a9efa78 math/big: faster string conversion routines
Eliminated unnecessary string conversions throughout and removed
(internal) capability for arbitrary character sets in conversion
routines (functionality was not exported and not used internally).

benchmark                         old ns/op     new ns/op     delta
BenchmarkDecimalConversion-8      198283        187085        -5.65%
BenchmarkStringPiParallel-8       46116         47822         +3.70%
BenchmarkString10Base2-8          216           166           -23.15%
BenchmarkString100Base2-8         886           762           -14.00%
BenchmarkString1000Base2-8        7296          6625          -9.20%
BenchmarkString10000Base2-8       72371         65563         -9.41%
BenchmarkString100000Base2-8      725849        672766        -7.31%
BenchmarkString10Base8-8          160           114           -28.75%
BenchmarkString100Base8-8         398           309           -22.36%
BenchmarkString1000Base8-8        2650          2244          -15.32%
BenchmarkString10000Base8-8       24974         21745         -12.93%
BenchmarkString100000Base8-8      245457        217489        -11.39%
BenchmarkString10Base10-8         337           288           -14.54%
BenchmarkString100Base10-8        1298          1046          -19.41%
BenchmarkString1000Base10-8       6200          5752          -7.23%
BenchmarkString10000Base10-8      24942         22589         -9.43%
BenchmarkString100000Base10-8     8012921       7947152       -0.82%
BenchmarkString10Base16-8         156           107           -31.41%
BenchmarkString100Base16-8        344           255           -25.87%
BenchmarkString1000Base16-8       2067          1705          -17.51%
BenchmarkString10000Base16-8      19026         16112         -15.32%
BenchmarkString100000Base16-8     184038        163457        -11.18%

Change-Id: I68bd807529bd9b985f4b6ac2a87764bcc1a7d2f7
Reviewed-on: https://go-review.googlesource.com/14926
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-24 23:07:47 +00:00
Rob Pike
007fa019a3 cmd/doc: don't stop after first package if the symbol is not found
The test case is
	go doc rand.Float64
The first package it finds is crypto/rand, which does not have a Float64.
Before this change, cmd/doc would stop there even though math/rand
has the symbol. After this change, we get:

	% go doc rand.Float64
	package rand // import "math/rand"

	func Float64() float64

	    Float64 returns, as a float64, a pseudo-random number in [0.0,1.0) from the
	    default Source.
	%

Another nice consequence is that if a symbol is not found, we might get
a longer list of packages that were examined:

	% go doc rand.Int64
	doc: no symbol Int64 in packages crypto/rand, math/rand
	exit status 1
	%

This change introduces a coroutine to scan the file system so that if
the symbol is not found, the coroutine can deliver another path to try.
(This is darned close to the original motivation for coroutines.)
Paths are delivered on an unbuffered channel so the scanner does
not proceed until candidate paths are needed.

The scanner is attached to a new type, called Dirs, that caches the results
so if we need to scan a second time, we don't walk the file system
again. This is significantly more efficient than the existing code, which
could scan the tree multiple times looking for a package with
the symbol.

Change-Id: I2789505b9992cf04c19376c51ae09af3bc305f7f
Reviewed-on: https://go-review.googlesource.com/14921
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-24 23:04:37 +00:00
Robert Griesemer
3f7c3e01db math/big: fix test for denormalized inputs and enable more test cases
Also: removed unnecessary BUG comment (was fixed).

Change-Id: I8f11fbcb4e30a19ec5a25df742b3e25e2ee7f846
Reviewed-on: https://go-review.googlesource.com/14923
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-24 22:23:55 +00:00
Marvin Stenger
44ab8bab1c compile/internal/gc,internal/obj: remove some usages of obj.Bool2int
Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Iea8c7bba2401f61ddf2caffc4bece2c293d10f74
Reviewed-on: https://go-review.googlesource.com/14951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 15:39:50 +00:00
Marvin Stenger
550b7ccf77 cmd/link/internal/ld: removed some uses of stringsCompare
Only one use of stringsCompare is left. Cannot simply be replaced by
strings.Compare for bootstrapping reasons I guess.
Moving the function away from util.go to the actual destination data.go
also would not help much. So I left this one unchanged for readability and convenience.

Change-Id: I60d22fec0be8f8c47c80586436f9a550af59194e
Reviewed-on: https://go-review.googlesource.com/14953
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 15:05:04 +00:00
Marvin Stenger
ffe743945f cmd/compile/internal/gc: move functions from util.go to lex.go
Moves the functions:
        isSpace(int) bool
        isAlpha(int) bool
        isDigit(int) bool
        isAlnum(int) bool
        plan9quote(string) string

Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I6f946981abb6f29b047ad90d5c117847e826789f
Reviewed-on: https://go-review.googlesource.com/14952
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-24 14:45:28 +00:00
Marvin Stenger
d08f34e744 cmd/compile/internal/gc: convert return values from int to bool
Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I895350987661c1855803d1594dbab16068f8d1bc
Reviewed-on: https://go-review.googlesource.com/14873
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 12:54:22 +00:00
Francisco Claude
8560ead38a multipart: fixes problem parsing mime/multipart of certain lengths
When parsing the multipart data, if the delimiter appears but doesn't
finish with -- or \n or \r\n, it assumes the data can be consumed. This
is incorrect when the peeking buffer finishes with --delimiter-

Fixes #12662

Change-Id: I329556a9a206407c0958289bf7a9009229120bb9
Reviewed-on: https://go-review.googlesource.com/14652
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-24 09:00:52 +00:00
Joe Tsai
d1b1487a64 archive/tar: remove dead code with USTAR path splitting
Convert splitUSTARPath to return a bool rather than an error since
the caller never ever uses the error other than to check if it is
nil. Thus, we can remove errNameTooLong as well.

Also, fold the checking of the length <= fileNameSize and whether
the string is ASCII into the split function itself.

Lastly, remove logic to set the MAGIC since that's already done on
L200. Thus, setting the magic is redundant.

There is no overall logic change.

Updates #12638

Change-Id: I26b6992578199abad723c2a2af7f4fc078af9c17
Reviewed-on: https://go-review.googlesource.com/14723
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
2015-09-23 23:55:13 +00:00
Shenghou Ma
2c96e5d2fc cmd/dist: fix build after "go test" argument order change
Change-Id: I332cd4a4b48cbb52d2beeb16c4a24833bb7069d7
Reviewed-on: https://go-review.googlesource.com/14890
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-23 23:10:14 +00:00
Robert Griesemer
c720875b76 spec: minor adjustment of prose in composite literal section
The prose discussing composite literals referred to the composite
literal type with 'LiteralType', denoting the literal type's EBNF
production explicitly. Changed 'LiteralType' to 'literal type' to
remove the literal (no pun intended) connection and instead mean
the underlying type. Seems a simpler and more readable change
than referring to the underlying type everywhere explicitly.

Fixes #12717.

Change-Id: I225df95f9ece2664b19068525ea8bda5ca05a44a
Reviewed-on: https://go-review.googlesource.com/14851
Reviewed-by: Rob Pike <r@golang.org>
2015-09-23 21:26:10 +00:00
Rob Pike
c0486b1293 doc: go1.6.txt: go test flag changes
Change-Id: Icb52589909776fbe195ef2502ec7c0a4b590f350
Reviewed-on: https://go-review.googlesource.com/14859
Reviewed-by: Rob Pike <r@golang.org>
2015-09-23 21:23:34 +00:00
Rob Pike
6acb4d944d cmd/go: fix processing of flags for test binaries.
The usage message says:

	test [-c] [-i] [build and test flags] [packages] [flags for test binary]

but this was not what was implemented. Instead, after packages are named,
flag processing continues, which makes it impossible, for example, to pass
to the binary a flag with the same name as a test flag. This was triggered
by the -v flag in glog.

Consider this test:

package pkg

... imports ...

var v = flag.Int("v", 0, "v flag")

func TestFoo(t *testing.T) {
	if *v != 7 { log.Fatal(*v) }
}

Attempting to run this test with go test pkg -v=7 would give a usage
message. This change allows it. In fact it allows

	go test -v pkg -v=7

The solution is to implement the usage message. One compatibility
issue is that flags after the package name are no longer processed
as test flags, so this no longer works:

	go test foo -cover

One must write

	go test -cover foo

I do not think this is onerous but it must be called out in the
release notes.

Fixes #12177.

Change-Id: Ib9267884b47a6b0c183efa888ec78333272113aa
Reviewed-on: https://go-review.googlesource.com/14826
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-23 21:21:40 +00:00
Robert Griesemer
0befa47ae8 strconv: slightly simplified roundShortest; better comments
Change-Id: If886f15468680f7e1c589873066b4391eb9784b5
Reviewed-on: https://go-review.googlesource.com/14856
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-23 21:14:29 +00:00
Robert Griesemer
59a6ba5634 math/big: factored out an internal accessor method (cleanup), added benchmark
Current result of DecimalConversion benchmark (for future reference):

BenchmarkDecimalConversion-8	   10000	    204770 ns/op

Measured on Mac Mini (late 2012) running OS X 10.10.5,
2.3 GHz Intel Core i7, 8 GB 1333 MHz DDR3.

Also: Removed comment suggesting to implement decimal by representing
digits as numbers 0..9 rather than ASCII chars '0'..'9' to avoid
repeated +/-'0' operations. Tried and it appears (per above benchmark)
that the +/-'0' operations are neglibile but the addition conversion
passes around it are not and that it makes things significantly slower.

Change-Id: I6ee033b1172043248093cc5d02abff5fc54c2e7a
Reviewed-on: https://go-review.googlesource.com/14857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-23 20:25:59 +00:00
Shenghou Ma
53c92f95a8 os: document that behavior of Seek on O_APPEND files is not specified
The actual behavior varies across platforms, and due to the inherent
race, we can't do anything better (other than to always return 0).

Fixes #12710.

Change-Id: Icb52f0f1f0a267e0f9f70767cae427f3f0239965
Reviewed-on: https://go-review.googlesource.com/14881
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-23 17:06:02 +00:00
Shenghou Ma
604fbab3f1 runtime: fix incomplete sentence in comment
Fixes #12709.

Change-Id: If5a2536458fcd26d6f003dde1bfc02f86b09fa94
Reviewed-on: https://go-review.googlesource.com/14793
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-23 17:05:39 +00:00
Robert Griesemer
4fc9565ffc math/big: implement negative precision for Float.Append/Text
Enabled all but a handful of disabled Float formatting test cases.

Fixes #10991.

Change-Id: Id18e160e857be2743429a377000e996978015a1a
Reviewed-on: https://go-review.googlesource.com/14850
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-23 16:45:38 +00:00
Alex Brainman
d02a4c1d60 runtime: test that timeBeginPeriod succeeds
Change-Id: I5183f767dadb6d24a34d2460d02e97ddbaab129a
Reviewed-on: https://go-review.googlesource.com/12546
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-23 09:01:08 +00:00
Joe Tsai
b0a1f6462f compress/gzip: detect truncated streams
Reader fails to detect truncated streams since calls to io.ReadFull
do not check if the error is io.EOF.

Change-Id: I052cd03161e43fec17e3d328106c40e17923e52b
Reviewed-on: https://go-review.googlesource.com/14832
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-23 08:29:13 +00:00
Joe Tsai
9deb940d24 compress/flate: detect truncated streams
Reader failed to detect truncated streams since calls to
io.ReadFull did not check if the error is io.EOF.

Change-Id: I0634e0d8de1ab04e8f93242c27a9f89e57743e87
Reviewed-on: https://go-review.googlesource.com/14833
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-23 08:28:17 +00:00
Alex Brainman
646401bdf0 os: add check for ERROR_BAD_NETPATH in windows IsNotExist
Otherwise IsNotExist does not account for not existent servers and shares.

Fixes #12374

Change-Id: I37f6850198f91dcb02a4a917b793339d7e30e934
Reviewed-on: https://go-review.googlesource.com/14579
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-23 04:51:45 +00:00
Chris Broadfoot
c604f48d24 doc: document go1.4.3
Change-Id: Ib1bfe4038e2b125a31acd9ff7772e462b0a6358f
Reviewed-on: https://go-review.googlesource.com/14852
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-23 04:01:40 +00:00
Seth Hoenig
226aaf4267 regexp: add runnable example to regex.Split
The existing comment for regex.Split contains a plain text example,
while many of the other regex functions have runnable examples. This
change provides a runnable example for Split.

Change-Id: I5373f57f532fe843d7d0adcf4b513061ec797047
Reviewed-on: https://go-review.googlesource.com/14737
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-23 03:29:32 +00:00
Andrew Gerrand
143f3fd0ee encoding/json: spell "marshaling" and "unmarshaling" consistently
Fixes #12431

Change-Id: I67c42bf2cd9285f471387248fd9c22a16b158349
Reviewed-on: https://go-review.googlesource.com/14150
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-09-23 00:48:35 +00:00
Robert Griesemer
7b7f85534c test/fixedbugs: update overly restrictive test case
See discussion in https://go-review.googlesource.com/14830 .

Change-Id: I94f25f92b8cdaa509d2c335865a645228425804d
Reviewed-on: https://go-review.googlesource.com/14837
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-22 17:54:01 +00:00
Austin Clements
b307910b6e runtime: fix offset in invalidptr panic message
Change-Id: I00e1eebbf5e1a01c8fad5ca5324aa8eec1e4d731
Reviewed-on: https://go-review.googlesource.com/14792
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-09-22 16:55:17 +00:00
Ilya Tocar
5cf281a9b7 runtime: optimize duffcopy on amd64
Use movups to copy 16 bytes at a time.
Results (haswell):

name            old time/op  new time/op  delta
CopyFat8-48     0.62ns ± 3%  0.63ns ± 3%     ~     (p=0.535 n=20+20)
CopyFat12-48    0.92ns ± 2%  0.93ns ± 3%     ~     (p=0.594 n=17+18)
CopyFat16-48    1.23ns ± 2%  1.23ns ± 2%     ~     (p=0.839 n=20+19)
CopyFat24-48    1.85ns ± 2%  1.84ns ± 0%   -0.48%  (p=0.014 n=19+20)
CopyFat32-48    2.45ns ± 0%  2.45ns ± 1%     ~     (p=1.000 n=16+16)
CopyFat64-48    3.30ns ± 2%  2.14ns ± 1%  -35.00%  (p=0.000 n=20+18)
CopyFat128-48   6.05ns ± 0%  3.98ns ± 0%  -34.22%  (p=0.000 n=18+17)
CopyFat256-48   11.9ns ± 3%   7.7ns ± 0%  -35.87%  (p=0.000 n=20+17)
CopyFat512-48   23.0ns ± 2%  15.1ns ± 2%  -34.52%  (p=0.000 n=20+18)
CopyFat1024-48  44.8ns ± 1%  29.8ns ± 2%  -33.48%  (p=0.000 n=17+19)

Change-Id: I8a78773c656d400726a020894461e00c59f896bf
Reviewed-on: https://go-review.googlesource.com/14836
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-22 15:02:37 +00:00
Robert Griesemer
b5d94b7d41 math/big: add test cases for min/max exponent values
Change-Id: I2e74e39628285e2fecaab712be6cff230619a6c2
Reviewed-on: https://go-review.googlesource.com/14778
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-22 07:59:02 +00:00
Robert Griesemer
16b3675bc8 math/big: optimize Float.Parse by reducing powers of 10 to powers of 2 and 5
Instead of computing the final adjustment factor as a power of 10,
it's more efficient to split 10**e into 2**e * 5**e . Powers of 2
are trivially added to the Float exponent, and powers of 5 are
smaller and thus faster to compute.

Also, use a table of uint64 values rather than float64 values for
initial power value. uint64 values appear to be faster to convert
to Floats (useful for small exponents).

Added two small benchmarks to confirm that there's no regresssion.

benchmark                         old ns/op     new ns/op     delta
BenchmarkParseFloatSmallExp-8     17543         16220         -7.54%
BenchmarkParseFloatLargeExp-8     60865         59996         -1.43%

Change-Id: I3efd7556b023316f86f334137a67fe0c6d52f8ef
Reviewed-on: https://go-review.googlesource.com/14782
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-22 05:48:02 +00:00
Robert Griesemer
c396c047c6 src/cmd/compile/internal/gc: remove now unnecessary restriction on float exponent parsing
https://go-review.googlesource.com/#/c/13778/ fixed this issue in math/big.
Remove restriction in compiler.

Fixes #11326.

Change-Id: I1429d0dd0d79431706c65616413373fff58f081e
Reviewed-on: https://go-review.googlesource.com/14830
Reviewed-by: Rob Pike <r@golang.org>
2015-09-22 00:22:49 +00:00
Nathan Otterness
66c25fa9be image/png: integer underflow when decoding
This change addresses an integer underflow appearing only on systems
using a 32-bit int type. The patch addresses the problem by limiting the
length of unknown chunks to 0x7fffffff. This value appears to already be
checked for when parsing other chunk types, so the bug shouldn't appear
elsewhere in the package. The PNG spec recommends the maximum size for
any chunk to remain under 2^31, so this shouldn't cause errors with
valid images.

Fixes #12687

Change-Id: I17f0e1683515532c661cf2b0b2bc65309d1b7bb7
Reviewed-on: https://go-review.googlesource.com/14766
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-21 23:09:22 +00:00
Rob Pike
980cb0caf2 cmd/asm: fix crash triggered by nested #define
A panic was in place for an impossible condition that turned
out to be possible if one used a macro to define a macro.

Another go-fuzz "win".

Fixes #12654.

Change-Id: I0a7bb0f0eabb260c986bf7a2288860c78d8db1af
Reviewed-on: https://go-review.googlesource.com/14777
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-21 22:38:39 +00:00
Håvard Haugen
bca70a66a7 cmd/compile/internal/gc: use sort.Interface for reflect methods
Generate slices of method *Sig(nature)s instead of linked lists.
Remove custom lsort function in favor of sort.Interface.

Eliminates another use of stringsCompare.

Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I9ed1664b7f55be9e967dd7196e396a76f6ea3422
Reviewed-on: https://go-review.googlesource.com/14559
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-21 22:27:53 +00:00
Rob Pike
ebd96933c1 cmd/vet: build the binary only once in the test
Recent changes caused vet to build the binary for each Test function.
This is wasteful and will become only more so as more tests are added.
Use testing.Main to build only once.

Verified that compilation errors still appear if the binary cannot be
built.

Before:
	real	0m11.169s
	user	0m18.328s
	sys	0m2.152s

After:
	real	0m5.132s
	user	0m9.404s
	sys	0m1.168s

Of course if the compiler were fast we might not notice, but vet is
a big program and growing bigger all the time, as are the tests.

Change-Id: I209a8fdcace94bc5cec946f5dd365d7191f44c02
Reviewed-on: https://go-review.googlesource.com/14822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-21 20:20:32 +00:00
Tarmigan Casebolt
c07ec392ac go/printer: avoid stomping on err before checking it
Change-Id: I97ba31e758d3396842ad99a08af696e49a5f1a7d
Reviewed-on: https://go-review.googlesource.com/13954
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-09-21 19:29:26 +00:00
Rob Pike
7454f53604 cmd/vet: copy changes from golang.org/x/tools to cmd/vet
This means bringing over the examples flag and sorting doc.go.

Subsequent changes will generalize the examples flag to a general
test naming flag, but let's start with the original code.

No more changes to golang.org/x/tools please. This should not have
happened (and letting it happen was partly my fault).

Change-Id: Ia879ea1d15d82372df14853f919263125dfb7b96
Reviewed-on: https://go-review.googlesource.com/14821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-21 17:48:38 +00:00
Rob Pike
4e99ed6fef cmd/doc: don't drop const/var block if first entry is unexported
The code assumed that if the first entry was unexported, all the
entries were. The fix is simple: delete a bunch of code.

Fixes #12286.

Change-Id: Icb09274e99ce97df4d8bddbe59d17a5c0622e4c6
Reviewed-on: https://go-review.googlesource.com/14780
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-21 16:42:09 +00:00
Marvin Stenger
fcf8143d63 encoding/json: scanner: use byte, more consistent
The fields step and redoState of struct scanner are now defined as
`func(s *scanner, c byte) int` instead of
`func(s *scanner, c int) int`, since bytes are sufficient.
Further changes improve the consistency in the scanner.go file.

Change-Id: Ifb85f2130d728d2b936d79914d87a1f0b5c6ee7d
Reviewed-on: https://go-review.googlesource.com/14801
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-21 01:55:52 +00:00