]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: refactor stackmap dumping code
authorMatthew Dempsky <mdempsky@google.com>
Tue, 11 Oct 2016 17:23:14 +0000 (10:23 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 11 Oct 2016 20:23:24 +0000 (20:23 +0000)
Also, fix a byte-ordering problem with stack maps for assembly
function signatures on big-endian targets.

Change-Id: I6e8698f5fbb04b31771a65f4a8f3f9c045ff3c98
Reviewed-on: https://go-review.googlesource.com/30816
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/plive.go

index a51e8999eafcb577c27eb973e19214d7b566e9ad..3610f16c747801c6b8d058eb13d365d7de7086fb 100644 (file)
@@ -271,6 +271,19 @@ func duintptr(s *Sym, off int, v uint64) int {
        return duintxx(s, off, v, Widthptr)
 }
 
+func dbvec(s *Sym, off int, bv bvec) int {
+       for j := 0; int32(j) < bv.n; j += 32 {
+               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))
+       }
+       return off
+}
+
 // stringConstantSyms holds the pair of symbols we create for a
 // constant string.
 type stringConstantSyms struct {
index ef4ac11a89c3a3cae25257414b99b33bbcd482de..f88e3702775e31965c78d397f37b91df1dfe8ef1 100644 (file)
@@ -157,15 +157,11 @@ func emitptrargsmap() {
                onebitwalktype1(Curfn.Type.Params(), &xoffset, bv)
        }
 
-       for j := 0; int32(j) < bv.n; j += 32 {
-               off = duint32(sym, off, bv.b[j/32])
-       }
+       off = dbvec(sym, off, bv)
        if Curfn.Type.Results().NumFields() > 0 {
                xoffset = 0
                onebitwalktype1(Curfn.Type.Results(), &xoffset, bv)
-               for j := 0; int32(j) < bv.n; j += 32 {
-                       off = duint32(sym, off, bv.b[j/32])
-               }
+               off = dbvec(sym, off, bv)
        }
 
        ggloblsym(sym, int32(off), obj.RODATA|obj.LOCAL)
index 588b69dc30ae0c69c9b5366d26978db9c9c093bb..1d5e5cfbbb4e4baa81883d7fc48209abdcc2a15b 100644 (file)
@@ -1666,7 +1666,7 @@ func livenessprintdebug(lv *Liveness) {
 // Dumps a slice of bitmaps to a symbol as a sequence of uint32 values. The
 // first word dumped is the total number of bitmaps. The second word is the
 // length of the bitmaps. All bitmaps are assumed to be of equal length. The
-// words that are followed are the raw bitmap words.
+// remaining bytes are the raw bitmaps.
 func onebitwritesymbol(arr []bvec, sym *Sym) {
        off := 4                                  // number of bitmaps, to fill in later
        off = duint32(sym, off, uint32(arr[0].n)) // number of bits in each bitmap
@@ -1678,16 +1678,7 @@ func onebitwritesymbol(arr []bvec, sym *Sym) {
                if bv.b == nil {
                        break
                }
-               for j := 0; int32(j) < bv.n; j += 32 {
-                       word := bv.b[j/32]
-
-                       // Runtime reads the bitmaps as byte arrays. Oblige.
-                       off = duint8(sym, off, uint8(word))
-
-                       off = duint8(sym, off, uint8(word>>8))
-                       off = duint8(sym, off, uint8(word>>16))
-                       off = duint8(sym, off, uint8(word>>24))
-               }
+               off = dbvec(sym, off, bv)
        }
 
        duint32(sym, 0, uint32(i)) // number of bitmaps