From: Jakub Ciolek Date: Fri, 18 Mar 2022 08:10:02 +0000 (+0100) Subject: runtime: combine wbuf checks in tryGetFast and putFast X-Git-Tag: go1.19beta1~968 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=86c8075675ed74c1f404894242c26b99800f1639;p=gostls13.git runtime: combine wbuf checks in tryGetFast and putFast 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 Reviewed-by: Robert Griesemer Trust: Michael Knyszek --- diff --git a/src/runtime/mgcwork.go b/src/runtime/mgcwork.go index 9c3f7fd223..56d0b1cd62 100644 --- a/src/runtime/mgcwork.go +++ b/src/runtime/mgcwork.go @@ -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 }