]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: incorporate hbits advancement in scanobject into loop
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 15 Mar 2021 23:15:23 +0000 (16:15 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 14 Apr 2021 14:27:05 +0000 (14:27 +0000)
This makes it clearer that i and hbits advance together.
As a bonus, it generates slightly better code.

Change-Id: I24d51102535c39f962a59c1a4a7c5c894339aa18
Reviewed-on: https://go-review.googlesource.com/c/go/+/309569
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgcmark.go

index 45ccc806bdf965d4fab3a5280f544dcfd7c3dbc5..cb73caf3bb77fc049e2101a17a7aa5e1d3888cf9 100644 (file)
@@ -1257,12 +1257,7 @@ func scanobject(b uintptr, gcw *gcWork) {
        }
 
        var i uintptr
-       for i = 0; i < n; i += sys.PtrSize {
-               // Find bits for this word.
-               if i != 0 {
-                       // Avoid needless hbits.next() on last iteration.
-                       hbits = hbits.next()
-               }
+       for i = 0; i < n; i, hbits = i+sys.PtrSize, hbits.next() {
                // Load bits once. See CL 22712 and issue 16973 for discussion.
                bits := hbits.bits()
                if bits&bitScan == 0 {