Michael Hudson-Doyle [Fri, 28 Apr 2017 01:01:03 +0000 (13:01 +1200)]
cmd/link: replace SSUB with an attribute bit
There is some stuff I don't understand very well involved in SSUB, better words
for the documentation gratefully accepted.
As this is the last use of a bit in SMASK, kill that off too.
Change-Id: Iddff1c9b2af02c9dfb12ac8e668d004e4642f997
Reviewed-on: https://go-review.googlesource.com/42026
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brian Kessler [Thu, 10 Aug 2017 06:17:07 +0000 (23:17 -0700)]
math/big: implement Lehmer's GCD algorithm
Updates #15833
Lehmer's GCD algorithm uses single precision calculations
to simulate several steps of multiple precision calculations
in Euclid's GCD algorithm which leads to a considerable
speed up. This implementation uses Collins' simplified
testing condition on the single digit cosequences which
requires only one quotient and avoids any possibility of
overflow.
Mark Pulford [Sun, 3 Sep 2017 11:46:51 +0000 (21:46 +1000)]
math: add RoundToEven function
Rounding ties to even is statistically useful for some applications.
This implementation completes IEEE float64 rounding mode support (in
addition to Round, Ceil, Floor, Trunc).
This function avoids subtle faults found in ad-hoc implementations, and
is simple enough to be inlined by the compiler.
Fixes #21748
Change-Id: I09415df2e42435f9e7dabe3bdc0148e9b9ebd609
Reviewed-on: https://go-review.googlesource.com/61211 Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Daniel Theophanes [Mon, 2 Oct 2017 18:16:53 +0000 (11:16 -0700)]
database/sql: add driver.ResetSessioner and add pool support
A single database connection ususally maps to a single session.
A connection pool is logically also a session pool. Most
sessions have a way to reset the session state which is desirable
to prevent one bad query from poisoning another later query with
temp table name conflicts or other persistent session resources.
It also lets drivers provide users with better error messages from
queryies when the underlying transport or query method fails.
Internally the driver connection should now be marked as bad, but
return the actual connection. When ResetSession is called on the
connection it should return driver.ErrBadConn to remove it from
the connection pool. Previously drivers had to choose between
meaningful error messages or poisoning the connection pool.
Lastly update TestPoolExhaustOnCancel from relying on a
WAIT query fixing a flaky timeout issue exposed by this
change.
Fixes #22049
Fixes #20807
Change-Id: I2b5df6d954a38d0ad93bf1922ec16e74c827274c
Reviewed-on: https://go-review.googlesource.com/73033
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Heschi Kreinick [Thu, 19 Oct 2017 22:59:41 +0000 (18:59 -0400)]
cmd/compile/internal/ssa: use reverse postorder traversal
Instead of the hand-written control flow analysis in debug info
generation, use a reverse postorder traversal, which is basically the
same thing. It should be slightly faster.
More importantly, the previous version simply gave up in the case of
non-reducible functions, and produced output that caused a later stage
to crash. It turns out that there's a non-reducible function in
compress/flate, so that wasn't a theoretical issue.
With this change, all blocks will be visited, even for non-reducible
functions.
Nils Larsgård [Tue, 24 Oct 2017 17:21:58 +0000 (19:21 +0200)]
mime/multipart: permit empty file name
Fixes #19183
Change-Id: I11502d855f5b521b03ed7a63a990cca2d0ed4083
Reviewed-on: https://go-review.googlesource.com/70931 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Daniel Theophanes [Mon, 2 Oct 2017 18:16:53 +0000 (11:16 -0700)]
database/sql: add driver.ResetSessioner and add pool support
A single database connection ususally maps to a single session.
A connection pool is logically also a session pool. Most
sessions have a way to reset the session state which is desirable
to prevent one bad query from poisoning another later query with
temp table name conflicts or other persistent session resources.
It also lets drivers provide users with better error messages from
queryies when the underlying transport or query method fails.
Internally the driver connection should now be marked as bad, but
return the actual connection. When ResetSession is called on the
connection it should return driver.ErrBadConn to remove it from
the connection pool. Previously drivers had to choose between
meaningful error messages or poisoning the connection pool.
Lastly update TestPoolExhaustOnCancel from relying on a
WAIT query fixing a flaky timeout issue exposed by this
change.
Fixes #22049
Fixes #20807
Change-Id: Idffa1a7ca9ccfe633257c4a3ae299b864f46c5b6
Reviewed-on: https://go-review.googlesource.com/67630 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Daniel Theophanes [Sun, 24 Sep 2017 02:38:32 +0000 (19:38 -0700)]
database/sql: allow drivers to only implement Context variants
Drivers shouldn't need to implement both Queryer and QueryerContext,
they should just implement QueryerContext. Same with Execer and
ExecerContext. This CL tests for QueryContext and ExecerContext
first so drivers do not need to implement Queryer and Execer
with an empty definition.
Fixes #21663
Change-Id: Ifbaa71da669f4bc60f8da8c41a04a4afed699a9f
Reviewed-on: https://go-review.googlesource.com/65733 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Sat, 21 Oct 2017 19:07:55 +0000 (12:07 -0700)]
encoding/csv: fix error documentation
We should be referring to ParseError.Err, which is the underlying error,
not ParseError.Error, which is the error method.
Change-Id: Ic3cef5ecbe1ada5fa14b9573222f29da8fc9a8d5
Reviewed-on: https://go-review.googlesource.com/72450 Reviewed-by: Tim Cooper <tim.cooper@layeh.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 23 Oct 2017 06:27:34 +0000 (17:27 +1100)]
runtime: make errno positive in netpollopen
Make netpollopen return what Windows GetLastError API returns.
It is probably copy / paste error from long time ago.
Change-Id: I28f78718c15fef3e8b5f5d11a259533d7e9c6185
Reviewed-on: https://go-review.googlesource.com/72592 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Matthew Dempsky [Fri, 20 Oct 2017 18:01:43 +0000 (11:01 -0700)]
cmd/compile: silence unnecessary unsafe error
If n.Type==nil after typechecking, then we should have already
reported a more useful error somewhere else. Just return 0 in
evalunsafe without trying to do anything else that's likely to cause
problems.
Also, further split out issue7525.go into more test files, because
cmd/compile reports at most one typechecking loop per compilation
unit.
Fixes #22351.
Change-Id: I3ebf505f72c48fcbfef5ec915606224406026597
Reviewed-on: https://go-review.googlesource.com/72251
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Robert Griesemer <gri@golang.org>
Artyom Pervukhin [Thu, 12 Oct 2017 19:03:13 +0000 (22:03 +0300)]
image/gif: avoid setting defers in the decode loop
decoder.decode() was defering close of lzw.decoders created for each
frame in a loop, thus increasing heap usage (referenced object + defered
function) until decode() returns. Memory increased proportionally to the
number of frames. Fix this by moving the sImageDescriptor case block
into its own method.
Than McIntosh [Mon, 23 Oct 2017 15:41:47 +0000 (11:41 -0400)]
cmd/compile: include non-decomposed vars for -dwarflocationlists
When enhanced DWARF location list generation is enabled (via internal
option -dwarflocationlists), variable entries were missing for "large"
(non-decomposable) locals and formals. From the debugging perspective,
this makes it appear that the variable doesn't exist, which is
probably not what we want. This change insures that a formal/local DIE
is created for these vars (with correct type, line, etc) but with a
conservative ("no info") location.
Cherry Zhang [Mon, 23 Oct 2017 13:39:13 +0000 (09:39 -0400)]
cmd/internal/obj/arm64: handle global address in LDP/STP
The addressing mode of global variable was missing, whereas the
compiler may make use of it, causing "illegal combination" error.
This CL adds support of that addressing mode.
Daniel Martí [Fri, 20 Oct 2017 10:56:31 +0000 (11:56 +0100)]
cmd/compile: clean up various bits of code
* replace a copy of IsMethod with a call of it.
* a few more switches where they simplify the code.
* prefer composite literals over "n := new(...); n.x = y; ...".
* use defers to get rid of three goto labels.
* rewrite updateHasCall into two funcs to remove gotos.
Passes toolstash-check on std cmd.
Change-Id: Icb5442a89a87319ef4b640bbc5faebf41b193ef1
Reviewed-on: https://go-review.googlesource.com/72070
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Matthew Dempsky [Fri, 20 Oct 2017 22:20:56 +0000 (15:20 -0700)]
cmd/compile: replace -l=2 with -d typecheckinl
Currently, benchmarking compile performance under -l=4 is confounded
by -l=2 enabling eager typechecking of unused inline function bodies
for debugging. This isn't logically an "inlining aggressiveness"
level, so instead move this logic under the -d umbrella flag.
Change-Id: I713f68952efbe25b6941d3ebc2f3707ccbbd6240
Reviewed-on: https://go-review.googlesource.com/72253
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Joe Tsai [Sat, 21 Oct 2017 00:04:17 +0000 (17:04 -0700)]
encoding/csv: add ParseError.RecordLine
CL 72150 fixes #22352 by reverting the problematic parts of that CL
where the line number and column number were inconsistent with each other.
This CL adds back functionality to address the issue that CL 72150
was trying to solve in the first place. That is, it reports the starting
line of the record, so that users have a frame of reference to start with
when debugging what went wrong.
In the event of gnarly CSV files with multiline quoted strings, a parse
failure likely occurs somewhere between the start of the record and
the point where the parser finally detected an error.
Since ParserError.{Line,Column} reports where the *error* occurs, we
add a RecordLine field to report where the record starts.
Also take this time to cleanup and modernize TestRead.
Fixes #19019
Fixes #22352
Change-Id: I16cebf0b81922c35f75804c7073e9cddbfd11a04
Reviewed-on: https://go-review.googlesource.com/72310 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Fri, 20 Oct 2017 01:44:00 +0000 (12:44 +1100)]
os: simplify windows Pipe
windows version of Pipe function is implemented by calling
syscall.Pipe which returns handles inheritable by client process,
and then adjusting returned handles with syscall.CloseOnExec.
Just create non-inheritable handles in the first place.
Now that we don't have a race window in the code, drop use
of syscall.ForkLock.
Change-Id: Ie325da7c2397b5995db4a5ddb0117e2ce1745187
Reviewed-on: https://go-review.googlesource.com/72010 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Tim Cooper [Thu, 12 Oct 2017 01:05:03 +0000 (22:05 -0300)]
encoding/hex: add NewEncoder, NewDecoder
NewEncoder returns an io.Writer that writes all incoming bytes as
hexadecimal characters to the underlying io.Writer. NewDecoder returns an
io.Reader that does the inverse.
Fixes #21590
Change-Id: Iebe0813faf365b42598f19a9aa41768f571dc0a8
Reviewed-on: https://go-review.googlesource.com/70210 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Fri, 20 Oct 2017 12:26:43 +0000 (05:26 -0700)]
encoding/csv: simplify and optimize Reader
The Reader implementation is slow because it operates on a rune-by-rune
basis via bufio.Reader.ReadRune. We speed this up by operating on entire
lines that we read from bufio.Reader.ReadSlice.
In order to ensure that we read the full line, we augment ReadSlice
in our Reader.readLine method to automatically expand the slice if
bufio.ErrBufferFull is every hit.
This change happens to fix #19410 because it no longer relies on
rune-by-rune parsing and only searches for the relevant delimiter rune.
In order to keep column accounting simple and consistent, this change
reverts parts of CL 52830.
This CL is an alternative to CL 36270 and builds on some of the ideas
from that change by Diogo Pinela.
Ian Lance Taylor [Thu, 19 Oct 2017 23:01:43 +0000 (16:01 -0700)]
runtime: for kqueue treat EVFILT_READ with EV_EOF as permitting a write
On systems that use kqueue, we always register descriptors for both
EVFILT_READ and EVFILT_WRITE. On at least FreeBSD and OpenBSD, when
the write end of a pipe is registered for EVFILT_READ and EVFILT_WRITE
events, and the read end of the pipe is closed, kqueue reports an
EVFILT_READ event with EV_EOF set, but does not report an EVFILT_WRITE
event. Since the write to the pipe is waiting for an EVFILT_WRITE
event, closing the read end of a pipe can cause the write end to hang
rather than attempt another write which will fail with EPIPE.
Fix this by treating EVFILT_READ with EV_EOF set as making both reads
and writes ready to proceed.
The real test for this is in CL 71770, which tests using various
timeouts with pipes.
Updates #22114
Change-Id: Ib23fbaaddbccd8eee77bdf18f27a7f0aa50e2742
Reviewed-on: https://go-review.googlesource.com/71973 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Cherry Zhang [Fri, 20 Oct 2017 14:53:48 +0000 (10:53 -0400)]
cmd/compile: skip runtime.nextFreeFast inlining test on MIPS64x
Since inlining budget calculation is fixed in CL 70151
runtime.nextFreeFast is no longer inlineable on MIPS64x because
it does not support Ctz64 as intrinsic. Skip the test.
Russ Cox [Wed, 18 Oct 2017 02:33:21 +0000 (22:33 -0400)]
cmd/go: delete ETXTBSY hack that is no longer needed
This hack existed because cmd/go used to install (write) and then run
cmd/cgo in the same invocation, and writing and then running a program
is a no-no in modern multithreaded Unix programs (see #22315).
As of CL 68338, cmd/go no longer installs any programs that it then
tries to use. It never did this for any program other than cgo, and
CL 68338 removed that special case for cgo.
Now this special case, added for #3001 long ago, can be removed too.
Change-Id: I338f1f8665e9aca823e33ef7dda9d19f665e4281
Reviewed-on: https://go-review.googlesource.com/71571
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Fri, 20 Oct 2017 16:51:45 +0000 (09:51 -0700)]
cmd/go: look for "unknown" when checking supported compiler flags
Where GCC says "unrecognized command line option", clang says "unknown
argument". This distinction usually doesn't matter because the
compiler will also exit with a non-zero status, but clang 3.4
reportedly exits with a zero status after reporting an unknown argument.
Change-Id: Ieb69ea352a8de0cd4171a1c26708dfe523421cfa
Reviewed-on: https://go-review.googlesource.com/72151
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Hana Kim [Thu, 19 Oct 2017 21:47:07 +0000 (17:47 -0400)]
cmd/trace: fix a javascript bug in handling import error
When traceviewer encounters a failure of json trace import
due to data error, onImportFail tried to access an error variable
which was not yet defined.
Michael Munday [Fri, 20 Oct 2017 14:21:05 +0000 (10:21 -0400)]
cmd/go: skip gold-specific part of TestNoteReading if gold is unavailable
The test already contained logic to do this however it did not match
the error "cannot find 'ld'" which appears to be how gcc fails when
ld.gold is missing.
Fixes #22340.
Change-Id: I841248cc489b8fa72bc00a95000ad405f9ef8a4f
Reviewed-on: https://go-review.googlesource.com/72111
Run-TryBot: Michael Munday <mike.munday@ibm.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ben Burkert [Thu, 19 Oct 2017 17:29:23 +0000 (10:29 -0700)]
net/http: ignore response body when forbidden by status code
A 1XX, 204, or 304 response may not include a response body according
to RFC 7230, section 3.3.3. If a buggy server returns a 204 or 304
response with a body that is chunked encoded, the invalid body is
currently made readable in the Response. This can lead to data races due
to the transport connection's read loop which does not wait for the body
EOF when the response status is 204 or 304.
The correct behavior is to ignore the body on a 204 or 304 response, and
treat the body data as the beginning of the next request on the
connection.
Updates #22330.
Change-Id: I89a457ceb783b6f66136d5bf9be0a9b0a04fa955
Reviewed-on: https://go-review.googlesource.com/71910 Reviewed-by: Tom Bergan <tombergan@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tom Bergan <tombergan@google.com>
griesemer [Thu, 19 Oct 2017 18:48:54 +0000 (11:48 -0700)]
spec: remove vestiges referring to iotas being incremented
https://golang.org/cl/71750 specifies iota values as indices,
thus making them independent from nested constant declarations.
This CL removes some of the comments in the examples that were
still referring to the old notion of iotas being incremented
and reset.
As an aside, please note that the spec still permits the use
of iota in a nested function (like before). Specifically, the
following cases are permitted by the spec (as before):
Change-Id: I9e5fec75daf7b628b1e08d970512397e9c348923
Reviewed-on: https://go-review.googlesource.com/71912 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Russ Cox [Wed, 18 Oct 2017 01:48:47 +0000 (21:48 -0400)]
cmd/go: skip updateBuildID on binaries we will run
On modern Unix systems it is basically impossible for a multithreaded
program to open a binary for write, close it, and then fork+exec that
same binary. So don't write the binary if we're going to fork+exec it.
This fixes the ETXTBSY flakes.
Fixes #22220.
See also #22315.
Change-Id: I6be4802fa174726ef2a93d5b2f09f708da897cdb
Reviewed-on: https://go-review.googlesource.com/71570
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
griesemer [Wed, 18 Oct 2017 22:31:42 +0000 (15:31 -0700)]
spec: clarify that each block has its own version of iota
Issue #15550 is clearly an esoteric case but the spec was silent
about it and we had diverging implementations. By making `iota`
and index that is relative to the respective constant declaration,
nested const declarations won't affect outer values of `iota`.
cmd/compile and go/types already follow this semantics.
Fixes #15550.
Change-Id: If138189e3ea4373f8ba50ac6fb1d219b481f8698
Reviewed-on: https://go-review.googlesource.com/71750 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Jed Denlea [Thu, 5 Oct 2017 00:32:44 +0000 (17:32 -0700)]
image/gif: make blockReader a ByteReader, harden tests
golang.org/cl/37258 was committed to fix issue #16146.
This patch seemed intent to allow at most one dangling byte. But, as
implemented, many more bytes may actually slip through. This is because
the LZW layer creates a bufio.Reader which will itself consume data
beyond the end of the LZW stream, and this isn't accounted for anywhere.
This change means to avoid the allocation of the bufio.Reader by making
blockReader implement io.ByteReader. Further, it adds a close() method
which detects extra data in the block sequence. To avoid any
regressions with poorly encoded GIFs which may have worked accidentally,
there are no restrictions on how many extra bytes may exist in the final
full sub-block that contained LZW data. If the end of the LZW stream
happened to align with the end of a sub-block, at most one more
sub-block with a length of 1 byte may exist before the block terminator.
This change aims to be at least as performant as the prior
implementation. But the primary gain is avoiding the allocation of a
bufio.Reader per frame:
name old time/op new time/op delta
Decode-8 276µs ± 0% 275µs ± 2% ~ (p=0.690 n=5+5)
name old speed new speed delta
Decode-8 55.9MB/s ± 0% 56.3MB/s ± 2% ~ (p=0.690 n=5+5)
name old alloc/op new alloc/op delta
Decode-8 49.2kB ± 0% 44.8kB ± 0% -9.10% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
Decode-8 269 ± 0% 267 ± 0% -0.74% (p=0.008 n=5+5)
When building test binaries, we build one archive with all of the test
sources and a second archive with the generated test package main and
link them together. If the test sources are themselves in package main
and the test was compiled with non-default compiler flags, then both
archives will contain a go.cuinfo.producer.main symbol, leading to a
duplicate symbol failure.
This has been causing test build failures on darwin-arm-a1428ios,
darwin-arm64-a1549ios, linux-amd64-noopt, android-arm-wiko-fever, and
android-arm64-wiko-fever since CL 71430 added this symbol. This CL
should fix the build.
Change-Id: I69051c846e7c0d97395a865a361cae07f411f9ad
Reviewed-on: https://go-review.googlesource.com/71771
Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
griesemer [Tue, 17 Oct 2017 22:30:12 +0000 (15:30 -0700)]
spec: simplify paragraph on certain range expressions over arrays
Fixes #22258.
Change-Id: I43e68f1cf3163e1a041ebff2734ff2cb7943f695
Reviewed-on: https://go-review.googlesource.com/71431 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Wed, 18 Oct 2017 23:04:45 +0000 (16:04 -0700)]
internal/poll: always decref if setting deadline fails
No test because at present it is never called in a way that fails.
When #22114 is implemented, failure will be possible. Not including this
change in that work because this change is separable and clearly correct.
Updates #22114
Change-Id: I81eb9eec8800e8082d918c0e5fb71282f538267e
Reviewed-on: https://go-review.googlesource.com/71751
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <joetsai@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Heschi Kreinick [Wed, 18 Oct 2017 18:29:21 +0000 (14:29 -0400)]
debug/dwarf: clarify StructField.ByteSize doc
StructField.ByteSize is almost always unset; document that Type.Size()
is the place to look.
The dwarf package doesn't spend much effort teaching you DWARF, so I
don't know what level of handholding is appropriate. Still, no harm in a
little comment.
Austin Clements [Tue, 17 Oct 2017 21:09:54 +0000 (17:09 -0400)]
cmd/compile, cmd/link: record compiler flags in DW_AT_producer
This adds a whitelisted subset of compiler flags to the DW_AT_producer
DWARF attribute of each package compilation unit DIE. This is common
practice in DWARF and can help debuggers determine the quality of the
produced debugging information.
Fixes #22168.
Change-Id: I1b994ef2262aa9b88b68eb6e883695d1103acc58
Reviewed-on: https://go-review.googlesource.com/71430 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Tue, 17 Oct 2017 00:28:29 +0000 (20:28 -0400)]
runtime: separate error result for mmap
Currently mmap returns an unsafe.Pointer that encodes OS errors as
values less than 4096. In practice this is okay, but it borders on
being really unsafe: for example, the value has to be checked
immediately after return and if stack copying were ever to observe
such a value, it would panic. It's also not remotely idiomatic.
Fix this by making mmap return a separate pointer value and error,
like a normal Go function.
Updates #22218.
Change-Id: Iefd965095ffc82cc91118872753a5d39d785c3a6
Reviewed-on: https://go-review.googlesource.com/71270
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Heschi Kreinick [Wed, 18 Oct 2017 17:45:03 +0000 (13:45 -0400)]
cmd/compile: distinguish args and return values in DWARF
Set DW_AT_variable_parameter on DW_TAG_formal_parameters that are
actually return values. variable_parameter is supposed to indicate inout
parameters, but Go doesn't really have those, and DWARF doesn't have
explicit support for multiple return values. This seems to be the best
compromise, especially since the implementation of the two is very
similar -- both are stack slots.
Ian Lance Taylor [Tue, 17 Oct 2017 22:38:13 +0000 (15:38 -0700)]
runtime: align stack in 386 lib startup before calling C function
Fixes Darwin 386 build. It turns out that the Darwin pthread_create
function saves the SSE registers, and therefore requires an aligned stack.
This worked before https://golang.org/cl/70530 because the stack sizes
were chosen to leave the stack aligned.
Russ Cox [Tue, 17 Oct 2017 19:10:59 +0000 (15:10 -0400)]
cmd/go: clean up x.exe properly in TestImportMain
More generally I'm concerned about these tests using
$GOROOT/src/cmd/go as scratch space, especially
combined wtih tg.parallel() - it's easy to believe some other
test might inadvertently also try to write x.exe about the
same time. This CL only solves the "didn't clean up x.exe"
problem and leaves for another day the "probably shouldn't
write to cmd/go at all" problem.
Fixes #22266.
Change-Id: I651534d70e2d360138e0373fb4a316081872550b
Reviewed-on: https://go-review.googlesource.com/71410
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
griesemer [Tue, 17 Oct 2017 20:38:10 +0000 (13:38 -0700)]
spec: explicitly state the import path for package unsafe
Nowhere in the spec did we mention the import path for package
unsafe. Now we do.
Fixes #22308.
Change-Id: Ifd42c873188e898c597cdee4284e7a9d234a9282
Reviewed-on: https://go-review.googlesource.com/71373 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Tim Cooper [Tue, 17 Oct 2017 23:00:55 +0000 (20:00 -0300)]
os: add period at end of O_EXCL comment
Change-Id: I9d723e49bf2cabf97a09e29e46fd2c426845fd1d
Reviewed-on: https://go-review.googlesource.com/71470 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reason for revert: Fails to fix all the locking issues.
Updates #21117
Change-Id: I6fc9cb7897244d6e1af78c089a2bf383258ec049
Reviewed-on: https://go-review.googlesource.com/71450 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Jay Conrod [Tue, 17 Oct 2017 19:33:45 +0000 (15:33 -0400)]
cmd/cover: don't try to attach directives to synthetic decls
Fixed an error that occurred in atomic mode. cover adds a global
variable declaration that forces sync/atomic to be used. fixDirectives
was confused by this declaration since it has an invalid
position. These declarations are now skipped.
Fixes #22309
Change-Id: I84f5fec13ef847fca35ad49f7704fb93b60503e0
Reviewed-on: https://go-review.googlesource.com/71351
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
griesemer [Tue, 17 Oct 2017 04:52:34 +0000 (21:52 -0700)]
cmd/compile/internal/parser: removed TODO (cleanup)
When an opening "{" of a block is missing and after advancing we
find a closing "}", it's likely better to assume the end of the
block. Fixed and removed TODO.
Change-Id: I20c9b4ecca798933a7cd4cbf21185bd4ca04f5f7
Reviewed-on: https://go-review.googlesource.com/71291 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Ben Shi [Sat, 14 Oct 2017 14:02:05 +0000 (14:02 +0000)]
cmd/internal/obj/arm: better solution of .S/.P/.U/.W suffix check
Current suffix check is based on instruction, which is not very
accurate. For example, "MOVW.S R1, R2" is valid, but
"MOVW.S $0xaaaaaaaa, R1" and "MOVW.P CPSR, R9" are not.
This patch fixes the above kinds of issues by checking suffix
based on []optab. And also more test cases are added.
Ian Lance Taylor [Fri, 13 Oct 2017 02:46:42 +0000 (19:46 -0700)]
runtime: unify 386 entry point code
Unify the 386 entry point code as much as possible.
The main function could not be unified because on Windows 386 it is
called _main. Putting main in asm_386.s caused multiple definition
errors when using the external linker.
Add the _lib entry point to various operating systems. A future CL
will enable c-archive/c-shared mode for those targets.
Fix _rt0_386_windows_lib_go--it was passing arguments as though it
were amd64.
Change-Id: Ic73f1c95cdbcbea87f633f4a29bbc218a5db4f58
Reviewed-on: https://go-review.googlesource.com/70530
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
griesemer [Tue, 17 Oct 2017 01:01:47 +0000 (18:01 -0700)]
cmd/compile/internal/parser: removed TODO (cleanup)
- checking for the correct closing token leads to slightly better
behavior for some randomly bogus programs
- removed `switch` in favor of an `if` statement
Follow-up on https://go-review.googlesource.com/c/go/+/71250.
Change-Id: I47f6c47b43baf790907f55ed97a947661687a9db
Reviewed-on: https://go-review.googlesource.com/71252 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Tim Cooper [Wed, 27 Sep 2017 00:14:03 +0000 (21:14 -0300)]
text/template: add break, continue actions in ranges
Adds the two range control actions "break" and "continue". They act the
same as the Go keywords break and continue, but are simplified in that
only the innermost range statement can be broken out of or continued.
Fixes #20531
Change-Id: I4412b3bbfd4dadb0ab74ae718e308c1ac7a0a1e9
Reviewed-on: https://go-review.googlesource.com/66410 Reviewed-by: Rob Pike <r@golang.org>
Jay Conrod [Tue, 10 Oct 2017 18:41:57 +0000 (14:41 -0400)]
cmd/cover: preserve compiler directives in floating comments
Previously, cover printed directives (//go: comments) near the top of
the file unless they were in doc comments. However, directives
frequently apply to specific definitions, and they are not written in
doc comments to prevent godoc from printing them. Moving all
directives to the top of the file affected semantics of tests.
With this change, directives are kept together with the following
top-level declarations. Only directives that occur after all top-level
declarations are moved.
Fixes #22022
Change-Id: Ic5c61c4d3969996e4ed5abccba0989163789254c
Reviewed-on: https://go-review.googlesource.com/69630
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
Alessandro Arzilli [Mon, 16 Oct 2017 11:57:54 +0000 (13:57 +0200)]
runtime/cgo: declare crosscall2 frame using TEXT for amd64 and 386
Use TEXT pseudo-instruction to adjust SP instead of a SUB instruction
so that the assembler knows how to fill in the pcsp table and the frame
description entry correctly.
Updates #21569
Change-Id: I436c840b2af99bbb3042ecd38a7d7c1ab4d7372a
Reviewed-on: https://go-review.googlesource.com/70937
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Cherry Zhang [Thu, 18 May 2017 19:38:44 +0000 (15:38 -0400)]
cmd/compile: remove needwritebarrier from the frontend
The write barrier insertion has moved to the SSA backend's
writebarrier pass. There is still needwritebarrier function
left in the frontend. This function is used in two places:
- fncall, which is called in ascompatet, which is called in
walking OAS2FUNC. For OAS2FUNC, in order pass we've already
created temporaries, and there is no write barrier for the
assignments of these temporaries.
- updateHasCall, which updates the HasCall flag of a node. the
HasCall flag is then used in
- fncall, mentioned above.
- ascompatet. As mentioned above, this is an assignment to
a temporary, no write barrier.
- reorder1, which is always called with a list produced by
ascompatte, which is a list of assignments to stack, which
have no write barrier.
- vmatch1, which is called in oaslit with r.Op as OSTRUCTLIT,
OARRAYLIT, OSLICELIT, or OMAPLIT. There is no write barrier
in those literals.
Therefore, the needwritebarrier function is unnecessary. This
CL removes it.
Cherry Zhang [Mon, 16 Oct 2017 17:48:06 +0000 (13:48 -0400)]
cmd/asm: reject STREX with same source and destination register on ARM
On ARM, STREX does not permit the same register used as both the
source and the destination. Reject the bad instruction.
The assembler also accepted special cases
STREX R0, (R1) as STREX R0, (R1), R0
STREX (R1), R0 as STREX R0, (R1), R0
both are illegal. Remove this special case as well.
For STREXD, check that the destination is not source, and not
source+1. Also check that the source register is even numbered,
as required by the architecture's manual.
Fixes #22268.
Change-Id: I6bfde86ae692d8f1d35bd0bd7aac0f8a11ce8e22
Reviewed-on: https://go-review.googlesource.com/71190
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tom Bergan [Fri, 13 Oct 2017 22:56:37 +0000 (15:56 -0700)]
net/http: preserve Host header following a relative redirect
If the client sends a request with a custom Host header and receives
a relative redirect in response, the second request should use the
same Host header as the first request. However, if the response is
an abolute redirect, the Host header should not be preserved. See
further discussion on the issue tracker.
Fixes #22233
Change-Id: I8796e2fbc1c89b3445e651f739d5d0c82e727c14
Reviewed-on: https://go-review.googlesource.com/70792 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
griesemer [Wed, 11 Oct 2017 23:57:39 +0000 (16:57 -0700)]
cmd/compile/internal/syntax: factor out list parsing
Instead of repeating the same list parsing pattern for parenthesized
of braced comma or semicolon-separated lists, introduce a single list
parsing function that can be parametrized and which takes a closure
to parse list elements.
This ensures the same error handling and recovery logic is used across
all lists and simplifies the code.
No semantic change.
Change-Id: Ia738d354d6c2e0c3d84a5f1c7269a6eb95685edc
Reviewed-on: https://go-review.googlesource.com/70492 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
griesemer [Wed, 11 Oct 2017 22:02:10 +0000 (15:02 -0700)]
cmd/compile/internal/syntax: match argument and parameter parsing (cleanup)
No semantic change. Move functionality not related to argument
out of the argument parsing function, and thus match parameter
parsing. Also, use a better function name.
Change-Id: Ic550875251d64e6fe1ebf91c11d33a9e4aec9fdd
Reviewed-on: https://go-review.googlesource.com/70491 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Ian Lance Taylor [Sat, 14 Oct 2017 15:46:50 +0000 (08:46 -0700)]
runtime: fix use of STREX in various exitThread implementations
STREX does not permit using the same register for the value to store
and the place where the result is returned. Also the code was wrong
anyhow if the first store failed.
Fixes #22248
Change-Id: I96013497410058514ffcb771c76c86faa1ec559b
Reviewed-on: https://go-review.googlesource.com/70911
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Kunpei Sakai [Mon, 16 Oct 2017 05:40:10 +0000 (14:40 +0900)]
net/http/httputil: extract duplicate code as removeConnectionHeaders
Change-Id: I50389752dcbf5d058ce11256a414be7955cdb77f
Reviewed-on: https://go-review.googlesource.com/71070
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com>
Michael Hudson-Doyle [Mon, 16 Oct 2017 01:20:01 +0000 (14:20 +1300)]
cmd/link: replace SCONTAINER with an attribute bit
This is much easier than replacing SSUB so split it out from my other CL.
Change-Id: If01e4005da5355895404456320a2156bde4ec09a
Reviewed-on: https://go-review.googlesource.com/71050
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Hudson-Doyle [Fri, 28 Apr 2017 00:43:06 +0000 (12:43 +1200)]
cmd/link: replace SHIDDEN bit in SymKind with a bit of Attribute
This is https://go-review.googlesource.com/42025 but with some more fixes --
hidden symbols implicitly passed "Type == 0 || Type == SXREF" checks. (This
sort of thing is part of why I wanted to make this change)
Change-Id: I2273ee98570fd7f2dd8a799c692a2083c014235e
Reviewed-on: https://go-review.googlesource.com/42330
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>