mark and sweep without bitvectors

This commit is contained in:
Araq 2013-02-19 17:31:54 +01:00
commit a4d47664d6
2 changed files with 77 additions and 29 deletions

View file

@ -303,7 +303,32 @@ iterator elements(t: TIntSet): int {.inline.} =
w = w shr 1
inc(i)
r = r.next
proc isSmallChunk(c: PChunk): bool {.inline.} =
return c.size <= SmallChunkSize-smallChunkOverhead()
proc chunkUnused(c: PChunk): bool {.inline.} =
result = not c.used
iterator allObjects(m: TMemRegion): pointer {.inline.} =
for s in elements(m.chunkStarts):
let c = cast[PChunk](s shl PageShift)
if not chunkUnused(c):
if isSmallChunk(c):
var c = cast[PSmallChunk](c)
let size = c.size
var a = cast[TAddress](addr(c.data))
while a <% c.acc:
yield cast[pointer](a)
a = a +% size
else:
let c = cast[PBigChunk](c)
yield addr(c.data)
proc isCell(p: pointer): bool {.inline.} =
result = cast[ptr TFreeCell](p).zeroField >% 1
# ------------- chunk management ----------------------------------------------
proc pageIndex(c: PChunk): int {.inline.} =
result = cast[TAddress](c) shr PageShift
@ -398,12 +423,6 @@ proc ListRemove[T](head: var T, c: T) {.inline.} =
c.next = nil
c.prev = nil
proc isSmallChunk(c: PChunk): bool {.inline.} =
return c.size <= SmallChunkSize-smallChunkOverhead()
proc chunkUnused(c: PChunk): bool {.inline.} =
result = not c.used
proc updatePrevSize(a: var TMemRegion, c: PBigChunk,
prevSize: int) {.inline.} =
var ri = cast[PChunk](cast[TAddress](c) +% c.size)