repos / gcs.git


commit
399d780
parent
0cf561f
author
Evgenii Akentev
date
2024-09-17 19:34:52 +0400 +04
exploring two fingers
1 files changed,  +7, -3
M src/MarkCompact/TwoFinger.hs
+7, -3
 1@@ -4,6 +4,7 @@
 2 
 3 module MarkCompact.TwoFinger where
 4 
 5+import Debug.Trace 
 6 import Data.List (sortBy)
 7 import Data.Function (on)
 8 import Data.Array
 9@@ -145,6 +146,7 @@ markFromRoots = do
10 
11 collect :: GcM ()
12 collect = do
13+  traceShowM "mark!!!"
14   markFromRoots
15   compact
16 
17@@ -171,13 +173,13 @@ relocate start end = go start end
18         let indicesToUnmark = fmap fst $ takeWhile (\(_, marked) -> marked) $ assocs bm 
19             free' = if indicesToUnmark == [] then free else maximum indicesToUnmark
20             bm' = bm // [(i, False) | i <- indicesToUnmark] 
21-        put $ gc { bitmap = bm' }
22+        put $ gc { bitmap = traceShow (free', indicesToUnmark) bm' }
23 
24         let
25           findIndexStep marked (ok, idx)
26             | not marked && idx > free' = (ok, idx - 1)
27             | otherwise = (True, idx) 
28-          scan' = snd $ foldr findIndexStep (False, scan) bm
29+          scan' = snd $ foldr findIndexStep (False, scan) bm'
30     
31         if scan' > free' then do
32           put $ gc { bitmap = bm' // [(scan', False)]}
33@@ -217,6 +219,9 @@ main = do
34   let
35     res = flip runState initState $ unGcM $ do
36         ptr <- new (IntVal 1)
37+
38+        writeToRoots 1 ptr 
39+
40         ptr2 <- new (IntVal 2) 
41         ptr3 <- new (IntVal 3) 
42         ptr4 <- new (IntVal 4) 
43@@ -225,7 +230,6 @@ main = do
44         ptr7 <- new (IntVal 7) 
45         ptr8 <- new (IntVal 8) 
46 
47-        writeToRoots 1 ptr 
48 
49         collect
50