Commit d36cc9ba authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: refactor dtypesym to return *obj.LSym

All of the callers want a *obj.LSym instead of a *types.Sym, and the
runtime type descriptors don't need Go source symbols anyway.

Passes toolstash-check.

Change-Id: I8ae4b64380fbb547857f49b42465118f41884eed
Reviewed-on: https://go-review.googlesource.com/68251
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarMarvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
parent ec40c7e1
......@@ -724,7 +724,7 @@ func dextratypeData(lsym *obj.LSym, ot int, t *types.Type) int {
nsym := dname(a.name, "", pkg, exported)
ot = dsymptrOff(lsym, ot, nsym, 0)
ot = dmethodptrOff(lsym, ot, dtypesym(a.mtype).Linksym())
ot = dmethodptrOff(lsym, ot, dtypesym(a.mtype))
ot = dmethodptrOff(lsym, ot, a.isym.Linksym())
ot = dmethodptrOff(lsym, ot, a.tsym.Linksym())
}
......@@ -863,7 +863,7 @@ func dcommontype(lsym *obj.LSym, ot int, t *types.Type) int {
if t.Sym != nil || methods(tptr) != nil {
sptrWeak = false
}
sptr = dtypesym(tptr).Linksym()
sptr = dtypesym(tptr)
}
gcsym, useGCProg, ptrdata := dgcsym(t)
......@@ -1138,15 +1138,16 @@ func formalType(t *types.Type) *types.Type {
return t
}
func dtypesym(t *types.Type) *types.Sym {
func dtypesym(t *types.Type) *obj.LSym {
t = formalType(t)
if t.IsUntyped() {
Fatalf("dtypesym %v", t)
}
s := typesym(t)
lsym := s.Linksym()
if s.Siggen() {
return s
return lsym
}
s.SetSiggen(true)
......@@ -1166,16 +1167,15 @@ func dtypesym(t *types.Type) *types.Sym {
if myimportpath != "runtime" || (tbase != types.Types[tbase.Etype] && tbase != types.Bytetype && tbase != types.Runetype && tbase != types.Errortype) { // int, float, etc
// named types from other files are defined only by those files
if tbase.Sym != nil && tbase.Sym.Pkg != localpkg {
return s
return lsym
}
// TODO(mdempsky): Investigate whether this can happen.
if isforw[tbase.Etype] {
return s
return lsym
}
}
ot := 0
lsym := s.Linksym()
switch t.Etype {
default:
ot = dcommontype(lsym, ot, t)
......@@ -1187,8 +1187,8 @@ func dtypesym(t *types.Type) *types.Sym {
t2 := types.NewSlice(t.Elem())
s2 := dtypesym(t2)
ot = dcommontype(lsym, ot, t)
ot = dsymptr(lsym, ot, s1.Linksym(), 0)
ot = dsymptr(lsym, ot, s2.Linksym(), 0)
ot = dsymptr(lsym, ot, s1, 0)
ot = dsymptr(lsym, ot, s2, 0)
ot = duintptr(lsym, ot, uint64(t.NumElem()))
ot = dextratype(lsym, ot, t, 0)
......@@ -1196,14 +1196,14 @@ func dtypesym(t *types.Type) *types.Sym {
// ../../../../runtime/type.go:/sliceType
s1 := dtypesym(t.Elem())
ot = dcommontype(lsym, ot, t)
ot = dsymptr(lsym, ot, s1.Linksym(), 0)
ot = dsymptr(lsym, ot, s1, 0)
ot = dextratype(lsym, ot, t, 0)
case TCHAN:
// ../../../../runtime/type.go:/chanType
s1 := dtypesym(t.Elem())
ot = dcommontype(lsym, ot, t)
ot = dsymptr(lsym, ot, s1.Linksym(), 0)
ot = dsymptr(lsym, ot, s1, 0)
ot = duintptr(lsym, ot, uint64(t.ChanDir()))
ot = dextratype(lsym, ot, t, 0)
......@@ -1237,13 +1237,13 @@ func dtypesym(t *types.Type) *types.Sym {
// Array of rtype pointers follows funcType.
for _, t1 := range t.Recvs().Fields().Slice() {
ot = dsymptr(lsym, ot, dtypesym(t1.Type).Linksym(), 0)
ot = dsymptr(lsym, ot, dtypesym(t1.Type), 0)
}
for _, t1 := range t.Params().Fields().Slice() {
ot = dsymptr(lsym, ot, dtypesym(t1.Type).Linksym(), 0)
ot = dsymptr(lsym, ot, dtypesym(t1.Type), 0)
}
for _, t1 := range t.Results().Fields().Slice() {
ot = dsymptr(lsym, ot, dtypesym(t1.Type).Linksym(), 0)
ot = dsymptr(lsym, ot, dtypesym(t1.Type), 0)
}
case TINTER:
......@@ -1278,7 +1278,7 @@ func dtypesym(t *types.Type) *types.Sym {
nsym := dname(a.name, "", pkg, exported)
ot = dsymptrOff(lsym, ot, nsym, 0)
ot = dsymptrOff(lsym, ot, dtypesym(a.type_).Linksym(), 0)
ot = dsymptrOff(lsym, ot, dtypesym(a.type_), 0)
}
// ../../../../runtime/type.go:/mapType
......@@ -1288,10 +1288,10 @@ func dtypesym(t *types.Type) *types.Sym {
s3 := dtypesym(bmap(t))
s4 := dtypesym(hmap(t))
ot = dcommontype(lsym, ot, t)
ot = dsymptr(lsym, ot, s1.Linksym(), 0)
ot = dsymptr(lsym, ot, s2.Linksym(), 0)
ot = dsymptr(lsym, ot, s3.Linksym(), 0)
ot = dsymptr(lsym, ot, s4.Linksym(), 0)
ot = dsymptr(lsym, ot, s1, 0)
ot = dsymptr(lsym, ot, s2, 0)
ot = dsymptr(lsym, ot, s3, 0)
ot = dsymptr(lsym, ot, s4, 0)
if t.Key().Width > MAXKEYSIZE {
ot = duint8(lsym, ot, uint8(Widthptr))
ot = duint8(lsym, ot, 1) // indirect
......@@ -1326,7 +1326,7 @@ func dtypesym(t *types.Type) *types.Sym {
s1 := dtypesym(t.Elem())
ot = dcommontype(lsym, ot, t)
ot = dsymptr(lsym, ot, s1.Linksym(), 0)
ot = dsymptr(lsym, ot, s1, 0)
ot = dextratype(lsym, ot, t, 0)
// ../../../../runtime/type.go:/structType
......@@ -1364,7 +1364,7 @@ func dtypesym(t *types.Type) *types.Sym {
for _, f := range t.Fields().Slice() {
// ../../../../runtime/type.go:/structField
ot = dnameField(lsym, ot, spkg, f)
ot = dsymptr(lsym, ot, dtypesym(f.Type).Linksym(), 0)
ot = dsymptr(lsym, ot, dtypesym(f.Type), 0)
offsetAnon := uint64(f.Offset) << 1
if offsetAnon>>1 != uint64(f.Offset) {
Fatalf("%v: bad field offset for %s", t, f.Sym.Name)
......@@ -1398,7 +1398,7 @@ func dtypesym(t *types.Type) *types.Sym {
}
lsym.Set(obj.AttrMakeTypelink, keep)
return s
return lsym
}
// for each itabEntry, gather the methods on
......@@ -1518,8 +1518,8 @@ func dumptabs() {
// _ [4]byte
// fun [1]uintptr // variable sized
// }
o := dsymptr(i.lsym, 0, dtypesym(i.itype).Linksym(), 0)
o = dsymptr(i.lsym, o, dtypesym(i.t).Linksym(), 0)
o := dsymptr(i.lsym, 0, dtypesym(i.itype), 0)
o = dsymptr(i.lsym, o, dtypesym(i.t), 0)
o = duint32(i.lsym, o, typehash(i.t)) // copy of type hash
o += 4 // skip unused field
for _, fn := range genfun(i.t, i.itype) {
......@@ -1545,7 +1545,7 @@ func dumptabs() {
// }
nsym := dname(p.s.Name, "", nil, true)
ot = dsymptrOff(s, ot, nsym, 0)
ot = dsymptrOff(s, ot, dtypesym(p.t).Linksym(), 0)
ot = dsymptrOff(s, ot, dtypesym(p.t), 0)
}
ggloblsym(s, int32(ot), int16(obj.RODATA))
......
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