diff options
Diffstat (limited to 'src/runtime/mbitmap.go')
| -rw-r--r-- | src/runtime/mbitmap.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index dc99ba768b..8fee8262b7 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -132,7 +132,8 @@ func (s *mspan) refillAllocCache(whichByte uintptr) { } // nextFreeIndex returns the index of the next free object in s at -// or after s.freeindex. +// or after s.freeindex. s.freeindex is not updated (except the full +// span case), but the alloc cache is updated. // There are hardware instructions that can be used to make this // faster if profiling warrants it. func (s *mspan) nextFreeIndex() uintptr { @@ -170,9 +171,18 @@ func (s *mspan) nextFreeIndex() uintptr { } s.allocCache >>= uint(bitIndex + 1) - sfreeindex = result + 1 - if sfreeindex%64 == 0 && sfreeindex != snelems { + // NOTE: s.freeindex is not updated for now (although allocCache + // is updated). mallocgc will update s.freeindex later after the + // memory is initialized. + + return result +} + +// updateFreeIndex updates s.freeindex to sfreeindex, refills +// the allocCache if necessary. +func (s *mspan) updateFreeIndex(sfreeindex uintptr) { + if sfreeindex%64 == 0 && sfreeindex != s.nelems { // We just incremented s.freeindex so it isn't 0. // As each 1 in s.allocCache was encountered and used for allocation // it was shifted away. At this point s.allocCache contains all 0s. @@ -182,7 +192,6 @@ func (s *mspan) nextFreeIndex() uintptr { s.refillAllocCache(whichByte) } s.freeindex = sfreeindex - return result } // isFree reports whether the index'th object in s is unallocated. |
