bugfix: mark&sweep GC

This commit is contained in:
Araq 2013-03-29 16:36:24 +01:00
commit e24305f1e1

View file

@ -312,20 +312,22 @@ proc chunkUnused(c: PChunk): bool {.inline.} =
iterator allObjects(m: TMemRegion): pointer {.inline.} = iterator allObjects(m: TMemRegion): pointer {.inline.} =
for s in elements(m.chunkStarts): for s in elements(m.chunkStarts):
let c = cast[PChunk](s shl PageShift) # we need to check here again as it could have been modified:
if not chunkUnused(c): if s in m.chunkStarts:
if isSmallChunk(c): let c = cast[PChunk](s shl PageShift)
var c = cast[PSmallChunk](c) if not chunkUnused(c):
if isSmallChunk(c):
let size = c.size var c = cast[PSmallChunk](c)
var a = cast[TAddress](addr(c.data))
let limit = a + c.acc let size = c.size
while a <% limit: var a = cast[TAddress](addr(c.data))
yield cast[pointer](a) let limit = a + c.acc
a = a +% size while a <% limit:
else: yield cast[pointer](a)
let c = cast[PBigChunk](c) a = a +% size
yield addr(c.data) else:
let c = cast[PBigChunk](c)
yield addr(c.data)
proc isCell(p: pointer): bool {.inline.} = proc isCell(p: pointer): bool {.inline.} =
result = cast[ptr TFreeCell](p).zeroField >% 1 result = cast[ptr TFreeCell](p).zeroField >% 1