1
0
mirror of https://github.com/golang/go synced 2024-09-25 01:20:13 -06:00
Commit Graph

39877 Commits

Author SHA1 Message Date
Clément Chigot
697f4183e6 cmd/link: allow buildmode c-archive for aix/ppc64
Change-Id: Ia268b0d64dc89866aa09bfffcaa109741088a904
Reviewed-on: https://go-review.googlesource.com/c/go/+/169119
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 17:39:13 +00:00
John
f7f4eef385 mime: add javascript module mime type (.mjs)
There are default mime types in this package for handling static content, but there's
a new one missing ".mjs"  that is "Content-Type: text/javascript".

https://developers.google.com/web/fundamentals/primers/modules#mjs

Change-Id: Ie842ece0cb55770fb6c9eb65f8bfee2ecf7bc624
GitHub-Last-Rev: e26d9f7617
GitHub-Pull-Request: golang/go#31071
Reviewed-on: https://go-review.googlesource.com/c/go/+/169502
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-27 17:30:53 +00:00
LE Manh Cuong
d47db6dc0c cmd/compile: fix literal struct interface {} lost passing by value
CL 135377 introduces pass strings and slices to convT2{E,I} by value.
Before that CL, all types, except interface will be allocated temporary
address. The CL changes the logic that only constant and type which
needs address (determine by convFuncName) will be allocated.

It fails to cover the case where type is static composite literal.
Adding condition to check that case fixes the issue.

Also, static composite literal node implies constant type, so consttype
checking can be removed.

Fixes #30956

Change-Id: Ifc750a029fb4889c2d06e73e44bf85e6ef4ce881
Reviewed-on: https://go-review.googlesource.com/c/go/+/168858
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-03-27 17:28:06 +00:00
Clément Chigot
38dc177d3a runtime: create library startup for aix/ppc64
As .init_array section aren't available on AIX, the Go runtime
initialization is made with gcc constructor attribute.
However, as cgo tool is building a binary in order to get imported
C symbols, Go symbols imported for this initilization must be ignored.
-Wl,-berok is mandatory otherwize ld will fail to create this binary,
_rt0_aix_ppc64_lib and runtime_rt0_go aren't defined in runtime/cgo.
These two symbols must also be ignored when creating _cgo_import.go.

Change-Id: Icf2e0282f5b50de5fa82007439a428e6147efef1
Reviewed-on: https://go-review.googlesource.com/c/go/+/169118
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 17:22:11 +00:00
Clément Chigot
53c9c06811 misc/cgo: enable testso and testsovar on aix/ppc64
On AIX, shared objects must be wrapped under an archive file.

For testso, creating libcgosotest with an extern symbol isn't
AIX-friendly. By default, ld will block such behavior. Rather than
forcing ld to work as on Linux and using the run-time linking,
goCallback became a function pointer which is set by setCallback().

Updates #30565

Change-Id: I455ab32faddd41f1b0c84cc9e503788044ad49b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/169020
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 17:21:28 +00:00
LE Manh Cuong
c7f7f59368 os: reject WriteAt if file opened in append mode
WriteAt use pwrite syscall on *nix or WriteFile on Windows.

On Linux/Windows, these system calls always write to end of file in
append mode, regardless of offset parameter.

It is hard (maybe impossible) to make WriteAt work portably.

Making WriteAt returns an error if file is opened in append mode, we
guarantee to get consistent behavior between platforms, also prevent
user from accidently corrupting their data.

Fixes #30716

Change-Id: If83d935a22a29eed2ff8fe53d13d0b4798aa2b81
Reviewed-on: https://go-review.googlesource.com/c/go/+/166578
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-27 17:04:57 +00:00
Brian Kessler
5ee2290420 math/big: implement Rat.SetUint64
Implemented via the underlying Int.SetUint64.
Added tests for Rat.SetInt64 and Rat.SetUint64.

Fixes #29579

Change-Id: I03faaffc93e36873b202b58ae72b139dea5c40f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/160682
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-27 15:20:28 +00:00
Elias Naur
90a3ce02dc cmd/link/internal/ld: skip TLS section on Android
We don't use the TLS section on android, and dropping it avoids
complaints about underalignment from the Android Q linker.

Updates #29674

Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/169618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 14:46:21 +00:00
Ben Hoyt
f24e1099cb bytes: make TrimSpace return nil on all-space input
Issue #29122 introduced a subtle regression due to the way that
TrimFuncLeft is written: previously TrimSpace returned nil when given
an input of all whitespace, but with the #29122 changes it returned an
empty slice on all-space input.

This change adds a special case to the new, optimized TrimSpace to go
back to that behavior. While it is odd behavior and people shouldn't be
relying on these functions returning a nil slice in practice, it's not
worth the breakage of code that does.

This tweak doesn't change the TrimSpace benchmarks significantly.

Fixes #31038

Change-Id: Idb495d02b474054d2b2f593c2e318a7a6625688a
Reviewed-on: https://go-review.googlesource.com/c/go/+/169518
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 13:52:52 +00:00
Brad Fitzpatrick
39a51a4b0d sort, internal/reflectlite: flesh out reflectlite enough for use by sort
Now the net package is back to no longer depending on unicode. And lock that in
with a test.

Fixes #30440

Change-Id: I18b89b02f7d96488783adc07308da990f505affd
Reviewed-on: https://go-review.googlesource.com/c/go/+/169137
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-27 04:58:23 +00:00
LE Manh Cuong
f0e0be6e90 os: document exit status range value
Fixes #30959

Change-Id: I9d30d79e2dbb3f8c8d6555f8c64862b133638d5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/169357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-03-27 04:37:34 +00:00
Agniva De Sarker
08ba9c0291 cmd/go/internal/{run,work,generate}: document file path location requirement
Mention that .go files must be from a single directory
for them to be treated as a single package.

Fixes #21529

Change-Id: I79cb08b9f43888814b1249a7b50bc7bc70bc1c72
Reviewed-on: https://go-review.googlesource.com/c/go/+/149797
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-27 03:41:10 +00:00
Brad Fitzpatrick
724a86fced context: don't depend on fmt
So the net package doesn't indirectly depend on unicode tables.

But we're still not quite there, because a new test added in this CL
reveals that we still have a path to unicode via:

deps_test.go:570:
  TODO(issue 30440): policy violation: net => sort => reflect => unicode

Updates #30440

Change-Id: I710c2061dfbaa8e866c92e6c824bd8df35784165
Reviewed-on: https://go-review.googlesource.com/c/go/+/169080
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-27 02:37:56 +00:00
Felix Bünemann
f2e51f0015 crypto/x509: look for CAs at /etc/ssl/cert.pem for Alpine Linux
Alpine Linux uses /etc/ssl/cert.pem as default ca-bundle which
is preinstalled since 3.7 and was installed as part of the libressl
package in 3.5 and 3.6.

The path /etc/ssl/certs/ca-certificates.crt is only valid if the full
ca-certificates package is installed by hand, which contains all
single CA certs and uses update-ca-certificates to bundle them.

The priority for /etc/ssl/certs/ca-certificates.crt should be kept
higher than /etc/ssl/cert.pem in case the user installed custom
CA certs.

Change-Id: I1c86a6ad84d8ee1163560655743a5ce9f2408af1
GitHub-Last-Rev: 0ba4d599e4
GitHub-Pull-Request: golang/go#31042
Reviewed-on: https://go-review.googlesource.com/c/go/+/169238
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-03-26 22:10:49 +00:00
Clément Chigot
b5cf035d1c runtime: improve sigtramp on aix/ppc64 to handle SIGPROF
R14, R15 must be saved in sigtramp because they might be modified by Go
code when a SIGPROF occurs.

Fixes #28555

Change-Id: I573541f108d7d6aac8e60d33c649e5db943f3ef5
Reviewed-on: https://go-review.googlesource.com/c/go/+/169117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-26 20:04:42 +00:00
Dmitri Shuralyov
e007916cea cmd/go/internal/load: always use DefaultExecName to determine binary name
It should produce equivalent results to split on the import path of the
package rather than its directory, in GOPATH mode. That means the common
code in DefaultExecName can be used.

We're in the middle of Go 1.12 cycle, so now is a good time to make it
happen for Go 1.13.

Modify isVersionElement to accept path elements like "v2", "v3", "v10",
rather than "/v2", "/v3", "/v10". Then use it in DefaultExecName instead
of the ad-hoc isVersion function. There is no change in behavior.

Add tests for DefaultExecName and isVersionElement.

Updates #26869

Change-Id: Ic6da2c92587459aa2b327385e994b72a6e183092
Reviewed-on: https://go-review.googlesource.com/c/go/+/168678
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-26 19:49:02 +00:00
Brad Fitzpatrick
db7e746960 cmd/vet/all: don't use the x/tools vet in GOPATH
Updates golang/go#31040

Change-Id: I76e3044b2cc992e63194654a825e70307075eff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169237
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-26 16:29:00 +00:00
Richard Musiol
cd5309355e syscall/js: improve type checks of js.Value's methods
Add more explicit checks if the given js.Value is of the correct type
instead of erroring on the JavaScript layer.

Change-Id: I30b18a76820fb68f6ac279bb88a57456f5bab467
Reviewed-on: https://go-review.googlesource.com/c/go/+/168886
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-26 09:47:28 +00:00
Brad Fitzpatrick
0ec302c49e cmd: update go.mod versions for vetall bug
Updates golang/go#30971
Updates golang/go#31040

Change-Id: I305fbddb6f79cbe3d7e29225841309ab00b1e7dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/169239
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-26 03:57:49 +00:00
Keith Randall
b7b7b4d6d4 reflect: initialize ptrdata earlier in StructOf
It needs to be set before addTypeBits is called.

Fixes #31043

Change-Id: I692b4047dc17bd68202d45da41dd55d432383e59
Reviewed-on: https://go-review.googlesource.com/c/go/+/169318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-26 03:54:07 +00:00
Keith Randall
17f888c5a8 reflect: fix typeptrdata
We can't use ptrdata inside of typeptrdata, because it won't be
properly initialized until typeptrdata returns.

Fixes #31039

Change-Id: Ib8c89191a7e4cce678a05d351bb6ded81ba23aae
Reviewed-on: https://go-review.googlesource.com/c/go/+/169317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-03-26 03:33:13 +00:00
Matthew Dempsky
c4f87ed26f cmd/compile: fix "append outside assignment" ICE
Some special-case code paths in order.go didn't expect OCALLFUNC to
have Ninit; in particular, OAS2FUNC and ODEFER/OGO failed to call
o.init on their child OCALLFUNC node. This resulted in not all of the
AST being properly ordered.

This was noticed because order is responsible for introducing an
invariant around how OAPPEND is used, which is enforced by walk.
However, there were perhaps simpler cases (e.g., simple order of
evaluation) that were being silently miscompiled.

Fixes #31010.

Change-Id: Ib928890ab5ec2aebd8e30a030bc2b404387f9123
Reviewed-on: https://go-review.googlesource.com/c/go/+/169257
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-03-26 02:20:09 +00:00
Neven Sajko
270de1c110 math: use Sincos instead of Sin and Cos in Jn and Yn
Change-Id: I0da3857013f1d4e90820fb043314d78924113a27
GitHub-Last-Rev: 7c3d813c6e
GitHub-Pull-Request: golang/go#31019
Reviewed-on: https://go-review.googlesource.com/c/go/+/169078
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-25 22:41:37 +00:00
Robert Griesemer
e4ba40030f math/big: accept non-decimal floats with Rat.SetString
This fixes an old oversight. Rat.SetString already permitted
fractions a/b where both a and b could independently specify
a base prefix. With this CL, it now also accepts non-decimal
floating-point numbers.

Fixes #29799.

Change-Id: I9cc65666a5cebb00f0202da2e4fc5654a02e3234
Reviewed-on: https://go-review.googlesource.com/c/go/+/168237
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-03-25 22:29:26 +00:00
Caleb Spare
a591fd08dd testing: correct two spelling/grammar issues
Change-Id: Ic7f7a34e12cc2845e0385a5a872e694d5dca7372
Reviewed-on: https://go-review.googlesource.com/c/go/+/169158
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 22:26:21 +00:00
Brad Fitzpatrick
e6df179979 cmd/dist: move GOPATH setting from init to bootstrap
CL 168697 unconditionally set GOPATH in dist, which broke the
misc-vet-vetall builder, because cmd/vet/all depends on GOPATH.

Fixes #30971

Change-Id: If6a58e054c6a4fedc2ea506a2c443348489c91f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169217
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-25 22:11:58 +00:00
Rob Pike
50fe9461eb fmt: fix spelling mistake in example
Mea culpa. Beat Takeshi, sumimasen.

Fixes #31023.

Change-Id: Ie2f27a5867724a8a1b8c3082c3389c8fd6d1dee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 21:03:10 +00:00
Keith Randall
db16de9203 runtime: remove kindNoPointers
We already have the ptrdata field in a type, which encodes exactly
the same information that kindNoPointers does.

My problem with kindNoPointers is that it often leads to
double-negative code like:

   t.kind & kindNoPointers != 0

Much clearer is:

   t.ptrdata == 0

Update #27167

Change-Id: I92307d7f018a6bbe3daca4a4abb4225e359349b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/169157
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 20:46:35 +00:00
Matt Layher
501632339f net: add missing period in conn.File documentation
Change-Id: Ie873d7ed595c91cee4c1aa6c22fa44b61b6190ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/169138
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 18:16:51 +00:00
Jay Conrod
6e7bc021ee cmd/dist: set GOPATH to internal directory during build
Since GO111MODULE=on by default, the Go command needs a location for
the module cache, even though it doesn't need to be written when
building std and cmd. If GOROOT is checked out to $HOME/go, which is
also the default location for GOPATH, this causes unnecessary problems
late in the build.

With this change, dist sets GOPATH to $GOROOT/pkg/obj/go-path. This is
next to the temporary GOCACHE, $GOROOT/pkg/obj/go-build.

Fixes #30960

Change-Id: I60771ee7f7c67ced1d2dc7c66b5885703fad1b63
Reviewed-on: https://go-review.googlesource.com/c/go/+/168697
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-25 17:58:46 +00:00
Josh Bleecher Snyder
24f846e212 runtime: skip wb call in growslice when unnecessary
Instrumenting make.bash reveals that almost half (49.54%)
of the >16 million calls to growslice for
pointer-containing slices are
growing from an empty to a non-empty slice.

In that case, there is no need to call the write barrier,
which does some work before discovering that no pointers need shading.

Change-Id: Ide741468d8dee7ad43ea0bfbea6ccdf680030a0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168959
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-03-25 17:11:46 +00:00
Keith Randall
2034fbab5b cmd/compile: use existing instructions instead of nops for inline marks
Instead of always inserting a nop to use as the target of an inline
mark, see if we can instead find an instruction we're issuing anyway
with the correct line number, and use that instruction. That way, we
don't need to issue a nop.

Makes cmd/go 0.3% smaller.

Update #29571

Change-Id: If6cfc93ab3352ec2c6e0878f8074a3bf0786b2f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/158021
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-03-25 16:49:29 +00:00
Michael Fraenkel
88adc33827 context: remove dependency on reflect
Make context depend on reflectlite instead of reflect in effort to
eventually make net no longer depend on unicode tables.

With this CL we're down to just:

    net -> context -> fmt -> unicode tables

The next CL can remove context -> fmt.

Updates #30440

Change-Id: I7f5df15f975d9dc862c59aa8477c1cfd6ff4967e
Reviewed-on: https://go-review.googlesource.com/c/go/+/164239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-25 16:31:40 +00:00
Vladimir Kovpak
9a8979deb0 math/rand: add example for Intn func
Change-Id: I831ffb5c3fa2872d71def8d8461f0adbd4ae2c1a
GitHub-Last-Rev: 2adfcd2d5a
GitHub-Pull-Request: golang/go#30706
Reviewed-on: https://go-review.googlesource.com/c/go/+/166426
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 16:05:37 +00:00
Hasan Ozgan
42cdc26665 database/sql: add example for DB.Prepare and Tx.Prepare
Change-Id: Ib9272a7713ed7aaf8ad54c4827be8c095763e648
Reviewed-on: https://go-review.googlesource.com/c/go/+/161677
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-25 15:51:17 +00:00
sergey
cf99535e21 net/http: reduce allocs on write cookie
Pregrow buffer to reduce allocs on building cookie string.
We calc cookie name value and domain size (most distributed by value) and
add 110 extra characters allows to write most cookie attributes
without additional allocations in most cases.

name              old time/op    new time/op    delta
CookieString-4      1.65µs ± 3%    1.27µs ± 2%  -23.01%  (p=0.008 n=5+5)
ReadSetCookies-4    5.78µs ± 4%    5.67µs ± 3%     ~     (p=0.310 n=5+5)
ReadCookies-4       7.12µs ± 4%    7.04µs ± 3%     ~     (p=0.690 n=5+5)

name              old alloc/op   new alloc/op   delta
CookieString-4        360B ± 0%      144B ± 0%  -60.00%  (p=0.008 n=5+5)
ReadSetCookies-4      976B ± 0%      976B ± 0%     ~     (all equal)
ReadCookies-4       2.17kB ± 0%    2.17kB ± 0%     ~     (all equal)

name              old allocs/op  new allocs/op  delta
CookieString-4        5.00 ± 0%      1.00 ± 0%  -80.00%  (p=0.008 n=5+5)
ReadSetCookies-4      15.0 ± 0%      15.0 ± 0%     ~     (all equal)
ReadCookies-4         16.0 ± 0%      16.0 ± 0%     ~     (all equal)

Change-Id: I50defac954a135b785b3551342b00878429b3d7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/163017
Reviewed-by: Volker Dobler <dr.volker.dobler@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 15:21:06 +00:00
Than McIntosh
6582ee9cba test: new test for issue 30908
New test case designed to mimic the code in issue 30908, which
features duplicate but non-indentical DWARF abstract subprogram DIEs.

Updates #30908.

Change-Id: Iacb4b53e6a988e46c801cdac236cef883c553f8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168957
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2019-03-25 15:00:08 +00:00
Than McIntosh
fbd74a8922 test: support -ldflags for "rundir" tests, new -P option
For "rundir" tests, allow users to add in linker flags as well as
compiler flags, e.g.

// rundir -m -ldflags -w

The directive above will pass "-m" to the compiler on each package compilation
and "-w" to the linker for the final link.

In addition, if "-P" is specified with 'rundir', then for each compile
pass in "-p <X>" to set the packagepath explicitly, which is closer to
how the compiler is run by 'go build'.

Change-Id: I04720011a89d1bd8dcb4f2ccb4af1d74f6a01da1
Reviewed-on: https://go-review.googlesource.com/c/go/+/168977
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-25 14:59:58 +00:00
Than McIntosh
68a98d5279 cmd/compile: better handling for PAUTOHEAP in DWARF inline gen
When generating DWARF inline info records, the post-SSA code looks
through the original "pre-inline" dcl list for the function so as to
handle situations where formal params are promoted or optimized away.
This code was not properly handling the case where an output parameter
was promoted to the heap -- in this case the param node is converted
in place from class PPARAMOUT to class PAUTOHEAP. This caused
inconsistencies later on, since the variable entry in the abstract
subprogram DIE wound up as a local and not an output parameter.

Fixes #30908.

Change-Id: Ia70b89f0cf7f9b16246d95df17ad6e307228b8c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168818
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-25 14:03:40 +00:00
Richard Musiol
9eef964800 misc/wasm: exit with code 1 if WebAssembly.instantiate fails
go_js_wasm_exec was returning with code 0 if WebAssembly.instantiate
failed. This made failing tests show as passed.

Change-Id: Icfb2f42e9f1c3c70ca4a130a61a63cb305edff32
Reviewed-on: https://go-review.googlesource.com/c/go/+/168885
Run-TryBot: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-25 07:55:12 +00:00
Richard Musiol
fb9b818bbd cmd/link/internal/wasm: do not generate more than 100000 data segments
Some WebAssembly runtimes (e.g. Node.js) fail to load a wasm binary if
it has more than 100000 data segments. Do not skip zero regions any more
if the limit was reached.

Change-Id: I14c4c2aba142d1d2b887bce6d03b8c1c1746c5ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/168884
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-25 07:54:44 +00:00
Hasan Ozgan
56e1614c47 path/filepath: add examples for Base, Dir and IsAbs
Change-Id: I7a438409748f0f9d6517a7ea1cdee6512ce3ca8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/161678
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-03-25 02:57:06 +00:00
Petr Jediný
869620bbea log: expose Writer() method of the standard logger
The Go 1.12 introduced Writer() method for logger objects, but
it was not exposed as log package function for standard logger.
This commit adds such Writer() function.

Change-Id: Ia81b1524839fe05c152ecb5eaef047a076349fea
GitHub-Last-Rev: dc152ea641
GitHub-Pull-Request: golang/go#31009
Reviewed-on: https://go-review.googlesource.com/c/go/+/168920
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-03-25 01:18:56 +00:00
sergey
c7bb4533cb net/url: check for lowercase before uppercase in shouldEscape
Most chars in URLs are lowercase, so check that first.

Performance change:

String-4               7.62µs ± 1%    7.27µs ± 3%  -4.61%  (p=0.008 n=5+5)
QueryEscape/#00-4      92.6ns ± 3%    90.3ns ± 1%  -2.48%  (p=0.016 n=5+5)
QueryEscape/#01-4       515ns ± 4%     510ns ± 2%    ~     (p=0.683 n=5+5)
QueryEscape/#02-4       375ns ± 1%     343ns ± 1%  -8.52%  (p=0.008 n=5+5)
QueryEscape/#03-4       758ns ± 1%     699ns ± 1%  -7.83%  (p=0.008 n=5+5)
QueryEscape/#04-4      6.06µs ± 1%    5.74µs ± 1%  -5.38%  (p=0.008 n=5+5)
PathEscape/#00-4        140ns ± 1%     135ns ± 2%  -3.85%  (p=0.008 n=5+5)
PathEscape/#01-4        511ns ± 3%     507ns ± 3%    ~     (p=0.587 n=5+5)
PathEscape/#02-4        372ns ± 1%     342ns ± 2%  -8.22%  (p=0.008 n=5+5)
PathEscape/#03-4        747ns ± 1%     685ns ± 1%  -8.30%  (p=0.008 n=5+5)
PathEscape/#04-4       5.94µs ± 1%    5.64µs ± 3%  -4.98%  (p=0.008 n=5+5)
QueryUnescape/#00-4     111ns ± 4%     110ns ± 2%    ~     (p=0.952 n=5+5)
QueryUnescape/#01-4     390ns ± 0%     391ns ± 2%    ~     (p=0.714 n=5+5)
QueryUnescape/#02-4     297ns ± 5%     295ns ± 3%    ~     (p=0.524 n=5+5)
QueryUnescape/#03-4     543ns ± 3%     556ns ± 2%  +2.39%  (p=0.032 n=5+5)
QueryUnescape/#04-4    3.23µs ± 3%    3.22µs ± 2%    ~     (p=1.000 n=5+5)
PathUnescape/#00-4      111ns ± 1%     110ns ± 3%    ~     (p=0.881 n=5+5)
PathUnescape/#01-4      389ns ± 2%     386ns ± 2%    ~     (p=0.444 n=5+5)
PathUnescape/#02-4      297ns ± 1%     295ns ± 3%    ~     (p=0.738 n=5+5)
PathUnescape/#03-4      557ns ± 3%     553ns ± 2%    ~     (p=0.810 n=5+5)
PathUnescape/#04-4     2.94µs ± 2%    2.97µs ± 2%    ~     (p=0.222 n=5+5)

Change-Id: I7e6d64cd5f8f5218cb40f52f0015168a8674aabb
Reviewed-on: https://go-review.googlesource.com/c/go/+/168883
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-24 19:03:16 +00:00
Alex Brainman
7722f6d228 cmd/go: keep WINDIR during TestScript
TestScript executes PowerShell. And PowerShell appears to require
WINDIR environment variable to exists on windows-arm.

So keep WINDIR environment variable when running PowerShell.

Fixes #30711

Change-Id: I14dde6614347325a8f3caf994ea8ab05294450a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/168859
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-24 09:15:09 +00:00
Daniel Martí
e770b5b3aa text/template: allow using -}} with many spaces
lexSpace consumed all spaces, even if the last one was part of a right
delimiter like " -}}". Thus, "3  -}}" wouldn't lex as "3" and a right
delimiter, but as "3", "-", and "}}".

To fix that, make lexSpace stop if it encounters a right delimiter.

Fixes #30948.

Change-Id: I80a5546e5809e54f6823e2bf3a57a7e8808329be
Reviewed-on: https://go-review.googlesource.com/c/go/+/168457
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-03-24 09:06:14 +00:00
Richard Musiol
b434bbf197 cmd/go: add GOWASM environment variable
This change adds the environment variable GOWASM, which is a comma
separated list of experimental WebAssembly features that the compiled
WebAssembly binary is allowed to use. The default is to use no
experimental features. Initially there are no features avaiable.

More information about feature proposals can be found at
https://github.com/WebAssembly/proposals

Change-Id: I4c8dc534c99ecff8bb075dded0186ca8f8decaef
Reviewed-on: https://go-review.googlesource.com/c/go/+/168881
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-23 20:33:57 +00:00
Richard Musiol
2396101e05 src/cmd/internal/obj/wasm: optimize blocks in wasm binary
This change optimizes the blocks in the wasm binary by generating the
entryPointLoop only if it is used and adding an unwindExit block to
be able to use the short BrIf instruction for unwinding the stack.
These changes were suggested by the wasm-opt tool and reduce the
wasm binary size of "hello world" by 1.5%.

Change-Id: Ie52db2fa2d9b8482f9a78b7c189231750811fe97
Reviewed-on: https://go-review.googlesource.com/c/go/+/167937
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-23 12:34:20 +00:00
Ben Shi
a189467cda cmd/internal/obj/mips: add MADD/MSUB
This CL implements MADD&MSUB, which are mips32r2 instructions.

Change-Id: I06fe51573569baf3b71536336b34b95ccd24750b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167680
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-23 01:39:16 +00:00
Austin Clements
1257d05088 testing: fix fractional ns/op printing
CL 166717 changed the way ns/op benchmark results were printed and
inadvertently rounded all ns/op results down to an integer, even if
they were small enough to print with digits after the decimal place.
For example, prior to this change, we got output like

    BenchmarkFast-8       380491575	 3.12 ns/op

CL 166717 changed this to

    BenchmarkFast-8       380491575      3.00 ns/op

This had the further side-effect that ns/op values between 0 and 1
would not be printed at all because they would be rounded down to 0.

This CL fixes this by always recomputing the float64 value of ns/op
instead of using the int64 truncation from BenchmarkResult.NsPerOp.

Fixes #30997. Fixes #31005.

Change-Id: I21f73b9d5cc5ad41e7ff535675d07ca00051ecd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168937
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-03-22 21:19:22 +00:00