Added set-global helpers that require CPS

This commit is contained in:
Justin Ethier 2020-01-23 21:46:56 -05:00
parent d104a0ad46
commit deb2337576
3 changed files with 25 additions and 0 deletions

View file

@ -108,6 +108,9 @@ object cell_get(object cell);
#define global_set(glo,value) Cyc_global_set(data, (object *)&glo, value) #define global_set(glo,value) Cyc_global_set(data, (object *)&glo, value)
object Cyc_global_set(void *thd, object * glo, object 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 /* Variable argument count support
This macro is intended to be executed at the top of a function that This macro is intended to be executed at the top of a function that

View file

@ -524,6 +524,14 @@ void add_mutation(void *data, object var, int index, object value);
void clear_mutations(void *data); 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 // END GC section

View file

@ -30,6 +30,20 @@ object Cyc_global_set(void *thd, object * glo, object value)
return 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 */ /* Error checking section - type mismatch, num args, etc */
/* Type names to use for error messages */ /* Type names to use for error messages */
const char *tag_names[] = { const char *tag_names[] = {