1
0
mirror of https://github.com/golang/go synced 2024-09-29 12:04:28 -06:00
Commit Graph

39269 Commits

Author SHA1 Message Date
Daniel Martí
f40cb19aff internal/lazyregexp: add a lazy Regexp package
This was implemented as part of go/doc, but it's going to be useful in
other packages. In particular, many packages under cmd/go like web and
vcs make somewhat heavy use of global regexes, which add a non-trivial
amount of init work to the cmd/go program.

A lazy wrapper around regexp.Regexp will make it trivial to get rid of
the extra cost with a trivial refactor, so make it possible for other
packages in the repository to make use of it. While naming the package,
give the members better names, such as lazyregexp.New and
lazyregexp.Regexp.

We're also considering adding some form of a lazy API to the public
regexp package, so this internal package will allow us to get some
initial experience across std and cmd.

For #29382.

Change-Id: I30b0e72871d5267c309786f95f4cb15c68b2393d
Reviewed-on: https://go-review.googlesource.com/c/164040
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27 15:58:10 +00:00
Clément Chigot
0d8c3637b1 cmd/go: fix -Wl,--whole-archive for aix/ppc64
--whole-archive doesn't exist on AIX. It was already removed most of
the time but was still added with c-archive or c-shared buildmodes.

Change-Id: Ia7360638509d4a4d91674b0281ed4b112508a2c9
Reviewed-on: https://go-review.googlesource.com/c/164037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-27 15:56:45 +00:00
Mikio Hara
850e3636d5 Revert "net: add missing error check in test"
This reverts commit ec521467e3.

Reson for revert: The test cases using slowDst4 and slowDst6 are
fragile. We need to find out a better approach to the trick on the IP
routeability.

Change-Id: I544453886e809d1c7b339673d8f1d5bdef357147
Reviewed-on: https://go-review.googlesource.com/c/163919
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27 15:42:26 +00:00
Agniva De Sarker
43732816be syscall/js: add a note about a bug in TypedArray
Fixes #29355

Change-Id: I4018d420c8d413b2681744af18ffb65da03ac504
Reviewed-on: https://go-review.googlesource.com/c/155778
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-02-27 15:08:01 +00:00
Bryan C. Mills
bd98628676 math/cmplx: avoid panic in Pow(x, NaN())
Fixes #30088

Change-Id: I08cec17feddc86bd08532e6b135807e3c8f4c1b2
Reviewed-on: https://go-review.googlesource.com/c/161197
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-27 14:01:03 +00:00
Clément Chigot
4a9aba5afe syscall: add missing Setrlimit and Termios on aix/ppc64
This commits adds a missing syscall and a missing structure in syscall
package.

Change-Id: I9d630454c56337267f7bbb023e601246e14fc929
Reviewed-on: https://go-review.googlesource.com/c/163978
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-27 13:47:27 +00:00
Gergely Brautigam
8ee9bca272 cmd/compile: suppress typecheck errors in a type switch case with broken type
If a type switch case expression has failed typechecking, the case body is
likely to also fail with confusing or spurious errors. Suppress
typechecking the case body when this happens.

Fixes #28926

Change-Id: Idfdb9d5627994f2fd90154af1659e9a92bf692c4
Reviewed-on: https://go-review.googlesource.com/c/158617
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-02-27 08:22:03 +00:00
Tobias Klauser
9cb2471334 debug/pe: prevent slice out of bounds access in (*File).ImportedSymbols
Fixes #30253

Change-Id: I0c3d67649ea379b67f3575c1219fe05a04f056ae
Reviewed-on: https://go-review.googlesource.com/c/162859
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-02-27 08:10:14 +00:00
Tobias Klauser
8da1b01e4c debug/pe: omit panic in (*File).ImportedSymbols on empty optional headers
If a PE file with invalid optional header size (neither
sizeofOptionalHeader32 nor sizeofOptionalHeader64) is passed to NewFile,
the File.OptionalHeader will be nil which leads to a panic in
(*File).ImportedSymbols().

Fixes #30250

Change-Id: Ie97306de4a0e2dcfdc7b1b599891f574aa63adca
Reviewed-on: https://go-review.googlesource.com/c/162858
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-02-27 08:10:00 +00:00
Filippo Valsorda
5a1c7b5841 crypto/tls: enable TLS 1.3 by default
Updates #30055

Change-Id: I3e79dd7592673c5d76568b0bcded6c391c3be6b3
Reviewed-on: https://go-review.googlesource.com/c/163081
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2019-02-27 07:54:19 +00:00
Filippo Valsorda
8834353072 Revert "crypto/tls: disable RSA-PSS in TLS 1.2"
In Go 1.13 we will enable RSA-PSS in TLS 1.2 at the same time as we make
TLS 1.3 enabled by default.

This reverts commit 7ccd3583ed.

Updates #30055

Change-Id: I6f2ddf7652d1172a6b29f4e335ff3a71a89974bc
Reviewed-on: https://go-review.googlesource.com/c/163080
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2019-02-27 07:54:00 +00:00
Josh Bleecher Snyder
f31305b71b cmd/asm: improve DATA size operand validation
Prior to this change, DATA instructions accepted
the values 1, 2, 4, and 8 as sizes.
The acceptable sizes were further restricted
to 4 and 8 for float constants.

This was both too restrictive and not restrictive enough:
string constants may reasonably have any length,
and address constants should really only accept pointer-length sizes.

Fixes #30269

Change-Id: I06e44ecdf5909eca7b19553861aec1fa39655c2b
Reviewed-on: https://go-review.googlesource.com/c/163747
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-27 05:52:20 +00:00
Ian Lance Taylor
4a91d55017 cmd/go: preserve more env vars for TestScript child processes
These are required when testing gccgo.

Change-Id: I6a81d7f4d48292c32a8b3b15ef44d859ab3aa26e
Reviewed-on: https://go-review.googlesource.com/c/163861
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-27 04:34:51 +00:00
Leon Klingele
ec521467e3 net: add missing error check in test
Change-Id: Id2e57bc8e18e062f60c6ac8a58dc15e049352088
GitHub-Last-Rev: 6d33b809cf
GitHub-Pull-Request: golang/go#30016
Reviewed-on: https://go-review.googlesource.com/c/160440
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
2019-02-27 02:41:04 +00:00
Mikio Hara
b9d19eff77 net: use EUI-48/EUI-64 reserved address blocks for documentation
Updates #15228.

Change-Id: I1b73defccb4c933d71c408aa31d32af9d1bc4ab8
Reviewed-on: https://go-review.googlesource.com/c/163357
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-02-27 02:36:14 +00:00
Rob Pike
9426d8c633 time: rewrite ExampleDuration_Nanoseconds to be more idiomatic.
Fix the punctuation and use the proper units for microseconds,
while explaining the incorrect but common variant 'us'.

Change-Id: I9e96694ef27ab4761efccd8616ac7b6700f60d39
Reviewed-on: https://go-review.googlesource.com/c/163917
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27 02:20:28 +00:00
Matthew Dempsky
6fa7669fd7 cmd/compile: unify duplicate const detection logic
Consistent logic for handling both duplicate map keys and case values,
and eliminates ad hoc value hashing code.

Also makes cmd/compile consistent with go/types's handling of
duplicate constants (see #28085), which is at least an improvement
over the status quo even if we settle on something different for the
spec.

As a side effect, this also suppresses cmd/compile's warnings about
duplicate nils in (non-interface expression) switch statements, which
was technically never allowed by the spec anyway.

Updates #28085.
Updates #28378.

Change-Id: I176a251e770c3c5bc11c2bf8d1d862db8f252a17
Reviewed-on: https://go-review.googlesource.com/c/152544
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-27 01:08:13 +00:00
Matthew Dempsky
e5fb1c6d7a cmd/compile/internal/ssa: fix bad CL rebase
CL 142497 renamed "statictmp_N" to ".stmp_N", but missed an instance
that was added by CL 151498 (submitted between the window that CL
142497 was reviewed/tested and later rebased/merged).

Change-Id: I597ee59dfa40821c7af2881b47e06f84a8140ec8
Reviewed-on: https://go-review.googlesource.com/c/163877
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27 00:13:19 +00:00
Brian Kessler
a73abca37b math/big: handle alias of cofactor inputs in GCD
If the variables passed in to the cofactor arguments of GCD (x, y)
aliased the input arguments (a, b), the previous implementation would
result in incorrect results for y.  This change reorganizes the calculation
so that the only case that need to be handled is when y aliases b, which
can be handled with a simple check.

Tests were added for all of the alias cases for input arguments and and
and irrelevant test case for a previous binary GCD calculation was dropped.

Fixes #30217

Change-Id: Ibe6137f09b3e1ae3c29e3c97aba85b67f33dc169
Reviewed-on: https://go-review.googlesource.com/c/162517
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27 00:11:17 +00:00
go101
572329ef7f go/ast: break out after first variable in ExampleCommentMap
The current ExampleCommentMap might panic if there are more satisfied
comments in the parsed program.

Change-Id: Ibe6943470aa0cfb450dae9fc07c1199acaabef73
GitHub-Last-Rev: c79e98c286
GitHub-Pull-Request: golang/go#28587
Reviewed-on: https://go-review.googlesource.com/c/147359
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-02-27 00:00:14 +00:00
Francesc Campoy
20930c7623 regexp: limit the capacity of slices of bytes returned by FindX
This change limits the capacity of the slices of bytes returned by:

- Find
- FindAll
- FindAllSubmatch

to be the same as their length.

Fixes #30169

Change-Id: I07b632757d2bfeab42fce0d42364e2a16c597360
Reviewed-on: https://go-review.googlesource.com/c/161877
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 23:51:17 +00:00
Ian Lance Taylor
98cbf45cfc go/types: add gccgo sizes information
This will need to be updated from time to time as new targets are
added to gccgo. But that is better than always returning nil.

Change-Id: I04b8c4d0f8efa38e2a148eb2e38b16b09f0351c3
Reviewed-on: https://go-review.googlesource.com/c/158844
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 23:43:42 +00:00
WhisperRain
7a9968f96f container/heap: avoid memory leak in example
Set element in slice to nil avoiding memory leak.

Change-Id: I9dbef9a0466407011e326725d3a0b681cd815389
GitHub-Last-Rev: 1bae5d3758
GitHub-Pull-Request: golang/go#30386
Reviewed-on: https://go-review.googlesource.com/c/163601
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 23:42:26 +00:00
Ian Lance Taylor
e609bd373f cmd/link: use SeekPC in testDWARF
This makes the tests slightly faster, though the bulk of the time is
still spent building the test programs.

Also run some tests in parallel.

Updates #26470

Change-Id: Ia5ec2b99831d69c426b43dbab80613aa03e705f5
Reviewed-on: https://go-review.googlesource.com/c/153258
Reviewed-by: Austin Clements <austin@google.com>
2019-02-26 23:41:29 +00:00
Ian Lance Taylor
b97e40fc30 net: remove unixgram test sockets
Updates https://gcc.gnu.org/PR89406

Change-Id: Iccf2760e42e9caa90720b96e74a805a9c0d48f35
Reviewed-on: https://go-review.googlesource.com/c/163277
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-02-26 23:33:36 +00:00
Ian Lance Taylor
4b05dc91b0 os: clarify that mode argument is only used if file is created
Fixes #30400

Change-Id: Icbd1dda29562afa80c8e37657133a6fe48070ac0
Reviewed-on: https://go-review.googlesource.com/c/163744
Reviewed-by: Rob Pike <r@golang.org>
2019-02-26 23:28:32 +00:00
Leon Klingele
dc0455225a net: explain why we ignore the first line of Plan 9 interface-status files
Change-Id: Ia0847790a597c35ebb572db6fc1b7534ecf8f006
GitHub-Last-Rev: 03f039d0ab
GitHub-Pull-Request: golang/go#30022
Reviewed-on: https://go-review.googlesource.com/c/160446
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:19:37 +00:00
Leon Klingele
97f81572c4 bytes: clean up a test
Change-Id: Iaa0e1721996b582bba9509c083755e1f125abb6b
GitHub-Last-Rev: c9b13ec0cd
GitHub-Pull-Request: golang/go#29996
Reviewed-on: https://go-review.googlesource.com/c/160420
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 23:16:46 +00:00
Ian Lance Taylor
068a832a7e time: read 64-bit data if available
Also store 64-bit data in lib/time/zoneinfo.zip.

The comments argue that we don't need the 64-bit data until 2037 or
2106, but that turns out not to be the case. We also need them for
dates before December 13, 1901, which is time.Unix(-0x80000000, 0).

Fixes #30099

Change-Id: Ib8c9efb29b7b3c08531ae69912c588209d6320e9
Reviewed-on: https://go-review.googlesource.com/c/161202
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:10:35 +00:00
Iskander Sharipov
c1050a8e54 cmd/compile: don't generate newobject call for 0-sized types
Emit &runtime.zerobase instead of a call to newobject for
allocations of zero sized objects in walk.go.

Fixes #29446

Change-Id: I11b67981d55009726a17c2e582c12ce0c258682e
Reviewed-on: https://go-review.googlesource.com/c/155840
Run-TryBot: Iskander Sharipov <quasilyte@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 23:08:15 +00:00
Bryan Heden
3a9037368e fmt: fix an error in documentation for fmt
Original Printf("%d", hi) obviously doesn't produce
%!d(string=hi) unless somewhere before this code
block you have hi := "hi" somewhere, also this change
maintains consistency with the rest of it

Change-Id: I40d8cca623176dcad66374ba74e3a1f8f975ac9e
GitHub-Last-Rev: 242e9ee6af
GitHub-Pull-Request: golang/go#30223
Reviewed-on: https://go-review.googlesource.com/c/162541
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:04:04 +00:00
Dmitry Mottl
b68624464d net/http: add godoc for Dir.Open function
This commit adds godoc for Dir.Open function.

Change-Id: Ibc3b22f38660a082802e1f868c5cf9d880fc2801
GitHub-Last-Rev: 774cfd7d8c
GitHub-Pull-Request: golang/go#30353
Reviewed-on: https://go-review.googlesource.com/c/163437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:03:32 +00:00
Ian Lance Taylor
c3c90d0132 test: add test case that caused a gccgo compiler crash
Change-Id: Icdc980e0dcb5639c49aba5f4f252f33bd207e4fa
Reviewed-on: https://go-review.googlesource.com/c/162617
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-02-26 23:02:54 +00:00
Jeremy Jay
b325799cad compress/gzip: clarify that Multistream gzip requires a ByteReader
Change-Id: Ib24778f3172c011e6a39ee65dce8764f3cc911ea
GitHub-Last-Rev: 9c617c1e60
GitHub-Pull-Request: golang/go#30284
Reviewed-on: https://go-review.googlesource.com/c/162999
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 23:02:40 +00:00
Leon Klingele
d090429ea9 all: fix typos as reported by 'misspell'
Change-Id: I904b8655f21743189814bccf24073b6fbb9fc56d
GitHub-Last-Rev: b032c14394
GitHub-Pull-Request: golang/go#29997
Reviewed-on: https://go-review.googlesource.com/c/160421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 23:02:05 +00:00
Derek Phan
337662f7ca io: align style of test comments in multi_test.go
Change-Id: Ic93a084311de46461ed3b30f4ac2fe11311e74d7
GitHub-Last-Rev: 32fbd63b10
GitHub-Pull-Request: golang/go#29705
Reviewed-on: https://go-review.googlesource.com/c/157642
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-02-26 23:01:20 +00:00
Alessandro Arzilli
08831b150c cmd/compile: avoid collisions between statictmps and user vars
Avoid name collisions between autogenerated statictmp variables and
user defined global variables.

Fixes #25113

Change-Id: I023eb42a5c2bd2f5352b046d33363faed87084dc
Reviewed-on: https://go-review.googlesource.com/c/142497
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 22:59:15 +00:00
Austin Clements
2cdebb5174 cmd/link: delete stale deadcode reference
Back when the linker did code generation after dead code elimination,
it had to know that references to runtime.read_tls_fallback could be
generated at code generation time (and never appear before that). Now
that code generation is done by the compiler, the references to
runtime.read_tls_fallback are obvious in the relocations, so the
linker no longer needs special knowledge of this symbol.

Change-Id: I9813a8478e85a6a13470b2d0528db53fd33fcfdf
Reviewed-on: https://go-review.googlesource.com/c/154601
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:58:39 +00:00
Marcel van Lohuizen
ef954a03eb bytes: hoist error creation out of function
generating frame information in errors will cause this
function to no longer be inlined.

Updates #29934.

Change-Id: I1d7bc11707f1872d7315f627bfb9a12afa41e358
Reviewed-on: https://go-review.googlesource.com/c/161760
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:57:25 +00:00
Tobias Klauser
c55eeeb718 runtime: use hw.ncpuonline sysctl in getncpu on openbsd
The number of CPUs reported by the hw.ncpu sysctl is twice as high as
the actual number of CPUs running on OpenBSD 6.4. with hyperthreading
disabled (hw.smt=0). Try hw.cpuonline first and fall back to hw.ncpu
in case it fails (which is the case on older OpenBSD before 6.4).

Fixes #30127

Change-Id: Id091234b8038cc9f7c40519d039fc1a05437c40d
Reviewed-on: https://go-review.googlesource.com/c/161757
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-02-26 22:56:59 +00:00
Ggicci
ea65d015b8 net/http: clean the path of the stripped URL by StripPrefix
The path of the new stripped URL should also be cleaned. Since an empty path
may cause unexpected errors in some HTTP handlers, e.g. http.ServeFile.

Fixes #30165

Change-Id: Ib44fdce6388b5d62ffbcab5266925ef8f13f26e2
Reviewed-on: https://go-review.googlesource.com/c/161738
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-26 22:55:59 +00:00
Yasser Abdolmaleki
5a7e8f466e crypto/tls: fix typo
Change-Id: If9332bae87449c94fc14710133614fcd84d2815c
Reviewed-on: https://go-review.googlesource.com/c/161726
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-02-26 22:54:37 +00:00
Tobias Klauser
38a4b37905 syscall: add empty line before marker comments in zsyscall_darwin_*.go
This was spotted during the review of the corresponding CL 154179 for
x/sys/unix. Let's change it in syscall as well to be consistent.

Change-Id: I33f25db1f6ba941b694c2aa276336448cc2b9b51
Reviewed-on: https://go-review.googlesource.com/c/154719
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 22:54:09 +00:00
Tooru Takahashi
8d057f3a0a cmd/internal/src: fix typo in pos.go
Change-Id: I31ac8845e72c3027c9a463b1f691f4d2b7913ec0
GitHub-Last-Rev: a6b185cc41
GitHub-Pull-Request: golang/go#29682
Reviewed-on: https://go-review.googlesource.com/c/157518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2019-02-26 22:53:21 +00:00
Keith Randall
f495f549ac cmd/compile: don't bother compiling functions named "_"
They can't be used, so we don't need code generated for them. We just
need to report errors in their bodies.

The compiler currently has a bunch of special cases sprinkled about
for "_" functions, because we never generate a linker symbol for them.
Instead, abort compilation earlier so we never reach any of that
special-case code.

Fixes #29870

Change-Id: I3530c9c353deabcf75ce9072c0b740e992349ee5
Reviewed-on: https://go-review.googlesource.com/c/158845
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26 20:56:24 +00:00
Keith Randall
933e34ac99 cmd/compile: treat slice pointers as non-nil
var a []int = ...
p := &a[0]
_ = *p

We don't need to nil check on the 3rd line. If the bounds check on the 2nd
line passes, we know p is non-nil.

We rely on the fact that any cap>0 slice has a non-nil pointer as its
pointer to the backing array. This is true for all safely-constructed slices,
and I don't see any reason why someone would violate this rule using unsafe.

R=go1.13

Fixes #30366

Change-Id: I3ed764fcb72cfe1fbf963d8c1a82e24e3b6dead7
Reviewed-on: https://go-review.googlesource.com/c/163740
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2019-02-26 20:44:52 +00:00
Keith Randall
57976fe2b4 cmd/compile: update comment about x86 nop instruction generator
The comment about losing the high bits is incorrect.  We now use these
nops in places where they really need to be a nop.  (Before inline
marks, we used them just before deferreturn calls, so they could
clobber any caller-saved values.)

Change-Id: I433d1ec455aa37dab8fef6eb7d407f3737dbb97f
Reviewed-on: https://go-review.googlesource.com/c/158057
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2019-02-26 20:41:14 +00:00
Alex Brainman
5cf4e442a5 runtime: fix syscall.NewCallback to return all bits for uintptr values
syscall.NewCallback mistakenly used MOVL even for windows/amd64,
which only returned the lower 32 bits regardless of the architecture.
This was due to a copy and paste after porting from windows/386.
The code now uses MOVQ, which will return all the available bits.

Also adjust TestReturnAfterStackGrowInCallback to ensure we never
regress.

Fixes #29331

Change-Id: I4f5c8021c33f234c2bb7baa9ef7a6b4870172509
Reviewed-on: https://go-review.googlesource.com/c/159579
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2019-02-26 20:22:39 +00:00
Josh Bleecher Snyder
c97e576576 html/template: use strings.Builder
...and size initial buffers more accurately.

Easy pickings only. More might remain.

name                             old time/op    new time/op    delta
CSSEscaper-8                       1.17µs ± 1%    0.80µs ± 2%  -31.55%  (p=0.000 n=44+48)
CSSEscaperNoSpecials-8              205ns ± 2%     204ns ± 3%   -0.73%  (p=0.014 n=46+49)
DecodeCSS-8                         438ns ± 2%     436ns ± 2%     ~     (p=0.099 n=48+47)
DecodeCSSNoSpecials-8              6.11ns ± 3%    5.93ns ± 3%   -2.85%  (p=0.000 n=50+48)
CSSValueFilter-8                    149ns ± 0%     145ns ± 0%   -2.68%  (p=0.000 n=32+35)
CSSValueFilterOk-8                  238ns ± 2%     234ns ± 2%   -1.40%  (p=0.000 n=49+47)
EscapedExecute-8                   2.53µs ± 2%    2.55µs ± 1%   +0.87%  (p=0.000 n=48+49)
HTMLNospaceEscaper-8               1.35µs ± 2%    0.92µs ± 1%  -31.74%  (p=0.000 n=48+48)
HTMLNospaceEscaperNoSpecials-8      278ns ± 2%     263ns ± 2%   -5.17%  (p=0.000 n=47+49)
StripTags-8                         778ns ± 2%     786ns ± 1%   +0.96%  (p=0.000 n=46+47)
StripTagsNoSpecials-8              84.2ns ± 1%    84.1ns ± 1%     ~     (p=0.300 n=48+48)
JSValEscaperWithNum-8               506ns ± 2%     486ns ± 3%   -3.82%  (p=0.000 n=47+45)
JSValEscaperWithStr-8              1.61µs ± 1%    1.64µs ± 1%   +1.75%  (p=0.000 n=44+49)
JSValEscaperWithStrNoSpecials-8     548ns ± 2%     552ns ± 2%   +0.78%  (p=0.000 n=48+46)
JSValEscaperWithObj-8              1.91µs ± 2%    1.87µs ± 1%   -2.08%  (p=0.000 n=49+47)
JSValEscaperWithObjNoSpecials-8     735ns ± 2%     742ns ± 2%   +1.01%  (p=0.000 n=47+49)
JSStrEscaperNoSpecials-8            228ns ± 4%     211ns ± 3%   -7.53%  (p=0.000 n=50+49)
JSStrEscaper-8                     1.11µs ± 1%    0.78µs ± 1%  -29.94%  (p=0.000 n=48+48)
JSRegexpEscaperNoSpecials-8         214ns ± 2%     212ns ± 3%   -1.12%  (p=0.000 n=50+49)
JSRegexpEscaper-8                  1.17µs ± 0%    0.79µs ± 1%  -31.92%  (p=0.000 n=48+47)
TemplateSpecialTags-8               172µs ± 1%     172µs ± 1%     ~     (p=0.976 n=48+47)
URLEscaper-8                       1.88µs ± 2%    1.87µs ± 2%   -0.56%  (p=0.001 n=49+49)
URLEscaperNoSpecials-8              162ns ± 1%     169ns ± 1%   +3.76%  (p=0.000 n=49+50)
URLNormalizer-8                    1.29µs ± 3%    1.29µs ± 2%   -0.37%  (p=0.041 n=48+48)
URLNormalizerNoSpecials-8           185ns ± 1%     186ns ± 1%   +0.15%  (p=0.013 n=49+49)
SrcsetFilter-8                      616ns ± 1%     618ns ± 1%   +0.36%  (p=0.000 n=46+46)
SrcsetFilterNoSpecials-8            359ns ± 0%     352ns ± 0%   -1.93%  (p=0.000 n=40+43)
[Geo mean]                          560ns          525ns        -6.17%

name                             old alloc/op   new alloc/op   delta
CSSEscaper-8                         672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8              0.00B          0.00B          ~     (all equal)
DecodeCSS-8                          160B ± 0%      160B ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8               0.00B          0.00B          ~     (all equal)
CSSValueFilter-8                    96.0B ± 0%     96.0B ± 0%     ~     (all equal)
CSSValueFilterOk-8                  48.0B ± 0%     48.0B ± 0%     ~     (all equal)
EscapedExecute-8                     688B ± 0%      624B ± 0%   -9.30%  (p=0.000 n=50+50)
HTMLNospaceEscaper-8                 752B ± 0%      368B ± 0%  -51.06%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8      48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=50+50)
StripTags-8                          224B ± 0%      224B ± 0%     ~     (all equal)
StripTagsNoSpecials-8                112B ± 0%      112B ± 0%     ~     (all equal)
JSValEscaperWithNum-8               96.0B ± 0%     40.0B ± 0%  -58.33%  (p=0.000 n=50+50)
JSValEscaperWithStr-8                384B ± 0%      384B ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8     96.0B ± 0%     96.0B ± 0%     ~     (all equal)
JSValEscaperWithObj-8                448B ± 0%      448B ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      160B ± 0%      160B ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8            0.00B          0.00B          ~     (all equal)
JSStrEscaper-8                       672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8         0.00B          0.00B          ~     (all equal)
JSRegexpEscaper-8                    672B ± 0%      336B ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8              48.0kB ± 0%    47.9kB ± 0%   -0.13%  (p=0.000 n=50+48)
URLEscaper-8                         336B ± 0%      336B ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               112B ± 0%      112B ± 0%     ~     (all equal)
URLNormalizer-8                      176B ± 0%      176B ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            112B ± 0%      112B ± 0%     ~     (all equal)
SrcsetFilter-8                       160B ± 0%      160B ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             160B ± 0%      160B ± 0%     ~     (all equal)
[Geo mean]                           259B           216B       -16.60%

name                             old allocs/op  new allocs/op  delta
CSSEscaper-8                         4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
CSSEscaperNoSpecials-8               0.00           0.00          ~     (all equal)
DecodeCSS-8                          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
DecodeCSSNoSpecials-8                0.00           0.00          ~     (all equal)
CSSValueFilter-8                     2.00 ± 0%      2.00 ± 0%     ~     (all equal)
CSSValueFilterOk-8                   3.00 ± 0%      3.00 ± 0%     ~     (all equal)
EscapedExecute-8                     18.0 ± 0%      18.0 ± 0%     ~     (all equal)
HTMLNospaceEscaper-8                 5.00 ± 0%      3.00 ± 0%  -40.00%  (p=0.000 n=50+50)
HTMLNospaceEscaperNoSpecials-8       1.00 ± 0%      1.00 ± 0%     ~     (all equal)
StripTags-8                          3.00 ± 0%      3.00 ± 0%     ~     (all equal)
StripTagsNoSpecials-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithNum-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithStr-8                2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithStrNoSpecials-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
JSValEscaperWithObj-8                3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSValEscaperWithObjNoSpecials-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
JSStrEscaperNoSpecials-8             0.00           0.00          ~     (all equal)
JSStrEscaper-8                       4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
JSRegexpEscaperNoSpecials-8          0.00           0.00          ~     (all equal)
JSRegexpEscaper-8                    4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=50+50)
TemplateSpecialTags-8                 185 ± 0%       185 ± 0%     ~     (all equal)
URLEscaper-8                         4.00 ± 0%      4.00 ± 0%     ~     (all equal)
URLEscaperNoSpecials-8               2.00 ± 0%      2.00 ± 0%     ~     (all equal)
URLNormalizer-8                      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
URLNormalizerNoSpecials-8            2.00 ± 0%      2.00 ± 0%     ~     (all equal)
SrcsetFilter-8                       3.00 ± 0%      3.00 ± 0%     ~     (all equal)
SrcsetFilterNoSpecials-8             3.00 ± 0%      3.00 ± 0%     ~     (all equal)
[Geo mean]                           3.41           3.05       -10.65%

Change-Id: I809ea56495ce1881656af7e24621448ab64b449a
Reviewed-on: https://go-review.googlesource.com/c/155919
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 20:12:09 +00:00
Josh Bleecher Snyder
c63dc6d459 cmd/compile: remove badgerbadgerbadger optimization
As discussed in #29242, this optimization is for a bash-ism.
No one writes Go code like this.

In this repo, it triggers only in test/fixedbugs/bug425.go
and that appears to be accidental.

Fixes #29242

Change-Id: I257e6ecc73f24680f7282c6ab28729de4e8b27af
Reviewed-on: https://go-review.googlesource.com/c/163728
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-26 20:11:48 +00:00