From 303b69feb7b26b583b53a3a82d824088064bbf2b Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 11 Oct 2016 11:34:20 -0700 Subject: [PATCH] cmd/compile, runtime: stop padding stackmaps to 4 bytes Shrinks cmd/go's text segment by 0.9%. text data bss dec hex filename 6447148 231643 146328 6825119 68249f go.before 6387404 231643 146328 6765375 673b3f go.after Change-Id: I431e8482dbb11a7c1c77f2196cada43d5dad2981 Reviewed-on: https://go-review.googlesource.com/30817 Reviewed-by: Austin Clements --- src/cmd/compile/internal/gc/obj.go | 10 +++------- src/runtime/symtab.go | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go index 3610f16c74..cb9ea52b62 100644 --- a/src/cmd/compile/internal/gc/obj.go +++ b/src/cmd/compile/internal/gc/obj.go @@ -272,14 +272,10 @@ func duintptr(s *Sym, off int, v uint64) int { } func dbvec(s *Sym, off int, bv bvec) int { - for j := 0; int32(j) < bv.n; j += 32 { + // Runtime reads the bitmaps as byte arrays. Oblige. + for j := 0; int32(j) < bv.n; j += 8 { word := bv.b[j/32] - - // Runtime reads the bitmaps as byte arrays. Oblige. - off = duint8(s, off, uint8(word)) - off = duint8(s, off, uint8(word>>8)) - off = duint8(s, off, uint8(word>>16)) - off = duint8(s, off, uint8(word>>24)) + off = duint8(s, off, uint8(word>>(uint(j)%32))) } return off } diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index c1cca7037d..24d63b70c0 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -603,5 +603,5 @@ func stackmapdata(stkmap *stackmap, n int32) bitvector { if n < 0 || n >= stkmap.n { throw("stackmapdata: index out of range") } - return bitvector{stkmap.nbit, (*byte)(add(unsafe.Pointer(&stkmap.bytedata), uintptr(n*((stkmap.nbit+31)/32*4))))} + return bitvector{stkmap.nbit, (*byte)(add(unsafe.Pointer(&stkmap.bytedata), uintptr(n*((stkmap.nbit+7)/8))))} }