]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make mspan.isFree do what's on the tin
authorAustin Clements <austin@google.com>
Sun, 2 Oct 2016 22:46:02 +0000 (18:46 -0400)
committerAustin Clements <austin@google.com>
Mon, 24 Oct 2016 02:33:39 +0000 (02:33 +0000)
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>
src/runtime/heapdump.go
src/runtime/mbitmap.go

index c317b5f969f7d4d54ee90d1b060e2579856aaac6..f7d7aac2a76467c0bdcbb23dbcdeb1613a666623 100644 (file)
@@ -474,7 +474,7 @@ func dumpobjs() {
                        throw("freemark array doesn't have enough entries")
                }
 
-               for freeIndex := s.freeindex; freeIndex < s.nelems; freeIndex++ {
+               for freeIndex := uintptr(0); freeIndex < s.nelems; freeIndex++ {
                        if s.isFree(freeIndex) {
                                freemark[freeIndex] = true
                        }
index 3363cd0682fc7ab5d4a7086b84b64aa32eb41426..7171d3adbd9facaa2888f0e3f6645e0501b68264 100644 (file)
@@ -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)