Author: yamakenz
Date: Mon Aug  6 10:05:34 2007
New Revision: 4795

Modified:
   sigscheme-trunk/src/sigschemeinternal.h
   sigscheme-trunk/src/storage-common.h
   sigscheme-trunk/src/storage-compact.h
   sigscheme-trunk/src/storage-fatty.h
   sigscheme-trunk/src/storage-gc.c

Log:
* src/sigschemeinternal.h
  - (SCM_MARKEDP, SCM_UNMARKEDP, SCM_MARK, SCM_UNMARK): Removed
* src/storage-common.h
  - (SCM_MARKEDP, SCM_MARK, SCM_CELL_MARKEDP, SCM_CELL_UNMARK): New macro
    defined with SCM_TYPESAFE_MACRO
* src/storage-compact.h
  - (SCM_SAL_MARK, SCM_SAL_UNMARK, SCM_SAL_MARKEDP, SCM_SAL_UNMARKEDP): Removed
  - (SCM_ISAL_MARKEDP, SCM_ISAL_MARK, SCM_ISAL_CELL_MARKEDP,
    SCM_ISAL_CELL_UNMARK): New macro
* src/storage-fatty.h
  - (SCM_SAL_MARKEDP, SCM_SAL_UNMARKEDP, SCM_SAL_MARK, SCM_SAL_UNMARK): Removed
  - (SCM_ISAL_MARKEDP, SCM_ISAL_MARK, SCM_ISAL_CELL_MARKEDP,
    SCM_ISAL_CELL_UNMARK): New macro
* src/storage-gc.c
  - (gc_sweep): Simplify with SCM_CELL_MARKEDP() and SCM_CELL_UNMARK()


Modified: sigscheme-trunk/src/sigschemeinternal.h
==============================================================================
--- sigscheme-trunk/src/sigschemeinternal.h     (original)
+++ sigscheme-trunk/src/sigschemeinternal.h     Mon Aug  6 10:05:34 2007
@@ -216,6 +216,7 @@
 #define TRACE_FRAME_OBJ CAR
 #define TRACE_FRAME_ENV CDR
 
+/* TODO: Remove valuecons to increase simiplicity. */
 /* Extraction of a valuepacket is granted only for SigScheme-internals */
 #define SCM_VALUEPACKET_VALUES(o)    SCM_SAL_VALUEPACKET_VALUES(o)
 #if SCM_USE_VALUECONS
@@ -227,6 +228,8 @@
     SCM_SAL_VALUEPACKET_SET_VALUES((o), (vals))
 #endif /* SCM_USE_VALUECONS */
 
+/* TODO: Remove the concept 'freecell object' from SAL and replace with
+ * ordinary cons cells with freecell-marker in storage-{compact,fatty}. */
 #define SCM_AS_FREECELL(o)              SCM_SAL_AS_FREECELL(o)
 
 #define SCM_FREECELLP(o)                SCM_SAL_FREECELLP(o)
@@ -235,19 +238,6 @@
 #define SCM_FREECELL_SET_NEXT(o, next)  SCM_SAL_FREECELL_SET_NEXT((o), (next))
 #define SCM_FREECELL_SET_FREESLOT(o, v) SCM_SAL_FREECELL_SET_FREESLOT((o), (v))
 #define SCM_FREECELL_CLEAR_FREESLOT(o)  SCM_SAL_FREECELL_CLEAR_FREESLOT((o))
-
-#if 0
-/* for future cleanup */
-#define SCM_CELL_MARKEDP(cell)   SCM_SAL_CELL_MARKEDP(cell)
-#define SCM_CELL_UNMARKEDP(cell) SCM_SAL_CELL_UNMARKEDP(cell)
-#define SCM_CELL_MARK(cell)      SCM_SAL_CELL_MARK(cell)
-#define SCM_CELL_UNMARK(cell)    SCM_SAL_CELL_UNMARK(cell)
-#else
-#define SCM_MARKEDP(o)   SCM_SAL_MARKEDP(o)
-#define SCM_UNMARKEDP(o) SCM_SAL_UNMARKEDP(o)
-#define SCM_MARK(o)      SCM_SAL_MARK(o)
-#define SCM_UNMARK(o)    SCM_SAL_UNMARK(o)
-#endif
 
 #define EQVP(a, b)   (SCM_EQVP((a), (b)))
 #define EQUALP(a, b) (TRUEP(scm_p_equalp((a), (b))))

Modified: sigscheme-trunk/src/storage-common.h
==============================================================================
--- sigscheme-trunk/src/storage-common.h        (original)
+++ sigscheme-trunk/src/storage-common.h        Mon Aug  6 10:05:34 2007
@@ -50,6 +50,27 @@
 /*=======================================
   Internal SAL
 =======================================*/
+/* for mark phase */
+#define SCM_MARKEDP(o)                                                  \
+    SCM_TYPESAFE_MACRO(SCM_ISAL_MARKEDP,                                \
+                       int,                                             \
+                       (ScmObj),                                        \
+                       (o))
+#define SCM_MARK(o)                                                     \
+    SCM_TYPESAFE_MACRO_VOID(SCM_ISAL_MARK,                              \
+                            (ScmObj),                                   \
+                            (o))
+
+/* for sweep phase */
+#define SCM_CELL_MARKEDP(c)                                             \
+    SCM_TYPESAFE_MACRO(SCM_ISAL_CELL_MARKEDP,                           \
+                       int,                                             \
+                       (ScmCell *),                                     \
+                       (c))
+#define SCM_CELL_UNMARK(c)                                              \
+    SCM_TYPESAFE_MACRO_VOID(SCM_ISAL_CELL_UNMARK,                       \
+                            (ScmCell *),                                \
+                            (c))
 #define SCM_CELL_FREECELLP(c)                                           \
     SCM_TYPESAFE_MACRO(SCM_ISAL_CELL_FREECELLP,                         \
                        int,                                             \

Modified: sigscheme-trunk/src/storage-compact.h
==============================================================================
--- sigscheme-trunk/src/storage-compact.h       (original)
+++ sigscheme-trunk/src/storage-compact.h       Mon Aug  6 10:05:34 2007
@@ -269,16 +269,16 @@
  * Garbage collection
  */
 
-#define SCM_SAL_MARK(o)                                                  \
-    SCM_SET_X(SCM_DROP_TAG(o),                                           \
+#define SCM_ISAL_MARKEDP(o)       (SCM_GCBIT(SCM_X(SCM_DROP_TAG(o)))    \
+                                   == SCM_GCBIT_MARKED)
+#define SCM_ISAL_MARK(o)                                                \
+    SCM_SET_X(SCM_DROP_TAG(o),                                          \
               SCM_DROP_GCBIT(SCM_X(SCM_DROP_TAG(o))) | SCM_GCBIT_MARKED)
 
+#define SCM_ISAL_CELL_MARKEDP(c)  (SCM_GCBIT(SCM_X(c)) == SCM_GCBIT_MARKED)
 /* O is always untagged, so no need to strip it. */
-#define SCM_SAL_UNMARK(o)                                               \
-    SCM_SET_X((o), SCM_DROP_GCBIT(SCM_X(o)) | SCM_GCBIT_UNMARKED)
-#define SCM_SAL_MARKEDP(o)   (SCM_GCBIT(SCM_X(SCM_DROP_TAG(o)))        \
-                              == SCM_GCBIT_MARKED)
-#define SCM_SAL_UNMARKEDP(o) (!SCM_GC_MARKEDP(o))
+#define SCM_ISAL_CELL_UNMARK(c)                                         \
+    SCM_SET_X((c), SCM_DROP_GCBIT(SCM_X(c)) | SCM_GCBIT_UNMARKED)
 
 /* See if O's tag and the content of the cell C it references are
  * consistent.  O must be a tagged ScmObj and SCM_DROP_TAG(O) == &C. */

Modified: sigscheme-trunk/src/storage-fatty.h
==============================================================================
--- sigscheme-trunk/src/storage-fatty.h (original)
+++ sigscheme-trunk/src/storage-fatty.h Mon Aug  6 10:05:34 2007
@@ -465,10 +465,10 @@
      SCM_FREECELL_CLEAR_FREESLOT(c),                                    \
      (ScmObj)(c))
 
-#define SCM_SAL_MARKEDP(o)   ((o)->attr.v.gcmark)
-#define SCM_SAL_UNMARKEDP(o) (!SCM_MARKEDP(o))
-#define SCM_SAL_MARK(o)      ((o)->attr.v.gcmark = scm_true)
-#define SCM_SAL_UNMARK(o)    ((o)->attr.v.gcmark = scm_false)
+#define SCM_ISAL_MARKEDP(o)      ((o)->attr.v.gcmark)
+#define SCM_ISAL_MARK(o)         ((o)->attr.v.gcmark = scm_true)
+#define SCM_ISAL_CELL_MARKEDP(c) ((c)->attr.v.gcmark)
+#define SCM_ISAL_CELL_UNMARK(c)  ((c)->attr.v.gcmark = scm_false)
 
 /*===========================================================================
   Abstract ScmObj Reference For Storage-Representation Independent Efficient

Modified: sigscheme-trunk/src/storage-gc.c
==============================================================================
--- sigscheme-trunk/src/storage-gc.c    (original)
+++ sigscheme-trunk/src/storage-gc.c    Mon Aug  6 10:05:34 2007
@@ -884,7 +884,7 @@
     size_t i, sum_collected, n_collected;
     ScmObjHeap heap;
     ScmCell *cell;
-    ScmObj obj, new_freelist;
+    ScmObj new_freelist;
 
     SCM_BEGIN_GC_SUBCONTEXT();
 
@@ -898,14 +898,8 @@
         heap = l_heaps[i];
 
         for (cell = &heap[0]; cell < &heap[l_heap_size]; cell++) {
-            /* FIXME: is this safe for SCM_USE_STORAGE_COMPACT? */
-            /* Yes, but it's probably cleaner to change SCM_MARKEDP()
-             * et al to SCM_CELL_MARKEDP() etc and take care of
-             * dereferencing in this file.  -- Jun Inoue */
-            obj = (ScmObj)cell;
-
-            if (SCM_MARKEDP(obj)) {
-                SCM_UNMARK(obj);
+            if (SCM_CELL_MARKEDP(cell)) {
+                SCM_CELL_UNMARK(cell);
             } else if (!SCM_CELL_FREECELLP(cell)) {
                 /* scm_gc_protectedp() causes GC sweep on heaps that contain
                  * freecells. So !SCM_CELL_FREECELLP(cell) is required. */

Reply via email to