Ian Lance Taylor <
ia...@golang.org> writes:
>
> I don't know all the details here, but scavChunkData packs into a
> 64-bit value (see the pack method). That is useful because that 64-bit
> value can be loaded and stored atomically. It works out that there are
> only six bits available for scavChunkFlags, as the comment says. So a
> 10-bit counter isn't available.
>
> Ian
Thanks very much, but I also found the layout of scanChunkData is like:
| 10-bit [inUse] + 6-bit unused | 10-bit [lastInUse] + 6-bit [scavChunkFlag] | 32 bit [gen] |
And actually we have 12-bit left besides inUse/lastInUse/gen.
```go
// pack returns sc packed into a uint64.
func (sc scavChunkData) pack() uint64 {
return uint64(sc.inUse) |
(uint64(sc.lastInUse) << 16) |
(uint64(sc.scavChunkFlags) << (16 + logScavChunkInUseMax)) |
(uint64(sc.gen) << 32)
}
```