From 72483de87a36969f0c4d6f01db19f769c8e16e82 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 15 Mar 2021 16:15:23 -0700 Subject: [PATCH] runtime: incorporate hbits advancement in scanobject into loop 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 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/mgcmark.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 45ccc806bdf..cb73caf3bb7 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -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 {