mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.garbage] runtime: use sys.Ctz64 intrinsic
Our compilers now provides instrinsics including sys.Ctz64 that support CTZ (count trailing zero) instructions. This CL replaces the Go versions of CTZ with the compiler intrinsic. Count trailing zeros CTZ finds the least significant 1 in a word and returns the number of less significant 0s in the word. Allocation uses the bitmap created by the garbage collector to locate an unmarked object. The logic takes a word of the bitmap, complements, and then caches it. It then uses CTZ to locate an available unmarked object. It then shifts marked bits out of the bitmap word preparing it for the next search. Once all the unmarked objects are used in the cached work the bitmap gets another word and repeats the process. Change-Id: Id2fc42d1d4b9893efaa2e1bd01896985b7e42f82 Reviewed-on: https://go-review.googlesource.com/21366 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
2063d5d903
commit
2fb75ea6c6
3 changed files with 12 additions and 66 deletions
|
|
@ -145,7 +145,7 @@ type mspan struct {
|
|||
// Cache of the allocBits at freeindex. allocCache is shifted
|
||||
// such that the lowest bit corresponds to the bit freeindex.
|
||||
// allocCache holds the complement of allocBits, thus allowing
|
||||
// ctz64 (count trailing zero) to use it directly.
|
||||
// ctz (count trailing zero) to use it directly.
|
||||
// allocCache may contain bits beyond s.nelems; the caller must ignore
|
||||
// these.
|
||||
allocCache uint64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue