[uim-commit] r2378 - branches/r5rs/sigscheme

kzk at freedesktop.org kzk at freedesktop.org
Mon Dec 5 09:44:26 PST 2005


Author: kzk
Date: 2005-12-05 09:43:42 -0800 (Mon, 05 Dec 2005)
New Revision: 2378

Modified:
   branches/r5rs/sigscheme/storage-gc.c
Log:
* implement GC related functions for SCM_OBJ_COMPACT
  Now bench/bench-fib.scm works.

* sigscheme/storage-gc.c
  - (gc_preprocess,
     mark_obj,
     sweep_obj,
     gc_sweep): implement for SCM_OBJ_COMPACT


Modified: branches/r5rs/sigscheme/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/storage-gc.c	2005-12-05 17:31:37 UTC (rev 2377)
+++ branches/r5rs/sigscheme/storage-gc.c	2005-12-05 17:43:42 UTC (rev 2378)
@@ -352,18 +352,21 @@
 
 static void gc_preprocess(void)
 {
+    int  i = 0;
+    long j = 0;
+
 #if SCM_OBJ_COMPACT
-    /* TODO : Implement Here! */
-    ;
+    for (i = 0; i < scm_heap_num; i++) {
+        for (j = 0; j < SCM_HEAP_SIZE; j++) {
+            SCM_DO_UNMARK(&scm_heaps[i][j]);
+        }
+    }    
 #else /* SCM_OBJ_COMPACT */
     ++scm_cur_marker;           /* make everything unmarked */
 
     if (scm_cur_marker == SCM_UNMARKER) {
         /* We've been running long enough to do
          * (1 << (sizeof(int)*8)) - 1 GCs, yay! */
-        int  i = 0;
-        long j = 0;
-
         scm_cur_marker = SCM_INITIAL_MARKER;
 
         /* unmark everything */
@@ -393,17 +396,18 @@
 
 static void mark_obj(ScmObj obj)
 {
-#if SCM_OBJ_COMPACT
-    /* TODO : Implement Here! */
-    ;
-#else /* SCM_OBJ_COMPACT */
     int i = 0;
 
 mark_loop:
+#if SCM_OBJ_COMPACT
+    /* no need to mark immediates */
+    if (INTP(obj) || CHARP(obj) || SCM_CONSTANTP(obj))
+        return;
+#else
     /* no need to mark SCM_NULL */
     if (NULLP(obj))
         return;
-
+#endif
     /* avoid cyclic marking */
     if (SCM_IS_MARKED(obj))
         return;
@@ -447,7 +451,6 @@
     default:
         break;
     }
-#endif /* SCM_OBJ_COMPACT */
 }
 
 static void finalize_protected_var(void)
@@ -547,10 +550,6 @@
 
 static void sweep_obj(ScmObj obj)
 {
-#if SCM_OBJ_COMPACT
-    /* TODO : Implement Here! */
-    ;
-#else /* SCM_OBJ_COMPACT */
     /* if the type has the pointer to free, then free it! */
     switch (SCM_TYPE(obj)) {
     case ScmCons:
@@ -597,15 +596,10 @@
     default:
         break;
     }
-#endif
 }
 
 static void gc_sweep(void)
 {
-#if SCM_OBJ_COMPACT
-    /* TODO : Implement Here! */
-    ;
-#else /* SCM_OBJ_COMPACT */
     int i = 0;
     int j = 0;
     int corrected_obj_num = 0;
@@ -619,7 +613,9 @@
         /* iterate in heap */
         for (j = 0; j < SCM_HEAP_SIZE; j++) {
             obj = &scm_heaps[i][j];
+#if !SCM_OBJ_COMPACT
             SCM_ASSERT(!SCM_MARK_CORRUPTED(obj));
+#endif
             if (!SCM_IS_MARKED(obj)) {
                 sweep_obj(obj);
 
@@ -634,5 +630,4 @@
         CDBG((SCM_DBG_GC, "heap[%d] swept = %d", i, corrected_obj_num));
     }
     scm_freelist = scm_new_freelist;
-#endif
 }



More information about the uim-commit mailing list