Commit 4d600b8e authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: convert dxxx to dxxxLSym

This is an automated refactoring to eliminate
all dxxx calls in gc/obj.go that accept types.Sym
instead of obj.LSym parameters.

The refactoring was of the form:

gorename -from '"cmd/compile/internal/gc".duintxx' -to Duintxx
gorename -from '"cmd/compile/internal/gc".duintxxLSym' -to DuintxxLSym
eg -t t.go -w cmd/compile/internal/gc
gofmt -r 'DuintxxLSym -> duintxxLSym' -w cmd/compile/internal/gc

where t.go looked like:

func before(s *types.Sym, off int, v uint64, wid int) int {
	return gc.Duintxx(s, off, v, wid)
}

func after(s *types.Sym, off int, v uint64, wid int) int {
	return gc.DuintxxLSym(s.Linksym(), off, v, wid)
}

The rename/gofmt shenanigans were to work around
limitations and bugs in eg and gorename.

The resulting code in reflect.go looks temporarily ugly,
but it makes refactoring and cleanup opportunities
much clearer.

Next step is to rename all the dxxx methods to rename the -LSym suffix
and clean up reflect.go.

The renaming is left for a separate CL to make the changes in
this CL more obvious, and thus hopefully easier to review.

Passes toolstash-check.

Change-Id: Ib31a2b6fd146ed03a855d20ecb0433f0f74e2f10
Reviewed-on: https://go-review.googlesource.com/41396
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent a5096213
......@@ -222,7 +222,7 @@ func dumpglobls() {
for _, s := range funcsyms {
sf := s.Pkg.Lookup(funcsymname(s))
dsymptr(sf, 0, s, 0)
dsymptrLSym(sf.Linksym(), 0, s.Linksym(), 0)
ggloblsym(sf, int32(Widthptr), obj.DUPOK|obj.RODATA)
}
......@@ -251,10 +251,6 @@ func addGCLocals() {
}
}
func duintxx(s *types.Sym, off int, v uint64, wid int) int {
return duintxxLSym(s.Linksym(), off, v, wid)
}
func duintxxLSym(s *obj.LSym, off int, v uint64, wid int) int {
if s.Type == 0 {
// TODO(josharian): Do this in obj.prepwrite instead.
......@@ -267,30 +263,22 @@ func duintxxLSym(s *obj.LSym, off int, v uint64, wid int) int {
return off + wid
}
func duint8(s *types.Sym, off int, v uint8) int {
return duintxx(s, off, uint64(v), 1)
}
func duint16(s *types.Sym, off int, v uint16) int {
return duintxx(s, off, uint64(v), 2)
}
func duint32(s *types.Sym, off int, v uint32) int {
return duintxx(s, off, uint64(v), 4)
}
func duintptr(s *types.Sym, off int, v uint64) int {
return duintxx(s, off, v, Widthptr)
}
func duint8LSym(s *obj.LSym, off int, v uint8) int {
return duintxxLSym(s, off, uint64(v), 1)
}
func duint16LSym(s *obj.LSym, off int, v uint16) int {
return duintxxLSym(s, off, uint64(v), 2)
}
func duint32LSym(s *obj.LSym, off int, v uint32) int {
return duintxxLSym(s, off, uint64(v), 4)
}
func duintptrLSym(s *obj.LSym, off int, v uint64) int {
return duintxxLSym(s, off, v, Widthptr)
}
func dbvecLSym(s *obj.LSym, off int, bv bvec) int {
// Runtime reads the bitmaps as byte arrays. Oblige.
for j := 0; int32(j) < bv.n; j += 8 {
......@@ -336,20 +324,16 @@ func slicebytes(nam *Node, s string, len int) {
sym := localpkg.Lookup(symname)
sym.Def = asTypesNode(newname(sym))
off := dsname(sym, 0, s)
off := dsnameLSym(sym.Linksym(), 0, s)
ggloblsym(sym, int32(off), obj.NOPTR|obj.LOCAL)
if nam.Op != ONAME {
Fatalf("slicebytes %v", nam)
}
off = int(nam.Xoffset)
off = dsymptr(nam.Sym, off, sym, 0)
off = duintxx(nam.Sym, off, uint64(len), Widthint)
duintxx(nam.Sym, off, uint64(len), Widthint)
}
func dsname(s *types.Sym, off int, t string) int {
return dsnameLSym(s.Linksym(), off, t)
off = dsymptrLSym(nam.Sym.Linksym(), off, sym.Linksym(), 0)
off = duintxxLSym(nam.Sym.Linksym(), off, uint64(len), Widthint)
duintxxLSym(nam.Sym.Linksym(), off, uint64(len), Widthint)
}
func dsnameLSym(s *obj.LSym, off int, t string) int {
......@@ -357,10 +341,6 @@ func dsnameLSym(s *obj.LSym, off int, t string) int {
return off + len(t)
}
func dsymptr(s *types.Sym, off int, x *types.Sym, xoff int) int {
return dsymptrLSym(s.Linksym(), off, x.Linksym(), xoff)
}
func dsymptrLSym(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
off = int(Rnd(int64(off), int64(Widthptr)))
s.WriteAddr(Ctxt, int64(off), Widthptr, x, int64(xoff))
......
This diff is collapsed.
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