mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 13:49:16 +02:00
Generalization of globals_changed thread param
This commit is contained in:
parent
ff5d313595
commit
27970524c5
5 changed files with 23 additions and 22 deletions
1
gc.c
1
gc.c
|
@ -1905,6 +1905,7 @@ void gc_thread_data_init(gc_thread_data * thd, int mut_num, char *stack_base,
|
||||||
thd->mutation_count = 0;
|
thd->mutation_count = 0;
|
||||||
thd->mutations =
|
thd->mutations =
|
||||||
vpbuffer_realloc(thd->mutations, &(thd->mutation_buflen));
|
vpbuffer_realloc(thd->mutations, &(thd->mutation_buflen));
|
||||||
|
thd->globals_changed = 1;
|
||||||
thd->param_objs = NULL;
|
thd->param_objs = NULL;
|
||||||
thd->exception_handler_stack = NULL;
|
thd->exception_handler_stack = NULL;
|
||||||
thd->scm_thread_obj = NULL;
|
thd->scm_thread_obj = NULL;
|
||||||
|
|
|
@ -701,6 +701,7 @@ object register_library(const char *name);
|
||||||
/**@{*/
|
/**@{*/
|
||||||
extern list global_table;
|
extern list global_table;
|
||||||
void add_global(object * glo);
|
void add_global(object * glo);
|
||||||
|
void Cyc_set_globals_changed(gc_thread_data *thd);
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#endif /* CYCLONE_RUNTIME_H */
|
#endif /* CYCLONE_RUNTIME_H */
|
||||||
|
|
|
@ -265,6 +265,8 @@ struct gc_thread_data_t {
|
||||||
void **mutations;
|
void **mutations;
|
||||||
int mutation_buflen;
|
int mutation_buflen;
|
||||||
int mutation_count;
|
int mutation_count;
|
||||||
|
// Is minor collection of globals necessary?
|
||||||
|
unsigned char globals_changed;
|
||||||
// List of objects moved to heap during minor GC
|
// List of objects moved to heap during minor GC
|
||||||
void **moveBuf;
|
void **moveBuf;
|
||||||
int moveBufLen;
|
int moveBufLen;
|
||||||
|
|
24
runtime.c
24
runtime.c
|
@ -20,22 +20,12 @@
|
||||||
|
|
||||||
//int JAE_DEBUG = 0;
|
//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 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)
|
object Cyc_global_set(void *thd, object * glo, object value)
|
||||||
{
|
{
|
||||||
gc_mut_update((gc_thread_data *) thd, *glo, value);
|
gc_mut_update((gc_thread_data *) thd, *glo, value);
|
||||||
*(glo) = value;
|
*(glo) = value;
|
||||||
|
((gc_thread_data *) thd)->globals_changed = 1;
|
||||||
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +428,6 @@ void add_global(object * glo)
|
||||||
// a contiguous block of memory for this... for now
|
// a contiguous block of memory for this... for now
|
||||||
// this is more expedient
|
// this is more expedient
|
||||||
global_table = malloc_make_pair(mcvar(glo), global_table);
|
global_table = malloc_make_pair(mcvar(glo), global_table);
|
||||||
globals_changed = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_dump_globals()
|
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 */
|
/* END Global table */
|
||||||
|
|
||||||
/* Mutation table functions
|
/* Mutation table functions
|
||||||
|
@ -4887,8 +4881,8 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont,
|
||||||
}
|
}
|
||||||
clear_mutations(data); // Reset for next time
|
clear_mutations(data); // Reset for next time
|
||||||
|
|
||||||
if (globals_changed) {
|
if (((gc_thread_data *) data)->globals_changed) {
|
||||||
globals_changed = 0;
|
((gc_thread_data *) data)->globals_changed = 0;
|
||||||
// Transport globals
|
// Transport globals
|
||||||
gc_move2heap(Cyc_global_variables); // Internal global used by the runtime
|
gc_move2heap(Cyc_global_variables); // Internal global used by the runtime
|
||||||
{
|
{
|
||||||
|
@ -4898,7 +4892,7 @@ if (globals_changed) {
|
||||||
gc_move2heap(*(c->pvar)); // Transport underlying global, not the pvar
|
gc_move2heap(*(c->pvar)); // Transport underlying global, not the pvar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check allocated objects, moving additional objects as needed
|
// Check allocated objects, moving additional objects as needed
|
||||||
while (scani < alloci) {
|
while (scani < alloci) {
|
||||||
|
|
|
@ -1474,6 +1474,9 @@
|
||||||
; DEBUG (emit (string-append "printf(\"init " (lib:name->string lib-name) "\\n\");"))
|
; 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
|
;; Initialize symbols
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (sym)
|
(lambda (sym)
|
||||||
|
|
Loading…
Add table
Reference in a new issue