1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:41:33 -07:00

cmd/internal/obj: unify Setuintxx and WriteInt

They do basically the same work.

Setuintxx was only used in a single place,
so eliminate it in favor of WriteInt.

duintxxLSym's alignment rounding was not used in practice;
change it into alignment assertion.

Passes toolstash-check. No compiler performance changes.

Change-Id: I0f7410cf2ccffbdc02ad796eaf973ee6a83074f8
Reviewed-on: https://go-review.googlesource.com/40863
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2017-04-16 08:11:38 -07:00
parent bb215de8a6
commit 89a355c930
2 changed files with 9 additions and 29 deletions

View File

@ -252,12 +252,15 @@ func duintxx(s *types.Sym, off int, v uint64, wid int) int {
}
func duintxxLSym(s *obj.LSym, off int, v uint64, wid int) int {
// Update symbol data directly instead of generating a
// DATA instruction that liblink will have to interpret later.
// This reduces compilation time and memory usage.
off = int(Rnd(int64(off), int64(wid)))
return int(obj.Setuintxx(Ctxt, s, int64(off), v, int64(wid)))
if s.Type == 0 {
// TODO(josharian): Do this in obj.prepwrite instead.
s.Type = obj.SDATA
}
if off&(wid-1) != 0 {
Fatalf("duintxxLSym: misaligned: v=%d wid=%d off=%d", v, wid, off)
}
s.WriteInt(Ctxt, int64(off), wid, int64(v))
return off + wid
}
func duint8(s *types.Sym, off int, v uint8) int {

View File

@ -181,26 +181,3 @@ func Addrel(s *LSym) *Reloc {
s.R = append(s.R, Reloc{})
return &s.R[len(s.R)-1]
}
func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
if s.Type == 0 {
s.Type = SDATA
}
if s.Size < off+wid {
s.Size = off + wid
s.Grow(s.Size)
}
switch wid {
case 1:
s.P[off] = uint8(v)
case 2:
ctxt.Arch.ByteOrder.PutUint16(s.P[off:], uint16(v))
case 4:
ctxt.Arch.ByteOrder.PutUint32(s.P[off:], uint32(v))
case 8:
ctxt.Arch.ByteOrder.PutUint64(s.P[off:], v)
}
return off + wid
}