mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: introduce a type for span states
Currently span states are untyped constants and the field is just a uint8. Make this more type-safe by introducing a type for the span state. Change-Id: I369bf59fe6e8234475f4921611424fceb7d0a6de Reviewed-on: https://go-review.googlesource.com/30141 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
5a6e511c61
commit
6879dbde4e
1 changed files with 19 additions and 17 deletions
|
|
@ -102,8 +102,10 @@ var mheap_ mheap
|
||||||
// * During GC (gcphase != _GCoff), a span *must not* transition from
|
// * During GC (gcphase != _GCoff), a span *must not* transition from
|
||||||
// stack or in-use to free. Because concurrent GC may read a pointer
|
// stack or in-use to free. Because concurrent GC may read a pointer
|
||||||
// and then look up its span, the span state must be monotonic.
|
// and then look up its span, the span state must be monotonic.
|
||||||
|
type mSpanState uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_MSpanInUse = iota // allocated for garbage collected heap
|
_MSpanInUse mSpanState = iota // allocated for garbage collected heap
|
||||||
_MSpanStack // allocated for use by stack allocator
|
_MSpanStack // allocated for use by stack allocator
|
||||||
_MSpanFree
|
_MSpanFree
|
||||||
_MSpanDead
|
_MSpanDead
|
||||||
|
|
@ -190,7 +192,7 @@ type mspan struct {
|
||||||
allocCount uint16 // capacity - number of objects in freelist
|
allocCount uint16 // capacity - number of objects in freelist
|
||||||
sizeclass uint8 // size class
|
sizeclass uint8 // size class
|
||||||
incache bool // being used by an mcache
|
incache bool // being used by an mcache
|
||||||
state uint8 // mspaninuse etc
|
state mSpanState // mspaninuse etc
|
||||||
needzero uint8 // needs to be zeroed before allocation
|
needzero uint8 // needs to be zeroed before allocation
|
||||||
divShift uint8 // for divide by elemsize - divMagic.shift
|
divShift uint8 // for divide by elemsize - divMagic.shift
|
||||||
divShift2 uint8 // for divide by elemsize - divMagic.shift2
|
divShift2 uint8 // for divide by elemsize - divMagic.shift2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue