From dc53f026909e5373e5c864429897d1dc0780cd6c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 23 Jul 1998 04:47:56 +0000 Subject: [PATCH] Simplify smob and port marking; set the mark bit in the generic 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. --- libguile/async.c | 3 --- libguile/debug.c | 2 +- libguile/dynl.c | 1 - libguile/dynwind.c | 2 +- libguile/filesys.c | 2 +- libguile/fluids.c | 2 +- libguile/fports.c | 4 ++-- libguile/gc.c | 24 +++++++++++++++++------- libguile/mallocs.c | 2 +- libguile/markers.c | 14 ++++++++++---- libguile/ports.c | 5 +---- libguile/regex-posix.c | 2 +- libguile/root.c | 2 +- libguile/smob.c | 6 +++--- libguile/srcprop.c | 1 - libguile/threads.c | 6 +++--- libguile/throw.c | 4 ++-- libguile/unif.c | 3 --- libguile/variable.c | 3 --- 19 files changed, 45 insertions(+), 43 deletions(-) diff --git a/libguile/async.c b/libguile/async.c index de7f00f1a..6dd36a061 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -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; } diff --git a/libguile/debug.c b/libguile/debug.c index 9ec243d61..68ba4f65d 100644 --- a/libguile/debug.c +++ b/libguile/debug.c @@ -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); diff --git a/libguile/dynl.c b/libguile/dynl.c index 0637b1217..5fd44e320 100644 --- a/libguile/dynl.c +++ b/libguile/dynl.c @@ -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; } diff --git a/libguile/dynwind.c b/libguile/dynwind.c index 832c77466..f0c3be986 100644 --- a/libguile/dynwind.c +++ b/libguile/dynwind.c @@ -119,7 +119,7 @@ printguards (SCM exp, SCM port, scm_print_state *pstate) } static scm_smobfuns guardsmob = { - scm_mark0, + 0, freeguards, printguards, 0 diff --git a/libguile/filesys.c b/libguile/filesys.c index dff946f08..8eca66bb6 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -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}; /* {Navigating Directories} diff --git a/libguile/fluids.c b/libguile/fluids.c index c07d01d9d..601ca8b93 100644 --- a/libguile/fluids.c +++ b/libguile/fluids.c @@ -107,7 +107,7 @@ print_fluid (exp, port, pstate) } static scm_smobfuns fluid_smob = { - scm_mark0, + 0, scm_free0, print_fluid }; diff --git a/libguile/fports.c b/libguile/fports.c index 1fd0d27e3..ec87bda8e 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -458,7 +458,7 @@ local_pclose (fp) 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, diff --git a/libguile/gc.c b/libguile/gc.c index 16de3d978..988379c8b 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -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: diff --git a/libguile/mallocs.c b/libguile/mallocs.c index b2f48cdd8..c7c2b6fa1 100644 --- a/libguile/mallocs.c +++ b/libguile/mallocs.c @@ -66,7 +66,7 @@ prinmalloc (exp, port, pstate) int scm_tc16_malloc; -static scm_smobfuns mallocsmob = {scm_mark0, fmalloc, prinmalloc, 0}; +static scm_smobfuns mallocsmob = {0, fmalloc, prinmalloc, 0}; diff --git a/libguile/markers.c b/libguile/markers.c index 0b1aa57e3..8967811e7 100644 --- a/libguile/markers.c +++ b/libguile/markers.c @@ -50,11 +50,20 @@ */ +/* 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); } diff --git a/libguile/ports.c b/libguile/ports.c index ea95305b9..52722862d 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -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? */ diff --git a/libguile/regex-posix.c b/libguile/regex-posix.c index f72efe455..d01b4e0ca 100644 --- a/libguile/regex-posix.c +++ b/libguile/regex-posix.c @@ -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 }; SCM_SYMBOL (scm_regexp_error_key, "regular-expression-syntax"); diff --git a/libguile/root.c b/libguile/root.c index 22a88f392..00f69bf03 100644 --- a/libguile/root.c +++ b/libguile/root.c @@ -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); diff --git a/libguile/smob.c b/libguile/smob.c index 25c8669de..a498c48b4 100644 --- a/libguile/smob.c +++ b/libguile/smob.c @@ -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 diff --git a/libguile/srcprop.c b/libguile/srcprop.c index 195b69964..b13e43d23 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -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); diff --git a/libguile/threads.c b/libguile/threads.c index 11fb87f99..c262c7ca7 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -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 diff --git a/libguile/throw.c b/libguile/throw.c index bd15f2a09..a55e043ea 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -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 }; diff --git a/libguile/unif.c b/libguile/unif.c index 5cd9e0b28..cc0fbb38b 100644 --- a/libguile/unif.c +++ b/libguile/unif.c @@ -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); } diff --git a/libguile/variable.c b/libguile/variable.c index 02f9a5caa..922647eeb 100644 --- a/libguile/variable.c +++ b/libguile/variable.c @@ -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); } -- 2.20.1