]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: eliminate a conditional branch from heapBits.bits
authorAustin Clements <austin@google.com>
Thu, 21 Jan 2016 18:44:16 +0000 (13:44 -0500)
committerAustin Clements <austin@google.com>
Thu, 25 Feb 2016 23:37:29 +0000 (23:37 +0000)
Change-Id: I1fa5e629b2890a8509559ce4ea17b74f47d71925
Reviewed-on: https://go-review.googlesource.com/19637
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mbitmap.go

index 04992890a18497de2f1967fbea5e2734f72c794c..154fc3e0f316f4fd445d8304c9bf80924f518db1 100644 (file)
@@ -290,7 +290,9 @@ func (h heapBits) forward(n uintptr) heapBits {
 // The result includes in its higher bits the bits for subsequent words
 // described by the same bitmap byte.
 func (h heapBits) bits() uint32 {
-       return uint32(*h.bitp) >> h.shift
+       // The (shift & 31) eliminates a test and conditional branch
+       // from the generated code.
+       return uint32(*h.bitp) >> (h.shift & 31)
 }
 
 // isMarked reports whether the heap bits have the marked bit set.