Brad Fitzpatrick [Fri, 2 Nov 2018 15:47:40 +0000 (15:47 +0000)]
runtime: look up runtime env variables case insensitively on Windows
Fixes #28557
Change-Id: Ifca958b78e8c62fbc66515e693f528d799e8e84b
Reviewed-on: https://go-review.googlesource.com/c/147039 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Fri, 2 Nov 2018 09:55:12 +0000 (10:55 +0100)]
all: fix tests for older versions of AIX 7.2
This commit fixes tests which fail on some versions of AIX 7.2 due
to internal bugs.
getsockname isn't working properly with unix networks.
Timezone files aren't returning a correct output.
Change-Id: I4ff15683912be62ab86dfbeeb63b73513404d086
Reviewed-on: https://go-review.googlesource.com/c/146940
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Fri, 2 Nov 2018 09:02:38 +0000 (10:02 +0100)]
internal/poll, os/exec, runtime: replace PollDescriptor by IsPollDescriptor
This commit changes poll.PollDescriptor by poll.IsPollDescriptor. This
is needed for OS like AIX which have more than one FD using inside their
netpoll implementation.
Change-Id: I49e12a8d74045c501e19fdd8527cf166a3c64850
Reviewed-on: https://go-review.googlesource.com/c/146938
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 14:07:57 +0000 (15:07 +0100)]
runtime: avoid runtimeNano call on a common netpoll path
runtimeNano is slower than nanotime, so pass the duration
to runtime_pollSetDeadline as is. netpoll can add nanotime itself.
Arguably a bit simpler because, say, a negative duration
clearly represents already expired timer, no need to compare to
nanotime again.
This may also fix an obscure corner case when a deadline in past
which happens to be nanotime 0 is confused with no deadline at all,
which are radically different things.
Also don't compute any durations and times if Time is zero
(currently we first compute everything and then reset d back to 0,
which is wasteful).
name old time/op new time/op delta
TCP4OneShotTimeout-6 17.1µs ± 0% 17.0µs ± 0% ~ (p=0.421 n=5+5)
SetReadDeadline-6 230ns ± 0% 205ns ± 1% -10.63% (p=0.008 n=5+5)
Change-Id: I2aad699270289a5b9ead68f5e44ec4ec6d96baa0
Reviewed-on: https://go-review.googlesource.com/c/146344 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Dmitry Vyukov [Wed, 31 Oct 2018 16:56:14 +0000 (17:56 +0100)]
runtime: execute memory barrier conditionally when changing netpoll timers
We only need the memory barrier in poll_runtime_pollSetDeadline only
when one of the timers has fired, which is not the expected case.
Memory barrier can be somewhat expensive on some archs,
so execute it only if one of the timers has in fact fired.
name old time/op new time/op delta
TCP4OneShotTimeout-6 17.0µs ± 0% 17.1µs ± 0% +0.35% (p=0.032 n=5+5)
SetReadDeadline-6 232ns ± 0% 230ns ± 0% -1.03% (p=0.000 n=4+5)
Update #25729
Change-Id: Ifce6f505b9e7ba3717bad8f454077a2e94ea6e75
Reviewed-on: https://go-review.googlesource.com/c/146343 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 16:36:51 +0000 (17:36 +0100)]
time: speed up Since and Until
time.now is somewhat expensive (much more expensive than nanotime),
in the common case when Time has monotonic time we don't actually
need to call time.now in Since/Until as we can do calculation
based purely on monotonic times.
name old time/op new time/op delta
TCP4OneShotTimeout-6 17.0µs ± 0% 17.1µs ± 1% ~ (p=0.151 n=5+5)
SetReadDeadline-6 261ns ± 0% 234ns ± 1% -10.35% (p=0.008 n=5+5)
Benchmark that only calls Until:
benchmark old ns/op new ns/op delta
BenchmarkUntil 54.0 29.5 -45.37%
Update #25729
Change-Id: I5ac5af3eb1fe9f583cf79299f10b84501b1a0d7d
Reviewed-on: https://go-review.googlesource.com/c/146341
Run-TryBot: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 16:27:16 +0000 (17:27 +0100)]
runtime, time: refactor startNano handling
Move startNano from runtime to time package.
In preparation for a subsequent change that speeds up Since and Until.
This also makes code simpler as we have less assembly as the result,
monotonic time handling is better localized in time package.
This changes values returned from nanotime on windows
(it does not account for startNano anymore), current comments state
that it's important, but it's unclear how it can be important
since no other OS does this.
Update #25729
Change-Id: I2275d57b7b5ed8fd0d53eb0f19d55a86136cc555
Reviewed-on: https://go-review.googlesource.com/c/146340 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 16:03:35 +0000 (17:03 +0100)]
runtime: add and use modtimer in netpoll
Currently when netpoll deadline is incrementally prolonged,
we delete and re-add timer each time.
Add modtimer function that does both and use it when we need
to modify an existing netpoll timer to avoid unnecessary lock/unlock.
Change-Id: I08b89dbbc1785dd180e967a37b0aa23b0c4613a8
Reviewed-on: https://go-review.googlesource.com/c/146339 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 15:18:36 +0000 (16:18 +0100)]
runtime: don't recreate netpoll timers if they don't change
Currently we always delete both read and write timers and then
add them again. However, if user setups read and write deadline
separately, then we don't need to touch the other one.
name old time/op new time/op delta
TCP4OneShotTimeout-6 17.2µs ± 0% 17.2µs ± 0% ~ (p=0.310 n=5+5)
SetReadDeadline-6 319ns ± 1% 274ns ± 2% -13.94% (p=0.008 n=5+5)
Update #25729
Change-Id: I4c869c3083521de6d0cd6ca99a7609d4dd84b4e4
Reviewed-on: https://go-review.googlesource.com/c/146338 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Wed, 31 Oct 2018 10:31:31 +0000 (11:31 +0100)]
runtime: don't wake timeproc needlessly
It's not always necessary to wake timerproc even if we add
a new timer to the top of the heap. Since we don't wake and
reset timerproc when we remove timers, it still can be sleeping
with shorter timeout. It such case it's more profitable to let it
sleep and then update timeout when it wakes on its own rather than
proactively wake it, let it update timeout and go to sleep again.
name old time/op new time/op delta
TCP4OneShotTimeout-6 18.6µs ± 1% 17.2µs ± 0% -7.66% (p=0.008 n=5+5)
SetReadDeadline-6 562ns ± 5% 319ns ± 1% -43.27% (p=0.008 n=5+5)
Update #25729
Change-Id: Iec8eacb8563dbc574a82358b3bac7ac479c16826
Reviewed-on: https://go-review.googlesource.com/c/146337 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Munday [Tue, 29 May 2018 06:26:17 +0000 (07:26 +0100)]
crypto/md5: simplify generic implementation
This change uses library functions such as bits.RotateLeft32 to
reduce the amount of code needed in the generic implementation.
Since the code is now shorter I've also removed the option to
generate a non-unrolled version of the code.
I've also tried to remove bounds checks where possible to make
the new version performant, however that is not the primary goal
of this change since most architectures have assembly
implementations already.
Alex Brainman [Sat, 20 Oct 2018 05:30:57 +0000 (16:30 +1100)]
os: use CreateFile for Stat of symlinks
Stat uses Windows FindFirstFile + CreateFile to gather symlink
information - FindFirstFile determines if file is a symlink,
and then CreateFile follows symlink to capture target details.
Lstat only uses FindFirstFile.
This CL replaces current approach with just a call to CreateFile.
Lstat uses FILE_FLAG_OPEN_REPARSE_POINT flag, that instructs
CreateFile not to follow symlink. Other than that both Stat and
Lstat look the same now. New code is simpler.
CreateFile + GetFileInformationByHandle (unlike FindFirstFile)
does not report reparse tag of a file. I tried to ignore reparse
tag altogether. And it works for symlinks and mount points.
Unfortunately (see https://github.com/moby/moby/issues/37026),
files on deduped disk volumes are reported with
FILE_ATTRIBUTE_REPARSE_POINT attribute set and reparse tag set
to IO_REPARSE_TAG_DEDUP. So, if we ignore reparse tag, Lstat
interprets deduped volume files as symlinks. That is incorrect.
So I had to add GetFileInformationByHandleEx call to gather
reparse tag after calling CreateFile and GetFileInformationByHandle.
Fixes #27225
Fixes #27515
Change-Id: If60233bcf18836c147597cc17450d82f3f88c623
Reviewed-on: https://go-review.googlesource.com/c/143578
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Alex Brainman [Sun, 21 Oct 2018 03:57:58 +0000 (14:57 +1100)]
path/filepath: change IsAbs("NUL") to return true
This CL changes IsAbs to return true for "NUL" and other Windows
reserved filenames (search
https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
for NUL for details). os.Open("NUL") and os.Stat("NUL") work
regardless of what current directory is, and it is mistake to join
"NUL" with current directory when building full path. Changing
IsAbs("NUL") to return true fixes that mistake.
Fixes #28035
Change-Id: Ife8f8aee48400702613ede8fc6834fd43e6e0f03
Reviewed-on: https://go-review.googlesource.com/c/145220
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Fri, 2 Nov 2018 05:06:51 +0000 (22:06 -0700)]
cmd/cgo: don't update each call in place
Updating each call in place broke when there were multiple cgo calls
used as arguments to another cgo call where some required rewriting.
Instead, rewrite calls to strings via the existing mangling mechanism,
and only substitute the top level call in place.
Martin Möhrmann [Thu, 1 Nov 2018 10:20:11 +0000 (11:20 +0100)]
runtime: only check the existence of variables in gdb info locals test
As discussed in golang.org/cl/28499:
Only test that all expected variables are listed in 'info locals' since
different versions of gdb print variables in different order and with
differing amount of information and formats.
Alan Donovan [Wed, 31 Oct 2018 17:18:17 +0000 (13:18 -0400)]
cmd/link: don't link sections not named .o
For many build systems, modular static analysis is most conveniently
implemented by saving analysis facts (which are analogous to export
data) in an additional section in the archive file, similar to
__PKGDEF. See golang.org/x/tools/go/analysis for an overview.
Because such sections are not object files, the linker must not
attempt to link them. This change causes the linker to skip special
sections whose name does not end with .o (and is short enough not to
be truncated).
Fixes #28429
Change-Id: I830852decf868cb017263308b114f72838032993
Reviewed-on: https://go-review.googlesource.com/c/146297
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Thu, 1 Nov 2018 08:02:46 +0000 (08:02 +0000)]
os: add support for long path names on freebsd RemoveAll
Follow CL 146020 and enable RemoveAll based on Unlinkat and Openat on
freebsd.
Since the layout of syscall.Stat_t changes in FreeBSD 12, Fstatat needs
a compatibility wrapper akin to Fstatat in x/sys/unix. See CL 138595 and
CL 136816 for details.
Updates #27029
Change-Id: I8851a5b7fa658eaa6e69a1693150b16d9a68f36a
Reviewed-on: https://go-review.googlesource.com/c/146597
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Thu, 1 Nov 2018 16:29:42 +0000 (16:29 +0000)]
net: enable RFC 6555 Fast Fallback by default
The Dialer.DualStack field is now meaningless and documented as
deprecated.
To disable fallback, set FallbackDelay to a negative value.
Fixes #22225
Change-Id: Icc212fe07bb69d7651ab81e539b8b3e3d3372fa9
Reviewed-on: https://go-review.googlesource.com/c/146659 Reviewed-by: Ian Lance Taylor <iant@golang.org>
net/textproto: do not buffer a line if we know the next line is empty
readContinuedLineSlice intends to buffer a continued line of text, where
a continued line can continue through newlines so long as the next line
begins with a space or tab.
The current optimization is to not try to buffer and build a line if we
immediately see that the next line begins with an ASCII character.
This adds avoiding copying the line if we see that the next line is \n
or \r\n as well.
Notably, headers always end in \r\n\r\n. In the general, well formatted
header case, we can now avoid ever allocating textproto.Reader's
internal reusable buf.
This can mildly be seen in net/http's BenchmarkClientServer:
name old time/op new time/op delta
ClientServer-4 66.4µs ± 0% 66.2µs ± 0% -0.35% (p=0.004 n=10+10)
name old alloc/op new alloc/op delta
ClientServer-4 4.87kB ± 0% 4.82kB ± 0% -1.01% (p=0.000 n=6+10)
name old allocs/op new allocs/op delta
ClientServer-4 64.0 ± 0% 63.0 ± 0% -1.56% (p=0.000 n=10+10)
Austin Clements [Thu, 1 Nov 2018 00:46:57 +0000 (20:46 -0400)]
cmd/compile: gofmt
I don't know how this file wasn't gofmted.
Change-Id: I9b3765ae63970b7bc4dc87107f546e64a78e2830
Reviewed-on: https://go-review.googlesource.com/c/146497 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Mon, 15 Oct 2018 22:14:48 +0000 (15:14 -0700)]
runtime: exit early when scanning map buckets
Divide the "empty" slot state into two, "emptyOne" and "emptyRest".
emptyOne means just that slot is empty. emptyRest means all subsequent
slots in that bucket are empty and the overflow pointer is nil.
When scanning a bucket, we can often stop at emptyRest, reducing
the total work we have to do. (This is similar to how tombstones
work in open addressing.)
Ideally on delete we have to figure out whether to zero the slot
with an emptyOne or emptyRest marker. For now, we choose the safe
but non-optimal choice. (Fix in subsequent CL?)
This is a simpler CL than some others we've tried, including my
CL sequence 11835[5-8] and Ilya's CL 115616.
Change-Id: I564ce0f40936589f0f9b837f7f2bbcca4c4a1070
Reviewed-on: https://go-review.googlesource.com/c/142437 Reviewed-by: Giovanni Bajo <rasky@develer.com> Reviewed-by: Martin Möhrmann <martisch@uos.de>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Darien Raymond [Wed, 31 Oct 2018 14:37:26 +0000 (14:37 +0000)]
crypto/tls: cache Leaf certificate during BuildNameToCertificate
I am working on a TLS server program, which issues new TLS certificates
on demand. The new certificates will be added into tls.Config.Certificates.
BuildNameToCertificate will be called to refresh the name table afterwards.
This change will reduce some workload on existing certificates.
Note that you can’t modify the Certificates field (or call BuildNameToCertificate)
on a Config in use by a Server. You can however modify an unused Config that gets
cloned in GetConfigForClient with appropriate locking.
Oliver Stenbom [Wed, 31 Oct 2018 10:55:24 +0000 (10:55 +0000)]
os: add support for long path names on unix RemoveAll
On unix systems, long enough path names will fail when performing syscalls
like `Lstat`. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, dragonfly,
netbsd and openbsd. Not yet implemented on freebsd due to fstatat 64-bit
inode compatibility issues.
Fixes #27029
Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>
Change-Id: I978a6a4986878fe076d3c7af86e7927675624a96
GitHub-Last-Rev: 9235489c81b90c228210144b7c25b28a46bb80b7
GitHub-Pull-Request: golang/go#28494
Reviewed-on: https://go-review.googlesource.com/c/146020
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Fri, 26 Oct 2018 07:44:17 +0000 (18:44 +1100)]
os: use Stat instead of Lstat in Symlink
Windows implementation of Symlink uses CreateSymbolicLink Windows
API. The API requires to identify the target type: file or
directory. Current Symlink implementation uses Lstat to determine
symlink type, but Lstat will not be able to determine correct
result if destination is symlink. Replace Lstat call with Stat.
Fixes #28432
Change-Id: Ibee6d8ac21e2246bf8d0a019c4c66d38b09887d4
Reviewed-on: https://go-review.googlesource.com/c/145217
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Wed, 24 Oct 2018 02:33:14 +0000 (13:33 +1100)]
cmd/doc: allow -all to apply to individual items
It really only matters for types, and the code already worked but was
blocked by a usage check.
Fixes #25595
Change-Id: I823f313b682b37616ea555aee079e2fe39f914c2
Reviewed-on: https://go-review.googlesource.com/c/144357 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Mon, 29 Oct 2018 12:39:53 +0000 (13:39 +0100)]
cmd: allow build with gccgo on AIX
This commit adapts cmd/internal/buildid and cmd/go to allow the use of
gccgo on AIX.
Buildid is supported only for AIX archives.
Change-Id: I14c790a8994ae8d2ee629d8751e04189c30ffd94
Reviewed-on: https://go-review.googlesource.com/c/145417
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Tue, 30 Oct 2018 17:56:02 +0000 (10:56 -0700)]
strings: declare IndexByte as noescape
This lets []byte->string conversions which are used as arguments to
strings.IndexByte and friends have their backing store allocated on
the stack.
It only prevents allocation when the string is small enough (32
bytes), so it isn't perfect. But reusing the []byte backing store
directly requires a bunch more compiler analysis (see #2205 and
related issues).
Michael Anthony Knyszek [Mon, 1 Oct 2018 19:58:01 +0000 (19:58 +0000)]
runtime: add physical memory scavenging test
This change introduces a test to malloc_test which checks for overuse
of physical memory in the large object treap. Due to fragmentation,
there may be many pages of physical memory that are sitting unused in
large-object space.
Michael Anthony Knyszek [Thu, 4 Oct 2018 15:33:08 +0000 (15:33 +0000)]
runtime: scavenge large spans before heap growth
This change scavenges the largest spans before growing the heap for
physical pages to "make up" for the newly-mapped space which,
presumably, will be touched.
In theory, this approach to scavenging helps reduce the RSS of an
application by marking fragments in memory as reclaimable to the OS
more eagerly than before. In practice this may not necessarily be
true, depending on how sysUnused is implemented for each platform.
Michael Anthony Knyszek [Fri, 5 Oct 2018 18:11:02 +0000 (18:11 +0000)]
runtime: sysUsed spans after trimming
Currently, we mark a whole span as sysUsed before trimming, but this
unnecessarily tells the OS that the trimmed section from the span is
used when it may have been scavenged, if s was scavenged. Overall,
this just makes invocations of sysUsed a little more fine-grained.
It does come with the caveat that now heap_released needs to be managed
a little more carefully in allocSpanLocked. In this case, we choose to
(like before this change) negate any effect the span has on
heap_released before trimming, then add it back if the trimmed part is
scavengable.
Michael Anthony Knyszek [Mon, 15 Oct 2018 23:00:58 +0000 (23:00 +0000)]
runtime: extend ReadMemStatsSlow to re-compute HeapReleased
This change extends the test function ReadMemStatsSlow to re-compute
the HeapReleased statistic such that it is checked in testing to be
consistent with the bookkeeping done in the runtime.
Michael Anthony Knyszek [Thu, 4 Oct 2018 15:59:47 +0000 (15:59 +0000)]
runtime: remove npreleased in favor of boolean
This change removes npreleased from mspan since spans may now either be
scavenged or not scavenged; how many of its pages were actually scavenged
doesn't matter. It saves some space in mpsan overhead too, as the boolean
fits into what would otherwise be struct padding.
Michael Anthony Knyszek [Thu, 25 Oct 2018 18:18:53 +0000 (18:18 +0000)]
runtime: add successor method to treap
This change adds a method for computing a treap node's successor
to the treap, which will simplify the implementation of algorithms
used for heap growth scavenging.
Michael Anthony Knyszek [Thu, 25 Oct 2018 18:11:54 +0000 (18:11 +0000)]
runtime: add predecessor method to treap
This change adds a method for computing a treap node's predecessor
to the treap, which will simplify the implementation of algorithms
used for heap growth scavenging.
Oliver Stenbom [Tue, 30 Oct 2018 00:40:24 +0000 (00:40 +0000)]
os: add support for long path names on unix RemoveAll
On unix systems, long enough path names will fail when performing syscalls
like `Lstat`. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, and several bsds.
Fixes #27029
Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>
Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56
GitHub-Last-Rev: b30a621fe359fa2acbb055445b54202b0c508167
GitHub-Pull-Request: golang/go#27871
Reviewed-on: https://go-review.googlesource.com/c/137442
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alan Donovan [Mon, 29 Oct 2018 17:49:32 +0000 (13:49 -0400)]
bufio: suggest io.ReadFull at (*Reader).Read
Many times when using bufio.Reader I imagine, incorrectly, that it
implements the retry loop itself, being a high-level buffered wrapper
around, say, a file descriptor prone to short reads. This comment
would have saved me much time.
Change-Id: I34c790e0d7c1515430a76d02ce4739b586a36ba7
Reviewed-on: https://go-review.googlesource.com/c/145577 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
BigMikes [Mon, 29 Oct 2018 10:45:16 +0000 (11:45 +0100)]
net/http: in Transport, don't error on non-chunked response with Trailer header
There are cases where HTTP message specifies the Trailer header
but not the Transfer-Encoding = chunked. The existing
implementation would return an error in those cases, without
returning also the message itself.
Instead, it would be preferable to let the library user decide when
the message is valid or not.
This change makes the fixTrailer() function not to return an error
and to keep the Trailer value in the Response.Header map but not
populate Response.Trailer.
Martin Möhrmann [Fri, 26 Oct 2018 16:09:42 +0000 (18:09 +0200)]
internal/cpu: remove unused and not required ppc64(le) feature detection
Minimum Go requirement for ppc64(le) architecture support is POWER8.
https://github.com/golang/go/wiki/MinimumRequirements#ppc64-big-endian
Reduce CPU features supported in internal/cpu to those needed to
test minimum requirements and cpu feature kernel support for ppc64(le).
Currently no internal/cpu feature variables are used to guard code
from using unsupported instructions. The IsPower9 feature variable
and detection is kept as it will soon be used to guard code execution.
Reducing the set of detected CPU features for ppc64(le) makes
implementing Go support for new operating systems easier as
CPU feature detection for ppc64(le) needs operating system support
(e.g. hwcap on Linux and getsystemcfg syscall on AIX).
Change-Id: Ic4c17b31610970e481cd139c657da46507391d1d
Reviewed-on: https://go-review.googlesource.com/c/145117
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Martin Möhrmann [Sun, 14 Oct 2018 20:28:58 +0000 (22:28 +0200)]
cmd/compile: move slice construction to callers of makeslice
Only return a pointer p to the new slices backing array from makeslice.
Makeslice callers then construct sliceheader{p, len, cap} explictly
instead of makeslice returning the slice.
Reduces go binary size by ~0.2%.
Removes 92 (~3.5%) panicindex calls from go binary.
Robert Griesemer [Mon, 29 Oct 2018 17:24:05 +0000 (10:24 -0700)]
math/big: shallow copies of Int/Rat/Float are not supported (documentation)
Fixes #28423.
Change-Id: Ie57ade565d0407a4bffaa86fb4475ff083168e79
Reviewed-on: https://go-review.googlesource.com/c/145537 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Daniel Martí [Tue, 29 May 2018 16:25:18 +0000 (18:25 +0200)]
cmd/compile: typecheck types and funcs before consts
This way, once the constant declarations are typechecked, all named
types are fully typechecked and have all of their methods added.
Usually this isn't important, as methods and interfaces cannot be used
in constant declarations. However, it can lead to confusing and
incorrect errors, such as:
$ cat f.go
package p
type I interface{ F() }
type T struct{}
const _ = I(T{})
func (T) F() {}
$ go build f.go
./f.go:6:12: cannot convert T literal (type T) to type I:
T does not implement I (missing F method)
The error is clearly wrong, as T does have an F method. If we ensure
that all funcs are typechecked before all constant declarations, we get
the correct error:
$ go build f2.go
# command-line-arguments
./f.go:6:7: const initializer I(T literal) is not a constant
Fixes #24755.
Change-Id: I182b60397b9cac521d9a9ffadb11b42fd42e42fe
Reviewed-on: https://go-review.googlesource.com/c/115096
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Filippo Valsorda [Thu, 25 Oct 2018 01:22:00 +0000 (21:22 -0400)]
crypto/tls: rewrite some messages with golang.org/x/crypto/cryptobyte
As a first round, rewrite those handshake message types which can be
reused in TLS 1.3 with golang.org/x/crypto/cryptobyte. All other types
changed significantly in TLS 1.3 and will require separate
implementations. They will be ported to cryptobyte in a later CL.
The only semantic changes should be enforcing the random length on the
marshaling side, enforcing a couple more "must not be empty" on the
unmarshaling side, and checking the rest of the SNI list even if we only
take the first.
Daniel Martí [Sun, 28 Oct 2018 20:46:58 +0000 (20:46 +0000)]
text/template/parse: simplify Tree.pipeline
The pipeline parsing code was unnecessarily complex. It used a for loop
with a trailing break, a complex switch, and up to seven levels of
indentation.
Instead, drop the loop in favor of a single named goto with a comment,
and flatten out the complex switch to be easier to follow. Two lines of
code are now duplicated, but they're simple and only three lines apart.
While at it, move the pipe initialization further up to remove the need
for three variables.
Change-Id: I07b29de195f4000336219aadeadeacaaa4285c58
Reviewed-on: https://go-review.googlesource.com/c/145285 Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
bill_ofarrell [Fri, 26 Oct 2018 21:33:51 +0000 (17:33 -0400)]
cmd/asm: add s390x VMSLG instruction variants
VMSLG has three variants on z14 and later machines. These variants are used in "limbified" squaring:
VMSLEG: Even Shift Indication -- the even-indexed intermediate result is doubled
VMSLOG: Odd Shift Indication -- the odd-indexed intermediate result is doubled
VMSLEOG: Even and Odd Shift Indication -- both intermediate results are doubled
Limbified squaring is very useful for high performance cryptographic algorithms, such as
elliptic curve. This change allows these instructions to be used in Go assembly.
Change-Id: Iaad577b07320205539f99b3cb37a2a984882721b
Reviewed-on: https://go-review.googlesource.com/c/145180 Reviewed-by: Michael Munday <mike.munday@ibm.com>
Alex Brainman [Sun, 28 Oct 2018 03:45:12 +0000 (14:45 +1100)]
os: remove sleep in windows Process.Wait
The wait was there, because we discovered that we could not remove
finished process executable without the wait on Windows XP. But
Windows XP is not supported by Go. Maybe we do not need the wait
with modern Windows versions. Remove the sleep.
Daniel Martí [Sun, 28 Oct 2018 16:23:00 +0000 (16:23 +0000)]
text/template/parse: error on bad range variables
The package used to accept invalid range pipelines, such as:
{{range $k, .}}
{{range $k, 123 := .}}
This is because the logic that allowed a range pipeline to declare
multiple variables was broken. When encountering a single comma inside a
range pipeline, it would happily continue parsing a second variable,
even if we didn't have a variable token at all.
Then, the loop would immediately break, and we'd parse the pipeline we'd
be ranging over. That is, we'd parse {{range $k, .}} as if it were
{{range $k = .}}.
To fix this, only allow the loop to continue if we know we're going to
parse another variable or a token that would end the pipeline. Also add
a few test cases for these error edge cases.
While at it, make use of T.Run, which was useful in debugging
Tree.pipeline via print statements.
Fixes #28437.
Change-Id: Idc9966bf643f0f3bc1b052620357e5b0aa2022ea
Reviewed-on: https://go-review.googlesource.com/c/145282
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> Reviewed-by: Rob Pike <r@golang.org>
Diogo Pinela [Sun, 28 Oct 2018 17:29:29 +0000 (17:29 +0000)]
os: ensure tests pass even if GOROOT is read-only
We achieve this by always running all tests that create files in a
fresh temporary directory, rather than just on darwin/{arm,arm64}.
As a bonus, this lets us simplify the cleanup code for these tests
and assume their working directory starts out empty.
During development and debugging, I often want to
write noteRule(fmt.Sprintf(...)), and end up
manually adding the import to the generated code.
Let's just make it always available instead.
Martin Möhrmann [Sun, 28 Oct 2018 14:37:13 +0000 (15:37 +0100)]
runtime: support GODEBUGCPU for more Unix-like operating systems
Adds AIX, DragonFly BSD, FreeBSD, NetBSD, OpenBSD and Solaris
to the list of operating systems where the GODEBUGCPU environment
variable will be parsed and interal/cpu features can be enabled
and disabled.
hearot [Sun, 28 Oct 2018 09:01:39 +0000 (10:01 +0100)]
math/big: fix a formula used as documentation
The function documentation was wrong, it was using a wrong parameter. This change
replaces it with the right parameter.
The wrong formula was: q = (u1<<_W + u0 - r)/y
The function has got a parameter "v" (of type Word), not a parameter "y".
So, the right formula is: q = (u1<<_W + u0 - r)/v
Fixes #28444
Change-Id: I82e57ba014735a9fdb6262874ddf498754d30d33
Reviewed-on: https://go-review.googlesource.com/c/145280 Reviewed-by: Robert Griesemer <gri@golang.org>
Martin Möhrmann [Fri, 26 Oct 2018 19:04:45 +0000 (21:04 +0200)]
internal/cpu: replace arch dependent with generic minimal feature test
Use information about required CPU features stored in the CPU feature
options slice to test if minimal CPU requirements are met instead
of hard coding this information in the tests directly.
Change-Id: I72d89b1cff305b8e751995d4230a2217e32f4236
Reviewed-on: https://go-review.googlesource.com/c/145118 Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Filippo Valsorda [Fri, 26 Oct 2018 15:41:02 +0000 (11:41 -0400)]
crypto/tls: bump test timeouts from 1s to 1m for slow builders
The arm5 and mips builders are can't-send-a-packet-to-localhost-in-1s
slow apparently. 1m is less useful, but still better than an obscure
test timeout panic.
Keith Randall [Fri, 26 Oct 2018 17:52:59 +0000 (10:52 -0700)]
cmd/compile: fix rule for combining loads with compares
Unlike normal load+op opcodes, the load+compare opcode does
not clobber its non-load argument. Allow the load+compare merge
to happen even if the non-load argument is used elsewhere.
Noticed when investigating issue #28417.
Change-Id: Ibc48d1f2e06ae76034c59f453815d263e8ec7288
Reviewed-on: https://go-review.googlesource.com/c/145097 Reviewed-by: Ainar Garipov <gugl.zadolbal@gmail.com> Reviewed-by: Ben Shi <powerman1st@163.com>
Clément Chigot [Fri, 26 Oct 2018 08:07:36 +0000 (10:07 +0200)]
runtime: remove instruction linked with AIX new stack layout
This instruction was linked with a new stack layout which might be
needed for AIX. This change might not be taken finally. So, this
instruction must be removed.
See https://go-review.googlesource.com/c/go/+/138733
Change-Id: Ic4a2566e2882696b437eb817d980b7c4bfc03b18
Reviewed-on: https://go-review.googlesource.com/c/144957
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>