diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 3607d637..8474f898 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -108,6 +108,9 @@ object cell_get(object cell); #define global_set(glo,value) Cyc_global_set(data, (object *)&glo, value) object Cyc_global_set(void *thd, object * glo, object value); +#define global_set2(thd,k,glo,value) Cyc_global_set2(thd, k, (object *)&glo, value) +object Cyc_global_set2(void *thd, object cont, object * glo, object value); + /* Variable argument count support This macro is intended to be executed at the top of a function that diff --git a/include/cyclone/types.h b/include/cyclone/types.h index e377e47a..65de20d4 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -524,6 +524,14 @@ void add_mutation(void *data, object var, int index, object value); void clear_mutations(void *data); /**@}*/ +/** + * \defgroup gc_minor_sh_obj Shared object write barrier + * @brief Minor GC write barrier to ensure there are no references to stack objects from the heap. + */ +/**@{*/ +object share_object(gc_thread_data *data, object var, object value, int *run_gc); +/**@}*/ + /**@}*/ // END GC section diff --git a/runtime.c b/runtime.c index eaea10a1..0e3a76c1 100644 --- a/runtime.c +++ b/runtime.c @@ -30,6 +30,20 @@ object Cyc_global_set(void *thd, object * glo, object value) return value; } +object Cyc_global_set2(void *thd, object cont, object * glo, object value) +{ + int do_gc = 0; + value = share_object(thd, NULL, value, &do_gc); + gc_mut_update((gc_thread_data *) thd, *glo, value); + *(glo) = value; +// ((gc_thread_data *) thd)->globals_changed = 1; // No longer needed?? + if (do_gc) { + object buf[1]; buf[0] = value; + GC(thd, cont, buf, 1); + } + return value; +} + /* Error checking section - type mismatch, num args, etc */ /* Type names to use for error messages */ const char *tag_names[] = {