1
0
mirror of https://github.com/golang/go synced 2024-11-06 15:36:24 -07:00
Commit Graph

37023 Commits

Author SHA1 Message Date
Cherry Zhang
1d303a0086 cmd/compile: fold offset into address on Wasm
On Wasm, the offset was not folded into LoweredAddr, so it was
not rematerializeable. This led to the address-taken operation
in some cases generated too early, before the local variable
becoming live. The liveness code thinks the variable live when
the address is taken, then backs it up to live at function
entry, then complains about it, because nothing other than
arguments should be live on entry.

This CL folds the offset into the address operation, so it is
rematerializeable and so generated right before use, after the
variable actually becomes live.

It might be possible to relax the liveness code not to think a
variable live when its address being taken, but until the address
actually being used. But it would be quite complicated. As we're
late in Go 1.11 freeze, it would be better not to do it. Also,
I think the address operation is rematerializeable now on all
architectures, so this is probably less necessary.

This may also be a slight optimization, as the address+offset is
now rematerializeable, which can be generated on the Wasm stack,
without using any "registers" which are emulated by local
variables on Wasm. I don't know how to do benchmarks on Wasm. At
least, cmd/go binary size shrinks 9K.

Fixes #25966.

Change-Id: I01e5869515d6a3942fccdcb857f924a866876e57
Reviewed-on: https://go-review.googlesource.com/120599
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2018-06-27 14:30:00 +00:00
Ian Lance Taylor
f03ee913e2 misc/cgo/test: add retry loop around pthread_create in TestSigprocmask
This is the same retry loop we use in _cgo_try_pthread_create in runtime/cgo.

Fixes #25078

Change-Id: I7ef4d4fc7fb89cbfb674c4f93cbdd7a033dd8983
Reviewed-on: https://go-review.googlesource.com/121096
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-27 04:33:10 +00:00
Ian Lance Taylor
fbfd38c575 misc/cgo/test: skip Test18146 in short mode
Fixes #21219

Change-Id: I1a2ec1afe06586ed33a3a855b77536490cac3a38
Reviewed-on: https://go-review.googlesource.com/121115
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-27 04:31:53 +00:00
LE Manh Cuong
6dd789fdea cmd/link: document limitation of -X
Fixes #26042

Change-Id: Ica16f14a65c03659a19926852cca5e554c99baf1
Reviewed-on: https://go-review.googlesource.com/120935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-27 04:29:51 +00:00
Ian Lance Taylor
f040e439cb mime/multipart: restore 1.9 handling of missing/empty form-data file name
Revert the code changes of CL 96975 and CL 70931, but keep the tests,
appropriately modified for the code changes. This restores the 1.9
handling of form-data entries with missing or empty file names.

Changing the handling of this simply confused existing programs for no
useful benefit. Go back to the old behavior.

Updates #19183
Fixes #24041

Change-Id: I4ebc32433911e6360b9fd79d8f63a6d884822e0e
Reviewed-on: https://go-review.googlesource.com/121055
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-26 23:56:13 +00:00
Mikio Hara
0436b16239 net: improve ExampleUDPConn_WriteTo docs
Also updates comment on isConnected field of netFD for clarification.

Change-Id: Icb1b0332e3b4c7802eae00ddc26cd5ba54c82dc2
Reviewed-on: https://go-review.googlesource.com/120955
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-26 21:30:43 +00:00
David Chase
a12c1f26e4 cmd/compile: improve escape analysis explanation
No code changes, only revised comments in an attempt to make
escape analysis slightly less confusing.

Updates #23109.

Change-Id: I5ee6cea0946ced63f6210ac4484a088bcdd862fb
Reviewed-on: https://go-review.googlesource.com/121001
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-26 20:00:51 +00:00
Rowan Marshall
1f3c0eefd2 ast: refer to "embedded" rather than "anonymous" fields in
documentation.

Fixes #25684.

Change-Id: I9d0e47dff2446c27a3df88fb9ccfefef7419470b
Reviewed-on: https://go-review.googlesource.com/120556
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-26 19:40:44 +00:00
Robert Griesemer
cd016af6b6 go/types: rename NewInterface2 to NewInterfaceType
NewInterface2 was introduced with https://go-review.googlesource.com/114317
which fixed #25301. Changed the name to NewInterfaceType to better match
Go naming styles, per discussion with @josharian, @iant, et al.

Change-Id: Ifa4708a5efd4f708295b33c3d20fdc5812e1b4fc
Reviewed-on: https://go-review.googlesource.com/120875
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-26 17:31:34 +00:00
Richard Musiol
8997ec1c4e syscall/js: use stable references to JavaScript values
This commit changes how JavaScript values are referenced by Go code.
After this change, a JavaScript value is always represented by the same
ref, even if passed multiple times from JavaScript to Go. This allows
Go's == operator to work as expected on js.Value (strict equality).
Additionally, the performance of some operations of the syscall/js
package got improved by saving additional roundtrips to JavaScript code.

Fixes #25802.

Change-Id: Ide6ffe66c6aa1caf5327a2d3ddbe48fe7c180461
Reviewed-on: https://go-review.googlesource.com/120561
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-26 16:40:09 +00:00
Xargin
d89efc3c06 syscall: fix typo in RawSyscall6 comment
Change-Id: I589a60459a3b0811da77d46428eca57c741b1184
GitHub-Last-Rev: f9ab775b9d
GitHub-Pull-Request: golang/go#26063
Reviewed-on: https://go-review.googlesource.com/120917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-26 14:41:15 +00:00
Ian Lance Taylor
5fad09016b cmd/cgo: mention character restrictions on #cgo lines
Fixes #26025

Change-Id: I43b3c9019ca8d2844e4d664c2090e506b2171077
Reviewed-on: https://go-review.googlesource.com/120975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-26 14:39:02 +00:00
Alberto Donizetti
97fa89497d time: run genzabbrs.go to update zoneinfo_abbrs_windows.go
The abbreviations list in zoneinfo_abbrs_windows.go was last updated
in June 2017, and it's currently outdated. Update it.

Change-Id: Ie2bf4268787f5aefe98ee110c2c279451e18fd97
Reviewed-on: https://go-review.googlesource.com/120559
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-06-26 09:55:39 +00:00
Vladimir Kuzmin
b080abf656 cmd/compile: map delete should clear value always
Map delete must clear value every time because
newly added map optimizations of compound-assignment
operators (CL #91557) rely on this behavior of map delete.

It slows down map delete operation for non-reference types:

name                   old time/op    new time/op    delta
MapDelete/Int32/100      23.9ns ± 2%    27.8ns ± 4%  +16.04%  (p=0.000 n=20+20)
MapDelete/Int32/1000     21.5ns ± 2%    25.2ns ± 2%  +17.06%  (p=0.000 n=20+19)
MapDelete/Int32/10000    24.2ns ± 6%    27.2ns ± 5%  +12.39%  (p=0.000 n=19+19)
MapDelete/Int64/100      24.2ns ± 4%    27.7ns ± 2%  +14.55%  (p=0.000 n=20+20)
MapDelete/Int64/1000     22.1ns ± 2%    24.8ns ± 2%  +12.36%  (p=0.000 n=10+20)

Fixes #25936

Change-Id: I8499b790cb5bb019938161b3e50f3243d9bbb79c
Reviewed-on: https://go-review.googlesource.com/120255
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-26 01:57:01 +00:00
Andrew
3c586d4483 cmd/dist: increase timeout scale to 3 for windows
cmd/go can sometimes take up to 400s on windows due
to various issues (disk I/O on builders being the
latest cause). Increase the timeout scale to account
for this.

Change-Id: I1fd4964472a70fb0f33cf6ed73298c034b9c1fb0
Reviewed-on: https://go-review.googlesource.com/120762
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 20:52:59 +00:00
David Chase
7e9d55eeeb cmd/compile: avoid remainder in loopbce when increment=0
For non-unit increment, loopbce checks to see if the
increment evenly divides the difference between (constant)
loop start and end.  This test panics when the increment
is zero.

Fix: check for zero, if found, don't optimize the loop.

Also added missing copyright notice to loopbce.go.

Fixes #26043.

Change-Id: I5f460104879cacc94481949234c9ce8c519d6380
Reviewed-on: https://go-review.googlesource.com/120759
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 20:36:42 +00:00
Brad Fitzpatrick
6d70952897 cmd/dist: enable more tests on js/wasm
Fixes #26050

Change-Id: I21697ac30eb3bc423263cba885bce5fea8f81d94
Reviewed-on: https://go-review.googlesource.com/120796
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-25 20:01:45 +00:00
Guilherme Goncalves
37f05cc636 net/http: document and test behavior of ServeMux with ports
Beginning on Go 1.9, ServeMux has been dropping the port number from the Host
header and in the path pattern. This commit explicitly mentions the change in
behavior and adds a simple test case to ensure consistency.

Fixes #23351.

Change-Id: I0270c8bd96cda92c13ac6437cdf66c2807b3042d
Reviewed-on: https://go-review.googlesource.com/120557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 19:12:51 +00:00
Jeremy Jackins
444e7ddb27 runtime/trace: reword the trace package summary
Reword the package summary to be a little easier to read.

Change-Id: I84a9301a02e228b46165410a429548b3774762d5
GitHub-Last-Rev: 1342c7219f
GitHub-Pull-Request: golang/go#26052
Reviewed-on: https://go-review.googlesource.com/120795
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 19:11:01 +00:00
Andrew Bonventre
50bd1c4d4e os: have UserCacheDir return an error on failure
Previously, it would return an empty string if it
could not determine the user's cache directory.
Return an error instead.

Change-Id: I74f00b1ad3858efa3fe2700c599271ebfe5764b6
Reviewed-on: https://go-review.googlesource.com/120757
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 18:59:39 +00:00
Andrew Bonventre
4f172e7a75 doc/go1.11: add note about package versioning
It will not be present in go1.11beta1 but will be present
in subsequent releases.

Change-Id: I298fb682945345bb4a34ec83802fd644f75bdd98
Reviewed-on: https://go-review.googlesource.com/120756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 18:17:49 +00:00
Richard Musiol
5881d3048d syscall/js: turn constant package vars into functions
This is so the values can not be changed and the type is easy to see.

Requested on https://go-review.googlesource.com/c/go/+/120561.

Change-Id: If2ed48ca3ba8874074687bfb2375d2f5592e8e0d
Reviewed-on: https://go-review.googlesource.com/120564
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 17:04:01 +00:00
Richard Musiol
9c35c1a503 syscall.js: add Value.InstanceOf
Change-Id: Icf56188fdb2b8ce6789830a35608203fdb9a3df6
Reviewed-on: https://go-review.googlesource.com/120560
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 17:03:20 +00:00
Nikhil Benesch
6fdbed0543 runtime: respect timeout in semasleep on Darwin
semasleep on Darwin was refactored in https://golang.org/cl/118736 to
use the pthread_cond_timedwait function from libc. The new code
incorrectly assumed that pthread_cond_timedwait took a timeout relative
to the current time, when it in fact it takes a timeout specified in
absolute time. semasleep thus specified a timeout well in the past,
causing it to immediately exceed the timeout and spin hot. This was the
source of a large performance hit to CockroachDB (#26019).

Adjust semasleep to instead call pthread_cond_timedwait_relative_np,
which properly interprets its timeout parameter as relative to the
current time.

pthread_cond_timedwait_relative_np is non-portable, but using
pthread_cond_timedwait correctly would require two calls to
gettimeofday: one in the runtime package to convert the relative timeout
to absolute time, then another in the pthread library to convert back to
a relative offset [0], as the Darwin kernel expects a relative offset.

[0]: https://opensource.apple.com/source/libpthread/libpthread-301.30.1/src/pthread_cond.c.auto.html

Fix #26019.

Change-Id: I1a8c2429f79513b43d2b256365cd9166d235af8b
Reviewed-on: https://go-review.googlesource.com/120635
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 02:22:05 +00:00
Alberto Donizetti
291e57f057 doc/contribute: fix typo and reword a few sentences
This change fixes a typo in doc/contribute.html (afects -> affects)
and rewords a few slightly akward sentences.

Change-Id: I6bfbacba0de29464fce134b0fdaf3898a97b8d57
Reviewed-on: https://go-review.googlesource.com/120105
Reviewed-by: Rob Pike <r@golang.org>
2018-06-24 16:01:45 +00:00
Michael Hudson-Doyle
d6a27e8edc cmd/link: never coalesce type descriptors when dynamically linking Go
Add a test by making misc/cgo/testshared/src/trivial.go marginally less
trivial.

Fixes #25970.

Change-Id: I8815d0c56b8850fcdbf9b45f8406f37bd21b6865
Reviewed-on: https://go-review.googlesource.com/120235
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-23 00:16:14 +00:00
Andrew Bonventre
899e0e3525 api: promote next to go1.11
Change-Id: Ib8fa0a12363993033201ff707c315f4030811f89
Reviewed-on: https://go-review.googlesource.com/120595
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 19:48:09 +00:00
Heschi Kreinick
726a2d04ea cmd/link: support DWARF compression on Darwin
We want to compress DWARF even on macOS, but the native toolchain isn't
going to understand it. Add a flag that can be used to disable
compression, then add Darwin to the whitelist used during internal
linking.

Unlike GNU ld, the Darwin linker doesn't have a handy linker flag to do
compression. But since we're already doing surgery to put the DWARF in
the output executable in the first place, compressing it at the same
time isn't unduly difficult. This does have the slightly odd effect of
compressing some Apple proprietary debug sections, which absolutely
nothing will understand. Leaving them uncompressed didn't make much
sense, though, since I doubt they're useful without (say) __debug_info.

Updates #11799

Change-Id: Ie00b0215c630a798c59d009a641e2d13f0e7ea01
Reviewed-on: https://go-review.googlesource.com/120155
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-22 19:16:14 +00:00
Brad Fitzpatrick
3dced519cb syscall, internal/poll: fix build on js/wasm
Fixes #26014

Change-Id: I9d92414a9181c5d189e3e266666950656bf00406
Reviewed-on: https://go-review.googlesource.com/120576
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-22 17:58:16 +00:00
Brad Fitzpatrick
7d50abf039 cmd/dist: skip non-std tests on js/wasm
After the std tests, most of the rest of the tests aren't applicable
to js/wasm. (anything with -cpu=>1, cgo, etc)

Skip them all for now. We can incrementally re-enable them over time
as the js/wasm port is fleshed out. But let's get the builder column
black again so we can enable trybots and keep it black.

Updates #26014
Updates #26015
Updates #18892

Change-Id: I8992ed3888f598fa42273ce8646a32d62ce45b1d
Reviewed-on: https://go-review.googlesource.com/120575
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-22 17:58:10 +00:00
Matthew Dempsky
f422bea498 cmd/compile: fix compile failure for lazily resolved shadowed types
If expanding an inline function body required lazily expanding a
package-scoped type whose identifier was shadowed within the function
body, the lazy expansion would instead overwrite the local symbol
definition instead of the package-scoped symbol. This was due to
importsym using s.Def instead of s.PkgDef.

Unfortunately, this is yet another consequence of the current awkward
scope handling code.

Passes toolstash-check.

Fixes #25984.

Change-Id: Ia7033e1749a883e6e979c854d4b12b0b28083dd8
Reviewed-on: https://go-review.googlesource.com/120456
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-22 17:57:09 +00:00
Cherry Zhang
78a579316b cmd/compile: convert uint32 to int32 in ARM constant folding rules
MOVWconst's AuxInt is Int32. SSA check complains if the AuxInt
does not fit in int32. Convert uint32 to int32 to make it happy.

The generated code is unchanged. MOVW only cares low 32 bits.

Passes "toolstash -cmp" std cmd for ARM.

Fixes #25993.

Change-Id: I2b6532c9c285ea6d89652505fb7c553f85a98864
Reviewed-on: https://go-review.googlesource.com/120335
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-22 16:25:32 +00:00
Dmitri Shuralyov
82d1c2a8aa doc/go1.11: clarify GOOS/GOARCH pair of WebAssembly port
It's more common to specify GOOS/GOARCH values in that order,
rather than the inverse. Fix the order.

Updates #18892.

Change-Id: I8551508599e019f6617dc007397b562c9926418d
Reviewed-on: https://go-review.googlesource.com/120057
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 16:16:26 +00:00
Dmitry Vyukov
f451a318bb sync: fix deficiency in RWMutex race annotations
Remove unnecessary race.Release annotation from Unlock.

For RWMutex we want to establish the following happens-before (HB) edges:
1. Between Unlock and the subsequent Lock.
2. Between Unlock and the subsequent RLock.
3. Between batch of RUnlock's and the subsequent Lock.

1 is provided by Release(&rw.readerSem) in Unlock and Acquire(&rw.readerSem) in Lock.
2 is provided by Release(&rw.readerSem) in Unlock and Acquire(&rw.readerSem) in RLock.
3 is provided by ReleaseMerge(&rw.writerSem) in RUnlock in Acquire(&rw.writerSem) in Lock,
since we want to establish HB between a batch of RUnlock's this uses ReleaseMerge instead of Release.

Release(&rw.writerSem) in Unlock is simply not needed.

FWIW this is also how C++ tsan handles mutexes, not a proof but at least something.
Making 2 implementations consistent also simplifies any kind of reasoning against both of them.

Since this only affects performance, a reasonable test is not possible.
Everything should just continue to work but slightly faster.

Credit for discovering this goes to Jamie Liu.

Change-Id: Ice37d29ecb7a5faed3f7781c38dd32c7469b2735
Reviewed-on: https://go-review.googlesource.com/120495
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-22 14:43:09 +00:00
Ian Lance Taylor
00eac8921e os, net: avoid races between dup, set-blocking-mode, and closing
Fixes #24481
Fixes #24483

Change-Id: Id7da498425a440c91582aa5480c253ae7a9c932c
Reviewed-on: https://go-review.googlesource.com/119955
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 14:27:22 +00:00
Thomas Bruyelle
75fdeaa801 net/http: fix test assertion
Logf doesn't make the test fail, so the test was always OK.

Change-Id: I7c10ee74ff7e5d28cbd3a35e185093cb9f349470
Reviewed-on: https://go-review.googlesource.com/120496
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 13:28:19 +00:00
Zhou Peng
b8d4d0218b runtime: fix comments style typo
Code comments should have a space between comments characters and
actual words.

Change-Id: I6274baf1fc09b37a32ec6c69ddbb8edca9eb5469
Reviewed-on: https://go-review.googlesource.com/120475
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-22 13:21:28 +00:00
Daniel Theophanes
bedfa4e1c3 text/template/parse: undo breaking API changes
golang.org/cl/84480 altered the API for the parse package for
clarity and consistency. However, the changes also broke the
API for consumers of the package. This CL reverts the API
to the previous spelling, adding only a single new exported
symbol.

Fixes #25968

Change-Id: Ieb81054b61eeac7df3bc3864ef446df43c26b80f
Reviewed-on: https://go-review.googlesource.com/120355
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-22 08:05:11 +00:00
Austin Clements
4991bc6257 runtime: avoid recursive panic on bad lock count
Currently, if lock or unlock calls throw because the g.m.lock count is
corrupted, we're unlikely to get a stack trace because startpanic_m
will itself attempt to acquire a lock, causing a recursive failure.

Avoid this by forcing the g.m.locks count to a sane value if it's
currently bad.

This might be enough to get a stack trace from #25128.

Change-Id: I52d7bd4717ffae94a821f4249585f3eb6cd5aa41
Reviewed-on: https://go-review.googlesource.com/120416
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-22 00:28:25 +00:00
Matthew Dempsky
011ea87921 cmd/compile: fix recursive inimport handling
expandDecl can be called recursively, so it's not an appropriate place
to clean inimport. Instead, move this up to resolve, along with an
appropriate recursion check.

Passes toolstash-check.

Change-Id: I138d37b057dcc6525c780b4b3fbaa5e97f99655b
Reviewed-on: https://go-review.googlesource.com/120455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-21 23:57:55 +00:00
Terin Stock
6c8100270c flag: add a Value example
Change-Id: I579cc9f4f8e5be5fd6447a99614797ab7bc53611
Reviewed-on: https://go-review.googlesource.com/120175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-21 23:32:53 +00:00
Paul Jolly
4b3428998d misc/wasm: fix permissions on wasm_exec.js
Currently wasm_exec.js is executable (0755) yet has no interpreter.
Indeed wasm_exec.js is only ever used as an argument to Node or loaded
via a <script> tag in a browser-loaded HTML file.  Hence the execute
mode bits are superfluous and simply serve to clutter your PATH if
$GOROOT/misc/wasm is on your PATH (as is required if you want to run go
test syscall/js).

Change-Id: I279e2457094f8a12b9bf380ad7f1a9f47b22fc96
Reviewed-on: https://go-review.googlesource.com/120435
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-21 22:55:55 +00:00
Andrei Tudor Călin
24fb2e015a internal/poll: use more fine-grained locking in Splice
The previous code acquired a read lock on src and a write lock on
dst for the entire duration of Splice. This resulted in deadlock,
in a situation akin to the following:

Splice is blocking, waiting to read from src.

The caller tries to close dst from another goroutine, but Close on
dst blocks in runtime.semacquire, because Splice is still holding a
write lock on it, and the Close didn't unblock any I/O.

The caller cannot unblock the read side of Splice through other means,
because they are stuck waiting in dst.Close().

Use more fine-grained locking instead: acquire the read lock on src
just before trying to splice from the source socket to the pipe,
and acquire the write lock on dst just before trying to splice from
the pipe to the destination socket.

Fixes #25985

Change-Id: I264c91c7a69bb6c5e28610e2bd801244804cf86d
Reviewed-on: https://go-review.googlesource.com/120317
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-21 22:13:34 +00:00
Ian Lance Taylor
1507502ff2 cmd/go: re-enable a couple of tests of gccgo
Updates #22472

Change-Id: I526d131f2ef8e0200f7a5634c75b31e0ee083f93
Reviewed-on: https://go-review.googlesource.com/120375
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-21 19:35:27 +00:00
Wei Xiao
0a7ac93c27 cmd/compile: improve atomic add intrinsics with ARMv8.1 new instruction
ARMv8.1 has added new instruction (LDADDAL) for atomic memory operations. This
CL improves existing atomic add intrinsics with the new instruction. Since the
new instruction is only guaranteed to be present after ARMv8.1, we guard its
usage with a conditional on CPU feature.

Performance result on ARMv8.1 machine:
name        old time/op  new time/op  delta
Xadd-224    1.05µs ± 6%  0.02µs ± 4%  -98.06%  (p=0.000 n=10+8)
Xadd64-224  1.05µs ± 3%  0.02µs ±13%  -98.10%  (p=0.000 n=9+10)
[Geo mean]  1.05µs       0.02µs       -98.08%

Performance result on ARMv8.0 machine:
name        old time/op  new time/op  delta
Xadd-46      538ns ± 1%   541ns ± 1%  +0.62%  (p=0.000 n=9+9)
Xadd64-46    505ns ± 1%   508ns ± 0%  +0.48%  (p=0.003 n=9+8)
[Geo mean]   521ns        524ns       +0.55%

Change-Id: If4b5d8d0e2d6f84fe1492a4f5de0789910ad0ee9
Reviewed-on: https://go-review.googlesource.com/81877
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-21 14:52:43 +00:00
Emmanuel T Odeke
1988b3ed0e net/http: avoid deferred unlock in ServeMux.shouldRedirect
CL 96575 introduced concurrency protection for
ServeMux.shouldRedirect with a read lock and deferred unlock.
However, the change produced a noticeable regression.
Instead add the suffix "RLocked" to the function name to
declare that we should hold the read lock as a pre-requisite
before calling it, hence avoiding the defer altogether.

Benchmarks:
name                  old time/op    new time/op    delta
ServeMux-8              63.3µs ± 0%    54.6µs ± 0%  -13.74%  (p=0.000 n=9+9)
ServeMux_SkipServe-8    41.4µs ± 2%    32.7µs ± 1%  -21.05%  (p=0.000 n=10+10)

name                  old alloc/op   new alloc/op   delta
ServeMux-8              17.3kB ± 0%    17.3kB ± 0%     ~     (all equal)
ServeMux_SkipServe-8     0.00B          0.00B          ~     (all equal)

name                  old allocs/op  new allocs/op  delta
ServeMux-8                 360 ± 0%       360 ± 0%     ~     (all equal)
ServeMux_SkipServe-8      0.00           0.00          ~     (all equal)

Updates #25383
Updates #25482

Change-Id: I2ffa4eafe165faa961ce23bd29b5653a89facbc2
Reviewed-on: https://go-review.googlesource.com/113996
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-21 12:53:33 +00:00
Tobias Klauser
85e38cccb4 syscall: check faccessat flags parameter on Linux
Port CL 119495 from golang.org/x/sys/unix to the syscall package.

Currently Linux faccessat(2) syscall implementation doesn't support the
flags parameter. As per the discussion in #25845, permit the same flags
as glibc [1].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/faccessat.c;h=ea42b2303ff4b2d2d6548ea04376fb265f773436;hb=HEAD

Updates #25845

Change-Id: I132b33275a9cc72b3a97acea5482806c7f47d7f7
Reviewed-on: https://go-review.googlesource.com/120015
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-21 06:47:46 +00:00
Brad Fitzpatrick
feeff23556 mime: change *.js mime type to application/javascript, not x-javascript
We delayed doing this for 4 years for fear that it might break something,
but it was standardized (RFC 4329) 12 years ago, and the default in Debian
and other places is correct:

   $ cat /etc/mime.types  | grep js$
   application/javascript                          js

Time for us to change too.

I doubt there will be problems, but we'll see during the Go 1.11 beta.

Fixes #7498

Change-Id: Iba0bf8a6e707a64dd63317e1c0d6dd9a18634527
Reviewed-on: https://go-review.googlesource.com/120058
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-20 22:20:41 +00:00
Agniva De Sarker
f3f7bd5558 cmd/go/internal: add a note about GOCACHE=off
Fixes #25928

Change-Id: I1401ecc54af26eeeee648bb8eeb5d2d3566fa60c
Reviewed-on: https://go-review.googlesource.com/119695
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 20:29:55 +00:00
Stephen Lewis
ee9c9392b8 doc: fix spelling of G Suite
'G Suite' seems to be the preferred spelling according to
https://gsuite.google.com/

Change-Id: Ica60938cf942594157bba84ef205e1cdcb8c1b08
Reviewed-on: https://go-review.googlesource.com/120132
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-06-20 18:43:22 +00:00