Skip to content

Commit

Permalink
cmd/compile: convert more dxxx functions to work with LSyms
Browse files Browse the repository at this point in the history
This batch from reflect.go.
Changes made manually, since they are simple,
few, and typechecked by the compiler.

Passes toolstash-check.

Change-Id: I0030daab2dac8e7c95158678c0f7141fd90441f9
Reviewed-on: https://go-review.googlesource.com/41399
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
  • Loading branch information
josharian committed Apr 21, 2017
1 parent bea8ffd commit b065c95
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,7 @@ func dimportpath(p *types.Pkg) {
p.Pathsym = s
}

func dgopkgpath(s *types.Sym, ot int, pkg *types.Pkg) int {
return dgopkgpathLSym(s.Linksym(), ot, pkg)
}

func dgopkgpathLSym(s *obj.LSym, ot int, pkg *types.Pkg) int {
func dgopkgpath(s *obj.LSym, ot int, pkg *types.Pkg) int {
if pkg == nil {
return duintptr(s, ot, 0)
}
Expand All @@ -476,8 +472,8 @@ func dgopkgpathLSym(s *obj.LSym, ot int, pkg *types.Pkg) int {
return dsymptr(s, ot, pkg.Pathsym, 0)
}

// dgopkgpathOffLSym writes an offset relocation in s at offset ot to the pkg path symbol.
func dgopkgpathOffLSym(s *obj.LSym, ot int, pkg *types.Pkg) int {
// dgopkgpathOff writes an offset relocation in s at offset ot to the pkg path symbol.
func dgopkgpathOff(s *obj.LSym, ot int, pkg *types.Pkg) int {
if pkg == nil {
return duint32(s, ot, 0)
}
Expand Down Expand Up @@ -561,7 +557,7 @@ func dnameData(s *obj.LSym, ot int, name, tag string, pkg *types.Pkg, exported b
ot = int(s.WriteBytes(Ctxt, int64(ot), b))

if pkg != nil {
ot = dgopkgpathOffLSym(s, ot, pkg)
ot = dgopkgpathOff(s, ot, pkg)
}

return ot
Expand Down Expand Up @@ -617,7 +613,7 @@ func dextratype(s *types.Sym, ot int, t *types.Type, dataAdd int) int {
dtypesym(a.type_)
}

ot = dgopkgpathOffLSym(s.Linksym(), ot, typePkg(t))
ot = dgopkgpathOff(s.Linksym(), ot, typePkg(t))

dataAdd += uncommonSize(t)
mcount := len(m)
Expand Down Expand Up @@ -665,14 +661,14 @@ func dextratypeData(s *types.Sym, ot int, t *types.Type) int {
nsym := dname(a.name, "", pkg, exported)

ot = dsymptrOff(lsym, ot, nsym, 0)
ot = dmethodptrOffLSym(lsym, ot, dtypesym(a.mtype).Linksym())
ot = dmethodptrOffLSym(lsym, ot, a.isym.Linksym())
ot = dmethodptrOffLSym(lsym, ot, a.tsym.Linksym())
ot = dmethodptrOff(lsym, ot, dtypesym(a.mtype).Linksym())
ot = dmethodptrOff(lsym, ot, a.isym.Linksym())
ot = dmethodptrOff(lsym, ot, a.tsym.Linksym())
}
return ot
}

func dmethodptrOffLSym(s *obj.LSym, ot int, x *obj.LSym) int {
func dmethodptrOff(s *obj.LSym, ot int, x *obj.LSym) int {
duint32(s, ot, 0)
r := obj.Addrel(s)
r.Off = int32(ot)
Expand Down Expand Up @@ -1201,7 +1197,7 @@ ok:
if t.Sym != nil && t != types.Types[t.Etype] && t != types.Errortype {
tpkg = t.Sym.Pkg
}
ot = dgopkgpath(s, ot, tpkg)
ot = dgopkgpath(s.Linksym(), ot, tpkg)

ot = dsymptr(s.Linksym(), ot, s.Linksym(), ot+Widthptr+2*Widthint+uncommonSize(t))
ot = duintptr(s.Linksym(), ot, uint64(n))
Expand Down Expand Up @@ -1295,7 +1291,7 @@ ok:
break
}
}
ot = dgopkgpath(s, ot, pkg)
ot = dgopkgpath(s.Linksym(), ot, pkg)
ot = dsymptr(s.Linksym(), ot, s.Linksym(), ot+Widthptr+2*Widthint+uncommonSize(t))
ot = duintptr(s.Linksym(), ot, uint64(n))
ot = duintptr(s.Linksym(), ot, uint64(n))
Expand Down

0 comments on commit b065c95

Please sign in to comment.