1
0
mirror of https://github.com/golang/go synced 2024-09-24 09:20:15 -06:00

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 <austin@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Jakub Ciolek 2022-03-18 09:10:02 +01:00 committed by Austin Clements
parent 4b6debaf28
commit 86c8075675

View 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
}