From: Evgenii Akentev Date: Tue, 17 Sep 2024 15:34:52 +0000 (+0400) Subject: exploring two fingers X-Git-Url: https://git.ak3n.com/?a=commitdiff_plain;h=399d7800626c72eadd88b115e98820c67e9da9a1;p=gcs.git exploring two fingers --- diff --git a/src/MarkCompact/TwoFinger.hs b/src/MarkCompact/TwoFinger.hs index 50f4204..1cc174c 100644 --- a/src/MarkCompact/TwoFinger.hs +++ b/src/MarkCompact/TwoFinger.hs @@ -4,6 +4,7 @@ module MarkCompact.TwoFinger where +import Debug.Trace import Data.List (sortBy) import Data.Function (on) import Data.Array @@ -145,6 +146,7 @@ markFromRoots = do collect :: GcM () collect = do + traceShowM "mark!!!" markFromRoots compact @@ -171,13 +173,13 @@ relocate start end = go start end let indicesToUnmark = fmap fst $ takeWhile (\(_, marked) -> marked) $ assocs bm free' = if indicesToUnmark == [] then free else maximum indicesToUnmark bm' = bm // [(i, False) | i <- indicesToUnmark] - put $ gc { bitmap = bm' } + put $ gc { bitmap = traceShow (free', indicesToUnmark) bm' } let findIndexStep marked (ok, idx) | not marked && idx > free' = (ok, idx - 1) | otherwise = (True, idx) - scan' = snd $ foldr findIndexStep (False, scan) bm + scan' = snd $ foldr findIndexStep (False, scan) bm' if scan' > free' then do put $ gc { bitmap = bm' // [(scan', False)]} @@ -217,6 +219,9 @@ main = do let res = flip runState initState $ unGcM $ do ptr <- new (IntVal 1) + + writeToRoots 1 ptr + ptr2 <- new (IntVal 2) ptr3 <- new (IntVal 3) ptr4 <- new (IntVal 4) @@ -225,7 +230,6 @@ main = do ptr7 <- new (IntVal 7) ptr8 <- new (IntVal 8) - writeToRoots 1 ptr collect