Renamed write barrier to mutation table

This naming convention is more appropriate, and matches the scheme standards.
This commit is contained in:
Justin Ethier 2015-03-13 16:51:31 -04:00
parent eb3dbfbfec
commit 583b9297de

View file

@ -426,34 +426,35 @@ static object find_or_add_symbol(const char *name){
} }
/* END symbol table */ /* END symbol table */
/* Write Barrier /* Mutation table
This is necessary when a mutation (EG: set-car!) occurs, because otherwise *
if the new value is on the stack, it will never be transported to the heap. * Keep track of mutations (EG: set-car!) so that new
*/ * values are transported to the heap during GC.
list write_barrier = nil; */
list mutation_table = nil;
static void add_to_write_barrier(object var, object value); static void add_mutation(object var, object value);
static void clear_write_barrier(); static void clear_mutations();
static void add_to_write_barrier(object var, object value){ static void add_mutation(object var, object value){
if (is_object_type(value)) { if (is_object_type(value)) {
write_barrier = mcons(var, write_barrier); mutation_table = mcons(var, mutation_table);
} }
} }
/* TODO: consider a more efficient implementation, such as reusing old nodes /* TODO: consider a more efficient implementation, such as reusing old nodes
instead of reclaiming them each time instead of reclaiming them each time
*/ */
static void clear_write_barrier() { static void clear_mutations() {
list l = write_barrier, next; list l = mutation_table, next;
while (!nullp(l)) { while (!nullp(l)) {
next = cdr(l); next = cdr(l);
free(l); free(l);
l = next; l = next;
} }
write_barrier = nil; mutation_table = nil;
} }
/* END write barrier */ /* END mutation table */
/* Global variables. */ /* Global variables. */
@ -789,13 +790,13 @@ static object Cyc_eq(object x, object y) {
static object Cyc_set_car(object l, object val) { static object Cyc_set_car(object l, object val) {
car(l) = val; car(l) = val;
add_to_write_barrier(l, val); add_mutation(l, val);
return l; return l;
} }
static object Cyc_set_cdr(object l, object val) { static object Cyc_set_cdr(object l, object val) {
cdr(l) = val; cdr(l) = val;
add_to_write_barrier(l, val); add_mutation(l, val);
return l; return l;
} }
@ -1747,7 +1748,7 @@ static void GC_loop(int major, closure cont, object *ans, int num_ans)
/* Transport mutations. */ /* Transport mutations. */
{ {
list l; list l;
for (l = write_barrier; !nullp(l); l = cdr(l)) { for (l = mutation_table; !nullp(l); l = cdr(l)) {
object o = car(l); object o = car(l);
if (type_of(o) == cons_tag) { if (type_of(o) == cons_tag) {
// Transport, if necessary // Transport, if necessary
@ -1763,7 +1764,7 @@ static void GC_loop(int major, closure cont, object *ans, int num_ans)
} }
} }
} }
clear_write_barrier(); /* Reset for next time */ clear_mutations(); /* Reset for next time */
/* Transport global variables. */ /* Transport global variables. */
transp(Cyc_global_variables); /* Internal global used by the runtime */ transp(Cyc_global_variables); /* Internal global used by the runtime */