aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/reflectdata
AgeCommit message (Collapse)Author
2023-02-17Revert "cmd/compile: use ONAME node directly from generated hash func"Matthew Dempsky
This reverts commit 25f5d9d4a253cb880bff909ebbdc05c8941c4a48. Causes ICE on valid code. Updates #58572. Change-Id: Ib276c87d9b0362bbd2a760ac2a242f82d4e20400 Reviewed-on: https://go-review.googlesource.com/c/go/+/468879 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-09cmd/compile: remove reflectdata.AfterGlobalEscapeAnalysisCuong Manh Le
This global variable was used by the old frontend to decide whether to perform escape analysis during method wrapper generation. The old frontend is gone now, the variable is not used anywhere else. Change-Id: I448f2761ea608a9a2ec39a9920fcf7aa12d98799 Reviewed-on: https://go-review.googlesource.com/c/go/+/466278 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-04cmd/compile: use ONAME node directly from generated hash funcCuong Manh Le
Same as CL 436436, but for hashfor. However, this passes toolstash-check, because the order of compiling functions do not change. Change-Id: Icc7d042e9c28b0fe4bb40a2b98b7f60cf3549bd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/436961 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-02-04cmd/compile: factor out code to generate hash funcCuong Manh Le
Passes toolstash-check. Change-Id: I86a078ffc5948cbcbec84ce8012f3dfb1c2269b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/436960 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2023-02-04cmd/compile: use runtime hash func for known typesCuong Manh Le
Those functions are defined in package runtime already, so just use them instead of creating ONAME nodes with nil Func. Change-Id: If29814a5254793c578c15b70f9c194b7414911d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/436959 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-02-04cmd/compile: use memhash from package runtimeCuong Manh Le
Simplify the code, and prevent creating ONAME node with nil Func. Passes toolstash-check. Change-Id: I5e5be660510dc0ef5521d278c6b9214a80b994eb Reviewed-on: https://go-review.googlesource.com/c/go/+/436958 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-02-04cmd/compile: generate type equal func during walkCuong Manh Le
So we don't generate ONAME node with nil Func. Do not pass toolstash-check because the CL changes the order of compiling functions. Change-Id: Ib967328f36b8c59a5525445667103c0c80ccdc82 Reviewed-on: https://go-review.googlesource.com/c/go/+/436436 Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-02-04cmd/compile: factor out code to generate equal funcCuong Manh Le
So next CL can use it for generating equal func during walk compare. Passes toolstash-check. Change-Id: I76545c1d471eb496be352908db1b05feae83fc33 Reviewed-on: https://go-review.googlesource.com/c/go/+/436435 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-01-26cmd/compile/internal/types: remove Markdcl/Pushdcl/PopdclMatthew Dempsky
Sym.Def used to be used for symbol resolution during the old (pre-types2) typechecker. But since moving to types2-based IR construction, we haven't really had a need for Sym.Def to ever refer to anything but the package-scope definition, because types2 handles symbol resolution for us. This CL finally removes the Markdcl/Pushdcl/Popdcl functions that have been a recurring source of issues in the past. Change-Id: I2b012a0f17203efdd724ebd1e9314bd128cc2d61 Reviewed-on: https://go-review.googlesource.com/c/go/+/458625 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-26cmd/compile/internal/types: remove unneeded functionalityMatthew Dempsky
This CL removes a handful of features that were only needed for the pre-unified frontends. In particular, Type.Pkg was a hack for iexport so that go/types.Var.Pkg could be precisely populated for struct fields and signature parameters by gcimporter, but it's no longer necessary with the unified export data format because we now write export data directly from types2-supplied type descriptors. Several other features (e.g., OrigType, implicit interfaces, type parameters on signatures) are no longer relevant to the unified frontend, because it only uses types1 to represent instantiated generic types. Updates #57410. Change-Id: I84fd1da5e0b65d2ab91d244a7bb593821ee916e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/458622 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26cmd/compile/internal/types: remove TTYPEPARAM and TUNION typesMatthew Dempsky
These were used by the nounified frontend for representing uninstantiated generic types; however, the unified frontend only needs types1 to represent instantiated types. Updates #57410. Change-Id: Iac417fbf2b86f4e08bd7fdd26ae8ed17395ce833 Reviewed-on: https://go-review.googlesource.com/c/go/+/458621 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26cmd/compile: remove GOEXPERIMENT=nounified frontendMatthew Dempsky
This CL removes most of the code specific to the nounified frontend. To simplify review, it's a strict remove-only CL. Updates #57410. Change-Id: Ic3196570aa4286618c1d5e7fd0d0e6601a18195b Reviewed-on: https://go-review.googlesource.com/c/go/+/458620 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2023-01-25cmd: remove GOEXPERIMENT=nounified knobMatthew Dempsky
This CL removes the GOEXPERIMENT=nounified knob, and any conditional statements that depend on that knob. Further CLs to remove unreachable code follow this one. Updates #57410. Change-Id: I39c147e1a83601c73f8316a001705778fee64a91 Reviewed-on: https://go-review.googlesource.com/c/go/+/458615 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-23internal/abi,runtime: refactor map constants into one placeDavid Chase
Previously TryBot-tested with bucket bits = 4. Also tested locally with bucket bits = 5. This makes it much easier to change the size of map buckets, and hopefully provides pointers to all the code that in some way depends on details of map layout. Change-Id: I9f6669d1eadd02f182d0bc3f959dc5f385fa1683 Reviewed-on: https://go-review.googlesource.com/c/go/+/462115 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Austin Clements <austin@google.com>
2022-11-16cmd/compile: do not emit a few more basic types from every compilationRuss Cox
We already emit types for any and func(error) string in runtime.a but unlike the other pre-emitted types, we don't then exclude them from being emitted in other packages. Fix that. Also add slices of non-func types that we already emit. Saves 0.3% of .a files in std cmd deps, computed by adding sizes from: ls -l $(go list -export -f '{{.Export}}' -deps std cmd The effect is small and not worth doing on its own. The real improvement is making “what to write always in runtime” and “what not to write in other packages” more obviously aligned. Change-Id: Ie5cb5fd7e5a3025d2776d9b4cece775fdf92d3b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/450135 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
2022-10-31cmd/compile/internal/pgo: remove most global stateMichael Pratt
Since pgo is a new package, it is reasonably straightforward to encapsulate its state into a non-global object that we pass around, which will help keep it isolated. There are no functional changes in this CL, just packaging up the globals into a new object. There are two major pieces of cleanup remaining: 1. reflectdata and noder have separate InlineCalls calls for method wrappers. The Profile is not plumbed there yet, but this is not a regression as the globals were previously set only right around the main inlining pass in gc.Main. 2. pgo.ListOfHotCallSites is still global, as it will require more work to clean up. It is effectively a local variable in InlinePackage, except that it assumes that InlineCalls is immediately preceded by a CanInline call for the same function. This is not necessarily true due to the recursive nature of CanInline. This also means that some InlineCalls calls may be missing the list of hot callsites right now. For #55022. Change-Id: Ic1fe41f73df96861c65f8bfeecff89862b367290 Reviewed-on: https://go-review.googlesource.com/c/go/+/446303 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com>
2022-09-02cmd/compile: new inline heuristic for struct comparesDerek Parker
This CL changes the heuristic used to determine whether we can inline a struct equality check or if we must generate a function and call that function for equality. The old method was to count struct fields, but this can lead to poor in lining decisions. We should really be determining the cost of the equality check and use that to determine if we should inline or generate a function. The new benchmark provided in this CL returns the following when compared against tip: ``` name old time/op new time/op delta EqStruct-32 2.46ns ± 4% 0.25ns ±10% -89.72% (p=0.000 n=39+39) ``` Fixes #38494 Change-Id: Ie06b80a2b2a03a3fd0978bcaf7715f9afb66e0ab GitHub-Last-Rev: e9a18d93893cc6493794683bf75b9848478a4de6 GitHub-Pull-Request: golang/go#53326 Reviewed-on: https://go-review.googlesource.com/c/go/+/411674 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-30cmd/compile: only inline method wrapper if method don't contain closuresCuong Manh Le
CL 327871 changes methodWrapper to always perform inlining after global escape analysis. However, inlining the method may reveal closures, which require walking all function bodies to decide whether to capture free variables by value or by ref. To fix it, just not doing inline if the method contains any closures. Fixes #53702 Change-Id: I4b0255b86257cc6fe7e5fafbc545cc5cff9113e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/426334 Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-16runtime: process ptr bitmaps one word at a timeKeith Randall
[This is a retry of CL 407036 + its revert CL 422394. The only content change is the 1-line change in cmd/internal/obj/objfile.go.] Read the bitmaps one uintptr at a time instead of one byte at a time. Performance so far: Allocation heavy, no retention: ~30% faster in heapBitsSetType Scan heavy, ~no allocation: ~even in scanobject Change-Id: I04d899e1dbd23e989e9f552cdc1880318779c14c Reviewed-on: https://go-review.googlesource.com/c/go/+/422635 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-10cmd/compile: do not use content addressable symbol for generic iface method ↵Cherry Mui
names When a generic interface method is used, we use a special relocation R_USEGENERICIFACEMETHOD to tell the linker the name of the generic interface method, so it can keep methods with that name live. The relocation references a symbol whose content is the name. Currently this is a string symbol, which is content addessable and may have trailing zero bytes (for better deduplication). The trailing bytes can cause confusion for the linker. This symbol doesn't need to be in the final binary and doesn't need to be deduplicated with other symbol. So we don't use content addressable symbol but make an (unnamed) symbol specifically for this. May fix #54346. Change-Id: If0c34f7844c3553a7be3846b66cf1c103bc231c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/422300 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-09Revert "runtime: process ptr bitmaps one word at a time"Keith Randall
This reverts commit c3833a55433f4b2981253f64444fe5c3d1bc910a. Reason for revert: Bug somewhere in this code, causing wasm and maybe linux/386 to fail. Change-Id: I05f7cfa467598ca0c2c84fd4f752cc4ef117cc51 Reviewed-on: https://go-review.googlesource.com/c/go/+/422394 Run-TryBot: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-09all: use ":" for compiler generated symbolsCuong Manh Le
As it can't appear in user package paths. There is a hack for handling "go:buildid" and "type:*" on windows/386. Previously, windows/386 requires underscore prefix on external symbols, but that's only applied for SHOSTOBJ/SUNDEFEXT or cgo export symbols. "go.buildid" is STEXT, "type.*" is STYPE, thus they are not prefixed with underscore. In external linking mode, the external linker can't resolve them as external symbols. But we are lucky that they have "." in their name, so the external linker see them as Forwarder RVA exports. See: - https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/pe-dll.c;h=e7b82ba6ffadf74dc1b9ee71dc13d48336941e51;hb=HEAD#l972) This CL changes "." to ":" in symbols name, so theses symbols can not be found by external linker anymore. So a hacky way is adding the underscore prefix for these 2 symbols. I don't have enough knowledge to verify whether adding the underscore for all STEXT/STYPE symbols are fine, even if it could be, that would be done in future CL. Fixes #37762 Change-Id: I92eaaf24c0820926a36e0530fdb07b07af1fcc35 Reviewed-on: https://go-review.googlesource.com/c/go/+/317917 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-08cmd/compile: rename types.Rnd -> types.RoundUpCuong Manh Le
Base on gri@'s suggestion in CL 308971. "Rnd" is a bit random. Change-Id: I4aad8b7992b31dfd26d20b3c332bc6e1e90f67db Reviewed-on: https://go-review.googlesource.com/c/go/+/422036 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-08runtime: process ptr bitmaps one word at a timeKeith Randall
Read the bitmaps one uintptr at a time instead of one byte at a time. Performance so far: Allocation heavy, no retention: ~30% faster in heapBitsSetType Scan heavy, ~no allocation: ~even in scanobject Change-Id: I40d492b50d7f89d1b4261c2de58f6d255fa5e93e Reviewed-on: https://go-review.googlesource.com/c/go/+/407036 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-07-19[dev.unified] cmd/compile/internal/reflectdata: remove hasRType's `required` ↵Matthew Dempsky
param Unified IR now always provides RTTI needed by the backend, no need to allow exceptions anymore. 🥳 Change-Id: Ie1ba42c81f92cc43e1b01b3289de10e261ccef57 Reviewed-on: https://go-review.googlesource.com/c/go/+/415576 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-07-18[dev.unified] cmd/compile/internal/reflectdata: prefer ITabAddrAt in ↵Matthew Dempsky
ConvIfaceTypeWord We already have an explicit `pos` parameter, so we should use ITabAddrAt instead of ITabAddr (which uses `base.Pos` instead). Change-Id: I7c8c5ae93d0ae7a6467cc972575cb547981576f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/415578 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: rename haveRType and implicitExprMatthew Dempsky
This CL renames: 1. "haveRType" to "hasRType", suggested by drchase@ during review of CL 413358; and 2. "implicitExpr" to "implicitConvExpr", suggested by khr@ during review of CL 413396. Change-Id: Ibb4deae20908d960706640991ea44d1b9c0b9e3c Reviewed-on: https://go-review.googlesource.com/c/go/+/413854 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-06-23[dev.unified] cmd/compile: plumb rtype through OSWITCH/OCASE clausesMatthew Dempsky
For (value) switch statements, we may generate OEQ comparisons between values of interface and concrete type, which in turn may require access to the concrete type's RType. To plumb this through, this CL adds CaseClause.RTypes to hold the rtype values, updates the GOEXPERIMENT=unified frontend to set it, and updates walk to plumb rtypes through into generated OEQ nodes. Change-Id: I6f1de2a1167ce54f5770147498a0a591efb3f012 Reviewed-on: https://go-review.googlesource.com/c/go/+/413361 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: plumb rtype through for OMAPLITMatthew Dempsky
OMAPLIT gets lowered into a bunch of OINDEXMAP operations, which in general may require a *runtime._type argument. This CL adds CompLitExpr.RType, updates the GOEXPERIMENT=unified frontend to start setting it, and updates walk to propagate it through to any generated OINDEXMAP operations. Change-Id: I278e7e8e615ea6d01f65a5eba6d6fc8e00045735 Reviewed-on: https://go-review.googlesource.com/c/go/+/413360 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: start setting RType fields for Unified IRMatthew Dempsky
This CL switches the GOEXPERIMENT=unified frontend to set RType fields in the simpler cases, and to make it fatal if they're missing. Subsequent CLs will handle the remaining more complex cases (e.g., expressions from later desugaring, and implicit conversions to interface type). Change-Id: If6257dcb3916905afd9b8371ea64b85f108ebbfb Reviewed-on: https://go-review.googlesource.com/c/go/+/413359 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-06-23[dev.unified] cmd/compile: add RType fieldsMatthew Dempsky
This CL adds RType/ITab fields to IR nodes that (may) ultimately become runtime calls that require a *runtime._type or *runtime.itab argument. It also updates the corresponding reflectdata IR helpers to use these fields in preference of calling TypePtr/ITabAddr. Subsequent CLs will start updating the GOEXPERIMENT=unified frontend to set the RType fields, and incrementally switch the reflectdata helpers to require them. Passes toolstash -cmp. Change-Id: I30e31d91f0a53961e3d6d872d7b5f9df2ec5074c Reviewed-on: https://go-review.googlesource.com/c/go/+/413358 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-06-21[dev.unified] cmd/compile: extract rtype code from walkMatthew Dempsky
This CL removes (almost*) all reflectdata.{TypePtr,ITabAddr} calls from package walk. This will allow us to next start adding RType/ITab fields to IR nodes directly, and have the helpers start returning them when available instead. The one survining ITabAddr call is due to ODOTTYPE{,2}, but we already have ODYNAMICDOTTYPE{,2}, which I plan to have Unified IR always use. (Longer term, once the Go 1.18 frontend is gone, we can get rid of ODOTTYPE*, and rename ODYNAMICDOTTYPE*.) Passes toolstash -cmp. Change-Id: I5e00da06a93d069abf383d7628e692dd7fd2a1c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/413356 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-21[dev.unified] cmd/compile: refactor reflectdata.{TypePtr,ITabAddr}Matthew Dempsky
Minor refactoring to decouple from base.Pos and deduplicate some common code paths. Passes toolstash -cmp. Change-Id: I8c0724cf821d28b0ede3b0e8e4b2d02302d9af3b Reviewed-on: https://go-review.googlesource.com/c/go/+/413355 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-06-14cmd/compile,runtime,reflect: move embedded bit from offset to nameKeith Randall
Previously we stole a bit from the field offset to encode whether a struct field was embedded. Instead, encode that bit in the name field, where we already have some unused bits to play with. The bit associates naturally with the name in any case. This leaves a full uintptr to specify field offsets. This will make the fix for #52740 cleaner. Change-Id: I0bfb85564dc26e8c18101bc8b432f332176d7836 Reviewed-on: https://go-review.googlesource.com/c/go/+/412138 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-05-17all: fix spellingJohn Bampton
Change-Id: Iee18987c495d1d4bde9da888d454eea8079d3ebc GitHub-Last-Rev: ff5e01599ddf7deb3ab6ce190ba92eb02ae2cb15 GitHub-Pull-Request: golang/go#52949 Reviewed-on: https://go-review.googlesource.com/c/go/+/406915 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-17cmd/compile: skip exporting generic functions for -buildmode=pluginMatthew Dempsky
Generic functions require instantiation, which package plugin doesn't support, and likely never will. So instead, we can just skip writing out any generic functions, which avoids an ICE in the plugin generation code. This issue doesn't affect GOEXPERIMENT=unified, because it avoids leaking any non-instantiated types/functions to the rest of the compiler backend. Fixes #52937. Change-Id: Ie35529c5c241e46b77fcb5b8cca48bb99ce7bfcb Reviewed-on: https://go-review.googlesource.com/c/go/+/406358 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-16cmd/compile: set LocalPkg.Path to -p flagMatthew Dempsky
Since CL 391014, cmd/compile now requires the -p flag to be set the build system. This CL changes it to initialize LocalPkg.Path to the provided path, rather than relying on writing out `"".` into object files and expecting cmd/link to substitute them. However, this actually involved a rather long tail of fixes. Many have already been submitted, but a few notable ones that have to land simultaneously with changing LocalPkg: 1. When compiling package runtime, there are really two "runtime" packages: types.LocalPkg (the source package itself) and ir.Pkgs.Runtime (the compiler's internal representation, for synthetic references). Previously, these ended up creating separate link symbols (`"".xxx` and `runtime.xxx`, respectively), but now they both end up as `runtime.xxx`, which causes lsym collisions (notably inittask and funcsyms). 2. test/codegen tests need to be updated to expect symbols to be named `command-line-arguments.xxx` rather than `"".foo`. 3. The issue20014 test case is sensitive to the sort order of field tracking symbols. In particular, the local package now sorts to its natural place in the list, rather than to the front. Thanks to David Chase for helping track down all of the fixes needed for this CL. Updates #51734. Change-Id: Iba3041cf7ad967d18c6e17922fa06ba11798b565 Reviewed-on: https://go-review.googlesource.com/c/go/+/393715 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-13cmd/compile: sort named types before unnamed in reflectDavid Chase
When the local package has an explicit name instead of "", this is necessary to get past a cgo plugin test that fails because of a package signature mismatch. There's something questionable going on in the package hash generation, and in particular it went wrong here. Updating the sort order helps. This CL is a prerequisite for a pending code cleanup, https://go-review.googlesource.com/c/go/+/393715 Updates #51734. The failure: GOROOT/misc/cgo/testplugin$ go test . mkdir -p $TMPDIR/src/testplugin rsync -a testdata/ $TMPDIR/src/testplugin echo 'module testplugin' > $TMPDIR/src/testplugin/go.mod mkdir -p $TMPDIR/alt/src/testplugin rsync -a altpath/testdata/ $TMPDIR/alt/src/testplugin echo 'module testplugin' > $TMPDIR/alt/src/testplugin/go.mod cd $TMPDIR/alt/src/testplugin ( PWD=$TMPDIR/alt/src/testplugin GOPATH=$TMPDIR/alt go build -gcflags '' -buildmode=plugin -o $TMPDIR/src/testplugin/plugin-mismatch.so ./plugin-mismatch ) cd $TMPDIR/src/testplugin ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -buildmode=plugin ./plugin1 ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -buildmode=plugin ./plugin2 ) cp plugin2.so plugin2-dup.so ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -buildmode=plugin -o=sub/plugin1.so ./sub/plugin1 ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -buildmode=plugin -o=unnamed1.so ./unnamed1/main.go ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -buildmode=plugin -o=unnamed2.so ./unnamed2/main.go ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go build -gcflags '' -o host.exe ./host ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go run -gcflags '' ./checkdwarf/main.go plugin2.so plugin2.UnexportedNameReuse ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin go run -gcflags '' ./checkdwarf/main.go ./host.exe main.main ) ( PWD=$TMPDIR/src/testplugin GOPATH=$TMPDIR LD_LIBRARY_PATH=$TMPDIR/src/testplugin ./host.exe ) --- FAIL: TestRunHost (0.02s) plugin_test.go:187: ./host.exe: exit status 1 2022/05/13 11:26:37 plugin.Open failed: plugin.Open("plugin1"): plugin was built with a different version of package runtime and many more after that. Change-Id: I0780decc5bedeea640ed0b3710867aeda5b3f725 Reviewed-on: https://go-review.googlesource.com/c/go/+/405995 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-05-05cmd/compile: construct ir.FuncType within typecheck.DeclFuncMatthew Dempsky
Currently all typecheck.DeclFunc callers already construct a fresh new ir.FuncType, which is the last type expression kind that we represent in IR. This CL pushes all of the ir.FuncType construction down into typecheck.DeclFunc. The next CL will simplify the internals so that we can get rid of ir.FuncType altogether. Change-Id: I221ed324f157eb38bb57c8886609f53cc4fd99fe Reviewed-on: https://go-review.googlesource.com/c/go/+/403848 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-05cmd/compile: remove ir.NewField's ntyp parameterMatthew Dempsky
ir.NewField is always called with ntyp as nil. Change-Id: Iccab4ce20ae70d056370a6469278e68774e685f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/403834 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-03cmd/compile: mark shape type dupokzhouguangyuan
Fixes #52633 Change-Id: I3f19804cd7c00cee7e365062402c264d84b596c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/403316 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: guangyuan zhou <zhouguangyuan@golangcn.org>
2022-04-21cmd/compile: Unify & improve struct comparisonsDerek Parker
Partially fixes https://github.com/golang/go/issues/38674 The first commit has the actual unification, the second commit just cleans things up by moving shared code into its own package for clarity. Change-Id: I85067f8b247df02f94684ec1297a1a42263bba0c GitHub-Last-Rev: 370a4ecad315f945b62195f8daddca693345a0c7 GitHub-Pull-Request: golang/go#52315 Reviewed-on: https://go-review.googlesource.com/c/go/+/399542 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12cmd/compile: always write fun[0] in incomplete itabWayne Zuo
runtime.getitab need filled fun[0] to identify whether implemented the interface. Fixes #51700 Fixes #52228 Change-Id: I0173b98f4e1b45e3a0183a5b60229d289140d1e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/399058 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05reflectdata: unroll a loop in array equal function generationvpachkov
As josharian mentioned, a compare function could benefit from unrolling a loop for arrays. This commit introduces such functionality. name old time/op new time/op delta EqArrayOfStrings5-12 12.5ns ± 1% 8.4ns ± 1% -33.05% (p=0.008 n=5+5) EqArrayOfStrings64-12 71.7ns ± 1% 64.1ns ± 1% -10.57% (p=0.008 n=5+5) EqArrayOfStrings1024-12 1.12µs ± 1% 1.01µs ± 0% -9.77% (p=0.008 n=5+5) [Geo mean] 100ns 81ns -18.56% name old time/op new time/op delta EqArrayOfFloats5-12 4.50ns ± 2% 3.32ns ± 1% -26.09% (p=0.008 n=5+5) EqArrayOfFloats64-12 41.3ns ± 1% 35.7ns ± 0% -13.63% (p=0.016 n=5+4) EqArrayOfFloats1024-12 619ns ± 1% 557ns ± 1% -9.95% (p=0.008 n=5+5) [Geo mean] 48.6ns 40.4ns -16.85% Change-Id: If1b69c5cf3fb246bb0275a292118b0b93ad9c9a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/368614 Reviewed-by: Keith Randall <khr@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-01all: fix various doc comment formatting nitsRuss Cox
A run of lines that are indented with any number of spaces or tabs format as a <pre> block. This commit fixes various doc comments that format badly according to that (standard) rule. For example, consider: // - List item. // Second line. // - Another item. Because the - lines are unindented, this is actually two paragraphs separated by a one-line <pre> block. This CL rewrites it to: // - List item. // Second line. // - Another item. Today, that will format as a single <pre> block. In a future release, we hope to format it as a bulleted list. Various other minor fixes as well, all in preparation for reformatting. For #51082. Change-Id: I95cf06040d4186830e571cd50148be3bf8daf189 Reviewed-on: https://go-review.googlesource.com/c/go/+/384257 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23cmd/compile: don't mark non-generic defined type symbol dupokCherry Mui
For a non-generic defined type, we generate its type descriptor symbol only in the defining package. So there is no duplicate and it doesn't need to be dupok. For unnamed types and instantiated types, the type descriptor can be generated in multiple packages and so still need to be dupok. Change-Id: I92ed68c998ad68c5917b77b1dfd62eac4ced6bcf Reviewed-on: https://go-review.googlesource.com/c/go/+/394636 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-21cmd/compile: replace Type.OrigSym with Type.OrigTypeMatthew Dempsky
First law of cmd/compile frontend development: thou shalt not rely on types.Sym. This CL replaces Type.OrigSym with Type.OrigType, which semantically matches what all of the uses within the frontend actually care about, and avoids using types.Sym, which invariably leads to mistakes because symbol scoping in the frontend doesn't work how anyone intuitively expects it to. Fixes #51765. Change-Id: I4affe6ee0718103ce5006ab68aa7e1bb0cac6881 Reviewed-on: https://go-review.googlesource.com/c/go/+/394274 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-03-07cmd/compile: represent derived types with ir.DynamicType in unified IRMatthew Dempsky
This CL switches unified IR to using ir.DynamicType for derived types. This has an immediate effect of fixing compilation of generic code that when fully stenciled results in statically invalid type assertions. This does require updating typecheck to expect ODYNAMICTYPE in type switches, but this is straightforward to implement. For now, we still statically resolve the runtime type (or itab) pointer. However, a subsequent CL will allow reading these pointers from the runtime dictionary. Change-Id: I1666678fcc588bc9cb8b97871bd02b9059848e6d Reviewed-on: https://go-review.googlesource.com/c/go/+/390336 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>