Cheney's algorithm: Difference between revisions

Content deleted Content added
Refined the algorithm example:
Fix a bug in the example implementation of the algorithm where `fromspace` was wrongly assigned to `allocPtr` and `scanPtr` in collect(). It should be `tospace` (after swapping) where `allocPtr` and `scanPtr` start at.
Line 43:
collect() =
swap(fromspace, tospace)
allocPtr = fromspacetospace
scanPtr = fromspacetospace
 
-- scan every root you've got
Line 51:
EndForEach
-- scan objects in the heapto-space (including objects added by this loop)
While scanPtr < allocPtr
ForEach reference r from o (pointed to by scanPtr)
r = copy(r)
EndForEach
scanPtr = scanPtr + o.size() -- points to the next object in the heapto-space, if any
EndWhile
 
</pre>