From 2b59307ac21135ab8db58e08fb98211fbedbb10d Mon Sep 17 00:00:00 2001 From: Michael Knyszek Date: Fri, 11 Nov 2022 18:34:18 +0000 Subject: 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 Reviewed-by: Cherry Mui Run-TryBot: Michael Knyszek --- src/runtime/mbitmap.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/runtime/mbitmap.go') 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. -- cgit v1.3