aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mbitmap.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-10-02 18:46:02 -0400
committerAustin Clements <austin@google.com>2016-10-24 02:33:39 +0000
commit3cbfcaa4ba898faba516fbb9f3debf4ceac1a557 (patch)
tree87104a5e6f223ea579470615804631731e29e55e /src/runtime/mbitmap.go
parentbf9c71cb434a730679f54a3a87c2e9e36ec400d0 (diff)
downloadgo-3cbfcaa4ba898faba516fbb9f3debf4ceac1a557.tar.xz
runtime: make mspan.isFree do what's on the tin
Currently mspan.isFree technically returns whether the object was not allocated *during this cycle*. Fix it so it actually returns whether or not the object is allocated so the method is more generally useful (especially for debugging). It has one caller, which is carefully written to be insensitive to this distinction, but this lets us simplify this caller. Change-Id: I9d79cf784a56015e434961733093c1d8d03fc091 Reviewed-on: https://go-review.googlesource.com/30145 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mbitmap.go')
-rw-r--r--src/runtime/mbitmap.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index 3363cd0682..7171d3adbd 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -264,7 +264,11 @@ func (s *mspan) nextFreeIndex() uintptr {
return result
}
+// isFree returns whether the index'th object in s is unallocated.
func (s *mspan) isFree(index uintptr) bool {
+ if index < s.freeindex {
+ return false
+ }
whichByte := index / 8
whichBit := index % 8
byteVal := *addb(s.allocBits, whichByte)