Adam Langley [Fri, 18 Aug 2017 20:51:07 +0000 (13:51 -0700)]
crypto/x509: get hash information from signatureAlgorithmDetails and check that it matches
signatureAlgorithmDetails already knows the hash function for each
signature algorithm so there's no point in duplicating that. Also, check
that the public key type of the signature algorithm actually matches the
given public key.
David Crawshaw [Sun, 3 Sep 2017 16:33:56 +0000 (12:33 -0400)]
cmd/go: put computed GOROOT in built binaries
As of CL 42533, cmd/go will recompute its GOROOT based on the
location of its own executable. This CL plumbs that computed GOROOT
into every binary it builds using the linker -X flag. This
means binaries built with a moved cmd/go will report the GOROOT
they were built in from runtime.GOROOT().
Fixes #21313
Change-Id: I6c2c559f40f2a0c867ab60cf47c6dbc73ae5e28a
Reviewed-on: https://go-review.googlesource.com/61310
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Munday [Fri, 8 Sep 2017 23:22:29 +0000 (00:22 +0100)]
math: fix Abs, Copysign and Signbit benchmarks
CL 62250 makes constant folding a bit more aggressive and these
benchmarks were optimized away. This CL adds some indirection to
the function arguments to stop them being folded.
The Copysign benchmark is a bit faster because I've left one
argument as a constant and it can be partially folded.
Matthew Dempsky [Thu, 31 Aug 2017 18:26:28 +0000 (11:26 -0700)]
cmd/pack: fix export data truncation bug
The binary export data format includes escaping to prevent "\n$$" from
appearing internally, but not "\n!\n". This could result in a false
positive when cmd/pack searched for "\n!\n" as the delimiter between
package definition and linker object.
To address this, this CL changes cmd/pack to also be aware of the
"\n$$" markers, and to ignore "\n!\n" within the export data.
Fixes #21703.
Change-Id: I71ea8ba49dbd066c7afb7717ddc0190e38fe5649
Reviewed-on: https://go-review.googlesource.com/60773
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Than McIntosh [Fri, 8 Sep 2017 15:11:19 +0000 (11:11 -0400)]
test: add test that caused gccgo incorrect compilation
Updates #21770
Change-Id: Ic31c3bdae30797f406f25c737b83bbe2de1ed1da
Reviewed-on: https://go-review.googlesource.com/62331 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Juan Carlos [Fri, 21 Jul 2017 22:55:57 +0000 (17:55 -0500)]
time: change wording in duration hours example
Change-Id: I86728a1c6c20471beaa3546ca7a43a8edeb9f0b7
Reviewed-on: https://go-review.googlesource.com/50691
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adrian Hesketh <adrianhesketh@hushmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Marvin Stenger [Thu, 31 Aug 2017 11:00:19 +0000 (13:00 +0200)]
cmd/dist: move functions for the better
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (6).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I1c49e3427079194210a6416057100a7e94a37619
Reviewed-on: https://go-review.googlesource.com/61012
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Marvin Stenger [Thu, 31 Aug 2017 10:44:28 +0000 (12:44 +0200)]
cmd/dist: remove trivial variables + functions
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (5).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I0efd1271b6a70bb9248d82f8a4d869556f4a557e
Reviewed-on: https://go-review.googlesource.com/61011
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Marvin Stenger [Thu, 31 Aug 2017 10:27:53 +0000 (12:27 +0200)]
cmd/dist: use standard generated code header
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (4).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I5e163f89a518f074e58bf2d44597e553c918d7e6
Reviewed-on: https://go-review.googlesource.com/61010
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
cmd/dist: unleash bootstrap optimization for windows
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (3).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I7612bbc3939e6fca3bee4b8e92c528178dd46cd7
Reviewed-on: https://go-review.googlesource.com/61023 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The behavior was changed unintentionally during the conversion from C to Go.
Reviewed-on: https://go-review.googlesource.com/2470
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (2).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I53373c7211b35ed68da485c55e510871bfb81267
Reviewed-on: https://go-review.googlesource.com/61022 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Marvin Stenger [Thu, 31 Aug 2017 10:21:51 +0000 (12:21 +0200)]
cmd/dist: apply minor fixes
This belongs to a series of clean-up changes (see below) for cmd/dist.
This is change (1).
These changes include:
(1) apply minor fixes
(2) restore behavior of branchtag
(3) unleash bootstrap optimization for windows
(4) use standard generated code header
(5) remove trivial variables + functions
(6) move functions for the better
(7) simplify code segments
(8) use bytes.Buffer for code generation
(9) rename variables + functions
(10) remove doc.go
Change-Id: I49e5f2a9b6146e2b60a067da5bac31434ffc9aaf
Reviewed-on: https://go-review.googlesource.com/60650 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
cmd/link: extract windows-specific code from dynrelocsym
No functional changes.
Change-Id: Ib31bb3f01b515aac6428ec61e0ef02b269623890
Reviewed-on: https://go-review.googlesource.com/62470 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Change-Id: Idad9cdee36679373ee223ff2bd4c021ea0afcce1
Reviewed-on: https://go-review.googlesource.com/61710 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diagnostics guide lists various dimensions of
diagnostics tools and libraries available in Go.
As a follow-up, I will add an entry section where
we navigate user to the right tool depending on
the type of problem they are willing to improve
or understand better.
Change-Id: I4e94b4b834014f51c988103457da84200c7827d9
Reviewed-on: https://go-review.googlesource.com/61693 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Michael Munday [Fri, 8 Sep 2017 00:31:13 +0000 (01:31 +0100)]
cmd/compile: propagate constants through math.Float{32,64}{,from}bits
This CL adds generic SSA rules to propagate constants through raw bits
conversions between floats and integers. This allows constants to
propagate through some math functions. For example, math.Copysign(0, -1)
is now constant folded to a load of -0.0.
Requires a fix to the ARM assembler which loaded -0.0 as +0.0.
Perm and Shuffle are fundamentally doing the same work.
This change makes Perm's algorithm match Shuffle's.
In addition to allowing developers to switch more
easily between the two methods, it affords a nice speed-up:
name old time/op new time/op delta
Perm3-8 75.7ns ± 1% 51.8ns ± 1% -31.59% (p=0.000 n=9+8)
Perm30-8 610ns ± 1% 405ns ± 1% -33.67% (p=0.000 n=9+9)
This change alters the output from Perm,
given the same Source and seed.
This is a change from Go 1.0 behavior.
This necessitates updating the regression test.
This also changes the number of calls made to the Source
during Perm, which changes the output of the math/rand examples.
This also slightly perturbs the output of Perm,
nudging it out of the range currently accepted by TestUniformFactorial.
However, it is complete unclear that the helpers relied on
by TestUniformFactorial are correct. That is #21211.
This change updates checkSimilarDistribution to respect
closeEnough for standard deviations, which makes the test pass.
The whole situation is muddy; see #21211 for details.
There is an alternative implementation of Perm
that avoids initializing m, which is more similar
to the existing implementation, plus some optimizations:
func (r *Rand) Perm(n int) []int {
m := make([]int, n)
max31 := n
if n > 1<<31-1-1 {
max31 = 1<<31 - 1 - 1
}
i := 1
for ; i < max31; i++ {
j := r.int31n(int32(i + 1))
m[i] = m[j]
m[j] = i
}
for ; i < n; i++ {
j := r.Int63n(int64(i + 1))
m[i] = m[j]
m[j] = i
}
return m
}
This is a tiny bit faster than the implementation
actually used in this change:
name old time/op new time/op delta
Perm3-8 51.8ns ± 1% 50.3ns ± 1% -2.83% (p=0.000 n=8+9)
Perm30-8 405ns ± 1% 394ns ± 1% -2.66% (p=0.000 n=9+8)
However, 3% in performance doesn't seem worth
having the two algorithms diverge,
nor the reduced readability of this alternative.
Updates #16213.
Change-Id: I11a7441ff8837ee9c241b4c88f7aa905348be781
Reviewed-on: https://go-review.googlesource.com/55972
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Since this is new API, it affords us the opportunity
to use a much faster Int31n implementation that mostly avoids division.
As a result, BenchmarkPerm30ViaShuffle is
about 30% faster than BenchmarkPerm30,
despite requiring a separate initialization loop
and using function calls to swap elements.
Fixes #20480
Updates #16213
Updates #21211
Change-Id: Ib8956c4bebed9d84f193eb98282ec16ee7c2b2d5
Reviewed-on: https://go-review.googlesource.com/51891
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Cholerae Hu [Tue, 25 Jul 2017 06:04:50 +0000 (14:04 +0800)]
time: don't match '---' month in time.Parse
The existing implementation will panic when month in date string is '---'.
Fixed #21113
Change-Id: I8058ae7a4102e882f8b7e9c65d80936b563265e4
Reviewed-on: https://go-review.googlesource.com/51010
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change-Id: I143203a9dcf9a4da0e53a3aab6e370244b849296
Reviewed-on: https://go-review.googlesource.com/62270
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
net/http: make ServeMux preserve query string during redirects
Ensure that the implicitly created redirect
for
"/route"
after
"/route/"
has been registered doesn't lose the query string information.
A previous attempt (https://golang.org/cl/43779) changed http.Redirect, however, that change broke direct calls to http.Redirect.
To avoid that problem, this change touches ServeMux.Handler only.
Fixes #17841
Change-Id: I303c1b1824615304ae68147e254bb41b0ea339be
Reviewed-on: https://go-review.googlesource.com/61210
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Matthew Dempsky [Wed, 6 Sep 2017 01:49:36 +0000 (18:49 -0700)]
cmd/compile: simplify exporting universal 'error' type
There shouldn't be any problems setting error's "Orig" (underlying)
type to a separate anonymous interface, as this is already how
go/types defines it.
Change-Id: I44e9c4048ffe362ce329e8306632e38b5ccfecff
Reviewed-on: https://go-review.googlesource.com/61790
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Alan Donovan <adonovan@google.com>
cmd/compile: more compact DWARF location for locals and arguments
Now that all functions have a DW_AT_frame_base defined we can use
DW_OP_fbreg to specify the location of variables and formal parameters,
instead of the DW_OP_call_frame_cfa/DW_OP_consts/DW_OP_plus, saving 2
bytes for every variable and 2 bytes for every formal parameter after
the first one.
cmd/compile: more compact representation of DW_AT_high_pc
DWARF version 4 allows DW_AT_high_pc to be represented as a constant
offset from DW_AT_low_pc, this can help save up to 7 bytes per
function/lexical scope.
`EXTRACTPS immb, xmm, r/m` is not included in this
change due to new ytab set 'yextractps'. This should simplify
code review.
4-operand instructions are a subject of upcoming changes that
make 4-th (and so on) operands explicit.
Related TODO note in asm6.go:
"dont't hide 4op, some version have xmm version".
Part of the mission to add missing amd64 SSE4 instructions to Go asm.
Joe Kyo [Wed, 6 Sep 2017 09:31:03 +0000 (10:31 +0100)]
crypto/cipher: panic when IV length does not equal block size in NewOFB
Functions like NewCBCDecrypter, NewCBCEncrypter, NewCFBDecrypter,
NewCFBEncrypter and NewCTR all panic when IV length does not equal block size.
This commit changes NewOFB to panic too, instead of returning nil silently.
Martin Möhrmann [Wed, 30 Aug 2017 23:00:39 +0000 (01:00 +0200)]
cmd/compile: avoid stack allocation of a map bucket for large constant hints
runtime.makemap will allocate map buckets on the heap for hints larger
than the number of elements a single map bucket can hold.
Do not allocate any map bucket on the stack if it is known at compile time
that hint is larger than the number of elements one map bucket can hold.
This avoids zeroing and reserving memory on the stack that will not be used.
Change-Id: I1a5ab853fb16f6a18d67674a77701bf0cf29b550
Reviewed-on: https://go-review.googlesource.com/60450
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Martin Möhrmann [Sat, 2 Sep 2017 06:33:21 +0000 (08:33 +0200)]
runtime: cleanup amd64p32 memmove and memclr file organization
Move memclr to a separate file to make it consistent
with other platforms asm function to file organization.
Remove nacl from the memmove filename as the implementation
is generic for the amd64p32 platform even if currently only
nacl is supported for amd64p32.
Change-Id: I8930b76da430a5cf2664801974e4f5185fc0f82f
Reviewed-on: https://go-review.googlesource.com/61031
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Matthew Dempsky [Tue, 29 Aug 2017 22:40:32 +0000 (15:40 -0700)]
cmd/compile: fix evaluation order for OASOP
Currently, we handle "x op= y" by rewriting as "x = x op y", while
ensuring that any calls or receive operations in 'x' are only
evaluated once. Notably, pointer indirection, indexing operations,
etc. are left alone as it's typically safe to re-evaluate those.
However, those operations were interleaved with evaluating 'y', which
could include function calls that might cause re-evaluation to yield
different memory addresses.
As a fix, simply ensure that we order side-effecting operations in 'y'
before either evaluation of 'x'.
Fixes #21687.
Change-Id: Ib14e77760fda9c828e394e8e362dc9e5319a84b2
Reviewed-on: https://go-review.googlesource.com/60091
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Matthew Dempsky [Wed, 30 Aug 2017 21:17:24 +0000 (14:17 -0700)]
cmd/compile: fix and improve struct field reflect information
The previous logic was overly complicated, generated suboptimally
encoded struct type descriptors, and mishandled embeddings of
predeclared universal types.
Keith Randall [Fri, 1 Sep 2017 19:32:38 +0000 (12:32 -0700)]
runtime: fix hashmap load factor computation
overLoadFactor wasn't really doing what it says it does.
It was reporting overOrEqualToLoadFactor. That's actually what we
want when adding an entry to a map, but it isn't what we want when
constructing a map in the first place.
The impetus for this change is that if you make a map with a hint
of exactly 8 (which happens, for example, with the unitMap in
time/format.go), we allocate 2 buckets for it instead of 1.
Instead, make overLoadFactor really report when it is > the max
allowed load factor, not >=. Adjust the callers who want to ensure
that the map is no more than the max load factor after an insertion
by adding a +1 to the current (pre-addition) size.
Change-Id: Ie8d85344800a9a870036b637b1031ddd9e4b93f9
Reviewed-on: https://go-review.googlesource.com/61053
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Ilya Tocar [Tue, 20 Jun 2017 20:36:34 +0000 (15:36 -0500)]
cmd/compile/internal/amd64: add MOVLloadidx8 and MOVLstoreidx8
Currently we only use 1 and 4 as a scale for indexed 4-byte load.
In code generated in #20711 we can use indexed load with scale=8,
to improve performance:
name old time/op new time/op delta
GM-6 108µs ± 0% 95µs ± 0% -12.06% (p=0.000 n=10+10)
So add new ops and combine loadidx1(shift 3..).. into loadidx8,
same for stores.
David Crawshaw [Fri, 1 Sep 2017 15:20:33 +0000 (11:20 -0400)]
cmd/go: pass plugin package name to compile -p
When compiling a plugin, package main gets a new name so as not to
conflict with the main package in the host binary, or any other
plugins. It is already defined by cmd/go, and used by cmd/link when
filling out the "" package placeholder in symbols.
With this CL, the plugin-specific name for main is also passed to
cmd/compile's -p flag. This is used to fill out the pkgpath field
of types, and ensures that two types defined in two different plugin
mains with the same name will not be mistaken for one another at
runtime.
Fixes #21386
Change-Id: I8a646d8d7451caff533fe0007343ea8b8e1704ed
Reviewed-on: https://go-review.googlesource.com/60910
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
griesemer [Wed, 30 Aug 2017 13:10:12 +0000 (15:10 +0200)]
spec: clarify context type for certain non-constant shifts
The spec is not conclusive about whether a non-constant shift of
certain untyped constant left operands is valid when the shift
expression appears as an index in an index or slice expression,
or as a size in a `make` function call.
Despite identical spec rules in all these cases, cmd/compile accepts
make([]byte, 1.0 << s)
but pronounces an error for
a[1.0 << s]
(go/types accepts both).
This change clarifies the spec by explicitly stating that an
untyped constant left operand in a non-constant shift (1.0 in
the above examples) will be given type `int` in these contexts.
A separate issue #21693 addresses the cmd/compile bug.
Fixes #14844.
Change-Id: I4b52125e487a607fae377fcbed55463cdce9836c
Reviewed-on: https://go-review.googlesource.com/60230 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Thu, 31 Aug 2017 11:26:40 +0000 (13:26 +0200)]
archive/tar: populate Devmajor and Devminor in FileInfoHeader on Darwin
Extract device major/minor number on Darwin and set Devmajor and
Devminor in FileInfoHeader. Code based on the Major/Minor functions for
Darwin in golang.org/x/sys/unix.
Change-Id: I51b65f607bfa2e6b177b8b66e2b246b771367b84
Reviewed-on: https://go-review.googlesource.com/60850 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
griesemer [Thu, 31 Aug 2017 15:41:51 +0000 (17:41 +0200)]
go/types: fix Info.Implicits entries
Packages of dot imports don't appear in the Info.Implicits map
since they are already taken care of by the Info.Defs map. Fix
documentation.
Implicitly dot-imported objects of a package shouldn't appear
in the Info.Implicits map because the documentation never said
so and there's no way to map multiple objects to the same
*ast.ImportSpec with the current data structure.
Added missing test for Info.Implicits.
The fix is a trivial one-line deletion, the rest is documentation
and test.
Fixes #21591.
Change-Id: I12a37dab85c531911c9363ec3d58daa095c7eb24
Reviewed-on: https://go-review.googlesource.com/60672 Reviewed-by: Alan Donovan <adonovan@google.com>
Rob Pike [Fri, 1 Sep 2017 03:00:51 +0000 (13:00 +1000)]
cmd/go: document the build flags properly for vet
The "build flags" mentioned in the documentation are only those
that apply to analyzing packages and executing the tool.
Fixes #21711.
Change-Id: Ie7b2a354f1e30c928b40888c51fc68e599a5444a
Reviewed-on: https://go-review.googlesource.com/60830 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Hiroshi Ioka [Thu, 31 Aug 2017 04:49:43 +0000 (13:49 +0900)]
cmd/cgo: support large unsigned macro again
The approach of https://golang.org/cl/43476 turned out incorrect.
The problem is that the sniff introduced by the CL only work for simple
expression. And when it fails it fallback to uint64, not int64, which
breaks backward compatibility.
In this CL, we use DWARF for guessing kind instead. That should be more
reliable than previous approach. And importanly, it fallbacks to int64 even
if it fails to guess kind.
Fixes #21708
Change-Id: I39a18cb2efbe4faa9becdcf53d5ac68dba180d46
Reviewed-on: https://go-review.googlesource.com/60510
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joel Sing [Thu, 31 Aug 2017 17:14:38 +0000 (03:14 +1000)]
cmd/go: fix clang option handling
On OpenBSD -current, clang is available/installed as 'cc'. This means that
the existing clang check fails and the clang related flags are not enabled.
Fix this by enabling the clang flags if the compiler claims to support them.
Change-Id: I84d124d2409a10f87002c6cbfdb69b4c9a55981a
Reviewed-on: https://go-review.googlesource.com/60750 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Filippo Valsorda [Mon, 27 Feb 2017 12:45:02 +0000 (18:15 +0530)]
crypto/cipher: extend the docs of BlockMode and Stream
Change-Id: Iebb5b67c8defec22edd482d587edaf399a7ba82a
Reviewed-on: https://go-review.googlesource.com/37418 Reviewed-by: Adam Langley <agl@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
cmd/link: emit DW_AT_data_member_location as a constant
Simplify the DWARF representation of structs by emitting field offsets
as constants rather than location descriptions.
This was not explicitly mentioned as an option in DWARF2. It is
mentioned in DWARF4, but isn't listed in the changes, so it's not clear
if this was always intended to work or is an undocumented change. Either
way, it should be valid DWARF4.
Change-Id: Idf7fdd397a21c8f8745673ecc77ef65afa3ffe1c
Reviewed-on: https://go-review.googlesource.com/51611
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com>
Bryan C. Mills [Tue, 15 Aug 2017 19:08:39 +0000 (15:08 -0400)]
io/ioutil: don't cap buffer size in ReadFile
When we added a Stat call to determine the initial buffer size in
https://golang.org/cl/163069, we included an arbitrary 1e9-byte limit
"just in case". That interacts badly with power-of-2 resizing in
*bytes.Buffer: it causes buffers reading from very large files to
consume up to twice the necessary space.
The documentation for (os.FileInfo).Size says that it reports "length
in bytes for regular files; system-dependent for others", but the
"system dependent" cases overwhelmingly return either a small number
(e.g., the length of the target path for a symlink) or a non-positive
number (e.g., for a file in /proc under Linux). It should be
appropriate to use the number reported by Size as an approximate lower
bound, even if it is large.
fixes #21455
Change-Id: I609c72519b7b87428c24d0b22db46eede30e0e54
Reviewed-on: https://go-review.googlesource.com/55870 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Kunpei Sakai [Tue, 29 Aug 2017 09:56:59 +0000 (18:56 +0900)]
net/http: make startBackgroundRead panic if hijacked
Fixes #20933
Change-Id: I827c8d265674a7448c51c1da991e9b3b4501ba11
Reviewed-on: https://go-review.googlesource.com/59850
Run-TryBot: Tom Bergan <tombergan@google.com> Reviewed-by: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
griesemer [Thu, 31 Aug 2017 09:39:17 +0000 (11:39 +0200)]
go/types: add +build ignore to file generated by hilbert test
This makes sure that the go/types package still builds even if
the hilbert test generated its test file in the go/types package
(when run as: go test -run Hilbert -out=h.go).
Change-Id: I60ecbaaa1537de14cfa95e2e6fc8ebedff651baf
Reviewed-on: https://go-review.googlesource.com/60531 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Joe Tsai [Thu, 31 Aug 2017 01:49:18 +0000 (18:49 -0700)]
compress/flate: remove non-standard extensions to flate
Some constants were added to flate that seem to be an experimental
attempt at increasing the window size. However, according to RFC1951,
the largest window size is 32KiB, so these constants are non-standard.
Delete them.
Fixes #18458
Change-Id: Ia94989637ca031a56bce2548624fa48044caa7b9
Reviewed-on: https://go-review.googlesource.com/60490
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Normal shift rules plus constant folding are enough to generate
efficient shift-by-constant instructions.
Add test to make sure we don't generate comparisons for constant
shifts.
TODO: there are still constant shift rules on PPC64. If they
are removed, the constant folding rules are not enough to remove
all the test and mask stuff for constant shifts. Leave them in
for now.
Chris Ball [Thu, 25 May 2017 19:48:02 +0000 (15:48 -0400)]
runtime: add symbols for Linux syscall numbers on 386/amd64
Matches other architectures by using names for syscalls instead of
numbers directly.
Fixes #20499.
Change-Id: I63d606b0b1fe6fb517fd994a7542a3f38d80dd54
Reviewed-on: https://go-review.googlesource.com/44213
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Hiroshi Ioka [Tue, 23 May 2017 14:01:08 +0000 (23:01 +0900)]
cmd/cgo: support niladic function-like macros
Currently, cgo supports only macros which can be reduced to constants
or variables. The CL addresses remaining parts, macros which can be
represented as niladic functions.
The basic idea is simple:
1. make a thin wrapper function per macros.
2. replace macro expansions with function calls.
Fixes #10715
Fixes #18720
Change-Id: I150b4fb48e9dc4cc34466ef6417c04ac93d4bc1a
Reviewed-on: https://go-review.googlesource.com/43970
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Sat, 26 Aug 2017 09:12:56 +0000 (02:12 -0700)]
archive/tar: minor doc fixes
Use "file" consistently instead of "entry".
Change-Id: Ia81c9665d0d956adb78f7fa49de40cdb87fba000
Reviewed-on: https://go-review.googlesource.com/60150 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Fri, 25 Aug 2017 23:48:46 +0000 (16:48 -0700)]
archive/tar: require opt-in to PAX or GNU format for time features
Nearly every Header obtained from FileInfoHeader via the FS has
timestamps with sub-second resolution and the AccessTime
and ChangeTime fields populated. This forces the PAX format
to almost always be used, which has the following problems:
* PAX is still not as widely supported compared to USTAR
* The PAX headers will occupy at minimum 1KiB for every entry
The old behavior of tar Writer had no support for sub-second resolution
nor any support for AccessTime or ChangeTime, so had neither problem.
Instead the Writer would just truncate sub-second information and
ignore the AccessTime and ChangeTime fields.
In this CL, we preserve the behavior such that the *default* behavior
would output a USTAR header for most cases by truncating sub-second
time measurements and ignoring AccessTime and ChangeTime.
To use either of the features, users will need to explicitly specify
that the format is PAX or GNU.
The exact policy chosen is this:
* USTAR and GNU may still be chosen even if sub-second measurements
are present; they simply truncate the timestamp to the nearest second.
As before, PAX uses sub-second resolutions.
* If the Format is unspecified, then WriteHeader ignores AccessTime
and ChangeTime when using the USTAR format.
This ensures that USTAR may still be chosen for a vast majority of
file entries obtained through FileInfoHeader.
Updates #11171
Updates #17876
Change-Id: Icc5274d4245922924498fd79b8d3ae94d5717271
Reviewed-on: https://go-review.googlesource.com/59230
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Marvin Stenger [Wed, 30 Aug 2017 11:52:12 +0000 (13:52 +0200)]
runtime/internal/sys: use standard generated code header
This change implements the convention for generated code header agreed upon in https://golang.org/s/generatedcode.
Additionally run go generate.
Also update some comments.
Updates #13560
Change-Id: If45f91b93aaa0d43280c2c4630823bc4d2dc7d3a
Reviewed-on: https://go-review.googlesource.com/60250
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Stapelberg [Wed, 30 Aug 2017 14:50:13 +0000 (07:50 -0700)]
context: fix lint warning “drop = 0 from declaration”
Previously, the suggested code would result in the following golint warning:
“should drop = 0 from declaration of var errorsOnlyKey; it is the zero value”
Change-Id: I1a302c1e40ca89acbc76897e39097ecd04865460
Reviewed-on: https://go-review.googlesource.com/60290 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ilya Tocar [Wed, 23 Aug 2017 16:08:56 +0000 (11:08 -0500)]
cmd/compile/internal/ssa: remove redundant zeroextensions on amd64
Some instructions operating on <= 32 bits also zero out upper 32bits.
Remove zeroextensions of such values. Triggers a few times during
all.bash. Also removes ugly code like:
MOVL CX,CX
griesemer [Tue, 29 Aug 2017 13:48:07 +0000 (15:48 +0200)]
doc: minor clarification regarding the sharing of underlying arrays
The last sentence in the section on slice expressions could be read
as if it might apply to strings. Changed the sentence a bit to
emphasize its applicability to slices only. See also the issue for
more background.
Fixes #19220.
Change-Id: I8551f34230e4ed93f951e7b871cc81f54a5874a9
Reviewed-on: https://go-review.googlesource.com/59890 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ben Shi [Fri, 25 Aug 2017 12:07:01 +0000 (12:07 +0000)]
cmd/compile: optimize ARM with MULS
MULS was introduced in ARMv7 and corresponding to MULA. This patch
duplicated all MULA related SSA rules with MULS.
Here was the contrast test result against the original go compiler.
There was no improvement in total, but big improvement in special cases.
1. A specific test case accelerated 18.62%.
(https://github.com/benshi001/ugo1/blob/master/mulsub_test.go)
name old time/op new time/op delta
MulSub-4 270µs ± 0% 219µs ± 0% -18.62% (p=0.000 n=35+40)
2. Total size of all .a files in pkg/ shrank by 0.002%.