Commit 2fe43cec authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: bubble out some Linksym calls

Change a few functions so that instead of
accepting a *types.Sym and calling Linksym
themselves, they accept an *obj.LSym.
Adapt the callsites.

Passes toolstash-check.

Change-Id: Ic5d3f306f2fdd3913281215a1f54d893a966bb1f
Reviewed-on: https://go-review.googlesource.com/41404
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 2f4ce69d
...@@ -507,7 +507,7 @@ func isExportedField(ft *types.Field) (bool, *types.Pkg) { ...@@ -507,7 +507,7 @@ func isExportedField(ft *types.Field) (bool, *types.Pkg) {
} }
// dnameField dumps a reflect.name for a struct field. // dnameField dumps a reflect.name for a struct field.
func dnameField(s *types.Sym, ot int, spkg *types.Pkg, ft *types.Field) int { func dnameField(lsym *obj.LSym, ot int, spkg *types.Pkg, ft *types.Field) int {
var name string var name string
if ft.Sym != nil { if ft.Sym != nil {
name = ft.Sym.Name name = ft.Sym.Name
...@@ -517,7 +517,7 @@ func dnameField(s *types.Sym, ot int, spkg *types.Pkg, ft *types.Field) int { ...@@ -517,7 +517,7 @@ func dnameField(s *types.Sym, ot int, spkg *types.Pkg, ft *types.Field) int {
fpkg = nil fpkg = nil
} }
nsym := dname(name, ft.Note, fpkg, isExported) nsym := dname(name, ft.Note, fpkg, isExported)
return dsymptr(s.Linksym(), ot, nsym, 0) return dsymptr(lsym, ot, nsym, 0)
} }
// dnameData writes the contents of a reflect.name into s at offset ot. // dnameData writes the contents of a reflect.name into s at offset ot.
...@@ -599,7 +599,7 @@ func dname(name, tag string, pkg *types.Pkg, exported bool) *obj.LSym { ...@@ -599,7 +599,7 @@ func dname(name, tag string, pkg *types.Pkg, exported bool) *obj.LSym {
// dextratype dumps the fields of a runtime.uncommontype. // dextratype dumps the fields of a runtime.uncommontype.
// dataAdd is the offset in bytes after the header where the // dataAdd is the offset in bytes after the header where the
// backing array of the []method field is written (by dextratypeData). // backing array of the []method field is written (by dextratypeData).
func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int { func dextratype(lsym *obj.LSym, ot int, t *types.Type, dataAdd int) int {
m := methods(t) m := methods(t)
if t.Sym == nil && len(m) == 0 { if t.Sym == nil && len(m) == 0 {
return ot return ot
...@@ -613,7 +613,7 @@ func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int { ...@@ -613,7 +613,7 @@ func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int {
dtypesym(a.type_) dtypesym(a.type_)
} }
ot = dgopkgpathOff(s.Linksym(), ot, typePkg(t)) ot = dgopkgpathOff(lsym, ot, typePkg(t))
dataAdd += uncommonSize(t) dataAdd += uncommonSize(t)
mcount := len(m) mcount := len(m)
...@@ -624,10 +624,10 @@ func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int { ...@@ -624,10 +624,10 @@ func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int {
Fatalf("methods are too far away on %v: %d", t, dataAdd) Fatalf("methods are too far away on %v: %d", t, dataAdd)
} }
ot = duint16(s.Linksym(), ot, uint16(mcount)) ot = duint16(lsym, ot, uint16(mcount))
ot = duint16(s.Linksym(), ot, 0) ot = duint16(lsym, ot, 0)
ot = duint32(s.Linksym(), ot, uint32(dataAdd)) ot = duint32(lsym, ot, uint32(dataAdd))
ot = duint32(s.Linksym(), ot, 0) ot = duint32(lsym, ot, 0)
return ot return ot
} }
...@@ -777,7 +777,7 @@ var ( ...@@ -777,7 +777,7 @@ var (
) )
// dcommontype dumps the contents of a reflect.rtype (runtime._type). // dcommontype dumps the contents of a reflect.rtype (runtime._type).
func dcommontype(s *types.Sym, ot int, t *types.Type) int { func dcommontype(lsym *obj.LSym, ot int, t *types.Type) int {
if ot != 0 { if ot != 0 {
Fatalf("dcommontype %d", ot) Fatalf("dcommontype %d", ot)
} }
...@@ -820,10 +820,9 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int { ...@@ -820,10 +820,9 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int {
// str nameOff // str nameOff
// ptrToThis typeOff // ptrToThis typeOff
// } // }
ot = duintptr(s.Linksym(), ot, uint64(t.Width)) ot = duintptr(lsym, ot, uint64(t.Width))
ot = duintptr(s.Linksym(), ot, uint64(ptrdata)) ot = duintptr(lsym, ot, uint64(ptrdata))
ot = duint32(lsym, ot, typehash(t))
ot = duint32(s.Linksym(), ot, typehash(t))
var tflag uint8 var tflag uint8
if uncommonSize(t) != 0 { if uncommonSize(t) != 0 {
...@@ -852,7 +851,7 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int { ...@@ -852,7 +851,7 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int {
} }
} }
ot = duint8(s.Linksym(), ot, tflag) ot = duint8(lsym, ot, tflag)
// runtime (and common sense) expects alignment to be a power of two. // runtime (and common sense) expects alignment to be a power of two.
i := int(t.Align) i := int(t.Align)
...@@ -863,8 +862,8 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int { ...@@ -863,8 +862,8 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int {
if i&(i-1) != 0 { if i&(i-1) != 0 {
Fatalf("invalid alignment %d for %v", t.Align, t) Fatalf("invalid alignment %d for %v", t.Align, t)
} }
ot = duint8(s.Linksym(), ot, t.Align) // align ot = duint8(lsym, ot, t.Align) // align
ot = duint8(s.Linksym(), ot, t.Align) // fieldAlign ot = duint8(lsym, ot, t.Align) // fieldAlign
i = kinds[t.Etype] i = kinds[t.Etype]
if !types.Haspointers(t) { if !types.Haspointers(t) {
...@@ -876,23 +875,23 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int { ...@@ -876,23 +875,23 @@ func dcommontype(s *types.Sym, ot int, t *types.Type) int {
if useGCProg { if useGCProg {
i |= objabi.KindGCProg i |= objabi.KindGCProg
} }
ot = duint8(s.Linksym(), ot, uint8(i)) // kind ot = duint8(lsym, ot, uint8(i)) // kind
if algsym == nil { if algsym == nil {
ot = dsymptr(s.Linksym(), ot, algarray, int(alg)*sizeofAlg) ot = dsymptr(lsym, ot, algarray, int(alg)*sizeofAlg)
} else { } else {
ot = dsymptr(s.Linksym(), ot, algsym.Linksym(), 0) ot = dsymptr(lsym, ot, algsym.Linksym(), 0)
} }
ot = dsymptr(s.Linksym(), ot, gcsym, 0) // gcdata ot = dsymptr(lsym, ot, gcsym, 0) // gcdata
nsym := dname(p, "", nil, exported) nsym := dname(p, "", nil, exported)
ot = dsymptrOff(s.Linksym(), ot, nsym, 0) // str ot = dsymptrOff(lsym, ot, nsym, 0) // str
// ptrToThis // ptrToThis
if sptr == nil { if sptr == nil {
ot = duint32(s.Linksym(), ot, 0) ot = duint32(lsym, ot, 0)
} else if sptrWeak { } else if sptrWeak {
ot = dsymptrWeakOff(s.Linksym(), ot, sptr.Linksym()) ot = dsymptrWeakOff(lsym, ot, sptr.Linksym())
} else { } else {
ot = dsymptrOff(s.Linksym(), ot, sptr.Linksym(), 0) ot = dsymptrOff(lsym, ot, sptr.Linksym(), 0)
} }
return ot return ot
...@@ -1102,34 +1101,34 @@ ok: ...@@ -1102,34 +1101,34 @@ ok:
ot := 0 ot := 0
switch t.Etype { switch t.Etype {
default: default:
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
case TARRAY: case TARRAY:
// ../../../../runtime/type.go:/arrayType // ../../../../runtime/type.go:/arrayType
s1 := dtypesym(t.Elem()) s1 := dtypesym(t.Elem())
t2 := types.NewSlice(t.Elem()) t2 := types.NewSlice(t.Elem())
s2 := dtypesym(t2) s2 := dtypesym(t2)
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0)
ot = dsymptr(s.Linksym(), ot, s2.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s2.Linksym(), 0)
ot = duintptr(s.Linksym(), ot, uint64(t.NumElem())) ot = duintptr(s.Linksym(), ot, uint64(t.NumElem()))
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
case TSLICE: case TSLICE:
// ../../../../runtime/type.go:/sliceType // ../../../../runtime/type.go:/sliceType
s1 := dtypesym(t.Elem()) s1 := dtypesym(t.Elem())
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0)
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
case TCHAN: case TCHAN:
// ../../../../runtime/type.go:/chanType // ../../../../runtime/type.go:/chanType
s1 := dtypesym(t.Elem()) s1 := dtypesym(t.Elem())
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0)
ot = duintptr(s.Linksym(), ot, uint64(t.ChanDir())) ot = duintptr(s.Linksym(), ot, uint64(t.ChanDir()))
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
case TFUNC: case TFUNC:
for _, t1 := range t.Recvs().Fields().Slice() { for _, t1 := range t.Recvs().Fields().Slice() {
...@@ -1144,7 +1143,7 @@ ok: ...@@ -1144,7 +1143,7 @@ ok:
dtypesym(t1.Type) dtypesym(t1.Type)
} }
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
inCount := t.Recvs().NumFields() + t.Params().NumFields() inCount := t.Recvs().NumFields() + t.Params().NumFields()
outCount := t.Results().NumFields() outCount := t.Results().NumFields()
if isddd { if isddd {
...@@ -1157,7 +1156,7 @@ ok: ...@@ -1157,7 +1156,7 @@ ok:
} }
dataAdd := (inCount + t.Results().NumFields()) * Widthptr dataAdd := (inCount + t.Results().NumFields()) * Widthptr
ot = dextratype(s, ot, t, dataAdd) ot = dextratype(s.Linksym(), ot, t, dataAdd)
// Array of rtype pointers follows funcType. // Array of rtype pointers follows funcType.
for _, t1 := range t.Recvs().Fields().Slice() { for _, t1 := range t.Recvs().Fields().Slice() {
...@@ -1178,7 +1177,7 @@ ok: ...@@ -1178,7 +1177,7 @@ ok:
} }
// ../../../../runtime/type.go:/interfaceType // ../../../../runtime/type.go:/interfaceType
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
var tpkg *types.Pkg var tpkg *types.Pkg
if t.Sym != nil && t != types.Types[t.Etype] && t != types.Errortype { if t.Sym != nil && t != types.Types[t.Etype] && t != types.Errortype {
...@@ -1190,7 +1189,7 @@ ok: ...@@ -1190,7 +1189,7 @@ ok:
ot = duintptr(s.Linksym(), ot, uint64(n)) ot = duintptr(s.Linksym(), ot, uint64(n))
ot = duintptr(s.Linksym(), ot, uint64(n)) ot = duintptr(s.Linksym(), ot, uint64(n))
dataAdd := imethodSize() * n dataAdd := imethodSize() * n
ot = dextratype(s, ot, t, dataAdd) ot = dextratype(s.Linksym(), ot, t, dataAdd)
lsym := s.Linksym() lsym := s.Linksym()
for _, a := range m { for _, a := range m {
...@@ -1212,7 +1211,7 @@ ok: ...@@ -1212,7 +1211,7 @@ ok:
s2 := dtypesym(t.Val()) s2 := dtypesym(t.Val())
s3 := dtypesym(mapbucket(t)) s3 := dtypesym(mapbucket(t))
s4 := dtypesym(hmap(t)) s4 := dtypesym(hmap(t))
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0)
ot = dsymptr(s.Linksym(), ot, s2.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s2.Linksym(), 0)
ot = dsymptr(s.Linksym(), ot, s3.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s3.Linksym(), 0)
...@@ -1236,13 +1235,13 @@ ok: ...@@ -1236,13 +1235,13 @@ ok:
ot = duint16(s.Linksym(), ot, uint16(mapbucket(t).Width)) ot = duint16(s.Linksym(), ot, uint16(mapbucket(t).Width))
ot = duint8(s.Linksym(), ot, uint8(obj.Bool2int(isreflexive(t.Key())))) ot = duint8(s.Linksym(), ot, uint8(obj.Bool2int(isreflexive(t.Key()))))
ot = duint8(s.Linksym(), ot, uint8(obj.Bool2int(needkeyupdate(t.Key())))) ot = duint8(s.Linksym(), ot, uint8(obj.Bool2int(needkeyupdate(t.Key()))))
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
case TPTR32, TPTR64: case TPTR32, TPTR64:
if t.Elem().Etype == TANY { if t.Elem().Etype == TANY {
// ../../../../runtime/type.go:/UnsafePointerType // ../../../../runtime/type.go:/UnsafePointerType
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
break break
} }
...@@ -1250,9 +1249,9 @@ ok: ...@@ -1250,9 +1249,9 @@ ok:
// ../../../../runtime/type.go:/ptrType // ../../../../runtime/type.go:/ptrType
s1 := dtypesym(t.Elem()) s1 := dtypesym(t.Elem())
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0) ot = dsymptr(s.Linksym(), ot, s1.Linksym(), 0)
ot = dextratype(s, ot, t, 0) ot = dextratype(s.Linksym(), ot, t, 0)
// ../../../../runtime/type.go:/structType // ../../../../runtime/type.go:/structType
// for security, only the exported fields. // for security, only the exported fields.
...@@ -1264,7 +1263,7 @@ ok: ...@@ -1264,7 +1263,7 @@ ok:
n++ n++
} }
ot = dcommontype(s, ot, t) ot = dcommontype(s.Linksym(), ot, t)
pkg := localpkg pkg := localpkg
if t.Sym != nil { if t.Sym != nil {
pkg = t.Sym.Pkg pkg = t.Sym.Pkg
...@@ -1284,11 +1283,11 @@ ok: ...@@ -1284,11 +1283,11 @@ ok:
ot = duintptr(s.Linksym(), ot, uint64(n)) ot = duintptr(s.Linksym(), ot, uint64(n))
dataAdd := n * structfieldSize() dataAdd := n * structfieldSize()
ot = dextratype(s, ot, t, dataAdd) ot = dextratype(s.Linksym(), ot, t, dataAdd)
for _, f := range t.Fields().Slice() { for _, f := range t.Fields().Slice() {
// ../../../../runtime/type.go:/structField // ../../../../runtime/type.go:/structField
ot = dnameField(s, ot, pkg, f) ot = dnameField(s.Linksym(), ot, pkg, f)
ot = dsymptr(s.Linksym(), ot, dtypesym(f.Type).Linksym(), 0) ot = dsymptr(s.Linksym(), ot, dtypesym(f.Type).Linksym(), 0)
offsetAnon := uint64(f.Offset) << 1 offsetAnon := uint64(f.Offset) << 1
if offsetAnon>>1 != uint64(f.Offset) { if offsetAnon>>1 != uint64(f.Offset) {
......
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