]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: combine wbuf checks in tryGetFast and putFast
authorJakub Ciolek <jakub@ciolek.dev>
Fri, 18 Mar 2022 08:10:02 +0000 (09:10 +0100)
committerAustin Clements <austin@google.com>
Mon, 21 Mar 2022 22:42:59 +0000 (22:42 +0000)
Less text and improves codegen a bit.

compilecmp on ARM64:

runtime
(*gcWork).putFast 160 -> 144  (-10.00%)
(*gcWork).tryGetFast 144 -> 128  (-11.11%)
scanobject 784 -> 752  (-4.08%)
greyobject 800 -> 784  (-2.00%)

AMD64:

runtime
greyobject 765 -> 748  (-2.22%)
(*gcWork).tryGetFast 102 -> 85  (-16.67%)
scanobject 837 -> 820  (-2.03%)
(*gcWork).putFast 102 -> 89  (-12.75%)

Change-Id: I6bb508afe1ba416823775c0bfc08ea9dc21de8a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/393754
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>

src/runtime/mgcwork.go

index 9c3f7fd223a943716dbab8549f1d638696fe6d74..56d0b1cd6214fce0f28834300fd63bdd45955e71 100644 (file)
@@ -148,9 +148,7 @@ func (w *gcWork) put(obj uintptr) {
 //go:nowritebarrierrec
 func (w *gcWork) putFast(obj uintptr) bool {
        wbuf := w.wbuf1
-       if wbuf == nil {
-               return false
-       } else if wbuf.nobj == len(wbuf.obj) {
+       if wbuf == nil || wbuf.nobj == len(wbuf.obj) {
                return false
        }
 
@@ -230,10 +228,7 @@ func (w *gcWork) tryGet() uintptr {
 //go:nowritebarrierrec
 func (w *gcWork) tryGetFast() uintptr {
        wbuf := w.wbuf1
-       if wbuf == nil {
-               return 0
-       }
-       if wbuf.nobj == 0 {
+       if wbuf == nil || wbuf.nobj == 0 {
                return 0
        }