Generalization of globals_changed thread param

This commit is contained in:
Justin Ethier 2017-06-09 17:17:01 +00:00
parent ff5d313595
commit 27970524c5
5 changed files with 23 additions and 22 deletions

1
gc.c
View file

@ -1905,6 +1905,7 @@ void gc_thread_data_init(gc_thread_data * thd, int mut_num, char *stack_base,
thd->mutation_count = 0;
thd->mutations =
vpbuffer_realloc(thd->mutations, &(thd->mutation_buflen));
thd->globals_changed = 1;
thd->param_objs = NULL;
thd->exception_handler_stack = NULL;
thd->scm_thread_obj = NULL;

View file

@ -701,6 +701,7 @@ object register_library(const char *name);
/**@{*/
extern list global_table;
void add_global(object * glo);
void Cyc_set_globals_changed(gc_thread_data *thd);
/**@}*/
#endif /* CYCLONE_RUNTIME_H */

View file

@ -265,6 +265,8 @@ struct gc_thread_data_t {
void **mutations;
int mutation_buflen;
int mutation_count;
// Is minor collection of globals necessary?
unsigned char globals_changed;
// List of objects moved to heap during minor GC
void **moveBuf;
int moveBufLen;

View file

@ -20,22 +20,12 @@
//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++;
//}
((gc_thread_data *) thd)->globals_changed = 1;
return value;
}
@ -438,7 +428,6 @@ 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()
@ -461,6 +450,11 @@ void debug_dump_globals()
}
}
void Cyc_set_globals_changed(gc_thread_data *thd)
{
thd->globals_changed = 1;
}
/* END Global table */
/* Mutation table functions
@ -4887,18 +4881,18 @@ 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
{
list l = global_table;
for (; l != NULL; l = cdr(l)) {
cvar_type *c = (cvar_type *) car(l);
gc_move2heap(*(c->pvar)); // Transport underlying global, not the pvar
if (((gc_thread_data *) data)->globals_changed) {
((gc_thread_data *) data)->globals_changed = 0;
// Transport globals
gc_move2heap(Cyc_global_variables); // Internal global used by the runtime
{
list l = global_table;
for (; l != NULL; l = cdr(l)) {
cvar_type *c = (cvar_type *) car(l);
gc_move2heap(*(c->pvar)); // Transport underlying global, not the pvar
}
}
}
}
// Check allocated objects, moving additional objects as needed
while (scani < alloci) {

View file

@ -1474,6 +1474,9 @@
; DEBUG (emit (string-append "printf(\"init " (lib:name->string lib-name) "\\n\");"))
))
;; Set global-changed indicator
(emit "Cyc_set_globals_changed((gc_thread_data *)data);")
;; Initialize symbols
(for-each
(lambda (sym)