Simplify smob and port marking; set the mark bit in the generic
authorJim Blandy <jimb@red-bean.com>
Thu, 23 Jul 1998 04:47:56 +0000 (04:47 +0000)
committerJim Blandy <jimb@red-bean.com>
Thu, 23 Jul 1998 04:47:56 +0000 (04:47 +0000)
marking code, and make marker routines only responsible for
turning up outgoing pointers.
* gc.c (scm_gc_mark): Set the mark bit on ports and smobs here,
before calling the marking function.  Don't call the marking
function if it's zero.
* markers.c (scm_mark0): Just return #f.  This function isn't
necessary at all now, but it's harmless to call it.  We'll leave
it in so other folks' code doesn't croak at link time.
(scm_markcdr): Don't call SCM_SETGC8MARK.
* async.c (mark_async): Don't call SCM_SETGC8MARK.
* dynl.c (mark_dynl_obj): Same.
* root.c (mark_root): Same.
* srcprop.c (marksrcprops): Same.
* unif.c (markra): Same.
* variable.c (scm_markvar): Same.
* ports.c (scm_markstream): Same.
(void_port_ptob): Specify zero for our marking function.
* debug.c (debugobjsmob): Same.
* dynwind.c (guardsmob): Same.
* filesys.c (dir_smob): Same.
* fluids.c (fluid_smob): Same.
* fports.c (scm_fptob, scm_pipob): Same.
* mallocs.c (mallocsmob): Same.
* regex-posix.c (regex_t_smob): Same.
* smob.c (freecell, flob, bigob): Same.
* threads.c (thread_smob, mutex_smob, condvar_smob): Same.
* throw.c (jbsmob, lazy_catch_funs): Same.

19 files changed:
libguile/async.c
libguile/debug.c
libguile/dynl.c
libguile/dynwind.c
libguile/filesys.c
libguile/fluids.c
libguile/fports.c
libguile/gc.c
libguile/mallocs.c
libguile/markers.c
libguile/ports.c
libguile/regex-posix.c
libguile/root.c
libguile/smob.c
libguile/srcprop.c
libguile/threads.c
libguile/throw.c
libguile/unif.c
libguile/variable.c

index de7f00f..6dd36a0 100644 (file)
@@ -285,9 +285,6 @@ mark_async (obj)
      SCM obj;
 {
   struct scm_async * it;
-  if (SCM_GC8MARKP (obj))
-    return SCM_BOOL_F;
-  SCM_SETGC8MARK (obj);
   it = SCM_ASYNC (obj);
   return it->thunk;
 }
index 9ec243d..68ba4f6 100644 (file)
@@ -562,7 +562,7 @@ prindebugobj (obj, port, pstate)
 }
 
 static scm_smobfuns debugobjsmob =
-{scm_mark0, scm_free0, prindebugobj, 0};
+{0, scm_free0, prindebugobj, 0};
 
 SCM_PROC (s_debug_object_p, "debug-object?", 1, 0, 0, scm_debug_object_p);
 
index 0637b12..5fd44e3 100644 (file)
@@ -302,7 +302,6 @@ mark_dynl_obj (ptr)
      SCM ptr;
 {
     struct dynl_obj *d = (struct dynl_obj *)SCM_CDR (ptr);
-    SCM_SETGC8MARK (ptr);
     return d->filename;
 }
 
index 832c774..f0c3be9 100644 (file)
@@ -119,7 +119,7 @@ printguards (SCM exp, SCM port, scm_print_state *pstate)
 }
 
 static scm_smobfuns guardsmob = {
-  scm_mark0,
+  0,
   freeguards,
   printguards,
   0
index dff946f..8eca66b 100644 (file)
@@ -832,7 +832,7 @@ scm_dir_free (p)
   return 0;
 }
 
-static scm_smobfuns dir_smob = {scm_mark0, scm_dir_free, scm_dir_print, 0};
+static scm_smobfuns dir_smob = {0, scm_dir_free, scm_dir_print, 0};
 
 \f
 /* {Navigating Directories}
index c07d01d..601ca8b 100644 (file)
@@ -107,7 +107,7 @@ print_fluid (exp, port, pstate)
 }
 
 static scm_smobfuns fluid_smob = {
-    scm_mark0,
+    0,
     scm_free0,
     print_fluid
 };
index 1fd0d27..ec87bda 100644 (file)
@@ -458,7 +458,7 @@ local_pclose (fp)
 \f
 scm_ptobfuns scm_fptob =
 {
-  scm_mark0,
+  0,
   (int (*) SCM_P ((SCM))) local_fclose,
   prinfport,
   0,
@@ -474,7 +474,7 @@ scm_ptobfuns scm_fptob =
 /* {Pipe ports} */
 scm_ptobfuns scm_pipob =
 {
-  scm_mark0,
+  0,
   (int (*) SCM_P ((SCM))) local_pclose,  
   print_pipe_port,
   0,
index 16de3d9..988379c 100644 (file)
@@ -819,31 +819,41 @@ gc_mark_nimp:
        goto def;
       if (SCM_GC8MARKP (ptr))
        break;
+      SCM_SETGC8MARK (ptr);
       if (SCM_PTAB_ENTRY(ptr))
        scm_gc_mark (SCM_PTAB_ENTRY(ptr)->file_name);
-      ptr = (scm_ptobs[i].mark) (ptr);
-      goto gc_mark_loop;
+      if (scm_ptobs[i].mark)
+       {
+         ptr = (scm_ptobs[i].mark) (ptr);
+         goto gc_mark_loop;
+       }
+      else
+       return;
       break;
     case scm_tc7_smob:
       if (SCM_GC8MARKP (ptr))
        break;
-      switch SCM_TYP16 (ptr)
+      SCM_SETGC8MARK (ptr);
+      switch SCM_GCTYP16 (ptr)
        { /* should be faster than going through scm_smobs */
        case scm_tc_free_cell:
          /* printf("found free_cell %X ", ptr); fflush(stdout); */
-         SCM_SETGC8MARK (ptr);
          SCM_SETCDR (ptr, SCM_EOL);
          break;
        case scm_tcs_bignums:
        case scm_tc16_flo:
-         SCM_SETGC8MARK (ptr);
          break;
        default:
          i = SCM_SMOBNUM (ptr);
          if (!(i < scm_numsmob))
            goto def;
-         ptr = (scm_smobs[i].mark) (ptr);
-         goto gc_mark_loop;
+         if (scm_smobs[i].mark)
+           {
+             ptr = (scm_smobs[i].mark) (ptr);
+             goto gc_mark_loop;
+           }
+         else
+           return;
        }
       break;
     default:
index b2f48cd..c7c2b6f 100644 (file)
@@ -66,7 +66,7 @@ prinmalloc (exp, port, pstate)
 
 \f
 int scm_tc16_malloc;
-static scm_smobfuns mallocsmob = {scm_mark0, fmalloc, prinmalloc, 0};
+static scm_smobfuns mallocsmob = {0, fmalloc, prinmalloc, 0};
 
 \f
 
index 0b1aa57..8967811 100644 (file)
  */
 
 
+/* This function is vestigial.  It used to be the mark function's
+   responsibility to set the mark bit on the smob or port, but now the
+   generic marking routine in gc.c takes care of that, and a zero
+   pointer for a mark function means "don't bother".  So you never
+   need scm_mark0.
+
+   However, we leave it here because it's harmless to call it, and
+   people out there have smob code that uses it, and there's no reason
+   to make their links fail.  */
+
 SCM 
 scm_mark0 (ptr)
      SCM ptr;
 {
-  SCM_SETGC8MARK (ptr);
   return SCM_BOOL_F;
 }
 
@@ -64,9 +73,6 @@ SCM
 scm_markcdr (ptr)
      SCM ptr;
 {
-  if (SCM_GC8MARKP (ptr))
-    return SCM_BOOL_F;
-  SCM_SETGC8MARK (ptr);
   return SCM_CDR (ptr);
 }
 
index ea95305..5272286 100644 (file)
@@ -81,10 +81,7 @@ scm_markstream (ptr)
      SCM ptr;
 {
   int openp;
-  if (SCM_GC8MARKP (ptr))
-    return SCM_BOOL_F;
   openp = SCM_CAR (ptr) & SCM_OPN;
-  SCM_SETGC8MARK (ptr);
   if (openp)
     return SCM_STREAM  (ptr);
   else
@@ -895,7 +892,7 @@ noop0 (SCM stream)
 
 static struct scm_ptobfuns  void_port_ptob =
 {
-  scm_mark0, 
+  0, 
   noop0,
   print_void_port,
   0,                           /* equal? */
index f72efe4..d01b4e0 100644 (file)
@@ -112,7 +112,7 @@ scm_print_regex_t (obj, port, pstate)
 
 
 static scm_smobfuns regex_t_smob =
-{ scm_mark0, scm_free_regex_t, scm_print_regex_t, 0 };
+{ 0, scm_free_regex_t, scm_print_regex_t, 0 };
 \f
 
 SCM_SYMBOL (scm_regexp_error_key, "regular-expression-syntax");
index 22a88f3..00f69bf 100644 (file)
@@ -77,7 +77,7 @@ mark_root (root)
      SCM root;
 {
   scm_root_state *s = SCM_ROOT_STATE (root);
-  SCM_SETGC8MARK (root);
+
   scm_gc_mark (s->rootcont);
   scm_gc_mark (s->dynwinds);
   scm_gc_mark (s->continuation_stack);
index 25c8669..a498c48 100644 (file)
@@ -89,7 +89,7 @@ scm_newsmob (smob)
 
 static scm_smobfuns freecell =
 {
-  scm_mark0,
+  0,
   scm_free0,
   0,
   0
@@ -97,7 +97,7 @@ static scm_smobfuns freecell =
 
 static scm_smobfuns flob =
 {
-  scm_mark0,
+  0,
   /*flofree*/ 0,
   scm_floprint,
   scm_floequal
@@ -105,7 +105,7 @@ static scm_smobfuns flob =
 
 static scm_smobfuns bigob =
 {
-  scm_mark0,
+  0,
   /*bigfree*/ 0,
   scm_bigprint,
   scm_bigequal
index 195b699..b13e43d 100644 (file)
@@ -86,7 +86,6 @@ static SCM
 marksrcprops (obj)
      SCM obj;
 {
-  SCM_SETGC8MARK (obj);
   scm_gc_mark (SRCPROPFNAME (obj));
   scm_gc_mark (SRCPROPCOPY (obj));
   return SRCPROPPLIST (obj);
index 11fb87f..c262c7c 100644 (file)
@@ -95,7 +95,7 @@ print_thread (exp, port, pstate)
 
 static scm_smobfuns thread_smob =
 {
-  scm_mark0,
+  0,
   scm_threads_free_thread,
   print_thread,
   0
@@ -115,7 +115,7 @@ print_mutex (exp, port, pstate)
 
 static scm_smobfuns mutex_smob =
 {
-  scm_mark0,
+  0,
   scm_threads_free_mutex,
   print_mutex,
   0
@@ -135,7 +135,7 @@ print_condvar (exp, port, pstate)
 
 static scm_smobfuns condvar_smob =
 {
-  scm_mark0,
+  0,
   scm_threads_free_condvar,
   print_condvar,
   0
index bd15f2a..a55e043 100644 (file)
@@ -103,7 +103,7 @@ printjb (exp, port, pstate)
 }
 
 static scm_smobfuns jbsmob = {
-  scm_mark0,
+  0,
 #ifdef DEBUG_EXTENSIONS
   freejb,
 #else
@@ -280,7 +280,7 @@ print_lazy_catch (SCM closure, SCM port, scm_print_state *pstate)
 }
 
 static scm_smobfuns lazy_catch_funs = {
-  scm_mark0, scm_free0, print_lazy_catch, 0
+  0, scm_free0, print_lazy_catch, 0
 };
 
 
index 5cd9e0b..cc0fbb3 100644 (file)
@@ -2532,9 +2532,6 @@ static SCM
 markra (ptr)
      SCM ptr;
 {
-  if SCM_GC8MARKP
-    (ptr) return SCM_BOOL_F;
-  SCM_SETGC8MARK (ptr);
   return SCM_ARRAY_V (ptr);
 }
 
index 02f9a5c..922647e 100644 (file)
@@ -92,9 +92,6 @@ static SCM
 scm_markvar (ptr)
      SCM ptr;
 {
-  if (SCM_GC8MARKP (ptr))
-    return SCM_BOOL_F;
-  SCM_SETGC8MARK (ptr);
   return SCM_CDR (ptr);
 }