aboutsummaryrefslogtreecommitdiff
path: root/src/reflect
AgeCommit message (Collapse)Author
2021-08-24reflect: add MapIter.SetKey and MapIter.SetValueJosh Bleecher Snyder
These augment the existing MapIter.Key and MapIter.Value methods. The existing methods return new Values. Constructing these new Values often requires allocating. These methods allow the caller to bring their own storage. The naming is somewhat unfortunate, in that the spec uses the word "element" instead of "value", as do the reflect.Type methods. In a vacuum, MapIter.SetElem would be preferable. However, matching the existing methods is more important. Fixes #32424 Fixes #46131 Change-Id: I19c4d95c432f63dfe52cde96d2125abd021f24fa Reviewed-on: https://go-review.googlesource.com/c/go/+/320929 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-08-23reflect: fix memmove for big endian cases with new ABILynn Boger
Some memmoves in reflect/value.go for copying arguments related to the new ABI were using the address of the target or source instead of using IntArgRegAddr or FloatArgRegAddr to adjust the address for big endian. This was found when testing patches for ppc64 and fixes the failures that were found. Change-Id: I119aa090a2a8eb859020ff1a1736107a6d0b76f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/343869 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Trust: Michael Knyszek <mknyszek@google.com> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-08-22reflect: add example for FieldByIndexMostafa Solati
Change-Id: I539453e50ab85ec1b023bc9e329e6451c674e0c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/236937 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-08-19reflect: add test for invalid conversionKeith Randall
Conversion between slices with different element types is not allowed. Previously (1.8 <= goversion <= 1.16), this conversion was allowed if the base types were from different packages and had identical names. Update #47785 Change-Id: I359de5b6fe3ff35bdbf9ab5a13902a0f820cac66 Reviewed-on: https://go-review.googlesource.com/c/go/+/343329 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-17all: fix typosYasuhiro Matsumoto
Change-Id: I83180c472db8795803c1b9be3a33f35959e4dcc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/336889 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2021-07-22[dev.typeparams] all: merge master (798ec73) into dev.typeparamsMatthew Dempsky
Merge List: + 2021-07-22 798ec73519 runtime: don't clear timerModifiedEarliest if adjustTimers is 0 + 2021-07-22 fdb45acd1f runtime: move mem profile sampling into m-acquired section + 2021-07-21 3e48c0381f reflect: add missing copyright header + 2021-07-21 48c88f1b1b reflect: add Value.CanConvert + 2021-07-20 9e26569293 cmd/go: don't add C compiler ID to hash for standard library + 2021-07-20 d568e6e075 runtime/debug: skip TestPanicOnFault on netbsd/arm Change-Id: I87e1cd4614bb3b00807f18dfdd02664dcaecaebd
2021-07-21reflect: add missing copyright headerwdvxdr
Change-Id: I5a2f7203f83be02b03aa7be5fe386e485bf68ca3 Reviewed-on: https://go-review.googlesource.com/c/go/+/336189 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Robert Findley <rfindley@google.com>
2021-07-21reflect: add Value.CanConvertIan Lance Taylor
For #395 For #46746 Change-Id: I4bfc094cf1cecd27ce48e31f92384cf470f371a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/334669 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2021-07-08[dev.typeparams] all: merge master (296ddf2) into dev.typeparamsMatthew Dempsky
Conflicts: - src/runtime/runtime2.go On master, CL 317191 fixed the mentions of gc/reflect.go in comments to reflectdata/reflect.go; but on dev.typeparams, CL 325921 fixed that the same comment to reflect that deferstruct actually ended up in ssagen/ssa.go. Merge List: + 2021-07-08 296ddf2a93 net: filter bad names from Lookup functions instead of hard failing + 2021-07-08 ce76298ee7 Update oudated comment + 2021-07-08 2ca44fe221 doc/go1.17: linkify time.UnixMilli and time.UnixMicro + 2021-07-07 5c59e11f5e cmd/compile: remove special-casing of blank in types.sconv{,2} + 2021-07-07 b003a8b1ae cmd/compile: optimize types.sconv + 2021-07-07 11f5df2d67 cmd/compile: extract pkgqual from symfmt + 2021-07-07 991fd381d5 cmd/go: don't lock .mod and .sum files for read in overlay + 2021-07-07 186a3bb4b0 cmd/go/internal/modfetch/codehost: skip hg tests if no hg binary is present + 2021-07-07 00c00558e1 cmd/go/internal/modload: remove unused functions + 2021-07-07 f264879f74 cmd/go/internal/modload: fix an apparent typo in the AutoRoot comment + 2021-07-07 c96833e5ba doc: remove stale comment about arm64 port Change-Id: I849046b6d8f7421f60323549f3f763ef418bf9e7
2021-07-08Update oudated commentmakdon
Update comment cause gc/select.go has been moved to walk/select.go and gc/reflect.go has been moved to reflectdata/reflect.go Change-Id: I6894527e1e9dbca50ace92a51bf942f9495ce88c GitHub-Last-Rev: 6d6a4471440403218b68ba32d4038ca41eae2901 GitHub-Pull-Request: golang/go#45976 Reviewed-on: https://go-review.googlesource.com/c/go/+/317191 Reviewed-by: Keith Randall <khr@golang.org> Trust: Michael Pratt <mpratt@google.com>
2021-06-25[dev.typeparams] all: merge master (37f9a8f) into dev.typeparamsCuong Manh Le
Conflicts: - src/go/types/check_test.go CL 330629 fixed a bug in package qualification logic - src/internal/buildcfg/exp.go CL 329930 make parseExperiments get go arch string as input param Merge List: + 2021-06-25 37f9a8f69d go/types: fix a bug in package qualification logic + 2021-06-24 c309c89db5 reflect: document that InterfaceData is a low-entropy RNG + 2021-06-24 cce621431a cmd/compile: fix wrong type in SSA generation for OSLICE2ARRPTR + 2021-06-24 600a2a4ffb cmd/go: don't try to add replaced versions that won't be selected + 2021-06-24 a9bb38222a net: remove hard-coded timeout in dialClosedPort test helper + 2021-06-24 86d72fa2cb time: handle invalid UTF-8 byte sequences in quote to prevent panic + 2021-06-24 44a12e5f33 cmd/go: search breadth-first instead of depth-first for test dependency cycles + 2021-06-24 73496e0df0 net: use absDomainName in the Windows lookupPTR test helper + 2021-06-24 222ed1b38a os: enable TestFifoEOF on openbsd + 2021-06-22 0ebd5a8de0 cmd/go: update ToolTags based on GOARCH value + 2021-06-22 5bd09e5efc spec: unsafe.Add/Slice are not permitted in statement context + 2021-06-22 666315b4d3 runtime/internal/atomic: remove incorrect pointer indirection in comment + 2021-06-22 63daa774b5 go/types: guard against checking instantiation when generics is disabled + 2021-06-22 197a5ee2ab cmd/gofmt: remove stale documentation for the -G flag + 2021-06-22 9afd158eb2 go/parser: parse an ast.IndexExpr for a[] + 2021-06-21 1bd5a20e3c cmd/go: add a -go flag to 'go mod graph' + 2021-06-21 761edf71f6 cmd/internal/moddeps: use a temporary directory for GOMODCACHE if needed + 2021-06-21 a0400420ad cmd/internal/moddeps: use -mod=readonly instead of -mod=mod + 2021-06-21 3f9ec83b10 cmd/go: document GOPPC64 environment variable + 2021-06-21 20bdfba325 go/scanner: fall back to next() when encountering 0 bytes in parseIdentifier + 2021-06-21 44f9a3566c database/sql: fix deadlock test in prepare statement Change-Id: I16490e8ea70ee65081f467223857033842da513a
2021-06-24reflect: document that InterfaceData is a low-entropy RNGMatthew Dempsky
Change-Id: Ie26b9060630e2e774ac23d8492eaaf785bfca6b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/330709 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
2021-06-17[dev.typeparams] reflect: support big endian architectures in callMethodMichael Anthony Knyszek
Currently, callMethod has some ABI translation code that is not agnostic of endianness. This change rectifies that by adding a method to internal/abi.RegArgs for safely returning an offset into a register slot that's endianness-dependent. No tests for this because it's just best-effort. There's no actual way to test this because we don't support a register ABI on any big endian architectures yet. Change-Id: Ic68d9ee1bfdea0fc2992d467d749e2b083e92de3 Reviewed-on: https://go-review.googlesource.com/c/go/+/328348 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-17[dev.typeparams] reflect: delete unused ptrSize and PtrSizeMichael Anthony Knyszek
Change-Id: I522263eb5112b78639340b83d92e80a13f738bd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/328811 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17[dev.typeparams] reflect: use goarch.PtrSize instead of the duplicated ↵Michael Anthony Knyszek
ptrSize [generated] [git-generate] cd src/reflect gofmt -w -r "PtrSize -> goarch.PtrSize" . gofmt -w -r "ptrSize -> goarch.PtrSize" . goimports -w *.go Change-Id: Ib534bb0ecde10d93f45365ab4f8efd620d6d2ef3 Reviewed-on: https://go-review.googlesource.com/c/go/+/328346 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-16[dev.typeparams] all: merge master (785a8f6) into dev.typeparamsCuong Manh Le
- test/run.go CL 328050 added fixedbugs/issue46749.go to -G=3 excluded files list Merge List: + 2021-06-16 785a8f677f cmd/compile: better error message for invalid untyped operation + 2021-06-16 a752bc0746 syscall: fix TestGroupCleanupUserNamespace test failure on Fedora + 2021-06-15 d77f4c0c5c net/http: improve some server docs + 2021-06-15 219fe9d547 cmd/go: ignore UTF8 BOM when reading source code + 2021-06-15 723f199edd cmd/link: set correct flags in .dynamic for PIE buildmode + 2021-06-15 4d2d89ff42 cmd/go, go/build: update docs to use //go:build syntax + 2021-06-15 033d885315 doc/go1.17: document go run pkg@version + 2021-06-15 ea8612ef42 syscall: disable c-shared test when no cgo, for windows/arm + 2021-06-15 abc56fd1a0 internal/bytealg: remove duplicate go:build line + 2021-06-15 4061d3463b syscall: rewrite handle inheritance test to use C rather than Powershell + 2021-06-15 cf4e3e3d3b reflect: explain why convertible or comparable types may still panic + 2021-06-14 7841cb14d9 doc/go1.17: assorted fixes + 2021-06-14 8a5a6f46dc debug/elf: don't apply DWARF relocations for ET_EXEC binaries + 2021-06-14 9d13f8d43e runtime: update the variable name in comment + 2021-06-14 0fd20ed5b6 reflect: use same conversion panic in reflect and runtime + 2021-06-14 6bbb0a9d4a cmd/internal/sys: mark windows/arm64 as c-shared-capable + 2021-06-14 d4f34f8c63 doc/go1.17: reword "results" in stack trace printing Change-Id: I60d1f67c4d48cd4093c350fc89bd60c454d23944
2021-06-15reflect: explain why convertible or comparable types may still panicJoe Tsai
Conversions of slices to arrays may panic since the slice is too short. Comparibility of interfaces may panic since the underlying value is incomparable. This is a follow-up to CL 301652 Change-Id: Ia5d84a6e556a7b82c39add4be93ed7463e63cc8d Reviewed-on: https://go-review.googlesource.com/c/go/+/327589 Trust: Joe Tsai <joetsai@digital-static.net> Trust: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-14reflect: use same conversion panic in reflect and runtimeIan Lance Taylor
Consistently say "pointer to array", not "array pointer". Fixes #46743 Change-Id: I2388ec5c16f96e82a3a383b9b462b350686ddc5e Reviewed-on: https://go-review.googlesource.com/c/go/+/327870 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-14[dev.typeparams] all: merge master (fdab5be) into dev.typeparamsMatthew Dempsky
Two non-conflict changes included because they're needed for all.bash: 1. Bump internal/goversion.Version to 18. This will happen eventually anyway (dev.typeparams will not be merged back to Go 1.17), and is needed for cmd/api to allow new API additions. 2. Add fixedbugs/issue46725.go (new test added on master) to the list of known failures for -G=3. This test exercises a bug that was fixed in typecheck, but -G=3 mode has duplicated that code and will need to be fixed as well. That's outside of the scope of a merge. Conflicts: - src/runtime/traceback.go Nearby lines were removed on both master and dev.typeparams. Merge List: + 2021-06-14 fdab5be159 doc/go1.17: further revise OpenBSD release notes + 2021-06-14 326ea438bb cmd/compile: rewrite a, b = f() to use temporaries when type not identical + 2021-06-14 3249b645c9 cmd/compile: factor out rewrite multi-valued f() + 2021-06-13 14305bf0b9 misc/cgo: generate Windows import libraries for clang + 2021-06-13 24cff0f044 cmd/go, misc/cgo: skip test if no .edata + 2021-06-13 67b1b6a2e3 cmd/compile: allow ir.OSLICE2ARRPTR in mayCall + 2021-06-12 1ed0d129e9 runtime: testprogcgo: don't call exported Go functions directly from Go + 2021-06-12 9d46ee5ac4 reflect: handle stack-to-register translation in callMethod + 2021-06-11 e552a6d312 cmd/go: remove hint when no module is suggested + 2021-06-11 16b5d766d8 syscall: do not load native libraries on non-native powershell on arm + 2021-06-11 77aa209b38 runtime: loop on EINTR in macOS sigNoteSleep + 2021-06-11 e2dc6dd5c9 doc/go1.17: clean up formatting of gofmt section + 2021-06-11 2f1128461d cmd/go: match Windows paths in TestScript/mod_invalid_version + 2021-06-11 2721da2608 doc/go1.17: fix formatting near httptest + 2021-06-10 770f1de8c5 net/http: remove test-only private key from production binaries + 2021-06-10 8d11b1d117 cmd/go: report the imports of CompiledGoFiles in ImportMap + 2021-06-10 dc00dc6c6b crypto/tls: let HTTP/1.1 clients connect to servers with NextProtos "h2" + 2021-06-09 27f83723e9 api: promote next to go1.17 + 2021-06-09 182157c81a doc/go1.17: remove lingering TODO + 2021-06-09 a5bc060b42 doc/go1.17: document strconv changes for Go 1.17 + 2021-06-09 1402b27d46 strconv: document parsing of leading +/- + 2021-06-09 df35ade067 doc/go1.17: document //go:build lines + 2021-06-09 e4e7807d24 net/http: add AllowQuerySemicolons + 2021-06-09 ec3026d032 doc/go1.17: remove TODO for ports section + 2021-06-09 e6dda19888 net/url: reject query values with semicolons + 2021-06-09 139e935d3c math/big: comment division + 2021-06-09 aa5540cd82 cmd/compile: make map.zero symbol content-addressable + 2021-06-09 07ca28d529 cmd/link: fix bug in -strictdups checking of BSS symbols + 2021-06-08 bcecae2af6 doc/go1.17: mention new possibility of type conversion panicking + 2021-06-08 63dcab2e91 doc/go1.17: mention new vet checks sigchanyzer and stdmethods. + 2021-06-08 6551763a60 doc/go1.17: mention block profile bias fix + 2021-06-08 cb80937bf6 Revert "doc/go1.17: mention block profile bias fix" + 2021-06-08 d3e3d03666 net: reject leading zeros in IP address parsers + 2021-06-08 da4a640141 doc/go1.17: revise OpenBSD release notes + 2021-06-08 689f4c7415 doc/go1.17: mention block profile bias fix + 2021-06-08 9afe071c60 doc/go1.17: remove TODO for Tools section + 2021-06-08 f753d7223e doc/go1.17: resolve TODO for cmd/cover + 2021-06-08 9498b0155d cmd/go: in Go 1.17+ modules, add indirect go.mod dependencies separately from direct ones + 2021-06-08 949f00cebe doc/go1.17: add release notes for crypto packages + 2021-06-08 0fb3e2c184 doc/go1.17: add a release note for the '-compat' flag to 'go mod tidy' + 2021-06-08 2169deb352 cmd/compile: use t.AllMethods when sorting typesByString + 2021-06-08 c20bcb6488 runtime: remove out-of-date comments about frame skipping + 2021-06-07 39c39ae52f doc: document Go 1.17 language changes + 2021-06-07 dc8b558951 cmd/dist: pass -Wno-lto-type-mismatch in swig_callback_lto + 2021-06-07 909dd5e010 strconv: ParseFloat: always return ErrSyntax for bad syntax Change-Id: Iffdf379d0275bbd12d50149ce38634773ced481d
2021-06-12reflect: handle stack-to-register translation in callMethodMichael Anthony Knyszek
callMethod previously assumed erroneously that between the "value" and "method" ABIs (that is, the ABI the caller is following to call this method value and the actual ABI of the method), it could never happen that an argument passed on the stack in the former could be passed in registers in the latter. The cited reason was that the latter always uses strictly more registers. However, there are situations where the value ABI could pass a value on the stack, but later is passed in a register. For instance, if the receiver pushes a value passed in registers that uses multiple registers to be passed on the stack, later arguments which were passed on the stack may now be passed in registers. This change fixes callMethod to no longer makes this assumption, and handles the stack-to-register translation explicitly. Fixes #46696. Change-Id: I7100a664d97bbe401302cc893b3a98b28cdcdfc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/327089 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-03[dev.typeparams] reflect: guard abi_test.go with regabiargs build tagCherry Mui
The test in abi_test.go relies on the compiler to generate register-ABI calls using a magic name. As of CL 300150 the name loses its magic. Guard it with regabiargs for the use of register-ABI calls. Change-Id: Ib8b3c24f71ea5161d607c9becfb3027ceee40ac1 Reviewed-on: https://go-review.googlesource.com/c/go/+/324767 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-02[dev.typeparams] reflect: implement register ABI for MakeFunc etc. on ARM64Cherry Mui
Implement register ABI for reflect.MakeFunc and method Value Call on ARM64. Change-Id: I5487febb9ea764af5ccf5d7c94858ab0acec7cac Reviewed-on: https://go-review.googlesource.com/c/go/+/323936 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-01[dev.typeparams] reflect: call ABI0 spill/unspill functions on AMD64Cherry Mui
CL 321950 changed runtime.spillArgs and unspillArgs to ABI0. References to those functions should have been updated to ABI0, but this one was missed. Change-Id: I99238e4a96c945a47bec0981a415037578c73de4 Reviewed-on: https://go-review.googlesource.com/c/go/+/323931 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-05-24[dev.typeparams] reflect: use internal/abi.FuncPCABI0 to take address of ↵Cherry Mui
assembly functions makeFuncStub and methodValueCall on AMD64 are marked as ABIInternal, so Go code can get their (unwrapped) addresses (using open-coded funcPC). Ues internal/abi.FuncPCABI0 instead, and un-mark the functions. Change-Id: Id28b6101ec7e55bc5a357d4236482cec70cd7e5d Reviewed-on: https://go-review.googlesource.com/c/go/+/322350 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-21[dev.typeparams] runtime: use internal/abi.FuncPCABI0 to take address of ↵Cherry Mui
assembly functions There are a few assembly functions in the runtime that are marked as ABIInternal, solely because funcPC can get the right address. The functions themselves do not actually follow ABIInternal (or irrelevant). Now we have internal/abi.FuncPCABI0, use that, and un-mark the functions. Also un-mark assembly functions that are only called in assembly. For them, it only matters if the caller and callee are consistent. Change-Id: I240e126ac13cb362f61ff8482057ee9f53c24097 Reviewed-on: https://go-review.googlesource.com/c/go/+/321950 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-13all: add //go:build lines to assembly filesTobias Klauser
Don't add them to files in vendor and cmd/vendor though. These will be pulled in by updating the respective dependencies. For #41184 Change-Id: Icc57458c9b3033c347124323f33084c85b224c70 Reviewed-on: https://go-review.googlesource.com/c/go/+/319389 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-05-10cmd/compile,reflect: allow longer type namesKeith Randall
Encode the length of type names and tags in a varint encoding instead of a fixed 2-byte encoding. This allows lengths longer than 65535 (which can happen for large unnamed structs). Removed the alignment check for #14962, it isn't relevant any more since we're no longer reading pointers directly out of this data (it is encoded as an offset which is copied out bytewise). Fixes #44155 Update #14962 Change-Id: I6084f6027e5955dc16777c87b0dd5ea2baa49629 Reviewed-on: https://go-review.googlesource.com/c/go/+/318249 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-06cmd/compile: set unsayable "names" for regabi testing triggersDavid Chase
This disables the "testing names" for method names and trailing input types passed to closure/interface/other calls. The logic using the names remains, so that editing the change to enable local testing is not too hard. Also fixes broken build tag in reflect/abi_test.go Updates #44816. Change-Id: I3d222d2473c98d04ab6f1122ede9fea70c994af1 Reviewed-on: https://go-review.googlesource.com/c/go/+/300150 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-21reflect: allow conversion from slice to array ptrJosh Bleecher Snyder
Note that this removes an invariant: v.Type().ConvertibleTo(t) might return true, yet v.Convert(t) might panic nevertheless. This is a fairly unavoidable consequence of the decision to add the first-ever conversion that can panic. ConvertibleTo describes a relationship between types, but whether the conversion panics now depends on the value, not just the type. If this turns out to be a problem, we can add v.ConvertibleTo(t), or something similar, to allow callers to avoid the panic. This is the last of the changes needed to complete the implementation. Fixes #395 Change-Id: I79b7e4dd87a67a47723e00a65d0b1ac6090371b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/301652 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-20reflect: fix stack overflow panic when using haveIdenticalUnderlyingTypeJinzhu
haveIdenticalUnderlyingType raises stack overflow when compares self-referential structs having same structure in different packages. Change-Id: I7c79ab988edcffadcf7e0730a50b4d31b136bb6a GitHub-Last-Rev: 4d4217f0c16ef14aa1f38ff7cf88c98755bb8ddd GitHub-Pull-Request: golang/go#45543 Reviewed-on: https://go-review.googlesource.com/c/go/+/309729 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-16reflect: preserve ctxt across moveMakeFuncArgPtrsCherry Zhang
In makeFuncStub and methodValueCall, it stores ctxt (DX) as an argument of moveMakeFuncArgPtrs, and assumes it does not change by the call. This is not guaranteed, and it does happen if -clobberdead compiler flag is used. Store it somewhere else and reload after the call. Change-Id: I9307e3cf94db4b38305ab35494088386dfcbaae8 Reviewed-on: https://go-review.googlesource.com/c/go/+/310409 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-14reflect: keep pointer register results alive in callMethodCherry Zhang
When callMethod calls the underlying method, after reflectcall it gets the result registers in "Ints" slots but not in "Ptrs" slots. If the GC runs at this point, it may lose track of those pointers and free the memory they point to. To make sure the GC sees the pointer results, copy "Ints" to "Ptrs", and keep them alive until we return to the caller. This fixes test/fixedbugs/issue27695.go with register ABI. Change-Id: I4092c91bcbd6954683740a12d91d689900446875 Reviewed-on: https://go-review.googlesource.com/c/go/+/309909 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-09reflect: panic on New of go:notinheap typeIan Lance Taylor
For #42076 Fixes #45451 Change-Id: I69646226d3480d5403205412ddd13c0cfc2c8a53 Reviewed-on: https://go-review.googlesource.com/c/go/+/308970 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-04-08reflect: fix typo in result-in-registers caseDavid Chase
t is the type of the function that was called tv is the type of the result This fixes the failures for GOEXPERIMENT=regabi,regabiargs go test go test text/template GOEXPERIMENT=regabi,regabiargs go test go test html/template Updates #40724. Change-Id: Ic9b02d72d18ff48c9de1209987cc39da619c2241 Reviewed-on: https://go-review.googlesource.com/c/go/+/308189 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-08internal/goexperiment: consolidate experiment-enabled constantsAustin Clements
Currently, we have boolean and integral constants for GOEXPERIMENTs in various places. Consolidate these into automatically generated constants in the internal/goexperiment package. Change-Id: I42a49aba2a3b4c722fedea23a613162cd8a67bee Reviewed-on: https://go-review.googlesource.com/c/go/+/307818 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-06reflect: refactor funcLayout testsMichael Anthony Knyszek
This change refactors the existing funcLayout tests and sets them up to support the new register ABI by explicitly setting the register counts to zero. This allows the test to pass if GOEXPERIMENT=regabiargs is set. A follow-up change will add tests for a non-zero register count. For #40724. Change-Id: Ibbe061b4ed4fd70566eb38b9e6182dca32b81127 Reviewed-on: https://go-review.googlesource.com/c/go/+/307869 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-05reflect: call ABI0 callReflect/callMethodCherry Zhang
Currently the assembly code marshals arguments in ABI0 layout. Call the ABI0 functions. We may want to move to ABIInternal at some point (maybe when register args is always enabled). Updates #40724. Change-Id: I23bb3073f3f6420a8d0c119b65ae3e577578aadb Reviewed-on: https://go-review.googlesource.com/c/go/+/307237 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Austin Clements <austin@google.com>
2021-04-02reflect: fix methodValueCall frame size on mips64Michael Anthony Knyszek
Fixes a mistake from golang.org/cl/298670. Change-Id: I2f789f9fe003c856a993f7d462a2e84936743a1a Reviewed-on: https://go-review.googlesource.com/c/go/+/306930 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Trust: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-02reflect: remove short-circuits for zero-sized types in ABI algorithmMichael Anthony Knyszek
This change removes two short-circuits for zero-sized types (zero-sized structs and zero-sized struct fields) in the recursive cases of the ABI algorithm, because this does not match the spec's algorithm, nor the compiler's algorithm. The failing case here is a struct with a field that is an array of non-zero length but whose element type is zero-sized. This struct must be stack-assigned because of the array, according to the algorithm. The reflect package was register-assigning it. Because there were two short-circuits, this can also appear if a struct has a field that is a zero-sized struct but contains such an array, also. This change adds regression tests for both of these cases. For #44816. For #40724. Change-Id: I956804170962448197a1c9853826e3436fc8b1ea Reviewed-on: https://go-review.googlesource.com/c/go/+/306929 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-02reflect: add register ABI support for makeFuncStub and methodValueCallMichael Anthony Knyszek
This change finishes off functionality register ABI for the reflect package. Specifically, it implements a call on a MakeFunc'd value by performing the reverse process that reflect.Value.Call does, using the same ABI steps. It implements a call on a method value created by reflect by translating between the method value's ABI to the method's ABI. Tests are added for both cases. For #40724. Change-Id: I302820b61fc0a8f94c5525a002bc02776aef41af Reviewed-on: https://go-review.googlesource.com/c/go/+/298670 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-01reflect,runtime: assume register ABI with GOEXPERIMENT=regabiargsMichael Anthony Knyszek
This change causes finalizers, reflect calls, and Windows syscall callbacks to assume the register ABI when GOEXPERIMENT=regabiargs is set. That is, when all Go functions are using the new ABI by default, these features should assume the new ABI too. For #40724. Change-Id: Ie4ee66b8085b692e1ff675f01134c9a4703ae1b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/306571 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-01reflect: undo register count increments on register assignment failureMichael Anthony Knyszek
Currently when register assignment fails we roll back all the abiParts that were generated in the process. However, the total number of registers also increases, but does not get rolled back. The result is a very incorrect register assignment. For #40724. For #44816. Change-Id: I1934ea5f95f7608ff2067166255099dbc9135e8c Reviewed-on: https://go-review.googlesource.com/c/go/+/306109 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: Cherry Zhang <cherryyz@google.com>
2021-03-30reflect: cache IsVariadic calls in CallIgnacio Hagopian
These calls are cacheable, so do that to avoid doing extra work. This opportunity was discovered while taking a look at a CPU profile while investigating #7818. I added a BenchmarkCallMethod, which is similar to BechmarkCall but for a method receiver. Benchmark results, including the new BenchmarkCallMethod: name old time/op new time/op delta Call-16 22.0ns ±19% 20.2ns ±17% -8.08% (p=0.000 n=40+40) CallMethod-16 100ns ± 3% 91ns ± 2% -9.13% (p=0.000 n=40+39) CallArgCopy/size=128-16 15.7ns ± 1% 14.3ns ± 4% -8.98% (p=0.000 n=38+37) CallArgCopy/size=256-16 15.9ns ± 3% 15.0ns ± 5% -6.12% (p=0.000 n=39+39) CallArgCopy/size=1024-16 18.8ns ± 6% 17.1ns ± 6% -9.03% (p=0.000 n=38+38) CallArgCopy/size=4096-16 26.6ns ± 3% 25.2ns ± 4% -5.19% (p=0.000 n=39+40) CallArgCopy/size=65536-16 379ns ± 3% 371ns ± 5% -2.11% (p=0.000 n=39+40) name old alloc/op new alloc/op delta Call-16 0.00B 0.00B ~ (all equal) CallMethod-16 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta Call-16 0.00 0.00 ~ (all equal) CallMethod-16 0.00 0.00 ~ (all equal) name old speed new speed delta CallArgCopy/size=128-16 8.13GB/s ± 1% 8.92GB/s ± 4% +9.77% (p=0.000 n=38+38) CallArgCopy/size=256-16 16.1GB/s ± 3% 17.1GB/s ± 5% +6.56% (p=0.000 n=39+39) CallArgCopy/size=1024-16 54.6GB/s ± 6% 60.1GB/s ± 5% +9.93% (p=0.000 n=38+38) CallArgCopy/size=4096-16 154GB/s ± 5% 163GB/s ± 4% +5.63% (p=0.000 n=40+40) CallArgCopy/size=65536-16 173GB/s ± 3% 177GB/s ± 5% +2.18% (p=0.000 n=39+40) Updates #7818. Change-Id: I94f88811ea9faf3dc2543984a13b360b5db66a4b GitHub-Last-Rev: 9bbaa1854aa32cade905eddb05737e6224c372a1 GitHub-Pull-Request: golang/go#43475 Reviewed-on: https://go-review.googlesource.com/c/go/+/281252 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Keith Randall <khr@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-18reflect: add tests for reflect.Value.Call for the new ABIMichael Anthony Knyszek
This change adds tests for reflect.Value.Call for calling functions using the new register-based ABI. For #40724. Change-Id: Ia9afd43e26dd80c7e36dd135a5b71acce8074801 Reviewed-on: https://go-review.googlesource.com/c/go/+/299269 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15reflect: panic if ArrayOf is called with negative lengthPaschalis Tsilias
Since we cannot change the signature of reflect.ArrayOf to return an error, we panic instead of producing a wrong result. Fixes #43603 Change-Id: I23915df8d190f35af4d00ab86768868cd621e839 Reviewed-on: https://go-review.googlesource.com/c/go/+/284136 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-05reflect: add VisibleFields functionRoger Peppe
When writing code that reflects over a struct type, it's a common requirement to know the full set of struct fields, including fields available due to embedding of anonymous members while excluding fields that are erased because they're at the same level as another field with the same name. The logic to do this is not that complex, but it's a little subtle and easy to get wrong. This CL adds a new `VisibleFields` function to the reflect package that returns the full set of effective fields that apply in a given struct type. Performance isn't a prime consideration, as it's common to cache results by type. Fixes #42782 Change-Id: I7f1af76cecff9b8a2490f17eec058826e396f660 Reviewed-on: https://go-review.googlesource.com/c/go/+/281233 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc>
2021-03-05reflect: include the alignment of zero-sized types in stack offsetsMichael Anthony Knyszek
This change modifies the reflect ABI assignment algorithm to catch zero-sized types at the top level of each argument and faux-stack-assign them. It doesn't actually generate an ABI step, which is unnecessary, but it ensures that the offsets of further stack-assigned arguments are aligned to the alignment of that zero-sized argument. This change is necessary to have the register ABI assignment algorithm gracefully degrade to ABI0 when no registers are present in the ABI. Fixes #44377. Change-Id: Ia95571688a61259302bb3c6d5fb33fbb6b5e8db8 Reviewed-on: https://go-review.googlesource.com/c/go/+/293789 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com>
2021-03-05reflect: use global variables for register countMichael Anthony Knyszek
This change switches reflect to use global variables for ABI-related register counts instead of internal/abi constants. The advantage of doing so is that we can make the internal/abi constants non-zero and enable the runtime register argument spiller/unspiller even if they're not used. It's basically turning two things we need to flip when we switch to the register ABI into one. It also paves the way for testing the reflect register ABI path independently, because now we can switch the global variables at will and run the register-assignment algorithm in tests without having the rest of the runtime be broken. Change-Id: Ie23629a37a5c80aeb24909d4bd9eacbd3f0c06d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/293149 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-02all: fix spellingJohn Bampton
Change-Id: Iad14571c3e19b01740cd744f0b3025b3e2f1cb72 GitHub-Last-Rev: e8064019299f4e593116060ce2bbd14d62830af7 GitHub-Pull-Request: golang/go#44685 Reviewed-on: https://go-review.googlesource.com/c/go/+/297409 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-26reflect: fix register ABI spill space calculationMichael Anthony Knyszek
Currently this does things the old way by computing the number of registers, but we're going to be using their ABI0 layout for the spill space for now. Change-Id: Ibcef1ee48fd834af7cbdaabe704bcabe066ed358 Reviewed-on: https://go-review.googlesource.com/c/go/+/293011 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Michael Knyszek <mknyszek@google.com>