From 5abc483d9a96b20f51df2c19d14d07165ba1f57a Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 28 Jun 2010 18:53:16 -0700 Subject: Move more of the GC logic into the runtime. --- src/rt/rust_internal.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_internal.h') diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index c9a28946..fafc1924 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -595,6 +595,19 @@ struct frame_glue_fns { uintptr_t reloc_glue_off; }; +struct gc_alloc { + gc_alloc *prev; + gc_alloc *next; + uintptr_t ctrl_word; + uint8_t data[]; + bool mark() { + if (ctrl_word & 1) + return false; + ctrl_word |= 1; + return true; + } +}; + struct rust_task : public rc_base, public dom_owned, @@ -604,7 +617,7 @@ rust_task : public rc_base, stk_seg *stk; uintptr_t runtime_sp; // Runtime sp while task running. uintptr_t rust_sp; // Saved sp when not running. - uintptr_t gc_alloc_chain; // Linked list of GC allocations. + gc_alloc *gc_alloc_chain; // Linked list of GC allocations. rust_dom *dom; rust_crate_cache *cache; @@ -614,6 +627,8 @@ rust_task : public rc_base, uintptr_t* dptr; // Rendezvous pointer for send/recv. rust_task *spawner; // Parent-link. size_t idx; + size_t gc_alloc_thresh; + size_t gc_alloc_accum; // Wait queue for tasks waiting for this task. rust_wait_queue waiting_tasks; @@ -633,6 +648,12 @@ rust_task : public rc_base, bool blocked_on(rust_cond *cond); bool dead(); + void link_gc(gc_alloc *gcm); + void unlink_gc(gc_alloc *gcm); + void *malloc(size_t sz, type_desc *td=0); + void *realloc(void *data, size_t sz, bool gc_mem=false); + void free(void *p, bool gc_mem=false); + const char *state_str(); void transition(ptr_vec *svec, ptr_vec *dvec); -- cgit v1.2.3