aboutsummaryrefslogtreecommitdiff
path: root/src/reflect
AgeCommit message (Collapse)Author
11 daysall: 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>
11 daysall: 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>
2024-05-07reflect: remove redundent ifaceIndirapocelipes
Use abi.(*Type).IfaceIndir instead. Change-Id: I31197cbf0edaf53bbb0455fa76d2a4a2ab40b420 GitHub-Last-Rev: 2659b696ef3680e13e22bdf6a63e5d82b7b1ecdf GitHub-Pull-Request: golang/go#67227 Reviewed-on: https://go-review.googlesource.com/c/go/+/583755 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-03runtime,reflect: move zeroVal to internal/abiqiulaidongfeng
Change-Id: I0e19e4aa2ea47a714e27b8d66c23c449e27861f2 GitHub-Last-Rev: 2d59b9589efcf4ade6cfd7c8feffc46bf9ba912c GitHub-Pull-Request: golang/go#67014 Reviewed-on: https://go-review.googlesource.com/c/go/+/581395 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> Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-22Refactor output messageLev Ustimenko
"/reflect/all_test.go : refactor message." This PR corrects a syntax %value -> %v Change-Id: Ie56b93d238f090c564a88eb963dc9b7773054356 GitHub-Last-Rev: 023fde3ed4f31d5d702d76a593a63aaad1b4ac39 GitHub-Pull-Request: golang/go#66974 Reviewed-on: https://go-review.googlesource.com/c/go/+/580935 Reviewed-by: Joedian Reid <joedian@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2024-04-19reflect: remove unnecessary type conversions of untyped PtrSizeIan Lance Taylor
Change-Id: I0f20020c2929b58958ce228b9f175d5b4fd77a1a Reviewed-on: https://go-review.googlesource.com/c/go/+/578855 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-19reflect: omit anonymous field name from StructOf type stringIan Lance Taylor
This makes the reflect package match the compiler for StructOf with an embedded field. Fixes #24781 Change-Id: Ice64b167cbe0b9d30a953c5d8e2a86f3ad1158bf Reviewed-on: https://go-review.googlesource.com/c/go/+/567897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-04-17internal/abi: define EmptyInterface, TypeOf, and NoEscapeMichael Anthony Knyszek
This change defines two commonly-defined functions and a commonly-defined type in internal/abi to try and deduplicate some definitions. This is motivated by a follow-up CL which will want access to TypeOf in yet another package. There still exist duplicate definitions of all three of these things in the runtime, and this CL doesn't try to handle that yet. There are far too many uses in the runtime to handle manually in a way that feels comfortable; automated refactoring will help. For #62483. Change-Id: I02fc64a28f11af618f6071f94d27f45c135fa8ac Reviewed-on: https://go-review.googlesource.com/c/go/+/573955 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2024-04-03reflect: add missing String case in Value.UnsafePointer docCuong Manh Le
CL 516596 changes Value.UnsafePointer to handle String case. However, the method's doc comment is not updated to reflect this change. Updates #61308 Change-Id: I84e02fd969ae0244184e1a2f05cac4651cdf7bff Reviewed-on: https://go-review.googlesource.com/c/go/+/575956 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02all: add reflect.SliceAt functionCuong Manh Le
Fixes #61308 Change-Id: Ic17d737fda055a60779985d5da497745c80d5cfa Reviewed-on: https://go-review.googlesource.com/c/go/+/516597 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-04-02reflect: handle String kind in Value.{Pointer,UnsafePointer}Cuong Manh Le
Updates #61308 Change-Id: I92d459383c520d137787ce5c8f135d205af74e5d Reviewed-on: https://go-review.googlesource.com/c/go/+/516596 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02reflect: add available godoc linkcui fliter
Change-Id: Ib199ce1a781e8e3a66d3dc8bda617e6bc30b290e Reviewed-on: https://go-review.googlesource.com/c/go/+/539578 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2024-04-02all: use kind* of abiqiulaidongfeng
For #59670 Change-Id: Id66e102f13e529dd041b68ce869026a56f0a1b9b GitHub-Last-Rev: 43aa9376f72bc02a9d86518cdc99494a6b2f8573 GitHub-Pull-Request: golang/go#65564 Reviewed-on: https://go-review.googlesource.com/c/go/+/562298 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Austin Clements <austin@google.com>
2024-03-04runtime: use .Pointers() instead of manual checkingPouriya
Change-Id: Ib78c1513616089f4942297cd17212b1b11871fd5 GitHub-Last-Rev: f97fe5b5bffffe25dc31de7964588640cb70ec41 GitHub-Pull-Request: golang/go#65819 Reviewed-on: https://go-review.googlesource.com/c/go/+/565515 Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-03-04reflect: clean up unnecessary comments for rtypeJes Cok
For consistency, this CL cleans up unnecessary comments, and moves these Overflow methods to exported area. For #60427 Change-Id: I14d4ffbc3552d31c211ea1e0b7a0f7090a4a8b89 GitHub-Last-Rev: acdc6ad51bd9ad60a34fdfa8f00a7652cbe34510 GitHub-Pull-Request: golang/go#66019 Reviewed-on: https://go-review.googlesource.com/c/go/+/567917 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: Michael Knyszek <mknyszek@google.com>
2024-02-28reflect: add Overflow methods to TypeJes Cok
This CL adds new methods synonymous with the method of the same name in reflect.Value to reflect.Type: OverflowComplex, OverflowFloat, OverflowInt, OverflowUint. Fixes #60427 Change-Id: I7a0bb35629e59a7429820f13fcd3a6f120194bc6 GitHub-Last-Rev: 26c11bcffe0f418e7d5c37e14587e738d5d939d6 GitHub-Pull-Request: golang/go#65955 Reviewed-on: https://go-review.googlesource.com/c/go/+/567296 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-27reflect: fix typo in commentguoguangwu
Change-Id: Ia8e666b128622391d72e42449c01c4e10f3c9e1e GitHub-Last-Rev: c74cf13b70772a965a14630108544a89690d1383 GitHub-Pull-Request: golang/go#65938 Reviewed-on: https://go-review.googlesource.com/c/go/+/566855 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-20cmd/compile/internal/reflectdata,reflect: merge MaxPtrmaskBytes const into ↵qiulaidongfeng
internal/abi For #59670 Change-Id: I5c0a463f54208db215683f11e6454d0178edda3c GitHub-Last-Rev: 6963f3c8fb9cf34cdc8dda7ee92a58c71ca65520 GitHub-Pull-Request: golang/go#64904 Reviewed-on: https://go-review.googlesource.com/c/go/+/553275 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: Michael Knyszek <mknyszek@google.com>
2024-02-17reflect: make Value.Comparable return true for nil interface valueJes Cok
Fixes #65718 Change-Id: I0b3edf9085f2d71f915bdf8ff9d312509b438c5f GitHub-Last-Rev: 9fb1ca1a631c648d1f38f75b1fcb2f878048706b GitHub-Pull-Request: golang/go#65750 Reviewed-on: https://go-review.googlesource.com/c/go/+/564795 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> 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>
2024-02-16reflect: use internal/abi itab typeKeith Randall
Change-Id: I4a40d9cda41d3601169ef0daf0f25fb1509bdcb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/549458 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-02-12reflect: optimize TypeFor for non-interface typesJoe Tsai
The reflect.Type.Elem method is somewhat slow, which is unfortunate since the reflect.TypeOf((*T)(nil)).Elem() trick is only needed if T is an interface. Optimize for concrete types by doing the faster reflect.TypeOf(v) call first and only falling back on the Elem method if needed. Performance: name old time/op new time/op delta TypeForString-24 9.10ns ± 1% 1.78ns ± 2% -80.49% (p=0.000 n=10+10) TypeForError-24 9.55ns ± 1% 9.78ns ± 1% +2.39% (p=0.000 n=10+9) Updates #60088 Change-Id: I2ae76988c9a3dbcbae10d2c19b55db3c8d4559bf Reviewed-on: https://go-review.googlesource.com/c/go/+/555597 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2024-01-26reflect: use MapMaxKeyBytes,MapMaxElemBytes,MapBucketCount of internal/abiqiulaidongfeng
For #59670 Change-Id: I63a6e2cfaf9eec03866ea61064164a059fc42bb2 GitHub-Last-Rev: a3aa46a36444b08382ddac79c10a064b314bd971 GitHub-Pull-Request: golang/go#64773 Reviewed-on: https://go-review.googlesource.com/c/go/+/550595 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-01-24reflect: fix isRegularMemory at case ArrayJes Cok
To match cmd/compile/internal/compare.IsRegularMemory, this CL adds code for empty arrays of comparable element type. Change-Id: I205fb9bfda60be6c9aac2d9098ed3f0eb51cd0fa GitHub-Last-Rev: 40db7ed510883633374895271145678a51418426 GitHub-Pull-Request: golang/go#65252 Reviewed-on: https://go-review.googlesource.com/c/go/+/558155 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2024-01-23reflect: delete TODO pass safe to packEface don't need to copy if safe==trueqiulaidongfeng
valueInterface not copy result in the follow incorrect behavior w1. x := ValueOf(&v).Elem() r1. iface := Value.Interface() w2. x.Set() or x.SetT() The write operation of W2 will be observed by the read operation of r1, but the existing behavior is not. The valueInterface in deepValueEqual can, in theory, pass safe==true to not copy the object, but there is no benchmark to indicate that the memory allocation has changed, maybe we don't actually need safe==true here. Change-Id: I55c423fd50adac8822a7fdbfe67af89ee223eace GitHub-Last-Rev: 4a6386709817f3ea6055711dd39d2694d58b3043 GitHub-Pull-Request: golang/go#64618 Reviewed-on: https://go-review.googlesource.com/c/go/+/548436 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> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
2024-01-23reflect: StructOf set abi.TFlagRegularMemoryqiulaidongfeng
Complete a TODO. Change-Id: I791d27266ccee69c371524e298120765f5736cf8 GitHub-Last-Rev: 8878003efa2f9f3d8609b88073c982d21ece774b GitHub-Pull-Request: golang/go#64617 Reviewed-on: https://go-review.googlesource.com/c/go/+/548435 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2023-12-30reflect: fix typo in type.goRenJiangdu
There is no 'of' relationships between float and string. This points to those interfaces with internal type float or string. Change-Id: I14449f00c192e0d3f8270b433ff508978b7fdf17 GitHub-Last-Rev: f301a8aa5294e7669361627c82b2978652cfc14b GitHub-Pull-Request: golang/go#64885 Reviewed-on: https://go-review.googlesource.com/c/go/+/552957 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Run-TryBot: qiulaidongfeng <2645477756@qq.com> Run-TryBot: Jorropo <jorropo.pgm@gmail.com>
2023-11-22internal/abi, runtime, reflect, cmd: merge maxZero const into internal/abiqiulaidongfeng
For #59670 Change-Id: If38a74ad067a3ea3ff551c0c25c8ef41abec114b GitHub-Last-Rev: fb1f2f3c9f320017627bc3342b061e1e7f6f7fad GitHub-Pull-Request: golang/go#64268 Reviewed-on: https://go-review.googlesource.com/c/go/+/543655 Run-TryBot: qiulaidongfeng <2645477756@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2023-11-21reflect, runtime: add reflect support for regABI on loong64Guoqi Chen
Update #40724 Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn> Change-Id: I0549fd1a2192ffb041034ff41bf0cc4be0b1662c Reviewed-on: https://go-review.googlesource.com/c/go/+/521784 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21reflect: tweak logic for 'case Array' in IsZeroJes Cok
For 'case Array' in IsZero, check 'v.flag&flagIndir == 0' in the first place, rename 'array' to 'typ' for consistency, and remove stale comment. Add line breaks for long sentence in isZero. Change-Id: Id06d01fd61eefd205bf4626e6b920ae82b459455 GitHub-Last-Rev: 7225ca3f7b55cbef58387365ed8f3ff104236a06 GitHub-Pull-Request: golang/go#64270 Reviewed-on: https://go-review.googlesource.com/c/go/+/543656 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Jes Cok <xigua67damn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-20src: a/an grammar fixesVille Skyttä
Change-Id: I179b50ae8e73677d4d408b83424afbbfe6aa17a1 GitHub-Last-Rev: 2e2d9c1e45556155d02db4df381b99f2d1bc5c0e GitHub-Pull-Request: golang/go#63478 Reviewed-on: https://go-review.googlesource.com/c/go/+/534015 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-11-19reflect: optimize Value.IsZero for struct typesqiulaidongfeng
For some types where the zero value is a value where all bits of this type are 0 optimize it. goos: windows goarch: amd64 pkg: reflect cpu: AMD Ryzen 7 7840HS w/ Radeon 780M Graphics │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ IsZero/StructInt_512-16 109.75n ± 0% 72.61n ± 1% -33.84% (p=0.000 n=12) Change-Id: I56de8b95f4d4482068960d6f38938763fa1caa90 GitHub-Last-Rev: c143f0cd7616cb3be52c59879f748e49a3c5cbf1 GitHub-Pull-Request: golang/go#64220 Reviewed-on: https://go-review.googlesource.com/c/go/+/543355 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2023-11-16reflect: uncomment allocation testCherry Mui
We no longer force Value content to escape and the compiler's escape analysis can handle it now. Change-Id: I0628f3241e6ef37dce710c2394725e280790479a Reviewed-on: https://go-review.googlesource.com/c/go/+/542975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2023-11-16reflect: remove go121noForceValueEscapeCherry Mui
Before Go 1.21, ValueOf always escapes and a Value's content is always heap allocated. In Go 1.21, we made it no longer always escape, guarded by go121noForceValueEscape. This behavior has been released for some time and there is no issue so far. We can remove the guard now. Change-Id: I81f5366412390f6c63b642f4c7c016da534da76a Reviewed-on: https://go-review.googlesource.com/c/go/+/542795 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-16runtime: optimize bulkBarrierPreWrite with allocheadersMichael Anthony Knyszek
Currently bulkBarrierPreWrite follows a fairly slow path wherein it calls typePointersOf, which ends up calling into fastForward. This does some fairly heavy computation to move the iterator forward without any assumptions about where it lands at all. It needs to be completely general to support splitting at arbitrary boundaries, for example for scanning oblets. This means that copying objects during the GC mark phase is fairly expensive, and is a regression from before allocheaders. However, in almost all cases bulkBarrierPreWrite and bulkBarrierPreWriteSrcOnly have perfect type information. We can do a lot better in these cases because we're starting on a type-size boundary, which is exactly what the iterator is built around. This change adds the typePointersOfType method which produces a typePointers iterator from a pointer and a type. This change significantly improves the performance of these bulk write barriers, eliminating some performance regressions that were noticed on the perf dashboard. There are still just a couple cases where we have to use the more general typePointersOf calls, but they're fairly rare; most bulk barriers have perfect type information. This change is tested by the GCInfo tests in the runtime and the GCBits tests in the reflect package via an additional check in getgcmask. Results for tile38 before and after allocheaders. There was previous a regression in the p90, now it's gone. Also, the overall win has been boosted slightly. tile38 $ benchstat noallocheaders.results allocheaders.results name old time/op new time/op delta Tile38QueryLoad 481µs ± 1% 468µs ± 1% -2.71% (p=0.000 n=10+10) name old average-RSS-bytes new average-RSS-bytes delta Tile38QueryLoad 6.32GB ± 1% 6.23GB ± 0% -1.38% (p=0.000 n=9+8) name old peak-RSS-bytes new peak-RSS-bytes delta Tile38QueryLoad 6.49GB ± 1% 6.40GB ± 1% -1.38% (p=0.002 n=10+10) name old peak-VM-bytes new peak-VM-bytes delta Tile38QueryLoad 7.72GB ± 1% 7.64GB ± 1% -1.07% (p=0.007 n=10+10) name old p50-latency-ns new p50-latency-ns delta Tile38QueryLoad 212k ± 1% 205k ± 0% -3.02% (p=0.000 n=10+9) name old p90-latency-ns new p90-latency-ns delta Tile38QueryLoad 622k ± 1% 616k ± 1% -1.03% (p=0.005 n=10+10) name old p99-latency-ns new p99-latency-ns delta Tile38QueryLoad 4.55M ± 2% 4.39M ± 2% -3.51% (p=0.000 n=10+10) name old ops/s new ops/s delta Tile38QueryLoad 12.5k ± 1% 12.8k ± 1% +2.78% (p=0.000 n=10+10) Change-Id: I0a48f848eae8777d0fd6769c3a1fe449f8d9d0a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/542219 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15reflect: optimize Value.IsZero for array typesqiulaidongfeng
For some types where the zero value is a value where all bits of this type are 0 optimize it goos: windows goarch: amd64 pkg: reflect cpu: AMD Ryzen 7 7840HS w/ Radeon 780M Graphics │ std.txt │ new.txt │ │ sec/op │ sec/op vs base │ IsZero/ArrayComparable-16 8.483n ± 0% 8.470n ± 2% ~ (p=0.542 n=10) IsZero/ArrayIncomparable-16 88.13n ± 1% 87.34n ± 2% ~ (p=0.110 n=10) IsZero/StructComparable-16 4.050n ± 2% 4.011n ± 1% ~ (p=0.093 n=10) IsZero/StructIncomparable-16 19.93n ± 1% 19.81n ± 1% ~ (p=0.493 n=10) IsZero/ArrayInt_4-16 4.445n ± 2% 4.478n ± 2% ~ (p=0.306 n=10) IsZero/ArrayInt_1024-16 3381.5n ± 3% 140.8n ± 1% -95.84% (p=0.000 n=10) IsZero/ArrayInt_1024_NoZero-16 1760.50n ± 3% 72.17n ± 1% -95.90% (p=0.000 n=10) IsZero/Struct4Int-16 4.495n ± 3% 4.478n ± 1% ~ (p=0.579 n=10) IsZero/ArrayStruct4Int_1024-16 1404.0n ± 3% 140.5n ± 0% -90.00% (p=0.000 n=10) IsZero/ArrayChanInt_1024-16 3437.0n ± 6% 140.5n ± 1% -95.91% (p=0.000 n=10) geomean 89.94n 27.38n -69.56% Change-Id: I835231a79b9cd89686d44c5b8c2fbe629ccd98ba GitHub-Last-Rev: 3abe118a108faf0070b56ba9098871746daa1ac1 GitHub-Pull-Request: golang/go#63661 Reviewed-on: https://go-review.googlesource.com/c/go/+/536855 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2023-11-09runtime: implement experiment to replace heap bitmap with alloc headersMichael Anthony Knyszek
This change replaces the 1-bit-per-word heap bitmap for most size classes with allocation headers for objects that contain pointers. The header consists of a single pointer to a type. All allocations with headers are treated as implicitly containing one or more instances of the type in the header. As the name implies, headers are usually stored as the first word of an object. There are two additional exceptions to where headers are stored and how they're used. Objects smaller than 512 bytes do not have headers. Instead, a heap bitmap is reserved at the end of spans for objects of this size. A full word of overhead is too much for these small objects. The bitmap is of the same format of the old bitmap, minus the noMorePtrs bits which are unnecessary. All the objects <512 bytes have a bitmap less than a pointer-word in size, and that was the granularity at which noMorePtrs could stop scanning early anyway. Objects that are larger than 32 KiB (which have their own span) have their headers stored directly in the span, to allow power-of-two-sized allocations to not spill over into an extra page. The full implementation is behind GOEXPERIMENT=allocheaders. The purpose of this change is performance. First and foremost, with headers we no longer have to unroll pointer/scalar data at allocation time for most size classes. Small size classes still need some unrolling, but their bitmaps are small so we can optimize that case fairly well. Larger objects effectively have their pointer/scalar data unrolled on-demand from type data, which is much more compactly represented and results in less TLB pressure. Furthermore, since the headers are usually right next to the object and where we're about to start scanning, we get an additional temporal locality benefit in the data cache when looking up type metadata. The pointer/scalar data is now effectively unrolled on-demand, but it's also simpler to unroll than before; that unrolled data is never written anywhere, and for arrays we get the benefit of retreading the same data per element, as opposed to looking it up from scratch for each pointer-word of bitmap. Lastly, because we no longer have a heap bitmap that spans the entire heap, there's a flat 1.5% memory use reduction. This is balanced slightly by some objects possibly being bumped up a size class, but most objects are not tightly optimized to size class sizes so there's some memory to spare, making the header basically free in those cases. See the follow-up CL which turns on this experiment by default for benchmark results. (CL 538217.) Change-Id: I4c9034ee200650d06d8bdecd579d5f7c1bbf1fc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/437955 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>