diff options
| author | Austin Clements <austin@google.com> | 2016-09-09 10:31:27 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2016-10-03 21:59:45 +0000 |
| commit | 6879dbde4e6dceceb272b83fc6682e97b9de2fa1 (patch) | |
| tree | 9751af3ce380bc3e27c484a6db6f4978819b9295 | |
| parent | 5a6e511c614a158cb58150fb62bfbc207a33922d (diff) | |
| download | go-6879dbde4e6dceceb272b83fc6682e97b9de2fa1.tar.xz | |
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>
| -rw-r--r-- | src/runtime/mheap.go | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index dfb484c06e..808f141946 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -102,9 +102,11 @@ var mheap_ mheap // * During GC (gcphase != _GCoff), a span *must not* transition from // 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. +type mSpanState uint8 + const ( - _MSpanInUse = iota // allocated for garbage collected heap - _MSpanStack // allocated for use by stack allocator + _MSpanInUse mSpanState = iota // allocated for garbage collected heap + _MSpanStack // allocated for use by stack allocator _MSpanFree _MSpanDead ) @@ -186,21 +188,21 @@ type mspan struct { // h->sweepgen is incremented by 2 after every GC sweepgen uint32 - divMul uint32 // for divide by elemsize - divMagic.mul - allocCount uint16 // capacity - number of objects in freelist - sizeclass uint8 // size class - incache bool // being used by an mcache - state uint8 // mspaninuse etc - needzero uint8 // needs to be zeroed before allocation - divShift uint8 // for divide by elemsize - divMagic.shift - divShift2 uint8 // for divide by elemsize - divMagic.shift2 - elemsize uintptr // computed from sizeclass or from npages - unusedsince int64 // first time spotted by gc in mspanfree state - npreleased uintptr // number of pages released to the os - limit uintptr // end of data in span - speciallock mutex // guards specials list - specials *special // linked list of special records sorted by offset. - baseMask uintptr // if non-0, elemsize is a power of 2, & this will get object allocation base + divMul uint32 // for divide by elemsize - divMagic.mul + allocCount uint16 // capacity - number of objects in freelist + sizeclass uint8 // size class + incache bool // being used by an mcache + state mSpanState // mspaninuse etc + needzero uint8 // needs to be zeroed before allocation + divShift uint8 // for divide by elemsize - divMagic.shift + divShift2 uint8 // for divide by elemsize - divMagic.shift2 + elemsize uintptr // computed from sizeclass or from npages + unusedsince int64 // first time spotted by gc in mspanfree state + npreleased uintptr // number of pages released to the os + limit uintptr // end of data in span + speciallock mutex // guards specials list + specials *special // linked list of special records sorted by offset. + baseMask uintptr // if non-0, elemsize is a power of 2, & this will get object allocation base } func (s *mspan) base() uintptr { |
