From 89a355c9306800df2062f9fb590cba2c2281948a Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sun, 16 Apr 2017 08:11:38 -0700 Subject: [PATCH] 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 Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/obj.go | 15 +++++++++------ src/cmd/internal/obj/data.go | 23 ----------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go index 8062a43126..184cccb965 100644 --- a/src/cmd/compile/internal/gc/obj.go +++ b/src/cmd/compile/internal/gc/obj.go @@ -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 { diff --git a/src/cmd/internal/obj/data.go b/src/cmd/internal/obj/data.go index 5f583071e6..e67852ac3b 100644 --- a/src/cmd/internal/obj/data.go +++ b/src/cmd/internal/obj/data.go @@ -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 -} -- 2.48.1