]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
6 years ago.gitignore: include only Go project artifiacts
Hana Kim [Tue, 15 Aug 2017 19:22:28 +0000 (15:22 -0400)]
.gitignore: include only Go project artifiacts

This effectively reverts

https://golang.org/cl/53770

and adds a guide on what not to add in this file.

Update #21458

Change-Id: I7c740d492b70628b5d9f9e1622014995a3f6f8ec
Reviewed-on: https://go-review.googlesource.com/55871
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: move selectdone into g
Daniel Morsing [Wed, 2 Aug 2017 18:01:17 +0000 (19:01 +0100)]
runtime: move selectdone into g

Writing to selectdone on the stack of another goroutine meant a
pretty subtle dance between the select code and the stack copying
code. Instead move the selectdone variable into the g struct.

Change-Id: Id246aaf18077c625adef7ca2d62794afef1bdd1b
Reviewed-on: https://go-review.googlesource.com/53390
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: set itab function pointers at compile time
Keith Randall [Tue, 30 May 2017 19:59:25 +0000 (12:59 -0700)]
cmd/compile: set itab function pointers at compile time

I noticed that we don't set an itab's function pointers at compile
time. Instead, we currently do it at executable startup.

Set the function pointers at compile time instead. This shortens
startup time. It has no effect on normal binary size. Object files
will have more relocations, but that isn't a big deal.

For PIE there are additional pointers that will need to be adjusted at
load time. There are already other pointers in an itab that need to be
adjusted, so the cache line will already be paged in. There might be
some binary size overhead to mark these pointers. The "go test -c
-buildmode=pie net/http" binary is 0.18% bigger.

Update #20505

Change-Id: I267c82489915b509ff66e512fc7319b2dd79b8f7
Reviewed-on: https://go-review.googlesource.com/44341
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
6 years agoruntime: make STW duration more accurate
Austin Clements [Mon, 24 Jul 2017 20:06:10 +0000 (16:06 -0400)]
runtime: make STW duration more accurate

Currently, GC captures the start-the-world time stamp after
startTheWorldWithSema returns. This is problematic for two reasons:

1. It's possible to get preempted between startTheWorldWithSema
starting the world and calling nanotime.

2. startTheWorldWithSema does several clean-up tasks after the world
is up and running that on rare occasions can take upwards of 10ms.

Since the runtime uses the start-the-world time stamp to compute the
STW duration, both of these can significantly inflate the reported STW
duration.

Fix this by having startTheWorldWithSema itself call nanotime once the
world is started.

Change-Id: I114630234fb73c9dabae50a2ef1884661f2459db
Reviewed-on: https://go-review.googlesource.com/55410
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agoencoding/asn1: handle application tag in Marshal
Hiroshi Ioka [Wed, 24 May 2017 22:48:08 +0000 (07:48 +0900)]
encoding/asn1: handle application tag in Marshal

Fixes #20488

Change-Id: Iae963b612aea3d9e814b08f655e2eb019ece256e
Reviewed-on: https://go-review.googlesource.com/44110
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>

6 years agocrypto/tls: disallow handshake messages fragmented across CCS
Filippo Valsorda [Wed, 18 Jan 2017 16:53:35 +0000 (16:53 +0000)]
crypto/tls: disallow handshake messages fragmented across CCS

Detected by BoGo test FragmentAcrossChangeCipherSpec-Server-Packed.

Change-Id: I9a76697b9cdeb010642766041971de5c7e533481
Reviewed-on: https://go-review.googlesource.com/48811
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>

6 years agocrypto/x509: add PublicKeyAlgorithm.String()
Martins Sipenko [Fri, 26 May 2017 11:35:29 +0000 (14:35 +0300)]
crypto/x509: add PublicKeyAlgorithm.String()

Change-Id: I77d9c77875519d77bac49cc8870c2e0c4563fe55
Reviewed-on: https://go-review.googlesource.com/44313
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>

6 years agocrypto/tls: add BenchmarkHandshakeServer
Filippo Valsorda [Fri, 2 Jun 2017 19:33:50 +0000 (12:33 -0700)]
crypto/tls: add BenchmarkHandshakeServer

name                                       time/op
HandshakeServer/RSA-4                      1.10ms ± 0%
HandshakeServer/ECDHE-P256-RSA-4           1.23ms ± 1%
HandshakeServer/ECDHE-P256-ECDSA-P256-4     178µs ± 1%
HandshakeServer/ECDHE-X25519-ECDSA-P256-4   180µs ± 2%
HandshakeServer/ECDHE-P521-ECDSA-P521-4    19.8ms ± 1%

Change-Id: I6b2c79392995d259cfdfc5199be44cc7cc40e155
Reviewed-on: https://go-review.googlesource.com/44730
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>

6 years agocrypto/tls: don't check whether an ec point is on a curve twice
Andreas Auernhammer [Fri, 26 May 2017 09:33:49 +0000 (11:33 +0200)]
crypto/tls: don't check whether an ec point is on a curve twice

The processClientKeyExchange and processServerKeyExchange functions unmarshal an
encoded EC point and explicitly check whether the point is on the curve. The explicit
check can be omitted because elliptic.Unmarshal fails if the point is not on the curve
and the returned error would always be the same.

Fixes #20496

Change-Id: I5231a655eace79acee2737dd036a0c255ed42dbb
Reviewed-on: https://go-review.googlesource.com/44311
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Adam Langley <agl@golang.org>

6 years agocrypto/x509: add MarshalPKCS8PrivateKey
James Hartig [Fri, 14 Apr 2017 04:53:09 +0000 (00:53 -0400)]
crypto/x509: add MarshalPKCS8PrivateKey

asn1.NullRawValue was used according to RFC 3279 2.2.1. Without this tag,
the output didn't match openssl.

Fixes #19972

Change-Id: Ia52ddb810888837f913dbd65c4e1328f6c8084bb
Reviewed-on: https://go-review.googlesource.com/40730
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

6 years agoruntime: fix getclosureptr doc
Austin Clements [Tue, 15 Aug 2017 15:32:02 +0000 (11:32 -0400)]
runtime: fix getclosureptr doc

Change-Id: I1b42fca2107b06e6fc95728f7bf3d08d005c4cb4
Reviewed-on: https://go-review.googlesource.com/55810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agosyscall: really use utimensat for UtimesNano on Solaris
Tobias Klauser [Mon, 14 Aug 2017 07:47:58 +0000 (09:47 +0200)]
syscall: really use utimensat for UtimesNano on Solaris

golang.org/cl/55130 added utimensat for Solaris but didn't use it in
UtimesNano (despite indicating otherwise in the commit message). Fix
this by also using utimensat for UtimesNano on Solaris.

Because all versions of Solaris suppported by Go support utimensat,
there is no need for the fallback logic and utimensat can be called
unconditionally.

This issue was pointed out by Shawn Walker-Salas.

Updates #16480

Change-Id: I114338113a6da3cfcb8bca950674bdc8f5a7a9e5
Reviewed-on: https://go-review.googlesource.com/55141
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years ago.gitignore: exclude /.idea/
Hana (Hyang-Ah) Kim [Fri, 4 Aug 2017 21:38:46 +0000 (17:38 -0400)]
.gitignore: exclude /.idea/

Some IDEs (e.g. intellij IDE based ones) create the .idea folder
to store project specific settings. This is irrelevant to Go project
that does not assume any specific IDEs, but interferes with git.

Change-Id: I0c93d9a3f7edff095fbe0c7a53b06c92b391c970
Reviewed-on: https://go-review.googlesource.com/53770
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoencoding/hex: save allocation in DecodeString()
Agniva De Sarker [Sun, 13 Aug 2017 18:15:04 +0000 (23:45 +0530)]
encoding/hex: save allocation in DecodeString()

The destination slice does not need to be created at all. The source
slice itself can be used as the destination because the decode loop
increments by one and then the 'seen' byte is not used anymore. Therefore
the decoded byte can be stored in that index of the source slice itself.

This trick cannot be applied to EncodeString() because in that case,
the destination slice is large than the source. And for a single byte
in the source slice, two bytes in the destination slice is written.

func BenchmarkDecodeString(b *testing.B) {
  for i := 0; i < b.N; i++ {
    DecodeString("0123456789abcdef")
  }
}

name          old time/op    new time/op    delta
DecodeString    71.0ns ± 6%    58.0ns ± 0%  -18.28%  (p=0.008 n=5+5)

name          old alloc/op   new alloc/op   delta
DecodeString     16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.008 n=5+5)

name          old allocs/op  new allocs/op  delta
DecodeString      1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Change-Id: Id98db4e712444557a804155457a4dd8d1b8b416d
Reviewed-on: https://go-review.googlesource.com/55611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agosyscall: fix definition of _AT_FDCWD on dragonfly
Tobias Klauser [Tue, 15 Aug 2017 08:27:42 +0000 (10:27 +0200)]
syscall: fix definition of _AT_FDCWD on dragonfly

CL golang.org/cl/55130 messed up the definition of _AT_FDCWD on
dragonfly.

This fixes the following test failure on dragonfly/amd64:

  --- FAIL: TestPackageMainTestImportsArchiveNotBinary (0.00s)
     go_test.go:192: chtimes ./testdata/src/main_test/m.go: bad file descriptor

Change-Id: I4c96983769e6b02d714859dc838875c3c0f1be50
Reviewed-on: https://go-review.googlesource.com/55690
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/internal/obj/arm64: fix assemble stxr/stxrw/stxrb/stxrh bug
fanzha02 [Wed, 14 Jun 2017 06:24:18 +0000 (06:24 +0000)]
cmd/internal/obj/arm64: fix assemble stxr/stxrw/stxrb/stxrh bug

The stxr/stxrw/stxrb/stxrh instructions belong to STLXR-like instructions
set and they require special handling. The current code has no special
handling for those instructions.

The fix adds the special handling for those instructions.

Uncomment stxr/stxrw/stxrb/stxrh test cases.

Fixes #21397
Change-Id: I31cee29dd6b30b1c25badd5c7574dda7a01bf016
Reviewed-on: https://go-review.googlesource.com/54951
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/internal/obj/arm64: improve arm64 wrapper prologue
ph [Tue, 8 Aug 2017 23:05:17 +0000 (23:05 +0000)]
cmd/internal/obj/arm64: improve arm64 wrapper prologue

Improve static branch prediction in arm64 wrapper prologue
by making the unusual case branch forwards. (Most other
architectures implement this optimization.)

Additionally, replace a CMP+BNE pair with a CBNZ
to save one instruction.

Change-Id: Id970038b34b4aaec18c101d62e2ee00f3e32a761
Reviewed-on: https://go-review.googlesource.com/54070
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agomisc/cgo/testshared: call flag.Parse in TestMain
Hiroshi Ioka [Tue, 15 Aug 2017 11:53:49 +0000 (20:53 +0900)]
misc/cgo/testshared: call flag.Parse in TestMain

Otherwise, some test flags don't work.

Change-Id: Iacf3930d0eec28e4d690cd382adbb2ecf866a0e2
Reviewed-on: https://go-review.googlesource.com/55615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: add support for arm64 bit-test instructions
philhofer [Wed, 9 Aug 2017 05:01:26 +0000 (05:01 +0000)]
cmd/compile: add support for arm64 bit-test instructions

Add support for generating TBZ/TBNZ instructions.

The bit-test-and-branch pattern shows up in a number of
important places, including the runtime (gc bitmaps).

Before this change, there were 3 TB[N]?Z instructions in the Go tool,
all of which were in hand-written assembly. After this change, there
are 285. Also, the go1 benchmark binary gets about 4.5kB smaller.

Fixes #21361

Change-Id: I170c138b852754b9b8df149966ca5e62e6dfa771
Reviewed-on: https://go-review.googlesource.com/54470
Run-TryBot: Philip Hofer <phofer@umich.edu>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/link: skip TestSizes on Plan 9
David du Colombier [Tue, 15 Aug 2017 09:33:18 +0000 (11:33 +0200)]
cmd/link: skip TestSizes on Plan 9

TestSizes has been added in CL 55551. This test is
failing on Plan 9 because executables don't have
a DWARF symbol table.

Fixes #21453.

Change-Id: I560611b49aea5417e8c5ac0cec6c7882bd9f8335
Reviewed-on: https://go-review.googlesource.com/55692
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
6 years agoruntime: remove redeclared structs to make tests build
Muhammad Falak R Wani [Tue, 15 Aug 2017 06:41:01 +0000 (12:11 +0530)]
runtime: remove redeclared structs to make tests build

struct32 and struct40 structs are already declared, remove them to
make runtime tests build.

Change-Id: I3814f2b850dcb15c4002a3aa22e2a9326e5a5e53
Reviewed-on: https://go-review.googlesource.com/55614
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
6 years agocmd/compile: generate makechan calls with int arguments
Martin Möhrmann [Sun, 13 Aug 2017 18:03:02 +0000 (20:03 +0200)]
cmd/compile: generate makechan calls with int arguments

Where possible generate calls to runtime makechan with int arguments
during compile time instead of makechan with int64 arguments.

This eliminates converting arguments for calls to makechan with
int64 arguments for platforms where int64 values do not fit into
arguments of type int.

A similar optimization for makeslice was introduced in CL
golang.org/cl/27851.

386:
name                old time/op  new time/op  delta
MakeChan/Byte       52.4ns ± 6%  45.0ns ± 1%  -14.14%  (p=0.000 n=10+10)
MakeChan/Int        54.5ns ± 1%  49.1ns ± 1%   -9.87%  (p=0.000 n=10+10)
MakeChan/Ptr         150ns ± 1%   143ns ± 0%   -4.38%  (p=0.000 n=9+7)
MakeChan/Struct/0   49.2ns ± 2%  43.2ns ± 2%  -12.27%  (p=0.000 n=10+10)
MakeChan/Struct/32  81.7ns ± 2%  76.2ns ± 1%   -6.71%  (p=0.000 n=10+10)
MakeChan/Struct/40  88.4ns ± 2%  82.5ns ± 2%   -6.60%  (p=0.000 n=10+10)

AMD64:
name                old time/op  new time/op  delta
MakeChan/Byte       83.4ns ± 8%  80.8ns ± 3%    ~     (p=0.171 n=10+10)
MakeChan/Int         101ns ± 3%   101ns ± 2%    ~     (p=0.412 n=10+10)
MakeChan/Ptr         128ns ± 1%   128ns ± 1%    ~     (p=0.191 n=10+10)
MakeChan/Struct/0   67.6ns ± 3%  68.7ns ± 4%    ~     (p=0.224 n=10+10)
MakeChan/Struct/32   138ns ± 1%   139ns ± 1%    ~     (p=0.185 n=10+9)
MakeChan/Struct/40   154ns ± 1%   154ns ± 1%  -0.55%  (p=0.027 n=10+9)

Change-Id: Ie854cb066007232c5e9f71ea7d6fe27e81a9c050
Reviewed-on: https://go-review.googlesource.com/55140
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoarchive/tar: re-implement USTAR path splitting
Joe Tsai [Tue, 15 Aug 2017 00:16:52 +0000 (17:16 -0700)]
archive/tar: re-implement USTAR path splitting

The logic for USTAR was disabled because a previous implementation of
Writer had a wrong understanding of the differences between USTAR and GNU,
causing the prefix field is incorrectly be populated in GNU files.

Now that this issue has been fixed, we can re-enable the logic for USTAR
path splitting, which allows Writer to use the USTAR for a wider range
of possible inputs.

Updates #9683
Updates #12594
Updates #17630

Change-Id: I9fe34e5df63f99c6dd56fee3a7e7e4d6ec3995c9
Reviewed-on: https://go-review.googlesource.com/55574
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoarchive/tar: centralize errors in common.go
Joe Tsai [Tue, 15 Aug 2017 03:11:02 +0000 (20:11 -0700)]
archive/tar: centralize errors in common.go

Move all sentinel errors to common.go since some of them are
returned by both the reader and writer and remove errInvalidHeader
since it not used.

Also, consistently use the "tar: " prefix for errors.

Change-Id: I0afb185bbf3db80dfd9595321603924454a4c2f9
Reviewed-on: https://go-review.googlesource.com/55650
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agostrconv: cleanup variable declarations in ParseUint
Martin Möhrmann [Sun, 13 Aug 2017 11:00:33 +0000 (13:00 +0200)]
strconv: cleanup variable declarations in ParseUint

Move variable declarations closer to their first uses.

Use an additional string variable s0 for error reporting that references
the original input string. This allows the variable s to be modified.

Change-Id: I4725152490ca1dc10c1161ad8ad2f4ae8933493f
Reviewed-on: https://go-review.googlesource.com/55138
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: simplify memory capacity check in growslice
Martin Möhrmann [Sat, 5 Aug 2017 11:44:25 +0000 (13:44 +0200)]
runtime: simplify memory capacity check in growslice

Instead of comparing if the number of elements will
not fit into memory check if the memory size of the
slices backing memory is higher then the memory limit.

This avoids a division or maxElems lookup.

With et.size > 0:
   uintptr(newcap)                > maxSliceCap(et.size)
-> uintptr(int(capmem / et.size)) > _MaxMem  /  et.size
->             capmem / et.size   > _MaxMem  /  et.size
->             capmem             > _MaxMem

Note that due to integer division from capmem > _MaxMem
it does not follow that uintptr(newcap) > maxSliceCap(et.size).

Consolidated runtime GrowSlice benchmarks by using sub-benchmarks and
added more struct sizes to show performance improvement when division
is avoided for element sizes larger than 32 bytes.

AMD64:
GrowSlice/Byte       38.9ns ± 2%  38.9ns ± 1%    ~     (p=0.974 n=20+20)
GrowSlice/Int        58.3ns ± 3%  58.0ns ± 2%    ~     (p=0.154 n=20+19)
GrowSlice/Ptr        95.7ns ± 2%  95.1ns ± 2%  -0.60%  (p=0.034 n=20+20)
GrowSlice/Struct/24  95.4ns ± 1%  93.9ns ± 1%  -1.54%  (p=0.000 n=19+19)
GrowSlice/Struct/32   110ns ± 1%   108ns ± 1%  -1.76%  (p=0.000 n=19+20)
GrowSlice/Struct/40   138ns ± 1%   128ns ± 1%  -7.09%  (p=0.000 n=20+20)

Change-Id: I1c37857c74ea809da373e668791caffb6a5cbbd3
Reviewed-on: https://go-review.googlesource.com/53471
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/link: implement R_X86_64_PC64 relocations
Russ Cox [Fri, 11 Aug 2017 20:22:10 +0000 (16:22 -0400)]
cmd/link: implement R_X86_64_PC64 relocations

Change-Id: I1d7bd5cff7350a4e0f78b8efc8406e79c74732d1
Reviewed-on: https://go-review.googlesource.com/55370
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoarchive/tar: add support for atime and ctime to Writer
Joe Tsai [Mon, 14 Aug 2017 22:39:19 +0000 (15:39 -0700)]
archive/tar: add support for atime and ctime to Writer

Both the GNU and PAX formats support atime and ctime fields.
The implementation is trivial now that we have:
* support for formatting PAX records for timestamps
* dedicated methods that only handle one format (e.g., GNU)

Fixes #17876

Change-Id: I0c604fce14a47d722098afc966399cca2037395d
Reviewed-on: https://go-review.googlesource.com/55570
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoarchive/tar: reject bad key-value pairs for PAX records
Joe Tsai [Mon, 14 Aug 2017 22:57:46 +0000 (15:57 -0700)]
archive/tar: reject bad key-value pairs for PAX records

We forbid empty keys or keys with '=' because it leads to ambiguous parsing.
Relevent PAX specification:
<<<
A keyword shall not include an <equals-sign>.
>>>

Also, we forbid the writer from encoding records with an empty value.
While, this is a valid record syntactically, the semantics of an empty
value is that previous records with that key should be deleted.
Since we have no support (and probably never will) for global PAX records,
deletion is a non-sensible operation.
<<<
If the <value> field is zero length,
it shall delete any header block field,
previously entered extended header value,
or global extended header value of the same name.
>>>

Fixes #20698
Fixes #15567

Change-Id: Ia29c5c6ef2e36cd9e6d7f6cff10e92b96a62f0d1
Reviewed-on: https://go-review.googlesource.com/55571
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoarchive/tar: support PAX subsecond resolution times
Joe Tsai [Mon, 14 Aug 2017 22:24:31 +0000 (15:24 -0700)]
archive/tar: support PAX subsecond resolution times

Add support for PAX subsecond resolution times. Since the parser
supports negative timestamps, the formatter also handles negative
timestamps.

The relevant PAX specification is:
<<<
Portable file timestamps cannot be negative. If pax encounters a
file with a negative timestamp in copy or write mode, it can reject
the file, substitute a non-negative timestamp, or generate a
non-portable timestamp with a leading '-'.
>>>

<<<
All of these time records shall be formatted as a decimal
representation of the time in seconds since the Epoch.
If a <period> ( '.' ) decimal point character is present,
the digits to the right of the point shall represent the units of
a subsecond timing granularity, where the first digit is tenths of
a second and each subsequent digit is a tenth of the previous digit.
>>>

Fixes #11171

Change-Id: Ied108f3d2654390bc1b0ddd66a4081c2b83e490b
Reviewed-on: https://go-review.googlesource.com/55552
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: initialize itab.hash always
Keith Randall [Wed, 31 May 2017 18:57:07 +0000 (11:57 -0700)]
runtime: initialize itab.hash always

We weren't initializing this field for dynamically-generated itabs.
Turns out it doesn't matter, as any time we use this field we also
generate a static itab for the interface type / concrete type pair.
But we should initialize it anyway, just to be safe.

Performance on the benchmarks in CL 44339:
benchmark               old ns/op     new ns/op     delta
BenchmarkItabFew-12     1040585       26466         -97.46%
BenchmarkItabAll-12     228873499     4287696       -98.13%

Change-Id: I58ed2b31e6c98b584122bdaf844fee7268b58295
Reviewed-on: https://go-review.googlesource.com/44475
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoruntime: remove link field from itab
Keith Randall [Wed, 31 May 2017 17:08:51 +0000 (10:08 -0700)]
runtime: remove link field from itab

We don't use it any more, remove it.

Change-Id: I76ce1a4c2e7048fdd13a37d3718b5abf39ed9d26
Reviewed-on: https://go-review.googlesource.com/44474
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoruntime: remove bad field from itab
Keith Randall [Wed, 31 May 2017 16:02:40 +0000 (09:02 -0700)]
runtime: remove bad field from itab

Just use fun[0]==0 to indicate a bad itab.

Change-Id: I28ecb2d2d857090c1ecc40b1d1866ac24a844848
Reviewed-on: https://go-review.googlesource.com/44473
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoruntime: new itab lookup table
Keith Randall [Wed, 31 May 2017 15:45:10 +0000 (08:45 -0700)]
runtime: new itab lookup table

Keep itabs in a growable hash table.
Use a simple open-addressable hash table, quadratic probing, power
of two sized.
Synchronization gets a bit more tricky. The common read path now
has two atomic reads, one to get the table pointer and one to read
the entry out of the table.

I set the max load factor to 75%, kind of arbitrarily. There's a
space-speed tradeoff here, and I'm not sure where we should land.

Because we use open addressing the itab.link field is no longer needed.
I'll remove it in a separate CL.

Fixes #20505

Change-Id: Ifb3d9a337512d6cf968c1fceb1eeaf89559afebf
Reviewed-on: https://go-review.googlesource.com/44472
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoarchive/tar: properly handle header-only "files" in Writer
Joe Tsai [Mon, 14 Aug 2017 22:33:46 +0000 (15:33 -0700)]
archive/tar: properly handle header-only "files" in Writer

Certain special type-flags, specifically 1, 2, 3, 4, 5, 6,
do not have a data section. Thus, regardless of what the size field
says, we should not attempt to write any data for these special types.

The relevant PAX and USTAR specification says:
<<<
If the typeflag field is set to specify a file to be of type 1 (a link)
or 2 (a symbolic link), the size field shall be specified as zero.
If the typeflag field is set to specify a file of type 5 (directory),
the size field shall be interpreted as described under the definition
of that record type. No data logical records are stored for types 1, 2, or 5.
If the typeflag field is set to 3 (character special file),
4 (block special file), or 6 (FIFO), the meaning of the size field is
unspecified by this volume of POSIX.1-2008, and no data logical records shall
be stored on the medium.
Additionally, for type 6, the size field shall be ignored when reading.
If the typeflag field is set to any other value, the number of logical
records written following the header shall be (size+511)/512, ignoring
any fraction in the result of the division.
>>>

Fixes #15565

Change-Id: Id11886b723b3b13deb15221dca51c25cd778a6b5
Reviewed-on: https://go-review.googlesource.com/55553
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoarchive/tar: roundtrip reading device numbers
Joe Tsai [Mon, 14 Aug 2017 23:14:08 +0000 (16:14 -0700)]
archive/tar: roundtrip reading device numbers

Both GNU and BSD tar do not care if the devmajor and devminor values are
set on entries (like regular files) that aren't character or block devices.

While this is non-sensible, it is more consistent with the Writer to actually
read these fields always. In a vast majority of the cases these will still
be zero. In the rare situation where someone actually cares about these,
at least information was not silently lost.

Change-Id: I6e4ba01cd897a1b13c28b1837e102a4fdeb420ba
Reviewed-on: https://go-review.googlesource.com/55572
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agosyscall: add missing int flag argument to utimensat
Yuval Pavel Zholkover [Mon, 14 Aug 2017 16:05:56 +0000 (19:05 +0300)]
syscall: add missing int flag argument to utimensat

Fixes #21437

Change-Id: I55fbf5114ae1bb7f4aa1a20450e8d5309756cd5b
Reviewed-on: https://go-review.googlesource.com/55430
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: remove unused global variable emptystring
Ian Lance Taylor [Mon, 14 Aug 2017 16:56:51 +0000 (09:56 -0700)]
runtime: remove unused global variable emptystring

Last runtime use was removed in https://golang.org/cl/133700043,
September 2014.

Replace plan9 syscall uses with plan9-specific variable.

Change-Id: Ifb910c021c1419a7c782959f90b054ed600d9e19
Reviewed-on: https://go-review.googlesource.com/55450
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/link: improve error message
Hiroshi Ioka [Sat, 12 Aug 2017 13:52:17 +0000 (22:52 +0900)]
cmd/link: improve error message

ld.SymKind and objabi.RelocType have string representations,
which is human friendly. Prefer to use it.

Change-Id: I458ee0ca5866be0db8462c36cd053561a8206c95
Reviewed-on: https://go-review.googlesource.com/55253
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: refactor out tophash calculation
Josh Bleecher Snyder [Wed, 7 Jun 2017 16:55:05 +0000 (09:55 -0700)]
runtime: refactor out tophash calculation

No functional changes; tophash is inlined.

Change-Id: Ic8ce95b3622eafbddcfbc97f8c630ab8c5bfe7ad
Reviewed-on: https://go-review.googlesource.com/55233
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: unify cases in mapiternext
Josh Bleecher Snyder [Fri, 11 Aug 2017 15:48:10 +0000 (08:48 -0700)]
runtime: unify cases in mapiternext

The preceding cleanup made it clear that two cases
(have golden data, unreachable key) are handled identically.
Simplify the control flow to reflect that.

Simplifies the code and generates shorter machine code.

Change-Id: Id612e0da6679813e855506f47222c58ea6497d70
Reviewed-on: https://go-review.googlesource.com/55093
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: mask a bounded slice access in hashmap evacuate
Josh Bleecher Snyder [Fri, 11 Aug 2017 15:21:31 +0000 (08:21 -0700)]
runtime: mask a bounded slice access in hashmap evacuate

Shaves a few instructions off.

Change-Id: I39f1b01ae7e770d632d5e77a6aa4b5a1f123b41a
Reviewed-on: https://go-review.googlesource.com/55090
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/go: correctly quote environment variables in -x output
Hiroshi Ioka [Mon, 14 Aug 2017 14:02:56 +0000 (23:02 +0900)]
cmd/go: correctly quote environment variables in -x output

This fixes the -x output so that when it reports environment variables they
are correctly quoted for later execution by the shell.
Also fix -x output to use the right path to the pack tool, and note when
we are touching a file.

Fixes #21427

Change-Id: I323ef4edf9905b08bc26944b94183d8da2fa9675
Reviewed-on: https://go-review.googlesource.com/55350
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodebug/macho: make Type implements fmt.(Go)Stringer interfaces
Hiroshi Ioka [Mon, 14 Aug 2017 08:26:22 +0000 (17:26 +0900)]
debug/macho: make Type implements fmt.(Go)Stringer interfaces

Fixes #21436

Change-Id: I56f43e2852696c28edbcc772a54125a9a9c32497
Reviewed-on: https://go-review.googlesource.com/55262
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/link: correct Mach-O file flag
Hiroshi Ioka [Sat, 12 Aug 2017 15:19:51 +0000 (00:19 +0900)]
cmd/link: correct Mach-O file flag

Only set MH_NOUNDEFS if there are no undefined symbols.
Doesn't seem to matter, but may as well do it right.

Change-Id: I6c472e000578346c28cf0e10f24f870e3a0de628
Reviewed-on: https://go-review.googlesource.com/55310
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/link,compile: Provide size for func types
Keith Randall [Mon, 14 Aug 2017 22:07:57 +0000 (15:07 -0700)]
cmd/link,compile: Provide size for func types

They are currently not given a size, which makes the DWARF reader
very confused. Particularly things like [4]func() get a size of -4, not 32.

Fixes #21097

Change-Id: I01e754134d82fbbe6567e3c7847a4843792a3776
Reviewed-on: https://go-review.googlesource.com/55551
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: refactor evacuate x/y handling
Josh Bleecher Snyder [Thu, 10 Aug 2017 14:16:27 +0000 (07:16 -0700)]
runtime: refactor evacuate x/y handling

This change unifies the x and y cases.

It shrinks evacuate's machine code by ~25% and its stack size by ~15%.

It also eliminates a critical branch.
Whether an entry should go to x or y is designed to be unpredictable.
As a result, half of the branch predictions for useX were wrong.
Mispredicting that branch can easily incur an expensive cache miss.
Switching to an xy array allows elimination of that branch,
which in turn reduces cache misses.

Change-Id: Ie9cef53744b96c724c377ac0985b487fc50b49b1
Reviewed-on: https://go-review.googlesource.com/54653
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: calculate k only once in mapiternext
Josh Bleecher Snyder [Fri, 11 Aug 2017 15:43:30 +0000 (08:43 -0700)]
runtime: calculate k only once in mapiternext

Make the calculation of k and v a bit lazier.
None of the following code cares about indirect-vs-direct k,
and it happens on all code paths, so check t.indirectkey earlier.

Simplifies the code and reduces both machine code and stack size.

Change-Id: I5ea4c0772848d7a4b15383baedb9a1f7feb47201
Reviewed-on: https://go-review.googlesource.com/55092
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: special case allocation of arrays of size 1
Josh Bleecher Snyder [Mon, 17 Jul 2017 03:46:52 +0000 (17:46 -1000)]
runtime: special case allocation of arrays of size 1

This avoids division and multiplication.
Instrumentation suggests that this is a very common case.

Change-Id: I2d5d5012d4f4df4c4af1f9f85ca9c323c9889c0e
Reviewed-on: https://go-review.googlesource.com/54657
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: use integer math for hashmap overLoadFactor
Josh Bleecher Snyder [Mon, 17 Jul 2017 03:37:27 +0000 (17:37 -1000)]
runtime: use integer math for hashmap overLoadFactor

Change-Id: I92cf39a05e738a03d956779d7a1ab1ef8074b2ab
Reviewed-on: https://go-review.googlesource.com/54655
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoarchive/tar: remove writeHeader and writePAXHeaderLegacy
Joe Tsai [Mon, 14 Aug 2017 21:59:18 +0000 (14:59 -0700)]
archive/tar: remove writeHeader and writePAXHeaderLegacy

Previous CLs (CL/54970, CL55231, and CL/55237) re-implemented tar.Writer
entirely using specialized methods (writeUSTARHeader, writePAXHeader,
and writeGNUHeader) allowing tar.Writer to entirely side-step the broken
and buggy logic in writeHeader.

Since writeHeader and writePAXHeaderLegacy is now dead-code,
we can delete them.

One minor change is that we call Writer.Flush at the start of WriteHeader.
This used to be performed by writeHeader, but doing so in WriteHeader
ensures each of the specialized methods can benefit from its effect.

Fixes #17665
Fixes #12594

Change-Id: Iff2ef8e7310d40ac5484d2f8852fc5df25201426
Reviewed-on: https://go-review.googlesource.com/55550
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoarchive/tar: implement specialized logic for GNU format
Joe Tsai [Mon, 14 Aug 2017 07:03:26 +0000 (00:03 -0700)]
archive/tar: implement specialized logic for GNU format

Rather than going through writeHeader, which attempts to handle all formats,
implement writeGNUHeader, which only has an understanding of the GNU format.

Currently, the implementation is nearly identical to writeUSTARHeader, except:
* formatNumeric is used instead of formatOctal
* the GNU magic value is used

This is kept as a separate method since it makes more logical sense
when we add support for sparse files, long filenames, and atime/ctime fields,
which do not affect USTAR.

Updates #12594

Change-Id: I76efc0b39dc649efc22646dfc9867a7c165f34a8
Reviewed-on: https://go-review.googlesource.com/55237
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
6 years agostrings: use slice instead of list and array in Fields comment
Martin Möhrmann [Mon, 14 Aug 2017 19:12:49 +0000 (21:12 +0200)]
strings: use slice instead of list and array in Fields comment

Change-Id: I70b839ff0ae5f015587390a82616ebb1d657d71a
Reviewed-on: https://go-review.googlesource.com/55490
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: replace some uses of newarray with newobject for maps
Martin Möhrmann [Thu, 10 Aug 2017 19:24:51 +0000 (21:24 +0200)]
runtime: replace some uses of newarray with newobject for maps

This avoids the never triggered capacity checks in newarray.

Change-Id: Ib72b204adcb9e3fd3ab963defe0cd40e22d5d492
Reviewed-on: https://go-review.googlesource.com/54731
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agobytes: speed up Fields and FieldsFunc
Martin Möhrmann [Sat, 12 Aug 2017 08:20:30 +0000 (10:20 +0200)]
bytes: speed up Fields and FieldsFunc

Applies the optimizations from golang.org/cl/42810 and golang.org/cl/37959
done to the strings package to the bytes package.

name                      old time/op    new time/op     delta
Fields/ASCII/16              417ns ± 4%      118ns ± 3%    -71.65%  (p=0.000 n=10+10)
Fields/ASCII/256            5.95µs ± 3%     0.88µs ± 0%    -85.23%  (p=0.000 n=10+7)
Fields/ASCII/4096           92.3µs ± 1%     12.8µs ± 2%    -86.13%  (p=0.000 n=10+10)
Fields/ASCII/65536          1.49ms ± 1%     0.25ms ± 1%    -83.14%  (p=0.000 n=10+10)
Fields/ASCII/1048576        25.0ms ± 1%      6.5ms ± 2%    -74.04%  (p=0.000 n=10+10)
Fields/Mixed/16              406ns ± 1%      222ns ± 1%    -45.24%  (p=0.000 n=10+9)
Fields/Mixed/256            5.78µs ± 1%     2.27µs ± 1%    -60.73%  (p=0.000 n=9+10)
Fields/Mixed/4096           97.9µs ± 1%     40.5µs ± 3%    -58.66%  (p=0.000 n=10+10)
Fields/Mixed/65536          1.58ms ± 1%     0.69ms ± 1%    -56.58%  (p=0.000 n=10+10)
Fields/Mixed/1048576        26.6ms ± 1%     12.6ms ± 2%    -52.44%  (p=0.000 n=9+10)
FieldsFunc/ASCII/16          395ns ± 1%      188ns ± 1%    -52.34%  (p=0.000 n=10+10)
FieldsFunc/ASCII/256        5.90µs ± 1%     2.00µs ± 1%    -66.06%  (p=0.000 n=10+10)
FieldsFunc/ASCII/4096       92.5µs ± 1%     33.0µs ± 1%    -64.34%  (p=0.000 n=10+9)
FieldsFunc/ASCII/65536      1.48ms ± 1%     0.54ms ± 1%    -63.38%  (p=0.000 n=10+9)
FieldsFunc/ASCII/1048576    25.1ms ± 1%     10.5ms ± 3%    -58.24%  (p=0.000 n=10+10)
FieldsFunc/Mixed/16          401ns ± 1%      205ns ± 2%    -48.87%  (p=0.000 n=10+10)
FieldsFunc/Mixed/256        5.70µs ± 1%     1.98µs ± 1%    -65.28%  (p=0.000 n=10+10)
FieldsFunc/Mixed/4096       97.5µs ± 1%     35.4µs ± 1%    -63.65%  (p=0.000 n=10+10)
FieldsFunc/Mixed/65536      1.57ms ± 1%     0.61ms ± 1%    -61.20%  (p=0.000 n=10+10)
FieldsFunc/Mixed/1048576    26.5ms ± 1%     11.4ms ± 2%    -56.84%  (p=0.000 n=10+10)

name                      old speed      new speed       delta
Fields/ASCII/16           38.4MB/s ± 4%  134.9MB/s ± 3%   +251.55%  (p=0.000 n=10+10)
Fields/ASCII/256          43.0MB/s ± 3%  290.6MB/s ± 1%   +575.97%  (p=0.000 n=10+8)
Fields/ASCII/4096         44.4MB/s ± 1%  320.0MB/s ± 2%   +620.90%  (p=0.000 n=10+10)
Fields/ASCII/65536        44.0MB/s ± 1%  260.7MB/s ± 1%   +493.15%  (p=0.000 n=10+10)
Fields/ASCII/1048576      42.0MB/s ± 1%  161.6MB/s ± 2%   +285.21%  (p=0.000 n=10+10)
Fields/Mixed/16           39.4MB/s ± 1%   71.7MB/s ± 1%    +82.20%  (p=0.000 n=10+10)
Fields/Mixed/256          44.3MB/s ± 1%  112.8MB/s ± 1%   +154.64%  (p=0.000 n=9+10)
Fields/Mixed/4096         41.9MB/s ± 1%  101.2MB/s ± 3%   +141.92%  (p=0.000 n=10+10)
Fields/Mixed/65536        41.5MB/s ± 1%   95.5MB/s ± 1%   +130.29%  (p=0.000 n=10+10)
Fields/Mixed/1048576      39.4MB/s ± 1%   82.9MB/s ± 2%   +110.28%  (p=0.000 n=9+10)
FieldsFunc/ASCII/16       40.5MB/s ± 1%   84.9MB/s ± 2%   +109.80%  (p=0.000 n=10+10)
FieldsFunc/ASCII/256      43.4MB/s ± 1%  127.9MB/s ± 1%   +194.58%  (p=0.000 n=10+10)
FieldsFunc/ASCII/4096     44.3MB/s ± 1%  124.2MB/s ± 1%   +180.44%  (p=0.000 n=10+9)
FieldsFunc/ASCII/65536    44.2MB/s ± 1%  120.6MB/s ± 1%   +173.06%  (p=0.000 n=10+9)
FieldsFunc/ASCII/1048576  41.8MB/s ± 1%  100.2MB/s ± 3%   +139.53%  (p=0.000 n=10+10)
FieldsFunc/Mixed/16       39.8MB/s ± 1%   77.8MB/s ± 2%    +95.46%  (p=0.000 n=10+10)
FieldsFunc/Mixed/256      44.9MB/s ± 1%  129.4MB/s ± 1%   +187.97%  (p=0.000 n=10+10)
FieldsFunc/Mixed/4096     42.0MB/s ± 1%  115.6MB/s ± 1%   +175.08%  (p=0.000 n=10+10)
FieldsFunc/Mixed/65536    41.6MB/s ± 1%  107.3MB/s ± 1%   +157.75%  (p=0.000 n=10+10)
FieldsFunc/Mixed/1048576  39.6MB/s ± 1%   91.8MB/s ± 2%   +131.72%  (p=0.000 n=10+10)

name                      old alloc/op   new alloc/op    delta
Fields/ASCII/16              80.0B ± 0%      80.0B ± 0%       ~     (all equal)
Fields/ASCII/256              768B ± 0%       768B ± 0%       ~     (all equal)
Fields/ASCII/4096           9.47kB ± 0%     9.47kB ± 0%       ~     (all equal)
Fields/ASCII/65536           147kB ± 0%      147kB ± 0%       ~     (all equal)
Fields/ASCII/1048576        2.27MB ± 0%     2.27MB ± 0%       ~     (all equal)
Fields/Mixed/16              96.0B ± 0%      96.0B ± 0%       ~     (all equal)
Fields/Mixed/256              768B ± 0%       768B ± 0%       ~     (all equal)
Fields/Mixed/4096           9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
Fields/Mixed/65536           147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
Fields/Mixed/1048576        2.26MB ± 0%     9.61MB ± 0%   +324.89%  (p=0.000 n=10+10)
FieldsFunc/ASCII/16          80.0B ± 0%      80.0B ± 0%       ~     (all equal)
FieldsFunc/ASCII/256          768B ± 0%       768B ± 0%       ~     (all equal)
FieldsFunc/ASCII/4096       9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
FieldsFunc/ASCII/65536       147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
FieldsFunc/ASCII/1048576    2.27MB ± 0%     9.61MB ± 0%   +323.72%  (p=0.000 n=10+10)
FieldsFunc/Mixed/16          96.0B ± 0%      96.0B ± 0%       ~     (all equal)
FieldsFunc/Mixed/256          768B ± 0%       768B ± 0%       ~     (all equal)
FieldsFunc/Mixed/4096       9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
FieldsFunc/Mixed/65536       147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
FieldsFunc/Mixed/1048576    2.26MB ± 0%     9.61MB ± 0%   +324.89%  (p=0.000 n=10+10)

name                      old allocs/op  new allocs/op   delta
Fields/ASCII/16               1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/ASCII/256              1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/ASCII/4096             1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/ASCII/65536            1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/ASCII/1048576          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/Mixed/16               1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/Mixed/256              1.00 ± 0%       1.00 ± 0%       ~     (all equal)
Fields/Mixed/4096             1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
Fields/Mixed/65536            1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
Fields/Mixed/1048576          1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)
FieldsFunc/ASCII/16           1.00 ± 0%       1.00 ± 0%       ~     (all equal)
FieldsFunc/ASCII/256          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
FieldsFunc/ASCII/4096         1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
FieldsFunc/ASCII/65536        1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
FieldsFunc/ASCII/1048576      1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)
FieldsFunc/Mixed/16           1.00 ± 0%       1.00 ± 0%       ~     (all equal)
FieldsFunc/Mixed/256          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
FieldsFunc/Mixed/4096         1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
FieldsFunc/Mixed/65536        1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
FieldsFunc/Mixed/1048576      1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)

Change-Id: If1926782decc2f60d3b4b8c41c2ce7d8bdedfd8f
Reviewed-on: https://go-review.googlesource.com/55131
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
6 years agostrconv: unify error creation in ParseUint with ParseInt
Martin Möhrmann [Sat, 12 Aug 2017 19:24:07 +0000 (21:24 +0200)]
strconv: unify error creation in ParseUint with ParseInt

Remove goto and use helper functions in ParseUint to create errors.

Change-Id: I1c4677ae1b9980db79065a9f8ca1f2c470249505
Reviewed-on: https://go-review.googlesource.com/55135
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
6 years agostrconv: adjust test output and names for parseUint and parseInt
Martin Möhrmann [Sat, 12 Aug 2017 20:05:11 +0000 (22:05 +0200)]
strconv: adjust test output and names for parseUint and parseInt

Instead of printing Atoi as function name for test failures
print the actual function name and arguments tested.

Add a base field to the parseUint64BaseTests for consistency with
the parseInt64BaseTests tests.

Change-Id: Ib9891bdb87b62672b4216625212acfe6474c70fc
Reviewed-on: https://go-review.googlesource.com/55136
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
6 years agoruntime: add a use of runtime.KeepAlive's argument
Keith Randall [Fri, 11 Aug 2017 16:48:46 +0000 (09:48 -0700)]
runtime: add a use of runtime.KeepAlive's argument

This makes sure that its argument is marked live on entry.
We need its arg to be live so defers of KeepAlive get
scanned correctly by the GC.

Fixes #21402

Change-Id: I906813e433d0e9726ca46483723303338da5b4d7
Reviewed-on: https://go-review.googlesource.com/55150
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go: parallelize fmt
Dmitry Vyukov [Tue, 13 Jun 2017 11:54:46 +0000 (13:54 +0200)]
cmd/go: parallelize fmt

Currently go fmt formats all files sequentially.
That's a shame. Parallelize it over files.

Reduces time of go fmt ./... in std lib
from ~6.1s to ~0.9s.

Reduces time of go fmt github.com/google/syzkaller/...
from ~5.2s to ~1.8s.

Change-Id: I3d27fc25326106b2a4781e13506a25c12d5bcdc5
Reviewed-on: https://go-review.googlesource.com/45491
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoencoding/base32: improve performance in common case
Ilya Tocar [Tue, 1 Aug 2017 20:12:54 +0000 (15:12 -0500)]
encoding/base32: improve performance in common case

Unroll loop to improve perfromance back to 1.8 level.
name              old time/op    new time/op    delta
EncodeToString-6    63.0µs ± 3%    51.7µs ± 2%  -17.94%  (p=0.000 n=10+10)

name              old speed      new speed      delta
EncodeToString-6   130MB/s ± 3%   159MB/s ± 2%  +21.83%  (p=0.000 n=10+10)

Vs 1.8:
EncodeToString-6    54.9µs ± 2%    51.7µs ± 2%   -5.95%  (p=0.000 n=10+10)

name              old speed      new speed      delta
EncodeToString-6   149MB/s ± 2%   159MB/s ± 2%   +6.32%  (p=0.000 n=10+10)

Fixes #21262

Change-Id: I41bf7e1f61041781386d16d573bffe1a7173c0c3
Reviewed-on: https://go-review.googlesource.com/52510
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/link: don't link the same dylib multiple times
Hiroshi Ioka [Thu, 1 Jun 2017 07:23:40 +0000 (16:23 +0900)]
cmd/link: don't link the same dylib multiple times

Also, unexport Machoadddynlib

n=`go test -c crypto/x509 && otool -l x509.test | grep libSystem | wc -l`

Before this CL, n = 3.
After this CL, n = 1.

on my environment.

Change-Id: Ic7b8157435cc85086404860dc6c84eb0aecc5d19
Reviewed-on: https://go-review.googlesource.com/44771
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>

6 years agodebug/macho: add relocation types
Hiroshi Ioka [Mon, 14 Aug 2017 10:39:17 +0000 (19:39 +0900)]
debug/macho: add relocation types

Fixes #21435

Change-Id: I5f8d93a45b84a871ceea881ecb1a38a37e96006c
Reviewed-on: https://go-review.googlesource.com/55263
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go, cmd/link: enable buildmode=pie on darwin/amd64
Hiroshi Ioka [Sat, 5 Aug 2017 09:25:26 +0000 (18:25 +0900)]
cmd/go, cmd/link: enable buildmode=pie on darwin/amd64

Change some configurations to enable the feature. Also add the test.
This CL doesn't include internal linking support which is tentatively
disabled due to #18968. We could do that another day.

Fixes #21220

Change-Id: I601d2d78446d36332acc70be0d5b9461ac635208
Reviewed-on: https://go-review.googlesource.com/54790
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoencoding/csv: preserve \r\n in quoted fields
Justin Nuß [Wed, 2 Aug 2017 17:46:41 +0000 (19:46 +0200)]
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>

6 years agonet/http: various small cleanups
Daniel Martí [Thu, 10 Aug 2017 02:31:11 +0000 (11:31 +0900)]
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>
6 years agocmd/compile/internal/syntax: fix 'delimiters' spelling
Alberto Donizetti [Mon, 14 Aug 2017 14:01:41 +0000 (16:01 +0200)]
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>
6 years agospec: better comment in example for type definition
griesemer [Fri, 11 Aug 2017 14:51:40 +0000 (16:51 +0200)]
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>
6 years agofmt: add ascii fast path for decoding verbs
Martin Möhrmann [Fri, 10 Mar 2017 19:55:51 +0000 (20:55 +0100)]
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>
6 years agoruntime, internal/cpu: CPU capabilities detection for ppc64x
Carlos Eduardo Seo [Mon, 10 Jul 2017 18:28:27 +0000 (15:28 -0300)]
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>
6 years agoarchive/tar: adjust bytediff to print full context
Joe Tsai [Fri, 11 Aug 2017 18:47:16 +0000 (11:47 -0700)]
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>

6 years agoarchive/tar: implement specialized logic for PAX format
Joe Tsai [Sat, 12 Aug 2017 01:58:58 +0000 (18:58 -0700)]
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>

6 years agocmd/cgo: use first error position instead of last one
Hiroshi Ioka [Mon, 5 Jun 2017 00:06:30 +0000 (09:06 +0900)]
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>
6 years agocmd/link: prefer to use constants in macho.go
Hiroshi Ioka [Sat, 12 Aug 2017 06:56:22 +0000 (15:56 +0900)]
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>

6 years agocmd/link: don't emit default entry symbol in some situations
Hiroshi Ioka [Wed, 21 Jun 2017 09:35:38 +0000 (18:35 +0900)]
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>
6 years agodebug/macho: add some file flags
Hiroshi Ioka [Sat, 12 Aug 2017 06:21:05 +0000 (15:21 +0900)]
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>

6 years agoencoding/hex: improve tests
Agniva De Sarker [Sun, 13 Aug 2017 16:40:49 +0000 (22:10 +0530)]
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>

6 years agoencoding/csv: report line start line in errors
Justin Nuß [Wed, 2 Aug 2017 17:18:30 +0000 (19:18 +0200)]
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>

6 years agocmd/link: remove redundant switch stmt
Hiroshi Ioka [Sun, 9 Jul 2017 00:01:47 +0000 (09:01 +0900)]
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>

6 years agocmd/vet: fix a couple of minor word choices in README
Rob Pike [Mon, 14 Aug 2017 03:47:13 +0000 (13:47 +1000)]
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>
6 years agosyscall: add utimensat and use it for UtimesNano on BSD and Solaris
Tobias Klauser [Fri, 11 Aug 2017 14:49:01 +0000 (16:49 +0200)]
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>

6 years agotime: remove unused parameter
Kevin Burke [Mon, 14 Aug 2017 01:49:27 +0000 (19:49 -0600)]
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>

6 years agoRevert "Revert "cmd/compile: discard duplicate inline method bodies""
Austin Clements [Fri, 11 Aug 2017 14:36:16 +0000 (14:36 +0000)]
Revert "Revert "cmd/compile: discard duplicate inline method bodies""

This reverts commit f612cd704a260cf362e5b6307b7ace4eb83f5f56.

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>
6 years agoruntime: remove indentation in mapiternext
Josh Bleecher Snyder [Fri, 11 Aug 2017 15:36:13 +0000 (08:36 -0700)]
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>
6 years agoruntime: simplify hashmap tooManyOverflowBuckets
Josh Bleecher Snyder [Thu, 10 Aug 2017 15:11:46 +0000 (08:11 -0700)]
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>
6 years agoruntime: CSE some function arguments in evacuate
Josh Bleecher Snyder [Wed, 7 Jun 2017 18:35:17 +0000 (11:35 -0700)]
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>
6 years agoruntime: remove indentation in evacuate
Josh Bleecher Snyder [Thu, 10 Aug 2017 13:46:36 +0000 (06:46 -0700)]
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>
6 years agoruntime: make map deletion benchmarks faster to run
Josh Bleecher Snyder [Fri, 9 Jun 2017 18:28:42 +0000 (11:28 -0700)]
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>
6 years agoruntime: support DT_GNU_HASH in VDSO
Austin Clements [Tue, 13 Jun 2017 12:52:53 +0000 (08:52 -0400)]
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>
6 years agoarchive/zip: fix Writer to validate file
Audrey Lim [Sat, 15 Jul 2017 18:33:06 +0000 (12:33 -0600)]
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>

6 years agostrconv: avoid truncation of output in parse int tests
Martin Möhrmann [Sat, 12 Aug 2017 20:15:43 +0000 (22:15 +0200)]
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>
6 years agostrings: speed up FieldsFunc
Martin Möhrmann [Tue, 2 May 2017 08:09:18 +0000 (10:09 +0200)]
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>
6 years agostrconv: fix ParseUint return value on range overflow
Martin Möhrmann [Sat, 12 Aug 2017 18:11:55 +0000 (20:11 +0200)]
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>
6 years agoarchive/tar: simplify toASCII and parseString
Joe Tsai [Thu, 10 Aug 2017 21:41:44 +0000 (14:41 -0700)]
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>

6 years agoarchive/tar: optimize formatPAXRecord() call
Agniva De Sarker [Fri, 11 Aug 2017 19:23:45 +0000 (00:53 +0530)]
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>
6 years agoarchive/tar: implement specialized logic for USTAR format
Joe Tsai [Fri, 11 Aug 2017 05:34:51 +0000 (22:34 -0700)]
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>
6 years agoencoding/binary: add example for Read multi
Mark Wolfe [Tue, 8 Aug 2017 11:22:41 +0000 (21:22 +1000)]
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>

6 years agotext/template: support indexing into *int* maps
Emmanuel Odeke [Mon, 22 May 2017 21:17:38 +0000 (15:17 -0600)]
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>
6 years agoruntime: fix crashing with foreign signal handlers on Darwin
Elias Naur [Fri, 11 Aug 2017 17:46:45 +0000 (19:46 +0200)]
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>
6 years agoruntime/cgo: make code robust
Hiroshi Ioka [Tue, 11 Jul 2017 09:57:54 +0000 (18:57 +0900)]
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>

6 years agoruntime, cmd/compile: add intrinsic getclosureptr
Cholerae Hu [Sat, 5 Aug 2017 06:44:00 +0000 (14:44 +0800)]
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>