diff --git a/runtime.c b/runtime.c index 2babc8b1..4b7f3052 100644 --- a/runtime.c +++ b/runtime.c @@ -20,11 +20,22 @@ //int JAE_DEBUG = 0; //int gcMoveCountsDEBUG[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int globals_changed = 1; // TODO: not good enough, needs to live in thread data! object Cyc_global_set(void *thd, object * glo, object value) { gc_mut_update((gc_thread_data *) thd, *glo, value); *(glo) = value; + + globals_changed = 1; + //gc_thread_data *d = (gc_thread_data *) thd; + //if (is_object_type(value)) { + // d->mutations = vpbuffer_add(d->mutations, + // &(d->mutation_buflen), + // d->mutation_count, + // ((object) (((uintptr_t)(*glo)) + 2))); + // d->mutation_count++; + //} return value; } @@ -427,6 +438,7 @@ void add_global(object * glo) // a contiguous block of memory for this... for now // this is more expedient global_table = malloc_make_pair(mcvar(glo), global_table); + globals_changed = 1; } void debug_dump_globals() @@ -4851,6 +4863,10 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, if (is_value_type(o)) { // Can happen if a vector element was already // moved and we found an index. Just ignore it + //if (obj_is_char(o)) { + // o = (object)(((uintptr_t) o) - 2); + // gc_move2heap(o); + //} } else if (type_of(o) == pair_tag) { gc_move2heap(car(o)); gc_move2heap(cdr(o)); @@ -4871,6 +4887,8 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, } clear_mutations(data); // Reset for next time +if (globals_changed) { + globals_changed = 0; // Transport globals gc_move2heap(Cyc_global_variables); // Internal global used by the runtime { @@ -4880,6 +4898,7 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, gc_move2heap(*(c->pvar)); // Transport underlying global, not the pvar } } +} // Check allocated objects, moving additional objects as needed while (scani < alloci) {