Elias Naur [Sat, 19 Aug 2017 14:59:19 +0000 (16:59 +0200)]
runtime: forward crashing signals to late handlers
CL 49590 made it possible for external signal handlers to catch
signals from a crashing Go process. This CL extends that support
to handlers registered after the Go runtime has initialized.
Updates #20392 (and possibly fix it).
Change-Id: I18eccd5e958a505f4d1782a7fc51c16bd3a4ff9c
Reviewed-on: https://go-review.googlesource.com/57291
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:52:11 +0000 (13:52 +1000)]
cmd/link: introduce and use peFile.writeOptionalHeader
Change-Id: I27b33f2425281bc1790528ae514d99a468ad7fce
Reviewed-on: https://go-review.googlesource.com/59429 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:49:15 +0000 (13:49 +1000)]
cmd/link: introduce and use peFile.dataDirectory
Change-Id: I61f64287a488ed82e71639540697b6ade5a0426a
Reviewed-on: https://go-review.googlesource.com/59428 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:45:56 +0000 (13:45 +1000)]
cmd/link: introduce and use peFile.writeFileHeader
Change-Id: I1324b69ab9edb870589197fa601b5764634d42a4
Reviewed-on: https://go-review.googlesource.com/59427 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:42:06 +0000 (13:42 +1000)]
cmd/link: introduce and use peFile.writeSymbolTableAndStringTable
Change-Id: I506f5e146f3b5bf359d6932a85ac5572d3a3f103
Reviewed-on: https://go-review.googlesource.com/59426 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:39:19 +0000 (13:39 +1000)]
cmd/link: introduce and use peFile.writeSymbols
Change-Id: If629b19cebc6ae8dfbf603dcd7f2dd3d0046a935
Reviewed-on: https://go-review.googlesource.com/59425 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:35:21 +0000 (13:35 +1000)]
cmd/link: simplify writePESymTableRecords
Change-Id: I2da982fdef826aaecb86431f7d80ffc0fb2c4337
Reviewed-on: https://go-review.googlesource.com/59424 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:32:19 +0000 (13:32 +1000)]
cmd/link: introduce and use peFile.mapToPESection
Change-Id: I598e9da5587908f39faa13c11d2b42054f5a632d
Reviewed-on: https://go-review.googlesource.com/59423 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:29:28 +0000 (13:29 +1000)]
cmd/link: introduce and use peFile.writeSymbol
Change-Id: I9fcae7bfd647b52d9b4f36f04710ba7921609c02
Reviewed-on: https://go-review.googlesource.com/59422 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:25:45 +0000 (13:25 +1000)]
cmd/link: move perelocsect into peFile.emitRelocations (no code changed)
Change-Id: I807412bd743d544195aaf9d720f81b128b4636b3
Reviewed-on: https://go-review.googlesource.com/59421 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:18:03 +0000 (13:18 +1000)]
cmd/link: introduce peFile.ctorsSect and use it in peFile.emitRelocations
Change-Id: I65058c150a19aa4e3083fd8754d08ea23721844b
Reviewed-on: https://go-review.googlesource.com/59420 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:14:43 +0000 (13:14 +1000)]
cmd/link: introduce and use peFile.emitRelocations
Change-Id: I2458d1391af063d99ba1e446bcf12f7c41ae5f6b
Reviewed-on: https://go-review.googlesource.com/59419 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alex Brainman [Mon, 28 Aug 2017 03:04:27 +0000 (13:04 +1000)]
cmd/link: introduce and use peSection.emitRelocations
Change-Id: I2bebee5566ee07786695f147c27661e69337a0f7
Reviewed-on: https://go-review.googlesource.com/59418 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Hiroshi Ioka [Sun, 27 Aug 2017 10:09:18 +0000 (19:09 +0900)]
cmd/link: fix warning for buildmode=plugin on darwin/amd64
Without this CL, the system linker complains about absolute addressing
in type..eqfunc.*.
Updates #18190
Change-Id: I68db37a7f4c96b16a9c13baffc0f043a3048df6d
Reviewed-on: https://go-review.googlesource.com/59373 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Hiroshi Ioka [Mon, 28 Aug 2017 22:39:57 +0000 (07:39 +0900)]
cmd/cgo: avoid using common names for sniffing
Current code uses names like "x" and "s" which can conflict with user's
code easily. Use cryptographic names.
Fixes #21668
Change-Id: Ib6d3d6327aa5b92d95c71503d42e3a79d96c8e15
Reviewed-on: https://go-review.googlesource.com/59710 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Mon, 28 Aug 2017 19:57:52 +0000 (12:57 -0700)]
cmd/compile: avoid generating large offsets
The assembler barfs on large offsets. Make sure that all the
instructions that need to have their offsets in an int32
1) check on any rule that computes offsets for such instructions
2) change their aux fields so the check builder checks it.
The assembler also silently misassembled offsets between 1<<31
and 1<<32. Add a check in the assembler to barf on those as well.
Fixes #21655
Change-Id: Iebf24bf10f9f37b3ea819ceb7d588251c0f46d7d
Reviewed-on: https://go-review.googlesource.com/59630
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Tom Bergan [Mon, 28 Aug 2017 18:09:37 +0000 (11:09 -0700)]
doc/1.9: add mention of net/http.LocalAddrContextKey
Fixes #21603
Change-Id: I42fb7ea2dd7f6d6a201171055beaeda68c26b823
Reviewed-on: https://go-review.googlesource.com/59530 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Fraenkel [Thu, 22 Jun 2017 01:58:42 +0000 (21:58 -0400)]
net/http: Set a timeout on Request.Context when using TimeoutHandler
In TimeoutHandler, use a request whose context has been configured with
the handler's timeout
Fixes #20712
Change-Id: Ie670148f85fdad46841ff29232042309e15665ae
Reviewed-on: https://go-review.googlesource.com/46412
Run-TryBot: Tom Bergan <tombergan@google.com> Reviewed-by: Tom Bergan <tombergan@google.com>
Ilya Tocar [Wed, 9 Aug 2017 18:43:34 +0000 (13:43 -0500)]
cmd/compile/internal/ssa: Mark ADD[Q|L]const as rematerializeable
We can rematerialize only ops that have SP or SB as their only argument.
There are some ADDQconst(SP) that can be rematerialized, but are spilled/filled instead,
so mark addconst as rematerializeable. This shaves ~1kb from go tool.
Artyom Pervukhin [Sun, 27 Aug 2017 08:30:19 +0000 (11:30 +0300)]
net/http: mention RegisterOnShutdown in Server.Shutdown docs
Closes #21637
Change-Id: Icc3528572ea2a25e62757cc8fbbb9c3fa96a78b2
Reviewed-on: https://go-review.googlesource.com/59350 Reviewed-by: Tom Bergan <tombergan@google.com>
Ben Shi [Thu, 24 Aug 2017 10:51:34 +0000 (10:51 +0000)]
cmd/compile: optimize ARM with more efficient MOVB/MOVBU/MOVH/MOVHU
Like the indexed MOVW (MOVWloadidx/MOVWstoreidx) used in current
ARM backend, the indexed MOVB/MOVBU/MOVH/MOVHU can also be used to
generate further optimized ARM code.
My patch implements this optimization. Here are some contrast test
results against the original go compiler.
1. The total size of all .a files in pkg/ shrinks by 0.03%.
Matej Baćo [Mon, 28 Aug 2017 10:41:27 +0000 (12:41 +0200)]
regexp: examples for Regexp.Expand and Regexp.ExpandString functions
Current documentation lacks simple examples for functions Regexp.Expand
and Regexp.ExpandString whose usage is unclear from description alone.
This commit adds examples that demonstrate usage in practical way.
Fixes #21649
Change-Id: I7b2c06c8ab747f69a6578f0595bf0f3c742ac479
Reviewed-on: https://go-review.googlesource.com/59470 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Hiroshi Ioka [Sun, 27 Aug 2017 13:00:00 +0000 (22:00 +0900)]
cmd/link: refactor *reloc
* use bool instead of int if it's adequate.
* remove blank lines.
Change-Id: Ic4a5644a33ed9fc7ce388ef8ba15f1732446fcfc
Reviewed-on: https://go-review.googlesource.com/59375
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This has been supported since Go 1 and there's even a test for it.
The documentation was missing.
Fixes #21409.
Change-Id: I5813488f6a98c1b4506c239e968d43344b91be12
Reviewed-on: https://go-review.googlesource.com/59412 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitri Shuralyov [Mon, 28 Aug 2017 03:17:12 +0000 (23:17 -0400)]
cmd/go/internal/load: fix IsMetaPackage function name in doc
The IsMetaPackage function was made exported when it was moved from
cmd/go to cmd/go/internal/load in CL 36196. Its documentation wasn't
updated accordingly. This change fixes that, resolving a golint issue.
Updates #18653.
Change-Id: Icf89461000754d0f09e6617b11c838e4c050d5a6
Reviewed-on: https://go-review.googlesource.com/59430 Reviewed-by: Dave Cheney <dave@cheney.net>
Joe Tsai [Fri, 25 Aug 2017 22:34:35 +0000 (15:34 -0700)]
archive/tar: improve package documentation
Many aspects of the package is woefully undocumented.
With the recent flurry of improvements, the package is now at feature
parity with the GNU and TAR tools. Thoroughly all of the public API
and perform some minor stylistic cleanup in some code segments.
Change-Id: Ic892fd72c587f30dfe91d1b25b88c9c8048cc389
Reviewed-on: https://go-review.googlesource.com/59210
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Fri, 25 Aug 2017 22:15:41 +0000 (15:15 -0700)]
archive/tar: add raw support for global PAX records
The PAX specification says the following:
<<<
'g' represents global extended header records for the following files in the archive.
The format of these extended header records shall be as described in pax Extended Header.
Each value shall affect all subsequent files that do not override that value
in their own extended header record and until another global extended header record
is reached that provides another value for the same field.
>>>
This CL adds support for parsing and composing global PAX records,
but intentionally does not provide support for automatically
persisting the global state across files.
Changes made:
* When Reader encounters a TypeXGlobalRecord header, it parses the
PAX records and returns them to the user ad-verbatim. Reader does not
store them in its state, ensuring it has no effect on future Next calls.
* When Writer receives a TypeXGlobalRecord header, it writes the
PAX records to the archive ad-verbatim. It does not store them in
its state, ensuring it has no effect on future WriteHeader calls.
* The restriction regarding empty record values is lifted since this
value is used to represent deletion in global headers.
Why provide raw support only:
* Some archives in the wild have a global header section (often empty)
and it is the user's responsibility to manually read and discard it's body.
The logic added here allows users to more easily skip over these sections.
* For users that do care about global headers, having access to the raw
records allows them to implement the functionality of global headers themselves
and manually persist the global state across files.
* We can still upgrade to a full implementation in the future.
Why we don't provide full support:
* Even though the PAX specification describes their operation in detail,
both the GNU and BSD tar tools (which are the most common implementations)
do not have a consistent interpretation of many details.
* Global headers were a controversial feature in PAX, by admission of the
specification itself:
<<<
The concept of a global extended header (typeflag g) was controversial.
The typeflag g global headers should not be used with interchange media that
could suffer partial data loss in transporting the archive.
>>>
* Having state persist from entry-to-entry complicates the implementation
for a feature that is not widely used and not well supported.
Change-Id: I1d904cacc2623ddcaa91525a5470b7dbe226c7e8
Reviewed-on: https://go-review.googlesource.com/59190 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Daniel Martí [Wed, 9 Aug 2017 07:56:08 +0000 (16:56 +0900)]
testing: error if -parallel is given N<1
Otherwise, if there are any parallel tests, it will hang and panic with
"all goroutines are asleep - deadlock!".
Do not use flag.Uint to handle the error for us because we also want to
error on N==0, and because it would make setting the default to
GOMAXPROCS(0) more difficult, since it's an int.
Check for it right after flag.Parse, and mimic flag errors by printing
the usage and returning exit code 2.
Fixes #20542.
Change-Id: I0c9d4587f83d406a8f5e42ed74e40be46d639ffb
Reviewed-on: https://go-review.googlesource.com/54150
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Meir Fischer [Fri, 14 Jul 2017 02:51:08 +0000 (22:51 -0400)]
testing: ensure profiles are written upon -timeout panic
This addresses the case of a -timeout panic, but not the more
general case of a signal arriving. See CL 48370 and CL 44352
for recent difficulties in that area.
"-timeout" here means flag usage to distinguish from the
default timeout termination which uses signals.
Fixes #19394
Change-Id: I5452d5422c0c080e940cbcc8c6606049975268c6
Reviewed-on: https://go-review.googlesource.com/48491 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Joe Tsai [Thu, 24 Aug 2017 06:44:33 +0000 (23:44 -0700)]
archive/tar: support arbitrary PAX records
This CL adds the following new publicly visible API:
type Header struct { ...; PAXRecords map[string]string }
The new Header.PAXRecords field is a map of all PAX extended header records.
We suggest (but do not enforce) that users use VENDOR-prefixed keys
according to the following in the PAX specification:
<<<
The standard developers have reserved keyword name space for vendor extensions.
It is suggested that the format to be used is:
VENDOR.keyword
where VENDOR is the name of the vendor or organization in all uppercase letters.
>>>
When reading, the Header.PAXRecords is populated with all PAX records
encountered so far, including basic ones (e.g., "path", "mtime", etc).
When writing, the fields of Header will be merged into PAXRecords,
overwriting any records that may conflict.
Since PAXRecords is a more expressive feature than Xattrs and
is entirely a superset of Xattrs, we mark Xattrs as deprecated,
and steer users towards the new PAXRecords API.
The issue has a discussion about adding a Header.SetPAXRecord method
to help validate records and keep the Header fields in sync.
However, we do not include that in this CL since that helper
method can always be added in the future.
There is no support for global records.
Fixes #14472
Change-Id: If285a52749acc733476cf75a2c7ad15bc1542071
Reviewed-on: https://go-review.googlesource.com/58390
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tom Levy [Tue, 22 Aug 2017 05:10:46 +0000 (17:10 +1200)]
sort: fix mix-up between "!less" and "greater" in examples
If Less(a, b) returns true when a is less than b, the correct way to
check if a is greater than b is to use Less(b, a). It is wrong to use
!Less(a, b) because that checks if a is greater than *or equal to* b.
1. The decreasingDistance function in Example_sortKeys makes this
mistake. Fix it.
2. The documentation of multiSorter.Less says it loops along the less
functions until it finds a comparison "that is either Less or
!Less". This is nonsense, because (Less(a, b) or !Less(a, b)) is
always true. Fix the documentation to say that it finds a
comparison "that discriminates between the two items (one is less
than the other)". The implementation already does this correctly.
Change-Id: If52b79f68e4fdb0d1095edf29bdecdf154a61b8d
Reviewed-on: https://go-review.googlesource.com/57752 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Heschi Kreinick [Fri, 25 Aug 2017 16:27:15 +0000 (12:27 -0400)]
cmd/compile: bug fixes for DWARF location lists
Fix two small but serious bugs in the DWARF location list code that
should have been caught by the automated tests I didn't write.
After emitting debug information for a user variable, mark it as done
so that it doesn't get emitted again. Otherwise it would be written once
per slot it was decomposed into.
Correct a merge error in CL 44350: the location list abbreviations need
to have DW_AT_decl_line too, otherwise the resulting DWARF is gibberish.
jaredculp [Thu, 10 Aug 2017 21:00:59 +0000 (17:00 -0400)]
math: add examples for trig functions
Change-Id: Ic3ce2f3c055f2636ec8fc9cec8592e596b18dc05
Reviewed-on: https://go-review.googlesource.com/54771
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
griesemer [Mon, 21 Aug 2017 13:47:51 +0000 (15:47 +0200)]
spec: explicitly define notion of "representability" (clarification)
Throughout the spec we use the notion of a constant x being
representable by a value of type T. While intuitively clear,
at least for floating-point and complex constants types, the
concept was not well-defined. In the section on Conversions
there was an extra rule for floating-point types only and it
missed the case of floating-point values overflowing to an
infinity after rounding.
Since the concept is important to Go, and a compiler most
certainly will have a function to test "representability",
it seems warranted to define the term explicitly in the spec.
This change introduces a new entry "Representability" under
the section on "Properties of types and values", and defines
the term explicitly, together with examples.
The phrase used is "representable by" rather than "representable as"
because the former use is prevalent in the spec.
Additionally, it clarifies that a floating-point constant
that overflows to an infinity after rounding is never
representable by a value of a floating-point type, even though
infinities are valid values of IEEE floating point types.
This is required because there are not infinite value constants
in the language (like there is also no -0.0) and representability
also matters for constant conversions. This is not a language
change, and type-checkers have been following this rule before.
The change also introduces links throughout the spec to the new
section as appropriate and removes duplicate text and examples
elsewhere (Constants and Conversions sections), leading to
simplifications in the relevant paragraphs.
Fixes #15389.
Change-Id: I8be0e071552df0f18998ef4c5ef521f64ffe8c44
Reviewed-on: https://go-review.googlesource.com/57530 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
runtime: optimize storing new keys in mapassign_fastNN
Prior to this change, we use typedmemmove to write the key
value to its new location in mapassign_fast32 and mapassign_fast64.
(The use of typedmemmove was a last-minute fix in the 1.9 cycle;
see #21297 and CL 53414.)
This is significantly less inefficient than direct assignment or
calling writebarrierptr directly.
Fortunately, there aren't many cases to consider.
On systems with 32 bit pointers:
* A 32 bit AMEM value either is a single pointer or has no pointers.
* A 64 bit AMEM value may contain a pointer at the beginning,
a pointer at 32 bits, or two pointers.
On systems with 64 bit pointers:
* A 32 bit AMEM value contains no pointers.
* A 64 bit AMEM value either is a single pointer or has no pointers.
All combinations except the 32 bit pointers / 64 bit AMEM value are
cheap and easy to handle, and the problematic case is likely rare.
The most popular map keys appear to be ints and pointers.
So we handle them exhaustively. The sys.PtrSize checks are constant branches
and are eliminated by the compiler.
An alternative fix would be to return a pointer to the key,
and have the calling code do the assignment, at which point the compiler
would have full type information.
Initial tests suggest that the performance difference between these
strategies is negligible, and this fix is considerably simpler,
and has much less impact on binary size.
Keith Randall [Thu, 24 Aug 2017 20:19:40 +0000 (13:19 -0700)]
cmd/compile,math: improve code generation for math.Abs
Implement int reg <-> fp reg moves on amd64.
If we see a load to int reg followed by an int->fp move, then we can just
load to the fp reg instead. Same for stores.
Austin Clements [Thu, 24 Aug 2017 19:06:26 +0000 (15:06 -0400)]
runtime: capture runtimeInitTime after nanotime is initialized
CL 36428 changed the way nanotime works so on Darwin and Windows it
now depends on runtime.startNano, which is computed at runtime.init
time. Unfortunately, the `runtimeInitTime = nanotime()` initialization
happened *before* runtime.init, so on these platforms runtimeInitTime
is set incorrectly. The one (and only) consequence of this is that the
start time printed in gctrace lines is bogus:
gc 1 18446653480.186s 0%: 0.092+0.47+0.038 ms clock, 0.37+0.15/0.81/1.8+0.15 ms cpu, 4->4->1 MB, 5 MB goal, 8 P
To fix this, this commit moves the runtimeInitTime initialization to
shortly after runtime.init, at which point nanotime is safe to use.
This also requires changing the condition in newproc1 that currently
uses runtimeInitTime != 0 simply to detect whether or not the main M
has started. Since runtimeInitTime could genuinely be 0 now, this
introduces a separate flag to newproc1.
Fixes #21554.
Change-Id: Id874a4b912d3fa3d22f58d01b31ffb3548266d3b
Reviewed-on: https://go-review.googlesource.com/58690
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Hana Kim [Thu, 24 Aug 2017 20:32:54 +0000 (16:32 -0400)]
misc/trace: update trace-viewer
Generated with
github.com/catapult/tracing/bin/vulcanize_trace_viewer
catapult @ ab4d571fa
Renamed trace_viewer_lean.html to trace_viewer_full.html
to make it clear we are using the full version of trace viewer
(waiting for https://github.com/catapult-project/catapult/issues/2247
to be fixed).
Matthew Dempsky [Thu, 24 Aug 2017 22:36:47 +0000 (15:36 -0700)]
cmd/compile: simplify noding for struct embedding
Since golang.org/cl/31670, we've stopped using the 'embedded' function
for handling struct embeddings within package export data. Now the
only remaining use is for Go source files, which allows for some
substantial simplifications:
1. CenterDot never appears within Go source files, so that logic can
simply be removed.
2. The field name will always be declared in the local package.
Passes toolstash-check.
Change-Id: I59505f62824206dd5de0782918f98fbef6e93224
Reviewed-on: https://go-review.googlesource.com/58790
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
griesemer [Thu, 24 Aug 2017 13:20:18 +0000 (15:20 +0200)]
spec: clarify zero value for complex types
The enumeration of numeric types missed the complex types.
Clarify by removing the explicit enumeration and referring
to numeric types instead.
Fixes #21579.
Change-Id: If36c2421f8501eeec82a07f442ac2e16a35927ba
Reviewed-on: https://go-review.googlesource.com/58491 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
griesemer [Thu, 24 Aug 2017 13:05:53 +0000 (15:05 +0200)]
spec: clarify nil case in type switches
The old wording seemed to imply that nil is a kind of type.
Slightly reworded for clarity.
Fixes #21580.
Change-Id: I29898bf0125a10cb8dbb5c7e63ec5399ebc590ca
Reviewed-on: https://go-review.googlesource.com/58490 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Rob Pike <r@golang.org>
Tom Levy [Thu, 24 Aug 2017 01:44:04 +0000 (13:44 +1200)]
sort: fix TestAdversary
There are some major problems with TestAdversary (based on "A Killer
Adversary for Quicksort"[1] by M. D. McIlroy). See #21581 for details.
Rewrite the test to closely match the version in the paper so it can
be verified as correct by virtue of similarity.
The only major difference between this new version and the version in
the paper is that this version swaps the values directly instead of
permuting an array of indices because we don't need to recover the
original permutation.
This new version also counts the number of calls to Less() and fails
the test if there are too many.
Fixes #21581.
[1]: http://www.cs.dartmouth.edu/~doug/mdmspe.pdf
Change-Id: Ia94b5b6d288b8fa3805a5fa27661cebbc5bad9a7
Reviewed-on: https://go-review.googlesource.com/58330
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tom Levy [Fri, 25 Aug 2017 05:13:34 +0000 (17:13 +1200)]
sync/atomic: remove references to old atomic pointer hammer tests
The tests were removed in https://golang.org/cl/2311 but some
references to them were missed.
Change-Id: I163e554a0cc99401a012deead8fda813ad74dbfe
Reviewed-on: https://go-review.googlesource.com/58870 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
David du Colombier [Thu, 24 Aug 2017 23:56:50 +0000 (01:56 +0200)]
cmd/compile: don't use MOVOstore instruction on plan9/amd64
CL 54410 and CL 56250 recently added use of the MOVOstore
instruction to improve performance.
However, we can't use the MOVOstore instruction on Plan 9,
because floating point operations are not allowed in the
note handler.
This change adds a configuration flag useSSE to enable the
use of SSE instructions for non-floating point operations.
This flag is enabled by default and disabled on Plan 9.
When this flag is disabled, the MOVOstore instruction is
not used and the MOVQstoreconst instruction is used instead.
Fixes #21599
Change-Id: Ie609e5d9b82ec0092ae874bab4ce01caa5bc8fb8
Reviewed-on: https://go-review.googlesource.com/58850 Reviewed-by: Keith Randall <khr@golang.org>
Wei Congrui [Tue, 22 Aug 2017 05:36:19 +0000 (13:36 +0800)]
build: add `go env GOROOT` as default GOROOT_BOOTSTRAP value
This change also added the same check in make.bash to make.rc,
which makes sure $GOROOT_BOOTSTRAP != $GOROOT.
Fixes #14339
Change-Id: I2758f4a845bae42ace02492fc6a911f6d6247d26
Reviewed-on: https://go-review.googlesource.com/57753
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 [Thu, 24 Aug 2017 01:36:46 +0000 (18:36 -0700)]
archive/tar: return better WriteHeader errors
WriteHeader may fail to encode a header for any number of reasons,
which can be frustrating for the user when trying to create a tar archive.
As we validate the Header, we generate an informative error message
intended for human consumption and return that if and only if no
format can be selected.
This allows WriteHeader to return informative errors like:
tar: cannot encode header: invalid PAX record: "linkpath = \x00hello"
tar: cannot encode header: invalid PAX record: "SCHILY.xattr.foo=bar = baz"
tar: cannot encode header: Format specifies GNU; and only PAX supports Xattrs
tar: cannot encode header: Format specifies GNU; and GNU cannot encode ModTime=1969-12-31 15:59:59.0000005 -0800 PST
tar: cannot encode header: Format specifies GNU; and GNU supports sparse files only with TypeGNUSparse
tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode ModTime=292277026596-12-04 07:30:07 -0800 PST
tar: cannot encode header: Format specifies USTAR; and USTAR does not support sparse files
tar: cannot encode header: Format specifies PAX; and only GNU supports TypeGNUSparse
Updates #18710
Change-Id: I82a498d6f29d02c4e73bce47b768eb578da8499c
Reviewed-on: https://go-review.googlesource.com/58310
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Thu, 24 Aug 2017 22:23:27 +0000 (15:23 -0700)]
cmd/compile: remove more nil ptr checks after newobject
For code like the following (where x escapes):
x := []int{1}
We're currently generating a nil check. The line above is really 3 operations:
t := new([1]int)
t[0] = 1
x := t[:]
We remove the nil check for t[0] = 1, but not for t[:].
Our current nil check removal rule is too strict about the possible
memory arguments of the nil check. Unlike zeroing or storing to the
result of runtime.newobject, the nilness of runtime.newobject is
always false, even after other stores have happened in the meantime.
Heschi Kreinick [Thu, 24 Aug 2017 18:29:13 +0000 (14:29 -0400)]
cmd/link: don't create go.info symbols for non-Go functions
In writelines the linker uses various auxiliary information about a
function to create its line table entries. (It also does some unrelated
stuff, but never mind.) There's no reason to do this for non-Go
functions, so it bails out if the symbol has no FuncInfo.
However, it does so *after* it looks up (and implicitly creates!) the
go.info symbol for the function, which doesn't make sense and risks
creating duplicate symbols for static C functions. Move the check up so
that it doesn't do that.
Since non-Go functions can't reference Go types, there shouldn't be any
relocations to type info DIEs that need to be built, so there should be
no harm not doing that.
I wanted to change the Lookup to an ROLookup but that broke the
shared-mode tests with an inscrutable error.
No test. It seems too specific to worry about, but if someone disagrees
I can figure something out.
Fixes #21566
Change-Id: I61f03b7c504a3bf1c4245a8811795b6303469e91
Reviewed-on: https://go-review.googlesource.com/58630 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This eliminates a nil check of b while evaluating b.tophash,
which is in the inner loop of many hot map functions.
It also makes the code a bit clearer.
Also remove some gotos in favor of labeled breaks.
On non-x86 architectures, this change introduces a pointless reg-reg move,
although the cause is well-understood (#21572).
Ian Lance Taylor [Thu, 24 Aug 2017 00:44:51 +0000 (17:44 -0700)]
cmd/link: set correct alignment of ELF note section
Otherwise the default computation in symalign kicked in, setting the
alignment to be too high. This didn't matter with GNU ld, which put
each loadable note into a separate PT_NOTE segment, but it did matter
with gold which accumulated them all into a single PT_NOTE segment,
respecting the requested alignment. In the single PT_NOTE segment
generated by gold, the incorrect section alignment made the notes
unreadable.
Martin Möhrmann [Wed, 23 Aug 2017 07:05:29 +0000 (09:05 +0200)]
runtime: avoid infinite loop in growslice
On 386 the below code triggered an infinite loop in growslice:
x = make([]byte, 1<<30-1, 1<<30-1)
x = append(x, x...)
Check for overflow when calculating the new slice capacity
and set the new capacity to the requested capacity when an overflow
is detected to avoid an infinite loop.
No automatic test added due to requiring to allocate 1GB of memory
on a 32bit plaform before use of append is able to trigger the
overflow check.
Fixes #21441
Change-Id: Ia871cc9f88479dacf2c7044531b233f83d2fcedf
Reviewed-on: https://go-review.googlesource.com/57950
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
Dmitry Vyukov [Mon, 5 Jun 2017 08:37:37 +0000 (10:37 +0200)]
testing: parallelize tests over count
Currently all package tests are executed once
with Parallel tests executed in parallel.
Then this process is repeated count*cpu times.
Tests are not parallelized over count*cpu.
Parallelizing over cpu is not possible as
GOMAXPROCS is a global setting. But it is
possible for count.
Parallelize over count.
Brings down testing of my package with -count=100
form 10s to 0.3s.
Change-Id: I76d8322adeb8c5c6e70b99af690291fd69d6402a
Reviewed-on: https://go-review.googlesource.com/44830
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>