aboutsummaryrefslogtreecommitdiff
path: root/src/reflect
AgeCommit message (Collapse)Author
2025-06-27reflect: fix TypeAssert on nil interface valuesJoe Tsai
In the Go language a type assertion of a nil interface value will always report false: var err error v, ok := err.(error) // always reports (nil, false) Consequently, assertion on a reflect.Value.Interface() will also report false: var err error rv := ValueOf(&err).Elem() v, ok := rv.Interface().(error) // reports (nil, false) However, prior to this change, a TypeAssert would report true: var err error rv := ValueOf(&err).Elem() v, ok := TypeAssert[error](rv) // reports (nil, true) when it should report false. This fixes TypeAssert to match the Go language by pushing the typ != v.typ check to the very end after we have validated that neither v nor T are interface kinds. Fixes #74404 Change-Id: Ie14d5cf18c8370c3e27ce4bdf4570c89519d8a16 Reviewed-on: https://go-review.googlesource.com/c/go/+/684675 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-21reflect: leak packEface input to result rather than heapthepudds
This is part of a series of CLs that aim to help allocations in reflect and reduce how often interface arguments escape for the print functions in fmt. Before this change, the reflect.Value parameter for packEface leaks immediately to the heap due to the various ODOTPTR operations on the *emptyInterface. The -m=2 logs report: parameter v leaks to <heap> for packEface with derefs=0: flow: <heap> ← v: from v.ptr (dot) at .\value.go:145:13 from e.word = v.ptr (assign) at .\value.go:145:10 After this change, the input leaks to the result, which is what we want: parameter v leaks to ~r0 with derefs=0: flow: e = v: from v.ptr (dot) at .\value.go:143:13 from e.Data = v.ptr (assign) at .\value.go:143:10 flow: ~r0 = e: from &e (address-of) at .\value.go:147:32 from *(*any)(unsafe.Pointer(&e)) (indirection) at .\value.go:147:9 from return *(*any)(unsafe.Pointer(&e)) (return) at .\value.go:147:2 This change here is needed, but reflect.Value.Interface still leaks its input to the heap for other reasons having to do with method values, which we attempt to address in CL 530097, CL 530095, and CL 530096. Updates #8618 Updates #71349 Change-Id: Ie77bc850ff261212eeafe190bd6f9a879676a51d Reviewed-on: https://go-review.googlesource.com/c/go/+/528535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-05-21reflect: optimize IsZero with a pointer comparison to global zeroValthepudds
Our prior CL 649078 teaches the compiler to use a pointer to runtime.zeroVal as the data pointer for an interface in cases it where it can see that a zero value struct or array is being used in an interface conversion. This applies to some uses with reflect, such as: s := S{} v := reflect.ValueOf(s) This CL builds on that to do a cheap pointer check in reflect.IsZero to see if the Value points to runtime.zeroVal, which means it is a zero value. An alternative might be to do an initial pointer check in the typ.Equal function for types where it makes sense to do but doesn't already. This CL gives a performance boost of -51.71% geomean for BenchmarkZero/IsZero, with most of the impact there on arrays of structs. (The left column is CL 649078 and the right column is this CL). goos: linux goarch: amd64 pkg: reflect cpu: Intel(R) Xeon(R) CPU @ 2.80GHz │ find-zeroVal │ check-zeroVal │ │ sec/op │ sec/op vs base │ Zero/IsZero/ByteArray/size=16-4 4.171n ± 0% 3.123n ± 0% -25.13% (p=0.000 n=20) Zero/IsZero/ByteArray/size=64-4 3.864n ± 0% 3.129n ± 0% -19.02% (p=0.000 n=20) Zero/IsZero/ByteArray/size=1024-4 3.878n ± 0% 3.126n ± 0% -19.39% (p=0.000 n=20) Zero/IsZero/BigStruct/size=1024-4 5.061n ± 0% 3.273n ± 0% -35.34% (p=0.000 n=20) Zero/IsZero/SmallStruct/size=16-4 4.191n ± 0% 3.275n ± 0% -21.87% (p=0.000 n=20) Zero/IsZero/SmallStructArray/size=64-4 8.636n ± 0% 3.127n ± 0% -63.79% (p=0.000 n=20) Zero/IsZero/SmallStructArray/size=1024-4 80.055n ± 0% 3.126n ± 0% -96.10% (p=0.000 n=20) Zero/IsZero/Time/size=24-4 3.865n ± 0% 3.274n ± 0% -15.29% (p=0.000 n=20) geomean 6.587n 3.181n -51.71% Note these are of course micro benchmarks with easily predicted branches. The extra branch we introduce in the CL might hurt if there was for example a tight loop where 50% of the values used the global zeroVal and 50% didn't in a way that is not well predicted, although if the typ.Equal for many types already does an initial pointer check, it might not matter much. For the older BenchmarkIsZero in reflect, this change does not help. (The compiler does not use the global zeroVal as the data word for the interfaces in this benchmark because values are part of a larger value that is too big to be used in the global zeroVal, and also a piece of the larger value is mutated and is not zero). │ find-zeroVal │ check-zeroVal │ │ sec/op │ sec/op vs base │ IsZero/ArrayComparable-4 14.58n ± 0% 14.59n ± 0% ~ (p=0.177 n=20) IsZero/ArrayIncomparable-4 163.8n ± 0% 167.5n ± 0% +2.26% (p=0.000 n=20) IsZero/StructComparable-4 6.847n ± 0% 6.847n ± 0% ~ (p=0.703 n=20) IsZero/StructIncomparable-4 35.41n ± 0% 35.10n ± 0% -0.86% (p=0.000 n=20) IsZero/ArrayInt_4-4 8.631n ± 0% 8.363n ± 0% -3.10% (p=0.000 n=20) IsZero/ArrayInt_1024-4 265.5n ± 0% 265.4n ± 0% ~ (p=0.288 n=20) IsZero/ArrayInt_1024_NoZero-4 135.8n ± 0% 136.2n ± 0% +0.33% (p=0.000 n=20) IsZero/Struct4Int-4 8.451n ± 0% 8.386n ± 0% -0.77% (p=0.000 n=20) IsZero/ArrayStruct4Int_1024-4 265.2n ± 0% 266.0n ± 0% +0.30% (p=0.000 n=20) IsZero/ArrayChanInt_1024-4 265.5n ± 0% 265.4n ± 0% ~ (p=0.605 n=20) IsZero/StructInt_512-4 135.8n ± 0% 135.8n ± 0% ~ (p=0.396 n=20) geomean 55.22n 55.12n -0.18% Updates #71323 Change-Id: Ie083853a5bff03856277a293d94532a681f4a8d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/654135 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2025-05-21cmd/compile/internal/walk: use global zeroVal in interface conversions for ↵thepudds
zero values This is a small-ish adjustment to the change earlier in our stack in CL 649555, which started creating read-only global storage for a composite literal used in an interface conversion and setting the interface data pointer to point to that global storage. In some cases, there are execution-time performance benefits to point to runtime.zeroVal in particular. In reflect, pointer checks against the runtime.zeroVal memory address are used to side-step some work, such as in reflect.Value.Set and reflect.Value.IsZero. In this CL, we therefore dig up the zeroVal symbol, and we use the machinery from earlier in our stack to use a pointer to zeroVal for the interface data pointer if we see examples like: sink = S{} or: s := S{} sink = s CL 649076 (also earlier in our stack) added most of the tests along with debug diagnostics in convert.go to make it easier to test this change. We add a benchmark in reflect to show examples of performance benefit. The left column is our immediately prior CL 649555, and the right is this CL. (The arrays of structs here do not seem to benefit, which we attempt to address in our next CL). goos: linux goarch: amd64 pkg: reflect cpu: Intel(R) Xeon(R) CPU @ 2.80GHz │ cl-649555 │ new │ │ sec/op │ sec/op vs base │ Zero/IsZero/ByteArray/size=16-4 4.176n ± 0% 4.171n ± 0% ~ (p=0.151 n=20) Zero/IsZero/ByteArray/size=64-4 6.921n ± 0% 3.864n ± 0% -44.16% (p=0.000 n=20) Zero/IsZero/ByteArray/size=1024-4 21.210n ± 0% 3.878n ± 0% -81.72% (p=0.000 n=20) Zero/IsZero/BigStruct/size=1024-4 25.505n ± 0% 5.061n ± 0% -80.15% (p=0.000 n=20) Zero/IsZero/SmallStruct/size=16-4 4.188n ± 0% 4.191n ± 0% ~ (p=0.106 n=20) Zero/IsZero/SmallStructArray/size=64-4 8.639n ± 0% 8.636n ± 0% ~ (p=0.973 n=20) Zero/IsZero/SmallStructArray/size=1024-4 79.99n ± 0% 80.06n ± 0% ~ (p=0.213 n=20) Zero/IsZero/Time/size=24-4 7.232n ± 0% 3.865n ± 0% -46.56% (p=0.000 n=20) Zero/SetZero/ByteArray/size=16-4 13.47n ± 0% 13.09n ± 0% -2.78% (p=0.000 n=20) Zero/SetZero/ByteArray/size=64-4 14.14n ± 0% 13.70n ± 0% -3.15% (p=0.000 n=20) Zero/SetZero/ByteArray/size=1024-4 24.22n ± 0% 20.18n ± 0% -16.68% (p=0.000 n=20) Zero/SetZero/BigStruct/size=1024-4 24.24n ± 0% 20.18n ± 0% -16.73% (p=0.000 n=20) Zero/SetZero/SmallStruct/size=16-4 13.45n ± 0% 13.10n ± 0% -2.60% (p=0.000 n=20) Zero/SetZero/SmallStructArray/size=64-4 14.12n ± 0% 13.69n ± 0% -3.05% (p=0.000 n=20) Zero/SetZero/SmallStructArray/size=1024-4 24.62n ± 0% 21.61n ± 0% -12.26% (p=0.000 n=20) Zero/SetZero/Time/size=24-4 13.59n ± 0% 13.40n ± 0% -1.40% (p=0.000 n=20) geomean 14.06n 10.19n -27.54% Finally, here are results from the benchmark example from #71323. Note however that almost all the benefit shown here is from our earlier CL 649555, which is a more general purpose change and eliminates the allocation using a different read-only global than this CL. │ go1.24 │ new │ │ sec/op │ sec/op vs base │ InterfaceAny 112.6000n ± 5% 0.8078n ± 3% -99.28% (p=0.000 n=20) ReflectValue 11.63n ± 2% 11.59n ± 0% ~ (p=0.330 n=20) │ go1.24.out │ new.out │ │ B/op │ B/op vs base │ InterfaceAny 224.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=20) ReflectValue 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ │ go1.24.out │ new.out │ │ allocs/op │ allocs/op vs base │ InterfaceAny 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=20) ReflectValue 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ Updates #71359 Updates #71323 Change-Id: I64d8cf1a7900f011d2ec59b948388aeda1150676 Reviewed-on: https://go-review.googlesource.com/c/go/+/649078 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
2025-05-20reflect: turn off allocation test if instrumentation is onkhr@golang.org
Help fix the asan builders. Change-Id: I980f5171519643c3543bdefc6ea46fd0fca17c28 Reviewed-on: https://go-review.googlesource.com/c/go/+/674616 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-05-20reflect: add TypeAssert[T]Mateusz Poliwczak
This implementation is zero-alloc when T is a concrete type, allocates when val contains a method or when T is a interface and Value was obtained for example through Elem(), in which case it has to be allocated to avoid sharing the same memory. goos: linux goarch: amd64 pkg: reflect cpu: AMD Ryzen 5 4600G with Radeon Graphics │ /tmp/bench2 │ │ sec/op │ TypeAssert/TypeAssert[int](int)-12 2.725n ± 1% TypeAssert/TypeAssert[uint8](int)-12 2.599n ± 1% TypeAssert/TypeAssert[fmt.Stringer](reflect_test.testTypeWithMethod)-12 8.470n ± 0% TypeAssert/TypeAssert[fmt.Stringer](*reflect_test.testTypeWithMethod)-12 8.460n ± 1% TypeAssert/TypeAssert[interface_{}](int)-12 4.181n ± 1% TypeAssert/TypeAssert[interface_{}](reflect_test.testTypeWithMethod)-12 4.178n ± 1% TypeAssert/TypeAssert[time.Time](time.Time)-12 2.839n ± 0% TypeAssert/TypeAssert[func()_string](func()_string)-12 151.1n ± 1% geomean 6.645n │ /tmp/bench2 │ │ B/op │ TypeAssert/TypeAssert[int](int)-12 0.000 ± 0% TypeAssert/TypeAssert[uint8](int)-12 0.000 ± 0% TypeAssert/TypeAssert[fmt.Stringer](reflect_test.testTypeWithMethod)-12 0.000 ± 0% TypeAssert/TypeAssert[fmt.Stringer](*reflect_test.testTypeWithMethod)-12 0.000 ± 0% TypeAssert/TypeAssert[interface_{}](int)-12 0.000 ± 0% TypeAssert/TypeAssert[interface_{}](reflect_test.testTypeWithMethod)-12 0.000 ± 0% TypeAssert/TypeAssert[time.Time](time.Time)-12 0.000 ± 0% TypeAssert/TypeAssert[func()_string](func()_string)-12 72.00 ± 0% geomean ¹ Fixes #62121 Change-Id: I0911c70c5966672c930d387438643f94a40441c4 GitHub-Last-Rev: ce89a53097b53fc59ff3ce3996917f8484ad3967 GitHub-Pull-Request: golang/go#71639 Reviewed-on: https://go-review.googlesource.com/c/go/+/648056 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-05-13reflect: use runtime.AddCleanup instead of runtime.SetFinalizerCarlos Amedee
Replace a usage of runtime.SetFinalizer with runtime.AddCleanup in the TestCallReturnsEmpty test. There is an additional use of SetFinalizer in the reflect package which depends on object resurrection and needs further refactoring to replace. Updates #70907 Change-Id: I4c0e56c35745a225776bd611d026945efdaf96f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/667595 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-17reflect: document Method(ByName) w.r.t dead code eliminationIlya Priven
The behavior is described in src/cmd/link/internal/ld/deadcode.go but is not otherwise documented. Since the usage of those functions could have significant caveats (longer builds, larger binaries), we are informing the user. Change-Id: I87571dd14aa16d7aac59fe45dfc52cb7c5b956c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/658255 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-28reflect: add more tests for Type.{CanSeq,CanSeq2}Jes Cok
For #71874. Change-Id: I3850edfb3104305f3bf4847a73cdd826cc99837f GitHub-Last-Rev: 574c1edb7a6152c71891fab011ac0aaeca955fc8 GitHub-Pull-Request: golang/go#71890 Reviewed-on: https://go-review.googlesource.com/c/go/+/651775 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-26reflect: let Value.Seq return the iteration value correct typeqiulaidongfeng
Fixes #71905 Change-Id: I50a418f8552e071c6e5011af5b9accc7d41548d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/651855 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-21reflect: correctly handle method values in SeqMichael Anthony Knyszek
Currently method values aren't correctly handled in Seq because we call canRangeFunc on the reciever type, not the method value type, when we're handling a method value. reflect.Value.Type has the logic to obtain the method value type from the Value. This change slightly refactors reflect.Value.Type into a separate function so we can obtain the correct type as an abi.Type and pass it off to canRangeFunc (and canRangeFunc2). Fixes #71874. Change-Id: Ie62dfca2a84b8f2f816bb87ff1ed1a58a7bb8122 Reviewed-on: https://go-review.googlesource.com/c/go/+/651416 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-15std: add //go:fix inline directives to some deprecated functionsAlan Donovan
In particular, we apply it only to functions where it is always a code improvement to inline the call. We also apply it to some constants. In a few cases this may introduce a panic statement at the caller, which is debatable, but making the potential for panic evident is the purpose of the deprecation. The gofix analyzer in gopls v0.18 will show a diagnostic for calls to the annotated functions, and will offer to inline the call. The new //go:fix annotation needs a special exemption in the pragma check in the compiler. Updates #32816 Change-Id: I43bf15648ac12251734109eb7102394f8a76d55e Reviewed-on: https://go-review.googlesource.com/c/go/+/648995 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-12reflect, internal/abi: speed up TypeFor[T]Mateusz Poliwczak
goos: linux goarch: amd64 pkg: reflect cpu: AMD Ryzen 5 4600G with Radeon Graphics │ /tmp/before │ /tmp/after │ │ sec/op │ sec/op vs base │ TypeForString-12 2.091n ± 1% 1.174n ± 1% -43.84% (p=0.000 n=20) TypeForError-12 7.5810n ± 3% 0.9372n ± 1% -87.64% (p=0.000 n=20) Change-Id: I22022f99b2dd2029f02d9ed8477b209adf7e9496 GitHub-Last-Rev: 64d2ac5bb2f3b2a659663832a4641ff4fc83bddd GitHub-Pull-Request: golang/go#71654 Reviewed-on: https://go-review.googlesource.com/c/go/+/648395 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03all: run gofmtIan Lance Taylor
Change-Id: I0af1903ed1e4f2bf4ea273847b024520c577ef6d Reviewed-on: https://go-review.googlesource.com/c/go/+/642496 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-01-28runtime: rename mapiterinit and mapiternextMichael Pratt
mapiterinit allows external linkname. These users must allocate their own iter struct for initialization by mapiterinit. Since the type is unexported, they also must define the struct themselves. As a result, they of course define the struct matching the old hiter definition (in map_noswiss.go). The old definition is smaller on 32-bit platforms. On those platforms, mapiternext will clobber memory outside of the caller's allocation. On all platforms, the pointer layout between the old hiter and new maps.Iter does not match. Thus the GC may miss pointers and free reachable objects early, or it may see non-pointers that look like heap pointers and throw due to invalid references to free objects. To avoid these issues, we must keep mapiterinit and mapiternext with the old hiter definition. The most straightforward way to do this is to use mapiterinit and mapiternext as a compatibility layer between the old and new iter types. The first step to that is to move normal map use off of these functions, which is what this CL does. Introduce new mapIterStart and mapIterNext functions that replace the former functions everywhere in the toolchain. These have the same behavior as the old functions. This CL temporarily makes the old functions throw to ensure we don't have hidden dependencies on them. We cannot remove them entirely because GOEXPERIMENT=noswissmap still uses the old names, and internal/goobj requires all builtins to exist regardless of GOEXPERIMENT. The next CL will introduce the compatibility layer. I want to avoid using linkname between runtime and reflect, as that would also allow external linknames. So mapIterStart and mapIterNext are duplicated in reflect, which can be done trivially, as it imports internal/runtime/maps. For #71408. Change-Id: I6a6a636c6d4bd1392618c67ca648d3f061afe669 Reviewed-on: https://go-review.googlesource.com/c/go/+/643898 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-12-11reflect: consistently document when value must be settableIan Lance Taylor
Fixes #70760 Change-Id: Ia00723698b7e502fa2c63f8f1dbe1143af22e0a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/634799 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-21reflect: add test of maps with keys larger than key sizeMichael Pratt
This finds the bug fixed in CL 630279. reflect mutates the SwissMapType of a map[unsafe.Pointer]unsafe.Pointer, which happened to already have the correct GroupSize for all of the maps used in the reflect tests. For #54766. Change-Id: If4428e1e799598e7512edceb3cefb2ad00cfa712 Reviewed-on: https://go-review.googlesource.com/c/go/+/630676 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2024-11-21reflect: set swissmap GroupSizeMichael Pratt
This was missed in CL 627716. For #54766. Change-Id: Ib987efa8abe6e89367e2e1b71a33b64ac6b01b1f Reviewed-on: https://go-review.googlesource.com/c/go/+/630279 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-18runtime: get rid of gc programs for typesKeith Randall
Instead, have the runtime build the gc bitmaps on demand at runtime. Change-Id: If7a245bc62e4bce3ce80972410b0ed307d921abe Reviewed-on: https://go-review.googlesource.com/c/go/+/616255 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
2024-11-12runtime: fix iterator returns map entries after clear (pre-swissmap)Youlin Feng
Fixes #70189 Fixes #59411 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-noswissmap Change-Id: I4ef7ecd7e996330189309cb2a658cf34bf9e1119 Reviewed-on: https://go-review.googlesource.com/c/go/+/625275 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-30runtime,internal/runtime/maps: specialized swissmapsMichael Pratt
Add all the specialized variants that exist for the existing maps. Like the existing maps, the fast variants do not support indirect key/elem. Note that as of this CL, the Get and Put methods on Map/table are effectively dead. They are only reachable from the internal/runtime/maps unit tests. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: I95297750be6200f34ec483e4cfc897f048c26db7 Reviewed-on: https://go-review.googlesource.com/c/go/+/616463 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com>
2024-10-30cmd/compile,runtime: add indirect key/elem to swissmapMichael Pratt
We use the same heuristics as existing maps. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: I44bb51483cae2c1714717f1b501850fb9e55a39a Reviewed-on: https://go-review.googlesource.com/c/go/+/616461 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28all: skip and fix various tests with -asan and -msanMichael Anthony Knyszek
First, skip all the allocation count tests. In some cases this aligns with existing skips for -race, but in others we've got new issues. These are debug modes, so some performance loss is expected, and this is clearly no worse than today where the tests fail. Next, skip internal linking and static linking tests for msan and asan. With asan we get an explicit failure that neither are supported by the C and/or Go compilers. With msan, we only get the Go compiler telling us internal linking is unavailable. With static linking, we segfault instead. Filed #70080 to track that. Next, skip some malloc tests with asan that don't quite work because of the redzone. This is because of some sizeclass assumptions that get broken with the redzone and the fact that the tiny allocator is effectively disabled (again, due to the redzone). Next, skip some runtime/pprof tests with asan, because of extra allocations. Next, skip some malloc tests with asan that also fail because of extra allocations. Next, fix up memstats accounting for arenas when asan is enabled. There is a bug where more is added to the stats than subtracted. This also simplifies the accounting a little. Next, skip race tests with msan or asan enabled; they're mutually incompatible. Fixes #70054. Fixes #64256. Fixes #64257. For #70079. For #70080. Change-Id: I99c02a0b9d621e44f1f918b307aa4a4944c3ec60 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15 Reviewed-on: https://go-review.googlesource.com/c/go/+/622855 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2024-10-14all: wire up swisstable mapsMichael Pratt
Use the new SwissTable-based map in internal/runtime/maps as the basis for the runtime map when GOEXPERIMENT=swissmap. Integration is complete enough to pass all.bash. Notable missing features: * Race integration / concurrent write detection * Stack-allocated maps * Specialized "fast" map variants * Indirect key / elem For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-amd64-longtest-swissmap Change-Id: Ie97b656b6d8e05c0403311ae08fef9f51756a639 Reviewed-on: https://go-review.googlesource.com/c/go/+/594596 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-24reflect: slightly improve iter testsJes Cok
Change-Id: Ia0e3d668a2435b2ee72e1c641092445902168e4a Reviewed-on: https://go-review.googlesource.com/c/go/+/587875 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-09-18reflect: remove calling mapiterkey, mapiterelemKyle Xiao
It makes use of the hiter structure which matches runtime.hiter's. This change mainly improves the performance of Next method of MapIter. goos: darwin goarch: arm64 pkg: reflect cpu: Apple M2 │ ./old.txt │ ./new.txt │ │ sec/op │ sec/op vs base │ MapIterNext-8 61.95n ± 0% 54.95n ± 0% -11.28% (p=0.000 n=10) for the change of `test/escape_reflect.go`: removing mapiterkey, mapiterelem would cause leaking MapIter content when calling SetIterKey and SetIterValue, and this may cause map bucket to be allocated on heap instead of stack. Reproduce: ``` { m := map[int]int{1: 2} // escapes to heap after this change it := reflect.ValueOf(m).MapRange() it.Next() var k, v int reflect.ValueOf(&k).Elem().SetIterKey(it) reflect.ValueOf(&v).Elem().SetIterValue(it) println(k, v) } ``` This CL would not introduce abi.NoEscape to fix this. It may need futher optimization and tests on hiter field usage and its escape analysis. Fixes #69416 Change-Id: Ibaa33bcf86228070b4a505b9512680791aa59f04 Reviewed-on: https://go-review.googlesource.com/c/go/+/612616 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-10runtime, reflect: avoid allocation in structType.Field common casesIan Lance Taylor
Use assembler to make runtime.staticuint64s into a readonly array so that the reflect package can safely create a slice without requiring any allocation. Fixes #2320 Fixes #68380 Change-Id: If2c97238eca782d0632db265c840581d4ecb9d18 Reviewed-on: https://go-review.googlesource.com/c/go/+/597855 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-09-06reflect: gofmt all_test.goIan Lance Taylor
CL 580779 accidentally committed an un-gofmt-ed all_test.go Change-Id: I071ad8d8d08cab12032ff8d3eebecb55e808f14a Reviewed-on: https://go-review.googlesource.com/c/go/+/610561 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-08-02cmd/compile,runtime: disable swissmap fast variantsMichael Pratt
Temporary measure to reduce the required MVP code. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: I44dc8acd0dc8280c6beb40451998e84bc85c238a Reviewed-on: https://go-review.googlesource.com/c/go/+/580915 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2024-08-02all: split old and swiss map abi and compiler integrationMichael Pratt
The two map implementations are still identical, but now the compiler targets the appropriate ABI depending on GOEXPERIMENT. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-swissmap Change-Id: I8438f64f044ba9de30ddbf2b8ceb9b4edd2d5614 Reviewed-on: https://go-review.googlesource.com/c/go/+/580779 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2024-08-02all: create swissmap experiment and fork filesMichael Pratt
The _swiss.go files are identical to the originals (except build tag). Later CLs will change them. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: I9943e2d6f1cfa227ffbf27c9ddc9ce853695d225 Reviewed-on: https://go-review.googlesource.com/c/go/+/580778 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Commit-Queue: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com>
2024-07-31reflect: add flag tests for MapOfMichael Pratt
Add two tests that verify that MapOf sets the map NeedsKeyUpdate and HashMightPanic flags in the created map. Missing these flags would cause correctness issues not otherwise caught in the reflect tests. For #54766. Change-Id: Icd5f117e0794e7b4d1b70fa94e5afbe97c4543e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/594656 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-26cmd/compile, reflect: treat abi.NoEscape as cheap callCuong Manh Le
The abi.NoEscape function is introduced to replace all usages of noescape wrapper in the standard library. However, the last usage in reflect package is still present, because the inlining test failed if abi.NoEscape were used. The reason is that reflect.noescape is treated as a cheap call, while abi.NoEscape is not. By treating abi.NoEscape a cheap call, the last usage of noescape in reflect package can now be removed. Change-Id: I798079780129221a5a26cbcb18c95ee30855b784 Reviewed-on: https://go-review.googlesource.com/c/go/+/601275 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-23runtime,internal: move runtime/internal/sys to internal/runtime/sysDavid Chase
Cleanup and friction reduction For #65355. Change-Id: Ia14c9dc584a529a35b97801dd3e95b9acc99a511 Reviewed-on: https://go-review.googlesource.com/c/go/+/600436 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-05-29all: document legacy //go:linkname for final round of modulesRuss Cox
Add linknames for most modules with ≥50 dependents. Add linknames for a few other modules that we know are important but are below 50. Remove linknames from badlinkname.go that do not merit inclusion (very small number of dependents). We can add them back later if the need arises. Fixes #67401. (For now.) Change-Id: I1e49fec0292265256044d64b1841d366c4106002 Reviewed-on: https://go-review.googlesource.com/c/go/+/587756 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Bypass: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-29all: document legacy //go:linkname for modules with ≥100 dependentsRuss Cox
For #67401. Change-Id: I015408a3f437c1733d97160ef2fb5da6d4efcc5c Reviewed-on: https://go-review.googlesource.com/c/go/+/587598 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
2024-05-23all: document legacy //go:linkname for modules with ≥2,000 dependentsRuss Cox
For #67401. Change-Id: I3ae93042dffd0683b7e6d6225536ae667749515b Reviewed-on: https://go-review.googlesource.com/c/go/+/587221 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-22all: document legacy //go:linkname for modules with ≥50,000 dependentsRuss Cox
Note that this depends on the revert of CL 581395 to move zeroVal back. For #67401. Change-Id: I507c27c2404ad1348aabf1ffa3740e6b1957495b Reviewed-on: https://go-review.googlesource.com/c/go/+/587217 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-22runtime: revert "move zeroVal to internal/abi"Russ Cox
This reverts CL 581395, commit 2f5b420fb5984842afab37a9c2e66e6599107483. It breaks a linkname from github.com/ugorji/go/codec. For #67401. A followup CL will document this dependence. Change-Id: I66d6c39c03e769ab829ca4c3f4f61277b93380d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/587216 TryBot-Bypass: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-22all: document legacy //go:linkname for modules with ≥100,000 dependentsRuss Cox
For #67401. Change-Id: I51f5b561ee11eb242e3b1585d591281d0df4fc24 Reviewed-on: https://go-review.googlesource.com/c/go/+/587215 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-22reflect: add line breaks for long sentencesJes Cok
Change-Id: Id63ede5d50a8b287bc0b96382f9f3ee6c2e0b834 Reviewed-on: https://go-review.googlesource.com/c/go/+/586856 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-17all: add push linknames to allow legacy pull linknamesCherry Mui
CL 585358 adds restrictions to disallow pull-only linknames (currently off by default). Currently, there are quite some pull- only linknames in user code in the wild. In order not to break those, we add push linknames to allow them to be pulled. This CL includes linknames found in a large code corpus (thanks Matthew Dempsky and Michael Pratt for the analysis!), that are not currently linknamed. Updates #67401. Change-Id: I32f5fc0c7a6abbd7a11359a025cfa2bf458fe767 Reviewed-on: https://go-review.googlesource.com/c/go/+/586137 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-15net/http, reflect: rename Test function namesJes Cok
To be consistent with other tests. Change-Id: Ibea1d3bf57a295f024e05173d17112ce46a4f0bc Reviewed-on: https://go-review.googlesource.com/c/go/+/585895 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-05-13all: delete loong64 non-register ABI fallback pathGuoqi Chen
Change-Id: If1d3eba9a922ac6f9d78301bb8f07e445c712899 Reviewed-on: https://go-review.googlesource.com/c/go/+/525576 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Meidan Li <limeidan@loongson.cn> Commit-Queue: abner chenc <chenguoqi@loongson.cn> Run-TryBot: abner chenc <chenguoqi@loongson.cn>
2024-05-10reflect: let Value.Seq iterate integer conform to the specqiulaidongfeng
See CL 557596, according to the go specification, the iterated variable type should be the same as the iterated integer type. For #66056 Change-Id: I96c87440328c2c50c40d76ecf2f222a331be1ce9 GitHub-Last-Rev: 8f80e401e5d7e092290d94e2bfcac89f3e04c2c5 GitHub-Pull-Request: golang/go#67269 Reviewed-on: https://go-review.googlesource.com/c/go/+/584516 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-09reflect: improved ifaceIndir commentIan Lance Taylor
Change-Id: Ic88ef6b60b5a772865603971411fd5d37ef45006 Reviewed-on: https://go-review.googlesource.com/c/go/+/584656 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-05-09reflect: restore ifaceIndir function for nowIan Lance Taylor
CL 583755 removed all uses of the ifaceIndir function, and the function itself. Unfortunately, ifaceIndir is accessed using go:linkname by the popular github.com/goccy/go-json package. A bug has been filed to fix this upstream: https://github.com/goccy/go-json/issues/506 Until that bug is fixed and the fix is distributed, keep this function available. With luck we can remove this in the 1.24 release. For #67279 Change-Id: I15fccf82d7a172a0b15cdbefb0a0a48381998938 Reviewed-on: https://go-review.googlesource.com/c/go/+/584676 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-09reflect: clarify documentation for Value.Seq/Seq2qiulaidongfeng
For #66056 Change-Id: Ib47c07b2527d8213584b72e2575a353f2deaed68 GitHub-Last-Rev: 525a5c3fa469fcccfb1ab67b61c7d12e024cfb33 GitHub-Pull-Request: golang/go#67268 Reviewed-on: https://go-review.googlesource.com/c/go/+/584515 Reviewed-by: Cherry Mui <cherryyz@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-09reflect: add iterative related methodsqiulaidongfeng
Fixes #66056 Change-Id: I1e24636e43e68cd57576c39b014e0826fb6c322c GitHub-Last-Rev: 319ad8ea7cd5326d23f9fddb9607924326aaf927 GitHub-Pull-Request: golang/go#66824 Reviewed-on: https://go-review.googlesource.com/c/go/+/578815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>