Commit 19bd145d authored by Matthew Dempsky's avatar Matthew Dempsky

Revert "cmd/compile: make typenamesym do less work"

This reverts commit 91433eb5.

Reason for revert: broke deterministic build.

Fixes #19872.

Change-Id: Ia1a0fc651b818bdf69454df43bd189689c0348a0
Reviewed-on: https://go-review.googlesource.com/39871
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 385c13cf
...@@ -34,7 +34,7 @@ type ptabEntry struct { ...@@ -34,7 +34,7 @@ type ptabEntry struct {
} }
// runtime interface and reflection data structures // runtime interface and reflection data structures
var signatlist = make(map[*Type]bool) var signatlist []*Type
var itabs []itabEntry var itabs []itabEntry
var ptabs []ptabEntry var ptabs []ptabEntry
...@@ -933,22 +933,24 @@ func typesymprefix(prefix string, t *Type) *Sym { ...@@ -933,22 +933,24 @@ func typesymprefix(prefix string, t *Type) *Sym {
func typenamesym(t *Type) *Sym { func typenamesym(t *Type) *Sym {
if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() { if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() {
Fatalf("typenamesym %v", t) Fatalf("typename %v", t)
} }
s := typesym(t) s := typesym(t)
addsignat(t)
return s
}
func typename(t *Type) *Node {
s := typenamesym(t)
if s.Def == nil { if s.Def == nil {
n := newnamel(src.NoXPos, s) n := newnamel(src.NoXPos, s)
n.Type = Types[TUINT8] n.Type = Types[TUINT8]
n.Class = PEXTERN n.Class = PEXTERN
n.Typecheck = 1 n.Typecheck = 1
s.Def = n s.Def = n
signatlist = append(signatlist, t)
} }
return s.Def.Sym
}
func typename(t *Type) *Node {
s := typenamesym(t)
n := nod(OADDR, s.Def, nil) n := nod(OADDR, s.Def, nil)
n.Type = typPtr(s.Def.Type) n.Type = typPtr(s.Def.Type)
n.SetAddable(true) n.SetAddable(true)
...@@ -1415,37 +1417,23 @@ func itabsym(it *obj.LSym, offset int64) *obj.LSym { ...@@ -1415,37 +1417,23 @@ func itabsym(it *obj.LSym, offset int64) *obj.LSym {
return syms[methodnum] return syms[methodnum]
} }
func addsignat(t *Type) {
signatlist[t] = true
}
func dumptypestructs() { func dumptypestructs() {
// copy types from externdcl list to signatlist // copy types from externdcl list to signatlist
for _, n := range externdcl { for _, n := range externdcl {
if n.Op == OTYPE { if n.Op == OTYPE {
addsignat(n.Type) signatlist = append(signatlist, n.Type)
} }
} }
// Process signatlist. Use a loop, as dtypesym adds // Process signatlist. This can't use range, as entries are
// entries to signatlist while it is being processed. // added to the list while it is being processed.
signats := make([]typeAndStr, len(signatlist)) for i := 0; i < len(signatlist); i++ {
for len(signatlist) > 0 { t := signatlist[i]
signats = signats[:0]
// Transfer entries to a slice and sort, for reproducible builds.
for t := range signatlist {
signats = append(signats, typeAndStr{t: t, s: t.LongString()})
delete(signatlist, t)
}
sort.Sort(typesByLongString(signats))
for _, ts := range signats {
t := ts.t
dtypesym(t) dtypesym(t)
if t.Sym != nil { if t.Sym != nil {
dtypesym(typPtr(t)) dtypesym(typPtr(t))
} }
} }
}
// process itabs // process itabs
for _, i := range itabs { for _, i := range itabs {
...@@ -1539,18 +1527,6 @@ func dumptypestructs() { ...@@ -1539,18 +1527,6 @@ func dumptypestructs() {
} }
} }
type typeAndStr struct {
t *Type
s string
}
// TODO(josharian): simplify this to just use Type.cmp once issue 19869 has been fixed.
type typesByLongString []typeAndStr
func (a typesByLongString) Len() int { return len(a) }
func (a typesByLongString) Less(i, j int) bool { return a[i].s < a[j].s }
func (a typesByLongString) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type pkgByPath []*Pkg type pkgByPath []*Pkg
func (a pkgByPath) Len() int { return len(a) } func (a pkgByPath) Len() int { return len(a) }
......
...@@ -976,8 +976,6 @@ func (r *Sym) cmpsym(s *Sym) ssa.Cmp { ...@@ -976,8 +976,6 @@ func (r *Sym) cmpsym(s *Sym) ssa.Cmp {
// cmp compares two *Types t and x, returning ssa.CMPlt, // cmp compares two *Types t and x, returning ssa.CMPlt,
// ssa.CMPeq, ssa.CMPgt as t<x, t==x, t>x, for an arbitrary // ssa.CMPeq, ssa.CMPgt as t<x, t==x, t>x, for an arbitrary
// and optimizer-centric notion of comparison. // and optimizer-centric notion of comparison.
// TODO(josharian): make this safe for recursive interface types
// and use in signatlist sorting. See issue 19869.
func (t *Type) cmp(x *Type) ssa.Cmp { func (t *Type) cmp(x *Type) ssa.Cmp {
// This follows the structure of eqtype in subr.go // This follows the structure of eqtype in subr.go
// with two exceptions. // with two exceptions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment