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

44991 Commits

Author SHA1 Message Date
mengxiaodong
846dce9d05 runtime: code cleanup about map
1.Revise ambiguous comments: "all current buckets" means buckets in hmap.buckets, actually current bucket and all the overflow buckets connected to it are full
2.All the pointer address add use src/runtime/stubs.go:add, keep the code style uniform

Change-Id: Idc7224dbe6c391e1b03bf5d009c3734bc75187ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/257979
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-30 19:59:48 +00:00
Jeremy Faller
e674b7703e [dev.link] cmd/link run generators in parallel
Small runtime win:

Stats for darwin, building cmd/compile:

Asmb                      20.7ms ±14%    18.3ms ±14%  -11.54%  (p=0.002 n=10+10)
TotalTime                  365ms ±10%     351ms ± 2%     ~     (p=0.211 n=10+9)

Change-Id: Ia8afdf6948111d59b0c89e52cb50557a10f33c40
Reviewed-on: https://go-review.googlesource.com/c/go/+/257964
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-09-30 19:34:13 +00:00
Emmanuel T Odeke
2f6e7f0ed1 src/go.mod, net/http: update bundled and latest golang.org/x/net
Updates x/net/http2 to git rev 5d4f7005572804eaf7f5ecdd2473a62557f733ba

    http2: send WINDOW_UPDATE on a body's write failure
    https://golang.org/cl/245158 (fixes #40423)

also updates the vendored version of golang.org/x/net as per

$ go get golang.org/x/net@5d4f700557
$ go mod tidy
$ go mod vendor
$ go generate -run bundle std

For #40423.

Change-Id: I3270d0fb6f28889266596f7365d36d30ef2bb368
Reviewed-on: https://go-review.googlesource.com/c/go/+/258359
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-30 18:47:07 +00:00
Bryan C. Mills
f811663f04 cmd/go: test more commands in mod_build_info_error
For #26909
For #41688

Change-Id: I22f28d426ce499fce6f0f1295dbde425998042aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/258219
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-09-30 18:07:33 +00:00
Bryan C. Mills
bb9b319228 cmd/go: add yet another test case for ambiguous arguments to 'go get'
For #37438

Change-Id: Ie40971ff677d36ddadbf9834bba2d366a0fc34d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/256922
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-09-30 18:07:21 +00:00
Roland Shoemaker
1eeaff75f9 crypto/x509: enforce SAN IA5String encoding restrictions
Extends the IA5String encoding restrictions that are currently applied
to name constraints to dNSName, rfc822Name, and
uniformResourceIdentifier elements of the SAN. The utility function
isIA5String is updated to use unicode.MaxASCII rather than utf8.RuneSelf
as it is somewhat more readable.

Certificates that include these badly encoded names do exist, but are
exceedingly rare. zlint and other linters enforce this encoding and
searching censys.io reveals only three currently trusted certificates
with this particular encoding issue.

Fixes #26362

Change-Id: I7a4f3e165a1754e5b4bfaeabc03e01eb7367f3c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/235078
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-09-30 17:51:05 +00:00
Bryan C. Mills
ae329abec0 cmd/go: add another test case for package/module ambiguity in 'go get'
For #37438

Change-Id: Iae00ef7f97144e85f4f710cdb3087c2548b4b8f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/256799
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-09-30 17:24:53 +00:00
Paschalis Tsilias
27280d8c14 crypto/x509: return errors instead of panicking
Eliminate a panic in x509.CreateCertificate when passing templates with unknown ExtKeyUsage; return an error instead.

Fixes #41169

Change-Id: Ia229d3b0d4a1bdeef05928439d97dab228687b3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/252557
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-30 16:05:36 +00:00
Ruixin Bao
54a112d719 crypto/ecdsa: use FillBytes on s390x
Originally, zeroExtendAndCopy is used to pad src with leading zeros and
copy the padded src into the destination. It is no longer needed after
CL 230397 introduced FillBytes. We can simply use that and remove the
zeroExtendAndCopy function. It is cleaner and reduces some allocation.

In addition, this patch tries to avoid calling hashToInt function in
both Sign and Verify function so some allocation is reduced.

Benchmarks:
name             old alloc/op   new alloc/op   delta
SignP256-8         1.60kB ± 0%    1.49kB ± 0%    -7.23%  (p=0.000 n=20+20)
SignP384-8         1.74kB ± 0%    1.59kB ± 0%    -8.50%  (p=0.000 n=20+18)
VerifyP256-8         176B ± 0%        0B       -100.00%  (p=0.000 n=20+20)
KeyGeneration-8      640B ± 0%      640B ± 0%      ~     (all equal)

name             old allocs/op  new allocs/op  delta
SignP256-8           22.0 ± 0%      17.0 ± 0%   -22.73%  (p=0.000 n=20+20)
SignP384-8           22.0 ± 0%      17.0 ± 0%   -22.73%  (p=0.000 n=20+20)
VerifyP256-8         7.00 ± 0%      0.00       -100.00%  (p=0.000 n=20+20)
KeyGeneration-8      13.0 ± 0%      13.0 ± 0%      ~     (all equal)

Change-Id: Ic4c95191eded55deb3420d97db501689f3b173c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/232297
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
2020-09-30 15:32:53 +00:00
Jay Conrod
8b0d00b164 cmd/go: error if -modfile used with 'go install pkg@version'
'go install pkg@version' runs without a main module or a module root
directory. The -modfile flag cannot be used to set the module root
directory or to substitute a different go.mod file.

This error won't be reported if -modfile is set in
GOFLAGS. Unsupported flags there are generally ignored.

For #40276

Change-Id: I0b39b1fa9184c15c6e863b647d43c328710920f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/258297
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-30 13:18:19 +00:00
Andrei Vagin
3caaaddffd runtime: don't crash if vsyscall and vdso are disabled on x86_64
If vdso is disabled, the goruntime calls gettimeofday from vsyscall,
but if vsyscall is disabled too, all golang binaries crash:

SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffffffffff600000} ---
killed by SIGSEGV (core dumped) ++

vsyscall doesn't work as it was designed for a long time due to security
reasons and now vsyscall is a little more expensive than real syscalls:
https://github.com/torvalds/linux/commit/5cec93c216db

This patch reworks the code to call syscalls if the vdso library isn't
available.

Change-Id: I16cbf3f49871bea91e26af1f49aa0ae2fbd3a01d
GitHub-Last-Rev: 1d133cd30a
GitHub-Pull-Request: golang/go#41681
Reviewed-on: https://go-review.googlesource.com/c/go/+/257982
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
2020-09-30 05:39:59 +00:00
Matthew Dempsky
0e85fd7561 cmd/compile: report type loop for invalid recursive types
Similar to how we report initialization loops in initorder.go and type
alias loops in typecheck.go, this CL updates align.go to warn about
invalid recursive types. The code is based on the loop code from
initorder.go, with minimal changes to adapt from detecting
variable/function initialization loops to detecting type declaration
loops.

Thanks to Cuong Manh Le for investigating this, helping come up with
test cases, and exploring solutions.

Fixes #41575
Updates #41669.

Change-Id: Idb2cb8c5e1d645e62900e178fcb50af33e1700a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/258177
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-09-29 22:49:58 +00:00
Roland Shoemaker
af9c5e5dbc crypto/x509: prioritize potential parents in chain building
When building a x509 chain the algorithm currently looks for parents
that have a subject key identifier (SKID) that matches the child
authority key identifier (AKID), if it is present, and returns all
matches. If the child doesn't have an AKID, or there are no parents
with matching SKID it will instead return all parents that have a
subject DN matching the child's issuer DN. Prioritizing AKID/SKID
matches over issuer/subject matches means that later in buildChains we
have to throw away any pairs where these DNs do not match. This also
prevents validation when a child has a SKID with two possible parents,
one with matching AKID but mismatching subject DN, and one with a
matching subject but missing AKID. In this case the former will be
chosen and the latter ignored, meaning a valid chain cannot be built.

This change alters how possible parents are chosen. Instead of doing a
two step search it instead only consults the CertPool.byName subject DN
map, avoiding issues where possible parents may be shadowed by parents
that have SKID but bad subject DNs. Additionally it orders the list of
possible parents by the likelihood that they are in fact a match. This
ordering follows this pattern:
* AKID and SKID match
* AKID present, SKID missing / AKID missing, SKID present
* AKID and SKID don't match

In an ideal world this should save a handful of cycles when there are
multiple possible matching parents by prioritizing parents that have
the highest likelihood. This does diverge from past behavior in that
it also means there are cases where _more_ parents will be considered
than in the past. Another version of this change could just retain the
past behavior, and only consider parents where both the subject and
issuer DNs match, and if both parent and child have SKID and AKID also
compare those, without any prioritization of the candidate parents.

This change removes an existing test case as it assumes that the
CertPool will return a possible candidate where the issuer/subject DNs
do not match.

Fixes #30079

Change-Id: I629f579cabb0b3d0c8cae5ad0429cc5a536b3e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/232993
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-09-29 19:02:47 +00:00
Tobias Klauser
567ef8bd8e runtime: correct arguments to pipe2 syscall in pipe on netbsd/arm64
Follow the implementation of pipe2 to pass arguments and handle return
values.

With this fix the runtime tests pass on netbsd/arm64 (tested using
gomote on the netbsd-arm64-bsiegert builder).

Update #30824

Change-Id: I346db68fc9dde8dc7f11351af05c1ad3105f4a32
Reviewed-on: https://go-review.googlesource.com/c/go/+/258000
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-29 19:01:28 +00:00
Cherry Zhang
66770f4b1d cmd/compile: mark type namedata symbols content-addressable
Type namedata symbols are for type/field/method names and package
paths. We can use content-addressable symbol mechanism for them.

Change-Id: I923fda17b7094c7a0e46aad7c450622eb3826294
Reviewed-on: https://go-review.googlesource.com/c/go/+/257960
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-09-29 17:25:24 +00:00
Cherry Zhang
39dde09126 cmd/link: retain only used interface methods
Currently, in the linker's deadcode pass, when an interface type
is live, the linker thinks all its methods are live, and uses
them to match methods on concrete types. The interface method may
never be used, though.

This CL changes it to only keep used interface methods, for
matching concrete type methods. To do that, when an interface
method is used, the compiler generates a mark relocation. The
linker uses the marker relocations to mark used interface
methods, and only the used ones.

binary size    before      after
cmd/compile   18887400   18812200
cmd/go        13470652   13470492

Change-Id: I3cfd9df4a53783330ba87735853f2a0ec3c42802
Reviewed-on: https://go-review.googlesource.com/c/go/+/256798
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-09-29 16:30:26 +00:00
Alberto Donizetti
39a426d356 cmd/compile: convert last amd64 rules to typed aux
Passes

  gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I196d3bdef4a4b650534a4ddd3053e65e0846fdcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/257898
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-09-29 16:12:04 +00:00
Cherry Zhang
0ab72ed020 cmd/link, runtime: use a sentinel value for unreachable method
In the method table, the method's code pointer is stored as an
offset from the start of the text section. Currently, for an
unreachable method, the offset is left as 0, which resolves to
the start of the text section at run time. It is possible that
there is valid code there. If an unreachable method is ever
reached (due to a compiler or linker bug), the execution will
jump to a wrong location but may continue to run for a while,
until it fails with a seemingly unrelated error.

This CL changes it to use -1 for unreachable method instead. At
run time this will resolve to an invalid address, which makes it
fail immediately if it is ever reached.

Change-Id: Ied6ed7f1833c4f3b991fdf55d8810d70d307b2e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/257203
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-29 15:20:13 +00:00
Cherry Zhang
0163bdae68 crypto/tls: fix TestLinkerGC test
A test that checks if "tls.(*Conn)" appears in any symbol's name.
tls.Conn is a type, so the string "tls.(*Conn)" can only appear
in the name of a method of Conn. But the test code doesn't use
any of the methods. Not sure why this needs to be live. In
particular, the linker is now able to prune all methods of Conn.
Remove this requirement. In fact, just drop the only_conn test
case, as simply allocating a type doesn't necessarily bring
anything live.

Change-Id: I754291b75d38e1465b5291b4dea20806615d21b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/257973
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-09-29 14:36:12 +00:00
Daniel Martí
815a5e29f4 cmd/go: fix doc math for build cache hashing
The function takes five 24-bit chunks from the hash, resulting in 120
bits. When base-64 encoded, this results in a 20-byte output string,
which is confirmed by "var dst [chunks * 4]byte".

It seems like the documented math could have been written for a previous
implementation with shorter hashes, using 4 chunks instead of 5, as then
the math checks out.

Since this code has been working correctly for over three years, let's
fix the documentation to reflect the code.

Change-Id: I9e908e6bafb5dcc1e3c23915e2b6c8843ed444d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/257646
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-29 10:52:55 +00:00
KimMachineGun
a28edbfca2 encoding/asn1: error instead of panic on invalid value to Unmarshal
Changes Unmarshal to return an error, instead of
panicking when its value is nil or not a pointer.

This change matches the behavior of other encoding
packages like json.

Fixes #41509.

Change-Id: I92c3af3a960144566e4c2b55d00c3a6fe477c8d5
GitHub-Last-Rev: c668b6e4ad
GitHub-Pull-Request: golang/go#41485
Reviewed-on: https://go-review.googlesource.com/c/go/+/255881
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-29 10:31:59 +00:00
Chen.Zhidong
79e681d2a2 crypto/tls: make config.Clone return nil if the source is nil
Fixes #40565

Change-Id: I13a67be193f8cd68df02b8729529e627a73d364b
GitHub-Last-Rev: b03d2c04fd
GitHub-Pull-Request: golang/go#40566
Reviewed-on: https://go-review.googlesource.com/c/go/+/246637
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-29 09:32:59 +00:00
Alberto Donizetti
9a7a981ab7 cmd/compile: convert more amd64 rules to typed aux
Passes

  gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I2927283e444e7075e155cf29680553b92d471667
Reviewed-on: https://go-review.googlesource.com/c/go/+/257897
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-29 08:21:48 +00:00
Tobias Klauser
6fc094ceaf crypto/x509: define certDirectories per GOOS
Split the list of CA certificate directory locations in root_unix.go by
GOOS (aix, *bsd, js, linux, solaris).

On solaris, also include /etc/certs/CA as documented here:
https://docs.oracle.com/cd/E37838_01/html/E61024/kmf-cacerts.html

Same as CL 2208 did for certFiles.

Change-Id: Id24822d6a674bbbbf4088ebb8fe8437edad232b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/248762
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-09-29 06:10:34 +00:00
Tobias Klauser
15c8925df0 cmd/go/internal/lockedfile/internal/filelock: remove stale TODO comment
This was addressed by CL 255258.

Updates #35618

Change-Id: I8dd5b30a846f2d16a3d4752304861d7d2178d1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/257940
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-09-29 06:10:12 +00:00
Tobias Klauser
1f4d035178 runtime: initialise cpu.HWCap on netbsd/arm64
NetBSD does not supply AT_HWCAP, however we still need to initialise
cpu.HWCaps.  For now specify the bare minimum until we add some form of
capabilities detection. See
https://golang.org/issue/30824#issuecomment-494901591

Follows CL 174129 which did the same for openbsd/arm64.

Updates #30824

Change-Id: I43a86b583bc60d259a66772703de06970124bb7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/257998
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-28 22:28:06 +00:00
Cherry Zhang
af18bce87c cmd/link: consider interface conversions only in reachable code
The linker prunes methods that are not directly reachable if the
receiver type is never converted to interface. Currently, this
"never" is too strong: it is invalidated even if the interface
conversion is in an unreachable function. This CL improves it by
only considering interface conversions in reachable code. To do
that, we introduce a marker relocation R_USEIFACE, which marks
the target symbol as UsedInIface if the source symbol is reached.

binary size    before      after
cmd/compile   18897528   18887400
cmd/go        13607372   13470652

Change-Id: I66c6b69eeff9ae02d84d2e6f2bc7f1b29dd53910
Reviewed-on: https://go-review.googlesource.com/c/go/+/256797
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-28 21:30:01 +00:00
Matthew Dempsky
ad0ab812f8 cmd/compile: fix type checking of "make" arguments
As part of type checking make's arguments, we were converting untyped
float and complex constant arguments to integers. However, we were
doing this without concern for whether the argument was a declared
constant. Thus a call like "make([]T, n)" could change n from an
untyped float or untyped complex to an untyped integer.

The fix here is to simply change checkmake to not call SetVal, which
will be handled by defaultlit anyway. However, we also need to
properly return the defaultlit result value to the caller, so
checkmake's *Node parameter is also changed to **Node.

Fixes #41680.

Change-Id: I858927a052f384ec38684570d37b10a6906961f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/257966
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-28 20:54:13 +00:00
Emmanuel T Odeke
c4971a14a7 testing: add benchmark for TB.Helper
Adds a benchmark for TB.Helper, to use as a judge of future
improvements like CL 231717.

Change-Id: I17c40d482fc12caa3eb2c1cda39fd8c42356b422
Reviewed-on: https://go-review.googlesource.com/c/go/+/257317
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-28 20:51:39 +00:00
Roland Shoemaker
f33263d11a crypto/x509: hardcode RSA PSS parameters rather than generating them
Rather than generating the three possible RSA PSS parameters each time
they are needed just hardcode them and pick the required one based on
the hash function.

Fixes #41407

Change-Id: Id43bdaf40b3ca82c4c04c6588e3b643f63107657
Reviewed-on: https://go-review.googlesource.com/c/go/+/258037
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-09-28 18:46:39 +00:00
Lynn Boger
a424f6e45e cmd/asm,cmd/compile,cmd/internal/obj/ppc64: add extswsli support on power9
This adds support for the extswsli instruction which combines
extsw followed by a shift.

New benchmark demonstrates the improvement:
name      old time/op  new time/op  delta
ExtShift  1.34µs ± 0%  1.30µs ± 0%  -3.15%  (p=0.057 n=4+3)

Change-Id: I21b410676fdf15d20e0cbbaa75d7c6dcd3bbb7b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/257017
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@gmail.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-09-28 18:13:48 +00:00
avivklas
874b3132a8 mime/multipart: return overflow errors in Reader.ReadForm
Updates Reader.ReadForm to check for overflow errors that may
result from a leeway addition of 10MiB to the input argument
maxMemory.

Fixes #40430

Change-Id: I510b8966c95c51d04695ba9d08fcfe005fd11a5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/247477
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-28 08:59:02 +00:00
Changkun Ou
05b626e490 os: fix SyscallConn typos in the File.Fd comments
This CL fixes two typos introduced in CL 256899.

Change-Id: I47f0a3097deeeec8d6e9bbe7073fcf7a28c5dff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/257997
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-28 08:16:57 +00:00
Alberto Donizetti
e572218d12 cmd/compile: fix escape reason for MAKESLICE with no cap
When explaining why the slice from a make() call escapes for the -m -m
message, we print "non-const size" if any one of Isconst(n.Left) and
Isconst(n.Right) return false; but for OMAKESLICE nodes with no cap,
n.Right is nil, so Isconst(n.Right, CTINT) will be always false.

Only call Isconst on n.Right if it's not nil.

Fixes #41635

Change-Id: I8729801a9b234b68ae40adad64d66fa7653adf09
Reviewed-on: https://go-review.googlesource.com/c/go/+/257641
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-09-28 06:38:58 +00:00
Tobias Klauser
5755bad42a os: remove ENOTSUP special case in Getwd on darwin
ENOTSUP was used as a signaling error in the custom implementation of
syscall.Getwd to fall back to the slow algorithm. Since CL 257637 Getwd
directly calls the respective function from libSystem.dylib which can no
longer return ENOTSUP.

Change-Id: I8e65e42b3ea069bf78969a29f2af1c55552e2949
Reviewed-on: https://go-review.googlesource.com/c/go/+/257644
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-28 06:28:02 +00:00
Benny Siegert
8ab020adb2 runtime: netbsd-arm64 fixes
Add missing declaration of crosscall1.

Fix stack alignment for pipe2 return value.

Work around kernel clobbering of r28 on aarch64 by reloading from ucontext.
https://nxr.netbsd.org/xref/src/sys/arch/aarch64/aarch64/sig_machdep.c#104

Update #30824

Change-Id: I7f9472939f4c02953f8c207308610118f5d3c54c
Reviewed-on: https://go-review.googlesource.com/c/go/+/257645
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>
2020-09-28 06:01:37 +00:00
Ainar Garipov
72a9dec156 doc/go1.16: document net.ErrClosed usage in crypto/tls
Change-Id: I130cf79b93c6456dbe87f0042209e204c4e319b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/257457
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-27 06:23:18 +00:00
Changkun Ou
7bb6fed9b5 os: document and emphasize a potential misuse of File.Fd
This CL revises the document of File.Fd that explicitly points
its user to runtime.SetFinalizer where contains the information
that a file descriptor could be closed in a finalizer and therefore
causes a failure in syscall.Write if runtime.KeepAlive is not invoked.

The CL also suggests an alternative of File.Fd towards File.SyscallConn.

Fixes #41505

Change-Id: I6816f0157add48b649bf1fb793cf19dcea6894b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/256899
Reviewed-by: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2020-09-27 02:23:55 +00:00
David Chase
6f02578f9c cmd/compile: fix logopt log directory naming for windows
Allow Windows absolute paths, also fixed URI decoding on Windows.
Added a test, reorganized to make the test cleaner.
Also put some doc comments on exported functions that did not have them.

Fixes #41614.

Change-Id: I2871be0e5183fbd53ffb309896d6fe56c15a7727
Reviewed-on: https://go-review.googlesource.com/c/go/+/257677
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-26 22:01:34 +00:00
Tobias Klauser
ad618689ef cmd/dist: detect gohostarch on netbsd/arm64 hosts
On netbsd/arm64 `uname -m` reports `evbarm` which is mapped to
gohostarch=arm. Fix this by checking for "aarch64" in `uname -p` output
to fix self-hosted build on netbsd/arm64.

Updates #30824

Change-Id: I0f0450ff35af0bec51aeec3b210143ba892216c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/257643
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2020-09-26 18:06:37 +00:00
Constantin Konstantinidis
f5c3eda4c9 cmd/compile: enforce strongly typed rules for ARM (mergesym)
Replace mergeSym by mergeSymTyped.
L435-L459

toolstash-check successful.

Change-Id: Icbefe5c3589ed4ecdbca3dff9b3a758bdba3b34b
Reviewed-on: https://go-review.googlesource.com/c/go/+/257642
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-09-26 16:04:46 +00:00
Alberto Donizetti
66fbb80b72 cmd/compile: more amd64 typed rules
Passes

  gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I2621f9ab48199204cf6116941b19b6df4170d0e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/256497
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-26 15:48:06 +00:00
Tobias Klauser
7d3fd4f3c4 syscall: implement Getwd using getcwd from libSystem on darwin
Directly wrap the getcwd implementation provided by libSystem.dylib on
darwin and use it to implement Getwd like on the BSDs. This allows to
drop the custom implementation using getAttrList and to merge the
implementation of Getwd for darwin and the BSDs in syscall_bsd.go.

Same as CL 257497 did for golang.org/x/sys/unix

Change-Id: If30390c4c17cd463bb8fdcb5465f40d6fa11f391
Reviewed-on: https://go-review.googlesource.com/c/go/+/257637
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-26 10:09:33 +00:00
Tobias Klauser
dbb1c5bf74 syscall: remove mksysnum_darwin.pl script
Direct syscalls using syscall numbers are no longer supported on darwin
since Go 1.12, see https://golang.org/doc/go1.12#darwin. Also,
/usr/include/sys/syscall.h is no longer available on recent macOS
versions, so remove the generating script.

Change-Id: I8e2579c3d0e94a61fc041d06280149ec6ccf13e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/257638
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-26 10:08:43 +00:00
Carlos Alexandro Becker
8266570ba7 encoding/json: added docs to UnsupportedValueError
Added godoc to UnsupportedValueError.

Change-Id: I5fc13bac0b6e14b3a6eba27c9d3331ff5c5269aa
GitHub-Last-Rev: 516cd7a929
GitHub-Pull-Request: golang/go#41364
Reviewed-on: https://go-review.googlesource.com/c/go/+/254540
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
2020-09-25 19:10:05 +00:00
Cherry Zhang
74c3b508ec vendor, cmd/vendor: update vendored x/sys and x/net
Pick up GOOS=ios changes.

This is done by

cd $GOROOT/src
go get -d golang.org/x/net@latest
go mod tidy
go mod vendor
go get -d golang.org/x/sys@latest
go mod tidy
go mod vendor
cd $GOROOT/src/cmd
go get -d golang.org/x/sys@latest
go mod tidy
go mod vendor

Updates #38485.

Change-Id: Ic2b54febb1f851814c9d76c4b55a8837ac4779f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/257618
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-25 18:07:42 +00:00
Michael Pratt
989ab8a7d6 runtime: drop nosplit from primary lockrank functions
acquireLockRank and releaseLockRank are called from nosplit context, and
thus must be nosplit.

lockWithRank, unlockWithRank, and lockWithRankMayAcquire are called from
spittable context, and thus don't strictly need to be nosplit.

The stated reasoning for making these functions nosplit is to avoid
re-entrant calls due to a stack split on function entry taking a lock.
There are two potential issues at play here:

1. A stack split on function entry adds a new lock ordering edge before
   we (a) take lock l, or (b) release lock l.

2. A stack split in a child call (such as to lock2) introduces a new
   lock ordering edge _in the wrong order_ because e.g., in the case of
   lockWithRank, we've noted that l is taken, but the stack split in
   lock2 actually takes stack split locks _before_ l is actually locked.

(1) is indeed avoided by marking these functions nosplit, but this is
really just a bit of duct tape that generally has no effect overall. Any
earlier call can have a stack split and introduce the same new edge.
This includes lock/unlock which are not nosplit!

I began this CL as a change to extend nosplit to lock and unlock to try
to make this mitigation more effective, but I've realized that as long
as there is a _single_ nosplit call between a lock and unlock, we can
end up with the edge. There seems to be few enough cases without any
calls that is does not seem worth the extra cognitive load to extend
nosplit throughout all of the locking functions.

(2) is a real issue which would cause incorrect ordering, but it is
already handled by switching to the system stack before recording the
lock ordering. Adding / removing nosplit has no effect on this issue.

Change-Id: I94fbd21b2bf928dbf1bf71aabb6788fc0a012829
Reviewed-on: https://go-review.googlesource.com/c/go/+/254367
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Michael Pratt <mpratt@google.com>
2020-09-25 15:57:32 +00:00
Austin Clements
2e0f8c379f runtime: update go:notinheap documentation
The rules for go:notinheap were recently tweaked to disallow stack
allocation (CL 249917). This CL updates the documentation about
go:notinheap in runtime/HACKING.md.

Change-Id: Ibca5d9b9d02e1c22c6af1d303aa84c6303a86d92
Reviewed-on: https://go-review.googlesource.com/c/go/+/257357
Trust: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-25 15:35:59 +00:00
Keith Randall
2333c6299f runtime: use old capacity to decide on append growth regime
We grow the backing store on append by 2x for small sizes and 1.25x
for large sizes. The threshold we use for picking the growth factor
used to depend on the old length, not the old capacity. That's kind of
unfortunate, because then doing append(s, 0, 0) and append(append(s,
0), 0) do different things. (If s has one more spot available, then
the former expression chooses its growth based on len(s) and the
latter on len(s)+1.)  If we instead use the old capacity, we get more
consistent behavior. (Both expressions use len(s)+1 == cap(s) to
decide.)

Fixes #41239

Change-Id: I40686471d256edd72ec92aef973a89b52e235d4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/257338
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-09-25 03:59:54 +00:00
fanzha02
fa04d488bd cmd/asm: fix the issue of moving 128-bit integers to vector registers on arm64
The CL 249758 added `FMOVQ $vcon, Vd` instruction and assembler used
128-bit simd literal-loading to load `$vcon` from pool into 128-bit vector
register `Vd`. Because Go does not have 128-bit integers for now, the
assembler will report an error of `immediate out of range` when
assembleing `FMOVQ $0x123456789abcdef0123456789abcdef, V0` instruction.

This patch lets 128-bit integers take two 64-bit operands, for the high
and low parts separately and adds `VMOVQ $hi, $lo, Vd` instruction to
move `$hi<<64+$lo' into 128-bit register `Vd`.

In addition, this patch renames `FMOVQ/FMOVD/FMOVS` ops to 'VMOVQ/VMOVD/VMOVS'
and uses them to move 128-bit, 64-bit and 32-bit constants into vector
registers, respectively

Update the go doc.

Fixes #40725

Change-Id: Ia3c83bb6463f104d2bee960905053a97299e0a3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/255900
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-25 01:47:40 +00:00