]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: unify Setuintxx and WriteInt
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 16 Apr 2017 15:11:38 +0000 (08:11 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 17 Apr 2017 03:15:02 +0000 (03:15 +0000)
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>

src/cmd/compile/internal/gc/obj.go
src/cmd/internal/obj/data.go

index 8062a43126352260156d163dff1ee2f628ab6918..184cccb965f260d53779b4086a5159d0cd3c260d 100644 (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 {
index 5f583071e62047dcb86636f84315e57e5a2eb3ab..e67852ac3b6fe89758fae934a708cd21eb3727f8 100644 (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
-}