aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-04-20 08:55:12 -0700
committerGopher Robot <gobot@golang.org>2023-04-27 21:12:07 +0000
commit635839a17aeb086b3e1eeba73973aac6ccdb8df2 (patch)
tree539dbe6448b13280da119f03c3ff825caedfe70a /src/cmd/internal
parent3a7806d387e8dc62a327ce9d2c7a3ea913f1efde (diff)
downloadgo-635839a17aeb086b3e1eeba73973aac6ccdb8df2.tar.xz
cmd/compile: constant-fold loads from constant dictionaries and types
Update #59591 Change-Id: Id250a7779c5b53776fff73f3e678fec54d92a8e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/486895 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/obj/link.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index b50305f85c..74eb98520a 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -465,7 +465,7 @@ type LSym struct {
P []byte
R []Reloc
- Extra *interface{} // *FuncInfo or *FileInfo, if present
+ Extra *interface{} // *FuncInfo, *FileInfo, or *TypeInfo, if present
Pkg string
PkgIdx int32
@@ -564,6 +564,22 @@ func (s *LSym) File() *FileInfo {
return f
}
+// A TypeInfo contains information for a symbol
+// that contains a runtime._type.
+type TypeInfo struct {
+ Type interface{} // a *cmd/compile/internal/types.Type
+}
+
+func (s *LSym) NewTypeInfo() *TypeInfo {
+ if s.Extra != nil {
+ panic(fmt.Sprintf("invalid use of LSym - NewTypeInfo with Extra of type %T", *s.Extra))
+ }
+ t := new(TypeInfo)
+ s.Extra = new(interface{})
+ *s.Extra = t
+ return t
+}
+
// WasmImport represents a WebAssembly (WASM) imported function with
// parameters and results translated into WASM types based on the Go function
// declaration.