1
0
mirror of https://github.com/golang/go synced 2024-11-08 15:16:25 -07:00
Commit Graph

33586 Commits

Author SHA1 Message Date
Justin Nuß
9fbc06e6aa encoding/csv: preserve \r\n in quoted fields
The parser mistakenly assumed it could always fold \r\n into \n, which
is not true since a \r\n inside a quoted fields has no special meaning
and should be kept as is.

Fix this by not folding \r\n to \n inside quotes fields.

Fixes #21201

Change-Id: Ifebc302e49cf63e0a027ee90f088dbc050a2b7a6
Reviewed-on: https://go-review.googlesource.com/52810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 18:42:20 +00:00
Daniel Martí
f9cf8e5ab1 net/http: various small cleanups
* Remove an unnecessary type conversion
* Make golint happier about consistent receiver names
* Make golint happier about a foo_bar var name

Change-Id: I5223808109f6f8b69ed4be76de82faf2478c6a2e
Reviewed-on: https://go-review.googlesource.com/54530
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-08-14 16:37:27 +00:00
Alberto Donizetti
cc4aac2b9b cmd/compile/internal/syntax: fix 'delimiters' spelling
Change-Id: Iffb52a0bdc479642eda3b5a12ba5da6590d0f0ec
Reviewed-on: https://go-review.googlesource.com/55330
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-08-14 14:13:22 +00:00
griesemer
5abc8c897c spec: better comment in example for type definition
The old comment for the example

	type PtrMutex *Mutex

talked about the method set of the base type of PtrMutex.
It's more direct and clearer to talk about the underlying
type of PtrMutex for this specific example.
Also removed link inside pre-formatted region of text.

Fixes #20900.

Change-Id: Ie37340e53670e34ebe13e780ba8ccb1bba67795c
Reviewed-on: https://go-review.googlesource.com/55070
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14 13:35:43 +00:00
Martin Möhrmann
629b5e7561 fmt: add ascii fast path for decoding verbs
name                    old time/op  new time/op  delta
SprintfSlowParsingPath   108ns ± 4%   103ns ± 4%  -4.53%  (p=0.000 n=18+18)

Change-Id: I174463f303d1857e8d5b8a6283c025b3546e7b39
Reviewed-on: https://go-review.googlesource.com/44450
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-08-14 12:25:45 +00:00
Carlos Eduardo Seo
6661cf6dfd runtime, internal/cpu: CPU capabilities detection for ppc64x
This change replaces the current runtime capabilities check for ppc64x with the
new internal/cpu package. It also adds support for the new POWER9 ISA and
capabilities.

Updates #15403

Change-Id: I5b64a79e782f8da3603e5529600434f602986292
Reviewed-on: https://go-review.googlesource.com/53830
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 12:16:42 +00:00
Joe Tsai
01385b1bb6 archive/tar: adjust bytediff to print full context
Since test files don't exceed 10KiB, print the full context of the diff,
including bytes that are equal.
Also, fix the labels for got and want; they were backwards before.

Change-Id: Ibac022e5f988d26812c3f75b643cae8b95603fc9
Reviewed-on: https://go-review.googlesource.com/55151
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-14 06:27:44 +00:00
Joe Tsai
7ae9561610 archive/tar: implement specialized logic for PAX format
Rather than going through writeHeader, which attempts to handle all formats,
implement writePAXHeader, which only has an understanding of the PAX format.

In PAX, the USTAR header is filled out in a best-effort manner.
Thus, we change logic of formatString and formatOctal to try their best to
output something (possibly truncated) in the event of an error.

The new implementation of PAX headers causes several tests to fail.
An investigation into the new output reveals that the new behavior is correct,
while the tests had actually locked in incorrect behavior before.

A dump of the differences is listed below (-before, +after):

<< writer-big.tar >>

This change is due to fact that we changed the Header.Devminor to force the
tar.Writer to choose the GNU format over the PAX one.
The ability to control the output is an open issue (see #18710).
- 00000150  00 30 30 30 30 30 30 30  00 00 00 00 00 00 00 00  |.0000000........|
+ 00000150  00 ff ff ff ff ff ff ff  ff 00 00 00 00 00 00 00  |................|

<< writer-big-long.tar>>

The previous logic generated the GNU magic values for a PAX file.
The new logic correctly uses the USTAR magic values.
- 00000100  00 75 73 74 61 72 20 20  00 00 00 00 00 00 00 00  |.ustar  ........|
- 00000500  00 75 73 74 61 72 20 20  00 67 75 69 6c 6c 61 75  |.ustar  .guillau|
+ 00000100  00 75 73 74 61 72 00 30  30 00 00 00 00 00 00 00  |.ustar.00.......|
+ 00000500  00 75 73 74 61 72 00 30  30 67 75 69 6c 6c 61 75  |.ustar.00guillau|

The previous logic tried to use the specified timestmap in the PAX headers file,
but this is problematic as this timestamp can overflow, defeating the point
of using PAX, which is intended to extend tar.
The new logic uses the zero timestamp similar to what GNU and BSD tar do.
- 00000080  30 30 30 30 32 33 32 00  31 32 33 33 32 37 37 30  |0000232.12332770|
+ 00000080  30 30 30 30 32 35 36 00  30 30 30 30 30 30 30 30  |0000256.00000000|

The previous logic populated the devminor and devmajor fields.
The new logic leaves them zeroed just like what GNU and BSD tar do.
- 00000140  00 00 00 00 00 00 00 00  00 30 30 30 30 30 30 30  |.........0000000|
- 00000150  00 30 30 30 30 30 30 30  00 00 00 00 00 00 00 00  |.0000000........|
+ 00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+ 00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

The previous logic uses PAX headers, but fails to add a record for the size.
The new logic does properly add a record for the size.
- 00000290  31 36 67 69 67 2e 74 78  74 0a 00 00 00 00 00 00  |16gig.txt.......|
- 000002a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+ 00000290  31 36 67 69 67 2e 74 78  74 0a 32 30 20 73 69 7a  |16gig.txt.20 siz|
+ 000002a0  65 3d 31 37 31 37 39 38  36 39 31 38 34 0a 00 00  |e=17179869184...|

The previous logic encoded the size as a base-256 field,
which is only valid in GNU, but the previous PAX headers implies this should
be a PAX file. This result in a strange hybrid that is neither GNU nor PAX.
The new logic uses PAX headers to store the size.
- 00000470  37 35 30 00 30 30 30 31  37 35 30 00 80 00 00 00  |750.0001750.....|
- 00000480  00 00 00 04 00 00 00 00  31 32 33 33 32 37 37 30  |........12332770|
+ 00000470  37 35 30 00 30 30 30 31  37 35 30 00 30 30 30 30  |750.0001750.0000|
+ 00000480  30 30 30 30 30 30 30 00  31 32 33 33 32 37 37 30  |0000000.12332770|

<< ustar.issue12594.tar >>

The previous logic used the specified timestamp for the PAX headers file.
The new logic just uses the zero timestmap.
- 00000080  30 30 30 30 32 33 31 00  31 32 31 30 34 34 30 32  |0000231.12104402|
+ 00000080  30 30 30 30 32 33 31 00  30 30 30 30 30 30 30 30  |0000231.00000000|

The previous logic populated the devminor and devmajor fields.
The new logic leaves them zeroed just like what GNU and BSD tar do.
- 00000140  00 00 00 00 00 00 00 00  00 30 30 30 30 30 30 30  |.........0000000|
- 00000150  00 30 30 30 30 30 30 30  00 00 00 00 00 00 00 00  |.0000000........|
+ 00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+ 00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

Change-Id: I33419eb1124951968e9d5a10d50027e03133c811
Reviewed-on: https://go-review.googlesource.com/55231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 06:26:35 +00:00
Hiroshi Ioka
b88e532a9e cmd/cgo: use first error position instead of last one
Just like https://golang.org/cl/34783

Given cgo.go:
     1	package main
     2
     3	/*
     4	long double x = 0;
     5	*/
     6	import "C"
     7
     8	func main() {
     9		_ = C.x
    10		_ = C.x
    11	}

Before:
    ./cgo.go:10:6: unexpected: 16-byte float type - long double

After:
    ./cgo.go:9:6: unexpected: 16-byte float type - long double

The above test case is not portable. So it is tested on only amd64.

Change-Id: If0b84cf73d381a22e2ada71c8e9a6e6ec77ffd2e
Reviewed-on: https://go-review.googlesource.com/54950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14 05:29:11 +00:00
Hiroshi Ioka
5b43bbe63b cmd/link: prefer to use constants in macho.go
We might want to replace some linker's feature by debug/macho in future.
This CL gathers information of required constants.

Change-Id: Iea14abdb32709a4f5404a17874f9c925d29ba999
Reviewed-on: https://go-review.googlesource.com/55252
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 05:28:38 +00:00
Hiroshi Ioka
6424c40c22 cmd/link: don't emit default entry symbol in some situations
Also, fix comment.

Change-Id: Ieb7ba21f34730dc51ab45a652d225e4145d4b861
Reviewed-on: https://go-review.googlesource.com/54870
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14 05:28:22 +00:00
Hiroshi Ioka
d03b89bd41 debug/macho: add some file flags
Fixes #21414

Change-Id: Idff6e269ae32b33253067c9f32cac25256eb7f1c
Reviewed-on: https://go-review.googlesource.com/55251
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 05:27:53 +00:00
Agniva De Sarker
98276d6abe encoding/hex: improve tests
The tests for error scenarios were done by manually checking
error strings. Improved them by checking the actual error type
instead of just the string.

Printing the actual error in case of failure instead of a
generic string.

Also added a new scenario with both an invalid byte and an
invalid length string to verify that the length is checked first
before doing any computation.

Change-Id: Ic2a19a6d6058912632d597590186ee2d8348cb45
Reviewed-on: https://go-review.googlesource.com/55256
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 04:45:52 +00:00
Justin Nuß
5d14ac74f6 encoding/csv: report line start line in errors
Errors returned by Reader contain the line where the Reader originally
encountered the error. This can be suboptimal since that line does not
always correspond with the line the current record/field started at.

This can easily happen with LazyQuotes as seen in #19019, but also
happens for example when a quoted fields has no closing quote and
the parser hits EOF before it finds another quote.

When this happens finding the erroneous field can be somewhat
complicated and time consuming, and in most cases it would be better to
report the line where the record started.

This change updates Reader to keep track of the line on which a record
begins and uses it for errors instead of the current line, making it
easier to find errors.

Although a user-visible change, this should have no impact on existing
code, since most users don't explicitly work with the line in the error
and probably already expect the new behaviour.

Updates #19019

Change-Id: Ic9bc70fad2651c69435d614d537e7a9266819b05
Reviewed-on: https://go-review.googlesource.com/52830
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 04:45:38 +00:00
Hiroshi Ioka
342d25fc05 cmd/link: remove redundant switch stmt
Change-Id: I5c4f8dc1e174b3438ef4fb509fac78d6e1b292c9
Reviewed-on: https://go-review.googlesource.com/54791
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 04:44:35 +00:00
Rob Pike
b1fab09901 cmd/vet: fix a couple of minor word choices in README
No semantic change, just clarifying a bit by choosing better words
in a couple of places.

Change-Id: I4496062ee7909baf83d4d22d25e13ef93b358b4b
Reviewed-on: https://go-review.googlesource.com/55255
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14 04:15:59 +00:00
Tobias Klauser
67c360594f syscall: add utimensat and use it for UtimesNano on BSD and Solaris
All the BSDs and Solaris support the utimensat syscall, but Darwin
doesn't. Account for that by adding the //sys lines not to
syscall_bsd.go but the individual OS's syscall_*.go files and implement
utimensat on Darwin as just returning ENOSYS, such that UtimesNano will
fall back to use utimes as it currently does unconditionally.

This also adds the previously missing utimensat syscall number for
FreeBSD and Dragonfly.

Fixes #16480

Change-Id: I367454c6168eb1f7150b988fa16cf02abff42f34
Reviewed-on: https://go-review.googlesource.com/55130
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-14 04:14:41 +00:00
Kevin Burke
6203a79b52 time: remove unused parameter
lookupName is only called in one location, and one of the return
values is unused, so let's remove it.

Change-Id: I35e22c7ec611e8eb349deb4f0561e212f7d9de0b
Reviewed-on: https://go-review.googlesource.com/55232
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2017-08-14 02:22:20 +00:00
Austin Clements
c8e9fd5db0 Revert "Revert "cmd/compile: discard duplicate inline method bodies""
This reverts commit f612cd704a.

Reason for revert: We thought the original change had broken the
linux/amd64 and linux/386 builders, but it turned out to be a problem
with the build infrastructure, not the change.

Change-Id: Ic3318a63464fcba8d845ac04494115a7ba620364
Reviewed-on: https://go-review.googlesource.com/55050
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-08-14 01:38:08 +00:00
Josh Bleecher Snyder
e0789d734d runtime: remove indentation in mapiternext
Invert the condition and continue, to remove indentation.

Change-Id: Id62a5d9abc9a4df1193bcf15f95f70f2c2e2abac
Reviewed-on: https://go-review.googlesource.com/55091
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 00:52:16 +00:00
Josh Bleecher Snyder
f5804ce4f3 runtime: simplify hashmap tooManyOverflowBuckets
This generates better code.

Masking B in the return statement should be unnecessary,
but the compiler is understandably not yet clever enough to see that.

Someday, it'd also be nice for the compiler to generate
a CMOV for the saturation if statement.

Change-Id: Ie1c157b21f5212610da1f3c7823a93816b3b61b9
Reviewed-on: https://go-review.googlesource.com/54656
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 00:51:48 +00:00
Josh Bleecher Snyder
aca92f352d runtime: CSE some function arguments in evacuate
Shrinks evacuate's machine code a little.

Change-Id: I08874c92abdc7e621bc0737e22f2a6be31542cab
Reviewed-on: https://go-review.googlesource.com/54652
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 00:51:14 +00:00
Josh Bleecher Snyder
a6136ded32 runtime: remove indentation in evacuate
Combine conditions into a single if statement.
This is more readable.

It should generate identical machine code, but it doesn't.
The new code is shorter.

Change-Id: I9bf52f8f288b0df97a2b9b4e4183f6ca74175e8a
Reviewed-on: https://go-review.googlesource.com/54651
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 00:51:02 +00:00
Josh Bleecher Snyder
38044eca7c runtime: make map deletion benchmarks faster to run
This reduces the wall time to run these benchmarks by about 30%.

Change-Id: I494a93c93e5acb1514510d85f65796f62e1629a5
Reviewed-on: https://go-review.googlesource.com/54650
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2017-08-14 00:50:52 +00:00
Austin Clements
9065c3bf34 runtime: support DT_GNU_HASH in VDSO
Currently we only support finding symbols in the VDSO using the old
DT_HASH. These days everything uses DT_GNU_HASH instead. To keep up
with the times and future-proof against DT_HASH disappearing from the
VDSO in the future, this commit adds support for DT_GNU_HASH and
prefers it over DT_HASH.

Tested by making sure it found a DT_GNU_HASH section and all of the
expected symbols in it, and then disabling the DT_GNU_HASH path and
making sure the old DT_HASH path still found all of the symbols.

Fixes #19649.

Change-Id: I508c8b35a019330d2c32f04f3833b69cb2686f13
Reviewed-on: https://go-review.googlesource.com/45511
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-13 22:08:55 +00:00
Audrey Lim
816deacc70 archive/zip: fix Writer to validate file
The ZIP format uses uint16 to contain the length of the file name and
the length of the Extra section. This change verifies that the length
of these fields fit in an uint16 prior to writing the ZIP file. If not,
an error is returned.

Fixes #17402

Change-Id: Ief9a864d2fe16b89ddb9917838283b801a2c58a4
Reviewed-on: https://go-review.googlesource.com/50250
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-13 17:33:10 +00:00
Martin Möhrmann
09ed0f6805 strconv: avoid truncation of output in parse int tests
If needed cast the test table values to a higher bit size
integer type instead of casting the result values of the
tested function to a lower bit size integer type.

Change-Id: Iaa79742b2b1d90c7c7eac324f54032ebea0b1b41
Reviewed-on: https://go-review.googlesource.com/55137
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-13 10:08:42 +00:00
Martin Möhrmann
fee7f2ab16 strings: speed up FieldsFunc
Increases performance of FieldsFunc by recording the start and end
of the fields in an array. The first 32 fields are saved in a pre-allocated
array on the stack. This avoids the old behavior of iterating over the
input string two times but uses more allocations when more than 32 fields
are encountered.

Additionally code for handling non-ASCII containing strings from Fields is
removed and replaced by a call to the new faster FieldsFunc function.

Overall this still leads to a slowdown for Fields on non-ASCII strings
while speeding up Fields in general.

name                      old time/op    new time/op     delta
Fields/ASCII/16              116ns ± 5%      115ns ± 5%       ~     (p=0.480 n=10+10)
Fields/ASCII/256             765ns ± 1%      761ns ± 2%       ~     (p=0.171 n=10+10)
Fields/ASCII/4096           12.5µs ± 1%     12.7µs ± 1%     +1.82%  (p=0.000 n=10+10)
Fields/ASCII/65536           226µs ± 1%      226µs ± 2%       ~     (p=0.739 n=10+10)
Fields/ASCII/1048576        5.12ms ± 1%     5.12ms ± 1%       ~     (p=0.696 n=8+10)
Fields/Mixed/16              172ns ± 1%      233ns ± 1%    +35.90%  (p=0.000 n=9+10)
Fields/Mixed/256            1.18µs ± 2%     2.45µs ± 1%   +107.47%  (p=0.000 n=10+10)
Fields/Mixed/4096           20.3µs ± 1%     43.1µs ± 2%   +112.41%  (p=0.000 n=10+10)
Fields/Mixed/65536           364µs ± 1%      704µs ± 1%    +93.56%  (p=0.000 n=9+10)
Fields/Mixed/1048576        7.07ms ± 2%    13.34ms ± 4%    +88.83%  (p=0.000 n=10+10)
FieldsFunc/ASCII/16          274ns ± 1%      188ns ± 3%    -31.44%  (p=0.000 n=10+10)
FieldsFunc/ASCII/256        3.69µs ± 1%     2.06µs ± 2%    -44.26%  (p=0.000 n=10+10)
FieldsFunc/ASCII/4096       59.9µs ± 1%     35.3µs ± 2%    -41.10%  (p=0.000 n=10+10)
FieldsFunc/ASCII/65536       958µs ± 1%      567µs ± 1%    -40.82%  (p=0.000 n=10+9)
FieldsFunc/ASCII/1048576    16.3ms ± 2%     11.0ms ± 3%    -32.52%  (p=0.000 n=10+10)
FieldsFunc/Mixed/16          309ns ± 1%      213ns ± 0%    -30.98%  (p=0.000 n=10+6)
FieldsFunc/Mixed/256        3.83µs ± 1%     2.14µs ± 1%    -44.01%  (p=0.000 n=10+10)
FieldsFunc/Mixed/4096       66.2µs ± 2%     37.8µs ± 1%    -42.85%  (p=0.000 n=10+10)
FieldsFunc/Mixed/65536      1.09ms ± 1%     0.63ms ± 1%    -42.73%  (p=0.000 n=10+10)
FieldsFunc/Mixed/1048576    18.6ms ± 3%     12.0ms ± 2%    -35.50%  (p=0.000 n=10+10)

Fixes #17856
Fixes #19789

Change-Id: I9f5a560e534566fd81963651f342c8f44cfb0469
Reviewed-on: https://go-review.googlesource.com/42810
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-13 09:58:01 +00:00
Martin Möhrmann
fc6b74ce39 strconv: fix ParseUint return value on range overflow
If the value corresponding to the input string cannot be
represented by an unsigned integer of the given size,
err.Err = ErrRange and the returned value is the maximum
magnitude unsigned integer of the appropriate bitSize.
This is consistent with ParseInt's behavior and the documentation.

Expand tests to test 32 bit test value tables with bitsize 32 set.
These tests fail without the fix in this CL.

Fixes #21278

Change-Id: I8aab39279ec3e31905fcbf582a916cbf6d9b95da
Reviewed-on: https://go-review.googlesource.com/55134
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-13 09:11:32 +00:00
Joe Tsai
1d81251599 archive/tar: simplify toASCII and parseString
Use a simple []byte instead of bytes.Buffer to create a string.
Use bytes.IndexByte instead of our own for loop.

Change-Id: Ic4a1161d79017fd3af086a05c53d5f20a5f09326
Reviewed-on: https://go-review.googlesource.com/54752
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-13 02:32:28 +00:00
Agniva De Sarker
23cd87eb0a archive/tar: optimize formatPAXRecord() call
By replacing fmt.Sprintf with a simple string concat, we see
pretty good improvements across the board on time and memory.

name             old time/op    new time/op    delta
FormatPAXRecord     683ns ± 2%     210ns ± 5%  -69.22%  (p=0.000 n=10+10)

name             old alloc/op   new alloc/op   delta
FormatPAXRecord      112B ± 0%       32B ± 0%  -71.43%  (p=0.000 n=10+10)

name             old allocs/op  new allocs/op  delta
FormatPAXRecord      8.00 ± 0%      2.00 ± 0%  -75.00%  (p=0.000 n=10+10)

Ran with - -cpu=1 -count=10 on an AMD64 i5-5200U CPU @ 2.20GHz

Using the following benchmark:
func BenchmarkFormatPAXRecord(b *testing.B) {
  for n := 0; n < b.N; n++ {
    formatPAXRecord("foo", "bar")
  }
}

Change-Id: I828ddbafad2e5d937f0cf5f777b512638344acfc
Reviewed-on: https://go-review.googlesource.com/55210
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-08-12 04:52:27 +00:00
Joe Tsai
0d1a8f6e12 archive/tar: implement specialized logic for USTAR format
Rather than going through the complicated logic of writeHeader,
implement a writeUSTARHeader that only knows about the USTAR format.
This makes the logic much easier to reason about since you only
need to be concerned about USTAR and not all the subtle
differences between USTAR, PAX, and GNU.

We seperate out the logic in writeUSTARHeader into templateV7Plus
and writeRawHeader since the planned implementations of
writePAXHeader and writeGNUHeader will use them.

Change-Id: Ie75a54ac998420ece82686159ae6fa39f8b128e9
Reviewed-on: https://go-review.googlesource.com/54970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-12 01:48:06 +00:00
Mark Wolfe
812124a567 encoding/binary: add example for Read multi
Change-Id: I27ff99aa7abb070f6ae79c8f964aa9bd6a83b89d
Reviewed-on: https://go-review.googlesource.com/53730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-12 01:17:13 +00:00
Emmanuel Odeke
590c5b0807 text/template: support indexing into *int* maps
Ensure that we can index maps whose key types are:
* int
* uint
* int32
* uint32
* int64
* uint64
* uintptr

Fixes #20439

Change-Id: I8fa96b14073c8af72786482ff4ffc3508064ea86
Reviewed-on: https://go-review.googlesource.com/43850
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-12 00:21:16 +00:00
Elias Naur
057a34a281 runtime: fix crashing with foreign signal handlers on Darwin
The dieFromSignal runtime function attempts to forward crashing
signals to a signal handler registered before the runtime was
initialized, if any. However, on Darwin, a special signal handler
trampoline is invoked, even for non-Go signal handlers.

Clear the crashing signal's handlingSig entry to ensure sigtramp
forwards the signal.

Fixes the darwin/386 builder.

Updates #20392
Updates #19389

Change-Id: I441a3d30c672cdb21ed6d8f1e1322d7c0e5b9669
Reviewed-on: https://go-review.googlesource.com/55032
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-11 22:30:12 +00:00
Hiroshi Ioka
51ba2bb819 runtime/cgo: make code robust
According to http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html,
pthread_key_create return an error number which is greater than or equal
to 0. I don't know the scenario that pthread_setspecific would fail, but
also don't know the future. Add some error handlings just in case.

Change-Id: I0774b79ef658d67e300f4a9aab1f2e3879acc7ee
Reviewed-on: https://go-review.googlesource.com/54811
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-11 18:51:24 +00:00
Cholerae Hu
57bf6aca71 runtime, cmd/compile: add intrinsic getclosureptr
Intrinsic enabled on all architectures,
runtime asm implementation removed on all architectures.

Fixes #21258

Change-Id: I2cb86d460b497c2f287a5b3df5c37fdb231c23a7
Reviewed-on: https://go-review.googlesource.com/53411
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2017-08-11 18:11:22 +00:00
Alberto Donizetti
adc28cb1e0 cmd/dist: add doc file to fix go doc dist
$ go tool -h says:

  For more about each tool command, see 'go tool command -h'.

but it was suggested to change the suggestion to say:

  see 'go doc command'

In #18313.

That would work for every tool except dist, which has no doc.go.

This change adds a doc.go file to cmd/dist.

Updates #18313

Change-Id: If67a21934b87647a69359d9c14d8de3775c587b7
Reviewed-on: https://go-review.googlesource.com/54351
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-11 18:00:53 +00:00
Austin Clements
a1eec645e1 cmd/trace: don't shift trace slices to 0
Currently all trace slices get shifted to start at time 0. This makes
it very difficult to find specific points in time unless they fall in
the first slice.

For example, right now when you click "View trace
(6.005646218s-8.155419698s)" on the trace tool's main page, the trace
view puts the first event in that slice at time 0. If you're looking
for something that happened at time 7s, you have to look at time
0.9943537s in the trace view. And if you want to subtract times taken
from different slices, you have to figure out what those time really
correspond to.

Fix this by telling the trace viewer not to shift the times when it
imports the trace. In the above example, this makes the view of that
second trace slice start at time 6.005646218s, so you don't have to do
any gymnastics to find or calculate times in later slices.

Change-Id: I04e0afda60f5573fdd8ad96238c24013297ef263
Reviewed-on: https://go-review.googlesource.com/54633
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-08-11 17:53:17 +00:00
Austin Clements
55f19b8d1d cmd/trace: update HTML; expand viewer to whole window
This updates the HTML served for the trace viewer to follow the latest
revision of the example from the upstream tracing project.

The main thing this adds is CSS for the trace viewer (which was
actually in the example at the originally referenced revision, so I'm
not sure why it got dropped). In particular, this expands the trace
viewer to use the entire browser client area, which fixes several
problems with the current page:

1. The details pane gets cut off at a strange place and can get a
scroll bar even if there's plenty of room below it on the page. This
fixes the bottom of the details pane to the bottom of the window.

2. If the track view is very tall (lots of procs), there's no way to
view the top tracks and the details pane at the same time. This fixes
this problem by limiting the height of the track view to something
less than the height of the window so it gets a scroll bar of its own
if necessary.

3. Dragging the divider between the track pane and the details pane
actually moves the bottom of the details pane without moving the
divider. Fixing the height of the trace viewer fixes this problem.

Change-Id: Ia811e72a7413417ca21c45e932c9db2724974633
Reviewed-on: https://go-review.googlesource.com/54632
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-08-11 17:52:41 +00:00
Gerrit Code Review
385cd6681b Merge "Merge remote-tracking branch 'origin/dev.debug' into master" 2017-08-11 17:47:15 +00:00
Carlos Eduardo Seo
9aea0e89b6 runtime: make sure R0 is zero before _main on ppc64le
_main has an early check to verify if a binary is statically or dynamically
linked that depends on R0 being zero. R0 is not guaranteed to be zero at that
point and this was breaking Go on Alpine for ppc64le.

Change-Id: I4a1059ff7fd3db6fc489e7dcfe631c1814dd965b
Reviewed-on: https://go-review.googlesource.com/54730
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-08-11 17:46:24 +00:00
Tobias Klauser
98031d8cd0 test: reenable ... test
The gofmt bug in question seems to be fixed (at least gofmt doesn't
complain), so reenable the commented-out ... test.

Change-Id: Icbfe0511160210557894ec8eb9b206aa6133d486
Reviewed-on: https://go-review.googlesource.com/55030
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-11 17:41:17 +00:00
Lynn Boger
0f19e24da7 cmd/compile: intrinsics for trunc, floor, ceil on ppc64x
This implements trunc, floor, and ceil in the math package
as intrinsics on ppc64x.  Significant improvement mainly due
to avoiding call overhead of args and return value.

BenchmarkCeil-16                    5.95          0.69          -88.40%
BenchmarkFloor-16                   5.95          0.69          -88.40%
BenchmarkTrunc-16                   5.82          0.69          -88.14%

Updates #21390

Change-Id: I951e182694f6e0c431da79c577272b81fb0ebad0
Reviewed-on: https://go-review.googlesource.com/54654
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
2017-08-11 16:35:49 +00:00
Austin Clements
6f6a9398e2 Merge remote-tracking branch 'origin/dev.debug' into master
Change-Id: I85df2745af666b533f4f6f1d06f7c8e137590b5b
2017-08-11 12:17:43 -04:00
Carlos Eduardo Seo
3cb41be817 math/big: improve performance for AddMulVVW and mulAddVWW for ppc64x
This change adds a better implementation in asm for AddMulVVW and
mulAddVWW for ppc64x, with speedups up to 1.54x.

benchmark                       old ns/op     new ns/op     delta
BenchmarkAddMulVVW/1-8          6.58          6.29          -4.41%
BenchmarkAddMulVVW/2-8          7.43          7.25          -2.42%
BenchmarkAddMulVVW/3-8          8.95          8.15          -8.94%
BenchmarkAddMulVVW/4-8          10.1          9.37          -7.23%
BenchmarkAddMulVVW/5-8          12.0          10.7          -10.83%
BenchmarkAddMulVVW/10-8         22.1          20.1          -9.05%
BenchmarkAddMulVVW/100-8        211           154           -27.01%
BenchmarkAddMulVVW/1000-8       2046          1450          -29.13%
BenchmarkAddMulVVW/10000-8      20407         14793         -27.51%
BenchmarkAddMulVVW/100000-8     223857        145548        -34.98%

benchmark                       old MB/s     new MB/s     speedup
BenchmarkAddMulVVW/1-8          9719.88      10175.79     1.05x
BenchmarkAddMulVVW/2-8          17233.97     17657.54     1.02x
BenchmarkAddMulVVW/3-8          21446.05     23550.49     1.10x
BenchmarkAddMulVVW/4-8          25375.70     27334.33     1.08x
BenchmarkAddMulVVW/5-8          26650.52     30029.34     1.13x
BenchmarkAddMulVVW/10-8         28984.29     31833.68     1.10x
BenchmarkAddMulVVW/100-8        30249.41     41531.69     1.37x
BenchmarkAddMulVVW/1000-8       31273.35     44108.54     1.41x
BenchmarkAddMulVVW/10000-8      31360.47     43263.54     1.38x
BenchmarkAddMulVVW/100000-8     28589.58     43971.66     1.54x

Change-Id: I8a8105d4da3592afdef3125757a99f378a0254bb
Reviewed-on: https://go-review.googlesource.com/53931
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-08-11 13:59:52 +00:00
romanyx
92cfd07a6c math/bits: examples generator
Change-Id: Icdd0566d3b7dbc034256e16f8a6b6f1af07069b3
Reviewed-on: https://go-review.googlesource.com/54350
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-11 11:05:01 +00:00
Brian Kessler
9c7bf0807a math/big: avoid unneeded sticky bit calculations
As noted in the TODO comment, the sticky bit is only used
when the rounding bit is zero or the rounding mode is
ToNearestEven.  This change makes that check explicit and
will eliminate half the sticky bit calculations on average
when rounding mode is not ToNearestEven.

Change-Id: Ia4709f08f46e682bf97dabe5eb2a10e8e3d7af43
Reviewed-on: https://go-review.googlesource.com/54111
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-11 09:52:30 +00:00
Hiroshi Ioka
e9348ab4e9 runtime: move mincore from stubs.go to os_linux.go
Although mincore is declared in stubs.go, mincore isn't used by any
OSes except linux. Move it to os_linux.go and clean up unused code.

Change-Id: I6cfb0fed85c0317a4d091a2722ac55fa79fc7c9a
Reviewed-on: https://go-review.googlesource.com/54910
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-11 05:08:44 +00:00
Daniel Martí
320b6fef18 fmt: remove stopAtNewline unused parameter
This parameter is always false. The last occurrence of s.skipSpace(true)
was removed in mid-2015.

While at it, merge skipSpace into SkipSpace, since the latter was just a
wrapper without the parameter.

Found with github.com/mvdan/unparam.

Change-Id: I884ea4036f41234a898d6aeee515211c49b0b435
Reviewed-on: https://go-review.googlesource.com/52890
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2017-08-11 04:56:58 +00:00