1
0
mirror of https://github.com/golang/go synced 2024-11-18 05:04:47 -07:00
Commit Graph

50244 Commits

Author SHA1 Message Date
Michael Anthony Knyszek
d419a80bc7 runtime: retype mheap.pagesInUse as atomic.Uint64
[git-generate]
cd src/runtime
mv export_test.go export.go
GOROOT=$(dirname $(dirname $PWD)) rf '
  add mheap.pagesInUse \
// Proportional sweep \
// \
// These parameters represent a linear function from gcController.heapLive \
// to page sweep count. The proportional sweep system works to \
// stay in the black by keeping the current page sweep count \
// above this line at the current gcController.heapLive. \
// \
// The line has slope sweepPagesPerByte and passes through a \
// basis point at (sweepHeapLiveBasis, pagesSweptBasis). At \
// any given time, the system is at (gcController.heapLive, \
// pagesSwept) in this space. \
// \
// It is important that the line pass through a point we \
// control rather than simply starting at a 0,0 origin \
// because that lets us adjust sweep pacing at any time while \
// accounting for current progress. If we could only adjust \
// the slope, it would create a discontinuity in debt if any \
// progress has already been made. \
pagesInUse_ atomic.Uint64 // pages of spans in stats mSpanInUse
  ex {
    import "runtime/internal/atomic"

    var t mheap
    var v, w uint64
    var d int64

    t.pagesInUse -> t.pagesInUse_.Load()
    t.pagesInUse = v -> t.pagesInUse_.Store(v)
    atomic.Load64(&t.pagesInUse) -> t.pagesInUse_.Load()
    atomic.LoadAcq64(&t.pagesInUse) -> t.pagesInUse_.LoadAcquire()
    atomic.Store64(&t.pagesInUse, v) -> t.pagesInUse_.Store(v)
    atomic.StoreRel64(&t.pagesInUse, v) -> t.pagesInUse_.StoreRelease(v)
    atomic.Cas64(&t.pagesInUse, v, w) -> t.pagesInUse_.CompareAndSwap(v, w)
    atomic.Xchg64(&t.pagesInUse, v) -> t.pagesInUse_.Swap(v)
    atomic.Xadd64(&t.pagesInUse, d) -> t.pagesInUse_.Add(d)
  }
  rm mheap.pagesInUse
  mv mheap.pagesInUse_ mheap.pagesInUse
'
mv export.go export_test.go

Change-Id: I495d188683dba0778518563c46755b5ad43be298
Reviewed-on: https://go-review.googlesource.com/c/go/+/356549
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-10-20 20:39:19 +00:00
Michael Anthony Knyszek
75b73d68b3 runtime: use atomic.Float64 for assist ratio
Change-Id: Ie7f09a7c9545ef9dd1860b1e332c4edbcbf8165e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356170
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-10-20 20:38:59 +00:00
Michael Anthony Knyszek
3ec8d4b5ed runtime/internal/atomic: add atomic types for all functions
Change-Id: I74f365316484feb819c31c77fbffd78fadfe32a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/356169
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-10-20 20:38:47 +00:00
Robert Griesemer
3ff39c5eda cmd/compile/internal/types2: use correct types when checking generic conversions
Iterate through the actual, possibly defined types of constraints
when type-checking generic conversions, not the underlying types.

For #47150.

Change-Id: Ia7af313bf46d6f6b0ad5292ff793b030b8e2d3d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/357333
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-20 19:30:13 +00:00
Robert Findley
4320949f36 go/internal/gcimporter: avoid setting unnecessary lines in fakeFileSet
This is a clean port of CL 357291 from x/tools.

For #46586

Change-Id: Ib22087ae7fe8477d368acd230b263b83cdad4d36
Reviewed-on: https://go-review.googlesource.com/c/go/+/357429
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-20 19:29:12 +00:00
Cuong Manh Le
4e565f7372 cmd/compile: fix crawling of embeddable types during inline
In CL 327872, there's a fix for crawling of embeddable types directly
reached by the user, so all of its methods need to be re-exported. But
we missed the cased when an un-exported type may be reachable by
embedding in exported type. Example:

	type t struct {}
	func (t) M() {}

	func F() interface{} { return struct{ t }{} }

We generate the wrapper for "struct{ t }".M, and when inlining call to
"struct{ t }".M makes "t.M" reachable.

It works well, and only be revealed in CL 327871, when we changed
methodWrapper to always call inline.InlineCalls, thus causes the crash
in #49016, which involve dot type in inlined function.

Fixes #49016

Change-Id: If174fa5575132da5cf60e4bd052f7011c4e76c5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356254
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-10-20 17:26:58 +00:00
Than McIntosh
27a1454ee0 cmd/internal/goobj: minor dead code cleanup
Remove a bit of dead code from the Go object file reader (io.ReaderAt
no longer needed in goobj.Reader).

Change-Id: I04150d37fb90b59c9dbe930878d4dd21cdcd7ca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/357309
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-20 15:03:54 +00:00
andig
d2ec73c1bf math/big: remove stray whitespace in addMulVVW on amd64
Minor leftover from CL 74851.

Change-Id: I1b56afcde3c505ba77a0f79e8ae9b01000362298
GitHub-Last-Rev: 87e97571a5
GitHub-Pull-Request: golang/go#48942
Reviewed-on: https://go-review.googlesource.com/c/go/+/355629
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-20 07:49:28 +00:00
Alexander Yastrebov
d9421cec00 net/http/internal: return unexpected EOF on incomplete chunk read
Fixes #48861

Change-Id: I3f55bfbdc4f2cf5b33d1ab2d76e01335bb497c6f
GitHub-Last-Rev: 0ecd790b87
GitHub-Pull-Request: golang/go#48903
Reviewed-on: https://go-review.googlesource.com/c/go/+/355029
Trust: Damien Neil <dneil@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-10-20 07:21:22 +00:00
Cuong Manh Le
b091189762 cmd/compile/internal/types2: print assignment operation for invalid operation errors
When invoking check.binary for assignment operation, the expression will
be nil, thus for printing the assignment operation error message, we
need to reconstruct the statement from lhs, op, rhs.

Fixes #48472

Change-Id: Ie38c3dd8069b47e508968d6e43cedcf7536559ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/357229
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-20 05:28:45 +00:00
Robert Griesemer
4cc6a91907 cmd/compile/internal/types2: implement generic conversions
Fixes #47150.

Change-Id: I7531ca5917d4e52ca0b9211d6f2114495b19ba09
Reviewed-on: https://go-review.googlesource.com/c/go/+/356010
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-20 00:05:22 +00:00
Keith Randall
2be5b84665 cmd/compile: allow importing and exporting of ODYNAMICTYPE
Change-Id: I2fca7a801c85ed93c002c23bfcb0cf9593f1bdf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/356571
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-10-19 22:47:48 +00:00
Keith Randall
9fa85518ff cmd/compile: substitute "". prefix with package in more import locations
The "" stand-in for the current package needs to be substituted
in more places when importing, because of generics.

""..dict.conv4["".MyString]

when imported in main and then exported, this becomes

a..dict.conv4["".MyString]

and then the linker makes that into

a..dict.conv4[main.MyString]

Which isn't correct. We need to replace on import not just
function names, but also globals, which this CL does.

Change-Id: Ia04a23b5ffd60aeeaba72c807f69261105670f8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356570
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-10-19 22:47:35 +00:00
Robert Griesemer
1b24c9e42e go/types, types2: always accept type parameters when running Manual test
This makes it easier to run tests on existing generic code that is
not using the `.go2` ending currently used by type checker tests.

For #49074.

Change-Id: I1501463c55dbe1d709918786e1a43b6d1bf1629a
Reviewed-on: https://go-review.googlesource.com/c/go/+/357050
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 21:05:11 +00:00
Cuong Manh Le
07e5527249 reflect: fix methodValueCall code pointer mismatch in Value.Pointer
This is the port of CL 356809 for Value.Pointer to fix the mismatch of
methodValueCall code pointer.

Change-Id: I080ac41b94b44d878cd5896207a76a28c57fd48b
Reviewed-on: https://go-review.googlesource.com/c/go/+/356950
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-19 18:56:08 +00:00
Cuong Manh Le
d7149e502d reflect: restore Value.Pointer implementation
CL 350691 added Value.UnsafePointer and make Value.Pointer call it
internally. It has a downside that Value.Pointer can now eligible to be
inlined, thus making un-intentional side effect, like the test in
fixedbugs/issue15329.go becomes flaky.

This CL restore Value.Pointer original implementation, pre CL 350691,
with the deprecation TODO removed.

Fixes #49067

Change-Id: I735af182f8e729294333ca906ffc062f477cfc99
Reviewed-on: https://go-review.googlesource.com/c/go/+/356949
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-19 18:55:51 +00:00
Michael Matloob
d94498470b cmd/go: add GOWORK to go env command
GOWORK will be set to the go.work file's path, if in workspace mode
or will be empty otherwise.

For #45713
Fixes #48589

Change-Id: I163ffaf274e0a41469c1f3b8514d6f90e20423b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/355689
Trust: Michael Matloob <matloob@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-19 18:43:12 +00:00
Michael Matloob
1d63052782 cmd/go: support replaces in the go.work file
Add support for replace directives in the go.work file. If there are
conflicting replaces in go.mod files, suggest that users add an
overriding replace in the go.work file.

Add HighestReplaced to MainModules so that it accounts for the
replacements in the go.work file.

(Reviewers: I'm not totally sure that HighestReplace is computed
correctly. Could you take a closer look at that?)

For #45713

Change-Id: I1d789219ca1dd065ba009ce5d38db9a1fc38ba83
Reviewed-on: https://go-review.googlesource.com/c/go/+/352812
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-19 18:43:08 +00:00
Matt T. Proud
7999fd4710 errors: mention Is methods should not call Unwrap
errors.Is internally unwraps the error until the error matches the
target. Because of this, a user-authored Is method on an error type
need not call errors.Unwrap on itself or the target, because that would
make the unwrapping operation O(N^2). It is a subtle detail to remind
authors for resource efficiency reasons.

Change-Id: Ic1ba59a5bdbfe2c7cb51a2cba2537ab6de4a13ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/356789
Reviewed-by: Jean de Klerk <deklerk@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Jean de Klerk <deklerk@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Jean de Klerk <deklerk@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 18:42:57 +00:00
Archana R
6c3cd5d2eb internal/bytealg: port bytes.Index and bytes.Count to reg ABI on ppc64x
This change adds support for the reg ABI to the Index and Count
functions for ppc64/ppc64le.

Most Index and Count benchmarks show improvement in performance on
POWER9 with this change. Similar numbers observed on POWER8 and POWER10.

name                             old time/op    new time/op    delta
Index/32                         71.0ns ± 0%    67.9ns ± 0%   -4.42% (p=0.001 n=7+6)
IndexEasy/10                     17.5ns ± 0%    17.2ns ± 0%   -1.30% (p=0.001 n=7+7)

name             old time/op    new time/op    delta
Count/10           26.6ns ± 0%    25.0ns ± 1%   -6.02%  (p=0.001 n=7+7)
Count/32           78.6ns ± 0%    74.7ns ± 0%   -4.97%  (p=0.001 n=7+7)
Count/4K           5.03µs ± 0%    5.03µs ± 0%   -0.07%  (p=0.000 n=6+7)
CountEasy/10       26.9ns ± 0%    25.2ns ± 1%   -6.31%  (p=0.001 n=7+7)
CountSingle/32     11.8ns ± 0%     9.9ns ± 0%  -15.70%  (p=0.002 n=6+6)

Change-Id: Ibd146c04f8107291c55f9e6100b8264dfccc41ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/355509
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 18:22:59 +00:00
Carlo Alberto Ferraris
ad7db1f90f sync: avoid a dynamic check in WaitGroup on 64-bit architectures
uint64 is guaranteed by the compiler to be aligned on 64-bit archs.
By using uint64+uint32 instead of [3]uint32 we can make use of the
guaranteed alignment to avoid the run-time alignment check.

On linux/amd64:

name                     old time/op    new time/op    delta
WaitGroupUncontended-4     8.84ns ± 3%    7.62ns ± 4%  -13.72%  (p=0.000 n=17+18)
WaitGroupAddDone-4         66.8ns ± 3%    45.9ns ± 2%  -31.31%  (p=0.000 n=20+18)
WaitGroupAddDoneWork-4     79.2ns ± 1%    56.6ns ± 1%  -28.54%  (p=0.000 n=17+20)
WaitGroupWait-4            2.83ns ± 2%    2.58ns ± 2%   -9.05%  (p=0.000 n=18+20)
WaitGroupWaitWork-4        16.8ns ± 6%    16.5ns ± 6%     ~     (p=0.072 n=20+18)
WaitGroupActuallyWait-4     263ns ± 2%     261ns ± 5%     ~     (p=0.063 n=18+20)

Change-Id: I314340f2ed8a47d8b9c15f8a3b07e41f252f4831
Reviewed-on: https://go-review.googlesource.com/c/go/+/189837
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 18:21:38 +00:00
Katie Hockman
982060203c testing: don't allow f.Log/Logf or f.Skipped inside f.Fuzz
This change also does some refactors around how
we prevent many (*F) methods from being called
inside (*F).Fuzz. Previously, there was a lot of
comment/code duplication, which was going to be
difficult to maintain and brittle. The refactor
lessens this duplication.

Previously, the methods Log, Logf, Failed, Name and
Skipped were the only (*common) methods that were
allowed to be called inside (*F).Fuzz. After this
change, Failed and Name are still allowed, but
Log, Logf, and Skipped are not (t.Log, t.Logf, or
t.Skipped should be used instead).

Fixes #48988

Change-Id: I4066247d551ea1908e8a2ca2889509fc68e3bb44
Reviewed-on: https://go-review.googlesource.com/c/go/+/356151
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-19 18:18:37 +00:00
Benjamin Peterson
404f84d417 runtime: remove reference to crypto/tls GODEBUG usage
crypto/tls briefly used GODEBUG. That usage was removed in CL 191999.

Change-Id: I759b6f1b02db8160075cba30d73823018e19ad9d
GitHub-Last-Rev: 12d2a4a82b
GitHub-Pull-Request: golang/go#49012
Reviewed-on: https://go-review.googlesource.com/c/go/+/356313
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>
2021-10-19 17:12:53 +00:00
Robert Griesemer
99fad12e47 cmd/compile/internal/types2: delay expansion of underlying in typeDecl
This is a clean port of CL 356533 from go/types to types2.

Fixes #49043.

Change-Id: If389b94ece28042b0c8b436959dd21f26147a144
Reviewed-on: https://go-review.googlesource.com/c/go/+/356517
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-19 17:01:56 +00:00
Robert Griesemer
a73c6cf762 cmd/compile/internal/types2: ensure named types are expanded after type-checking
This is a clean port of CL 356490 from go/types to types2.

Fixes #48703.
Fixes #48974.

Change-Id: I08c0db0b92250cbb043325541b21a577726b40ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/356515
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-19 17:01:50 +00:00
Robert Griesemer
3a07ab70a2 cmd/compile/internal/types2: add support for inferring type instances
This is an essentially clean port of CL 356489 from go/types to types2,
with minor adjustments due to the different AST packages and error
reporting.

Fixes #47990.

Change-Id: I52187872474bfc1fb49eb77905f22fc820b7295b
Reviewed-on: https://go-review.googlesource.com/c/go/+/356514
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-19 17:01:42 +00:00
Robert Griesemer
254c497e5c cmd/compile, types2: better error message for invalid type assertion
This CL addresses the 2nd part of the issue below.

- For types2, now use the same error messages as the compiler in this case.
- Make the mechanism for reporting clarifying error messages handle the case
  where we don't have additional position information.
- Provide context information (type assertion vs type switch).

Fixes #49005.

Change-Id: I4eeaf4f0c3f2f8735b63993778f58d713fef21ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/356512
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-19 17:01:35 +00:00
Cuong Manh Le
f92a3589fa reflect: fix methodValueCall code pointer mismatched
CL 322350 changed how to take address of assembly functions, using
abi.FuncPCABI0 intrinsic. But we forgot to update the code in
Value.UnsafePointer (was Value.Pointer) to reflect that change.

This CL fixes that bug, and also add a test to make sure the code
pointer is in sync.

Change-Id: I05ae7df31c706583a0f374d8af027066528f5ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/356809
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-19 16:19:27 +00:00
wdvxdr
fe7df4c4d0 cmd/compile: use MOVBE instruction for GOAMD64>=v3
In CL 354670, I copied some existing rules for convenience but forgot
to update the last rule which broke `GOAMD64=v3 ./make.bat`

Revive CL 354670

Change-Id: Ic1e2047c603f0122482a4b293ce1ef74d806c019
Reviewed-on: https://go-review.googlesource.com/c/go/+/356810
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 16:18:56 +00:00
Katie Hockman
067d796549 testing: write output to buffer when fuzzing
Fixes #48709

Change-Id: Ia6376a2f792946498d6565a53605b3e6c985ea7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/355909
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-19 15:48:56 +00:00
Bryan C. Mills
6294207a1c cmd/go: skip flaky fuzz tests
(Temporarily, until they can be fixed.)

For #49046
For #49047

Change-Id: Ib580a5e45a0955aabdfc1899ed38a262a37f66ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/356649
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-10-19 15:03:39 +00:00
Joel Sing
bde0463da3 cmd/internal/obj/riscv: fix trampoline calls from large functions
On riscv64, the JAL instruction is only capable of reaching +/-1MB. In the case where
a single function and its trampolines exceeds this size, it is possible that the JAL
is unable to reach the trampoline, which is laid down after the function text. In the
case of large functions, switch back to using a AUIPC+JALR pairs rather than using
trampolines.

Fixes #48791

Change-Id: I119cf3bc20ce4933a9b7ab41a8e514437c6addb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/356250
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-19 11:52:34 +00:00
Daniel Martí
b0351bfd7d Revert "cmd/compile: use MOVBE instruction for GOAMD64>=v3"
This reverts CL 354670.

Reason for revert: broke make.bash with GOAMD64=v3.

Fixes #49061.

Change-Id: I7f2ed99b7c10100c4e0c1462ea91c4c9d8c609b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/356790
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Koichi Shiraishi <zchee.io@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-10-19 09:49:38 +00:00
180909
1e49210ccd encoding/base64: add examples for Encode/Decode
Fixes #37595

Change-Id: I83e5f6105748a0a9238322a4f7ec4b0bbf61a263
Reviewed-on: https://go-review.googlesource.com/c/go/+/348394
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Cherry Mui <cherryyz@google.com>
2021-10-19 08:44:22 +00:00
Meng Zhuo
ee92daae25 runtime: ensure at least 1 tick between events
ticks might be same after tick division, although the real cputicks
is linear growth

Fixes #46737

Change-Id: I1d98866fbf21b426c6c1c96cc9cf802d7f440f18
Reviewed-on: https://go-review.googlesource.com/c/go/+/330849
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 07:45:46 +00:00
Joel Sing
8838a3b53f cmd/internal/obj/riscv: fix and enable test in short mode
The branch test only takes a few seconds so enable it in short mode. Also fix a
typo that currently prevents the code from compiling.

Change-Id: I25fc646b002a66c042c61fb1f56d5efa8e47903c
Reviewed-on: https://go-review.googlesource.com/c/go/+/356249
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-19 07:37:24 +00:00
Robert Findley
eba0e866fa go/types: delay expansion of underlying in typeDecl
Even after type-checking the RHS of a type declaration, we may not yet
be able to expand, if the RHS is itself an instance (see #49043).

We can instead rely on the mechanisms we have in place for delayed
expansion.

Fixes #49043

Change-Id: Ibffa4c1b1163c824b5c7e151aaac35f3e8c84ec7
Reviewed-on: https://go-review.googlesource.com/c/go/+/356533
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-18 22:56:07 +00:00
Robert Findley
323e009c75 go/types: ensure named types are expanded after type-checking
Rather than using Checker.later in newNamed, add a Checker.defTypes
field to track named types that have been created during type-checking,
and use this to expand named types as a final phase in type checking.

We have encountered several bugs related to infinite recursion while
expanding named types, because (I would argue) we have two conflicting
requirements in the type checker: ensuring that we eventually collapse
underlying chains, and yet allowing lazy substitution of the underlying
type in instances. The former is necessary for correctness, and to
ensure that we detect cycles during the type-checking pass. The latter
is necessary to allow infinitely expanding patterns of instances through
underlying or method definitions.

I believe this CL reconciles these conflicting requirements, by creating
a boundary between types that are encountered in the source during
type checking, and instances that are created by recursive evaluation.
At the end of the type checking pass, Checker.defTypes should contain
all possible origin types for instantiation. Once we compute the true
underlying for these origin types, any remaining instances that are
unresolved are guaranteed to have an origin with a valid underlying.
Therefore, we can return from the type-checking pass without calling
under() for these remaining instances.

Fixes #48703
Fixes #48974

Change-Id: I1474f514e2ab71c1ad4c3704fe32bfba11d59394
Reviewed-on: https://go-review.googlesource.com/c/go/+/356490
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-18 22:55:32 +00:00
Robert Findley
73971784dc go/types: add support for inferring type instances
Add constraint type inference for type instances, to be consistent with
inference of function values.

Fixes #47990

Change-Id: Ib99b5215cb2da5c10badc4de7e9e60ca0e48489f
Reviewed-on: https://go-review.googlesource.com/c/go/+/356489
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-18 22:55:05 +00:00
jiahua wang
3befaf0cdb net/url: fix stale RFC 3986 links
The URLs for RFC 3986 have been changed from:
  http://tools.ietf.org/html/rfc3986
to:
  https://datatracker.ietf.org/doc/html/rfc3986

Change-Id: I0662557d91bbb7de51d7ca4bc64e838741cd9074
Reviewed-on: https://go-review.googlesource.com/c/go/+/356429
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Cherry Mui <cherryyz@google.com>
2021-10-18 21:57:36 +00:00
Damien Neil
425db64811 bufio: use underlying ReadFrom even when data is buffered
When (*bufio.Writer).ReadFrom is called with a partially filled buffer,
fill out and flush the buffer and then call the underlying writer's
ReadFrom method if present.

Fixes #44815.

Change-Id: I15b3ef0746d0d60fd62041189a9b9df11254dd29
Reviewed-on: https://go-review.googlesource.com/c/go/+/340530
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-18 21:52:05 +00:00
Lynn Boger
33b3260c1e cmd/compile/internal/ssagen: set BitLen32 as intrinsic on PPC64
It was noticed through some other investigation that BitLen32
was not generating the best code and found that it wasn't recognized
as an intrinsic. This corrects that and enables the test for PPC64.

Change-Id: Iab496a8830c8552f507b7292649b1b660f3848b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/355872
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-18 21:33:08 +00:00
Richard Musiol
6c0daa7331 syscall/js: remove Wrapper interface
This change removes the js.Wrapper interface for performance reasons.
See proposal #44006 for details.

This is a breaking change, but syscall/js is exempt from Go's
compatibility promise.

Fixes #44006

Change-Id: I968cd14b1e61cc72ea9f84240b6bd29e8b8ae673
Reviewed-on: https://go-review.googlesource.com/c/go/+/356430
Trust: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-10-18 21:21:54 +00:00
Gusted
267abbe3ba html/template: remove unused mode field on Tree struct
This changes Go, to remove this unused field on the `Tree` struct. Which seems to replaced by the non-private field `Mode`.

Change-Id: I5b384424cf60aa0af36eb8aad1d8db3f99b9838e
GitHub-Last-Rev: 4b033f967b
GitHub-Pull-Request: golang/go#48028
Reviewed-on: https://go-review.googlesource.com/c/go/+/345789
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-10-18 20:39:22 +00:00
Keith Randall
394a1ad295 cmd/compile: allow importing and exporting of ODYANMICDOTTYPE[2]
Fixes #49027

Change-Id: I4520b5c754027bfffbc5cd92c9c27002b248c99a
Reviewed-on: https://go-review.googlesource.com/c/go/+/356569
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-10-18 19:46:27 +00:00
Cuong Manh Le
4d550727f8 reflect: add Value.UnsafePointer
Allowing eliminates a class of possible misuse of unsafe.Pointer, and
allow callers to migrate from Value.Addr and Value.Pointer, thus they
can be now deprecated.

Fixes #40592

Change-Id: I798e507c748922cac5cc1c1971c1b2cc7095a068
Reviewed-on: https://go-review.googlesource.com/c/go/+/350691
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-18 16:33:42 +00:00
Cuong Manh Le
543a513304 reflect: add test that method values have the same code pointers
Updates #40592

Change-Id: I16252dd57aceb5c49ddc11d8c12c601ca87ca902
Reviewed-on: https://go-review.googlesource.com/c/go/+/356252
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-18 16:32:38 +00:00
Cuong Manh Le
42515418a9 reflect: correct documentation of Value.UnsafeAddr
The doc mentions that "UnsafeAddr returns a _pointer_ to v's data", but
it returns a uintptr instead, which don't have pointer semantic.

Change-Id: I557d5597cbc485356ca803eb496a99d6db8c63ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/350690
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-10-18 16:32:23 +00:00
Katie Hockman
417100ec1b cmd/go: fix broken fuzz test
Fixes test breakage caused by CL 355691.

Change-Id: I85fcb1491dc39c45342f4cae91fdfda6aedecd1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/356530
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-18 16:06:08 +00:00
wdvxdr
3e5cc4d6f6 cmd/compile: use MOVBE instruction for GOAMD64>=v3
encoding/binary benchmark on my laptop:
name                      old time/op    new time/op     delta
ReadSlice1000Int32s-8       4.42µs ± 5%     4.20µs ± 1%   -4.94%  (p=0.046 n=9+8)
ReadStruct-8                 359ns ± 8%      368ns ± 5%   +2.35%  (p=0.041 n=9+10)
WriteStruct-8                349ns ± 1%      357ns ± 1%   +2.15%  (p=0.000 n=8+10)
ReadInts-8                   235ns ± 1%      233ns ± 1%   -1.01%  (p=0.005 n=10+10)
WriteInts-8                  265ns ± 1%      274ns ± 1%   +3.45%  (p=0.000 n=10+10)
WriteSlice1000Int32s-8      4.61µs ± 5%     4.59µs ± 5%     ~     (p=0.986 n=10+10)
PutUint16-8                 0.56ns ± 4%     0.57ns ± 4%     ~     (p=0.101 n=10+10)
PutUint32-8                 0.83ns ± 2%     0.56ns ± 6%  -32.91%  (p=0.000 n=10+10)
PutUint64-8                 0.81ns ± 3%     0.62ns ± 4%  -23.82%  (p=0.000 n=10+10)
LittleEndianPutUint16-8     0.55ns ± 4%     0.55ns ± 3%     ~     (p=0.926 n=10+10)
LittleEndianPutUint32-8     0.41ns ± 4%     0.42ns ± 3%     ~     (p=0.148 n=10+9)
LittleEndianPutUint64-8     0.55ns ± 2%     0.56ns ± 6%     ~     (p=0.897 n=10+10)
ReadFloats-8                60.4ns ± 4%     59.0ns ± 1%   -2.25%  (p=0.007 n=10+10)
WriteFloats-8               72.3ns ± 2%     71.5ns ± 7%     ~     (p=0.089 n=10+10)
ReadSlice1000Float32s-8     4.21µs ± 3%     4.18µs ± 2%     ~     (p=0.197 n=10+10)
WriteSlice1000Float32s-8    4.61µs ± 2%     4.68µs ± 7%     ~     (p=1.000 n=8+10)
ReadSlice1000Uint8s-8        250ns ± 4%      247ns ± 4%     ~     (p=0.324 n=10+10)
WriteSlice1000Uint8s-8       227ns ± 5%      229ns ± 2%     ~     (p=0.193 n=10+7)
PutUvarint32-8              15.3ns ± 2%     15.4ns ± 4%     ~     (p=0.782 n=10+10)
PutUvarint64-8              38.5ns ± 1%     38.6ns ± 5%     ~     (p=0.396 n=8+10)

name                      old speed      new speed       delta
ReadSlice1000Int32s-8      890MB/s ±17%    953MB/s ± 1%   +7.00%  (p=0.027 n=10+8)
ReadStruct-8               209MB/s ± 8%    204MB/s ± 5%   -2.42%  (p=0.043 n=9+10)
WriteStruct-8              214MB/s ± 3%    210MB/s ± 1%   -1.75%  (p=0.003 n=9+10)
ReadInts-8                 127MB/s ± 1%    129MB/s ± 1%   +1.01%  (p=0.006 n=10+10)
WriteInts-8                113MB/s ± 1%    109MB/s ± 1%   -3.34%  (p=0.000 n=10+10)
WriteSlice1000Int32s-8     868MB/s ± 5%    872MB/s ± 5%     ~     (p=1.000 n=10+10)
PutUint16-8               3.55GB/s ± 4%   3.50GB/s ± 4%     ~     (p=0.093 n=10+10)
PutUint32-8               4.83GB/s ± 2%   7.21GB/s ± 6%  +49.16%  (p=0.000 n=10+10)
PutUint64-8               9.89GB/s ± 3%  12.99GB/s ± 4%  +31.26%  (p=0.000 n=10+10)
LittleEndianPutUint16-8   3.65GB/s ± 4%   3.65GB/s ± 4%     ~     (p=0.912 n=10+10)
LittleEndianPutUint32-8   9.74GB/s ± 3%   9.63GB/s ± 3%     ~     (p=0.222 n=9+9)
LittleEndianPutUint64-8   14.4GB/s ± 2%   14.3GB/s ± 5%     ~     (p=0.912 n=10+10)
ReadFloats-8               199MB/s ± 4%    203MB/s ± 1%   +2.27%  (p=0.007 n=10+10)
WriteFloats-8              166MB/s ± 2%    168MB/s ± 7%     ~     (p=0.089 n=10+10)
ReadSlice1000Float32s-8    949MB/s ± 3%    958MB/s ± 2%     ~     (p=0.218 n=10+10)
WriteSlice1000Float32s-8   867MB/s ± 2%    857MB/s ± 6%     ~     (p=1.000 n=8+10)
ReadSlice1000Uint8s-8     4.00GB/s ± 4%   4.06GB/s ± 4%     ~     (p=0.353 n=10+10)
WriteSlice1000Uint8s-8    4.40GB/s ± 4%   4.36GB/s ± 2%     ~     (p=0.193 n=10+7)
PutUvarint32-8             262MB/s ± 2%    260MB/s ± 4%     ~     (p=0.739 n=10+10)
PutUvarint64-8             208MB/s ± 1%    207MB/s ± 5%     ~     (p=0.408 n=8+10)

Updates #45453

Change-Id: Ifda0d48d54665cef45d46d3aad974062633142c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/354670
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-10-18 16:01:55 +00:00