]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types: remove Type.vargen
authorMatthew Dempsky <mdempsky@google.com>
Tue, 12 Sep 2023 01:50:26 +0000 (18:50 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 12 Sep 2023 15:41:17 +0000 (15:41 +0000)
The unified frontend diasmbiguates local types by putting vargen
directly into their symbol name instead. We no longer need a separate
int field for it.

Change-Id: I556c588ed68c5e2cb324cd46abd934894b5aaef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527517
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/types/fmt.go
src/cmd/compile/internal/types/sizeof_test.go
src/cmd/compile/internal/types/type.go

index 4f27baeab7c45ced6bf29a31381e5625c442676e..c9b9853f78d8f7a84cd35237b3c4721b837d2cd8 100644 (file)
@@ -319,14 +319,6 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
                        }
                }
                sconv2(b, sym, verb, mode)
-
-               // TODO(mdempsky): Investigate including Vargen in fmtTypeIDName
-               // output too. It seems like it should, but that mode is currently
-               // used in string representation used by reflection, which is
-               // user-visible and doesn't expect this.
-               if mode == fmtTypeID && t.vargen != 0 {
-                       fmt.Fprintf(b, "ยท%d", t.vargen)
-               }
                return
        }
 
index 8a6f24124a88960ec70f4cf9159df441d0601391..a06ab0d18c6cfd8170f1d8fb5b7bc8c9abeb84bf 100644 (file)
@@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
                _64bit uintptr     // size on 64bit platforms
        }{
                {Sym{}, 32, 64},
-               {Type{}, 56, 96},
+               {Type{}, 52, 96},
                {Map{}, 12, 24},
                {Forward{}, 20, 32},
                {Func{}, 32, 56},
index fd01ef8c0e017af83443e973bb83b0c2d0ab5f2c..49ac5d7b1c1e653109c48965fb16cc4e09dd6044 100644 (file)
@@ -156,7 +156,7 @@ var DefaultKinds = [...]Kind{
 // package.Lookup(name)) and checking sym.Def. If sym.Def is non-nil, the type
 // already exists at package scope and is available at sym.Def.(*ir.Name).Type().
 // Local types (which may have the same name as a package-level type) are
-// distinguished by the value of vargen.
+// distinguished by their vargen, which is embedded in their symbol name.
 type Type struct {
        // extra contains extra etype-specific fields.
        // As an optimization, those etype-specific structs which contain exactly
@@ -195,8 +195,6 @@ type Type struct {
                slice *Type // []T, or nil
        }
 
-       vargen int32 // unique name for OTYPE/ONAME
-
        kind  Kind  // kind of type
        align uint8 // the required alignment of this type, in bytes (0 means Width and Align have not yet been computed)
 
@@ -1114,10 +1112,6 @@ func (t *Type) cmp(x *Type) Cmp {
        }
 
        if x.obj != nil {
-               // Syms non-nil, if vargens match then equal.
-               if t.vargen != x.vargen {
-                       return cmpForNe(t.vargen < x.vargen)
-               }
                return CMPeq
        }
        // both syms nil, look at structure below.
@@ -1617,25 +1611,6 @@ func (t *Type) Obj() Object {
        return t.obj
 }
 
-// typeGen tracks the number of function-scoped defined types that
-// have been declared. It's used to generate unique linker symbols for
-// their runtime type descriptors.
-var typeGen int32
-
-// SetVargen assigns a unique generation number to type t, which must
-// be a defined type declared within function scope. The generation
-// number is used to distinguish it from other similarly spelled
-// defined types from the same package.
-//
-// TODO(mdempsky): Come up with a better solution.
-func (t *Type) SetVargen() {
-       base.Assertf(t.Sym() != nil, "SetVargen on anonymous type %v", t)
-       base.Assertf(t.vargen == 0, "type %v already has Vargen %v", t, t.vargen)
-
-       typeGen++
-       t.vargen = typeGen
-}
-
 // SetUnderlying sets the underlying type of an incomplete type (i.e. type whose kind
 // is currently TFORW). SetUnderlying automatically updates any types that were waiting
 // for this type to be completed.