1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:46:16 -07:00

cmd/compile/internal/types: remove Type.vargen

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>
This commit is contained in:
Matthew Dempsky 2023-09-11 18:50:26 -07:00 committed by Gopher Robot
parent d9aca84da0
commit aa381c538a
3 changed files with 2 additions and 35 deletions

View File

@ -319,14 +319,6 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
} }
} }
sconv2(b, sym, verb, mode) 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 return
} }

View File

@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
_64bit uintptr // size on 64bit platforms _64bit uintptr // size on 64bit platforms
}{ }{
{Sym{}, 32, 64}, {Sym{}, 32, 64},
{Type{}, 56, 96}, {Type{}, 52, 96},
{Map{}, 12, 24}, {Map{}, 12, 24},
{Forward{}, 20, 32}, {Forward{}, 20, 32},
{Func{}, 32, 56}, {Func{}, 32, 56},

View File

@ -156,7 +156,7 @@ var DefaultKinds = [...]Kind{
// package.Lookup(name)) and checking sym.Def. If sym.Def is non-nil, the type // 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(). // 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 // 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 { type Type struct {
// extra contains extra etype-specific fields. // extra contains extra etype-specific fields.
// As an optimization, those etype-specific structs which contain exactly // As an optimization, those etype-specific structs which contain exactly
@ -195,8 +195,6 @@ type Type struct {
slice *Type // []T, or nil slice *Type // []T, or nil
} }
vargen int32 // unique name for OTYPE/ONAME
kind Kind // kind of type 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) 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 { 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 return CMPeq
} }
// both syms nil, look at structure below. // both syms nil, look at structure below.
@ -1617,25 +1611,6 @@ func (t *Type) Obj() Object {
return t.obj 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 // 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 // is currently TFORW). SetUnderlying automatically updates any types that were waiting
// for this type to be completed. // for this type to be completed.