diff options
| author | Michael Knyszek <mknyszek@google.com> | 2022-11-11 18:34:18 +0000 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2022-11-14 22:09:16 +0000 |
| commit | 2b59307ac21135ab8db58e08fb98211fbedbb10d (patch) | |
| tree | 6734f48f3c07070439dcfc35aac838dab9868a5f /src/runtime/mbitmap.go | |
| parent | 998c11d2187d8afaa315f58f29f80b6882d2701c (diff) | |
| download | go-2b59307ac21135ab8db58e08fb98211fbedbb10d.tar.xz | |
Revert "runtime: delay incrementing freeindex in malloc"
This reverts commit bed2b7cf41471e1521af5a83ae28bd643eb3e038.
Reason for revert: I clicked submit by accident on the wrong CL.
Change-Id: Iddf128cb62f289d472510eb30466e515068271b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/449501
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/mbitmap.go')
| -rw-r--r-- | src/runtime/mbitmap.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 8fee8262b7..dc99ba768b 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -132,8 +132,7 @@ func (s *mspan) refillAllocCache(whichByte uintptr) { } // nextFreeIndex returns the index of the next free object in s at -// or after s.freeindex. s.freeindex is not updated (except the full -// span case), but the alloc cache is updated. +// or after s.freeindex. // There are hardware instructions that can be used to make this // faster if profiling warrants it. func (s *mspan) nextFreeIndex() uintptr { @@ -171,18 +170,9 @@ func (s *mspan) nextFreeIndex() uintptr { } s.allocCache >>= uint(bitIndex + 1) + sfreeindex = result + 1 - // 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 { + if sfreeindex%64 == 0 && sfreeindex != snelems { // 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. @@ -192,6 +182,7 @@ func (s *mspan) updateFreeIndex(sfreeindex uintptr) { s.refillAllocCache(whichByte) } s.freeindex = sfreeindex + return result } // isFree reports whether the index'th object in s is unallocated. |
