Cyclone Scheme  0.28.0
Macros | Functions
gc.c File Reference
#include <ck_array.h>
#include <ck_pr.h>
#include "cyclone/types.h"
#include <stdint.h>
#include <time.h>

Macros

#define gc_align(n, bits)   (((n)+(1<<(bits))-1)&(((uintptr_t)-1)-((1<<(bits))-1)))
 
#define GC_BLOCK_BITS   5
 
#define GC_BLOCK_SIZE   (1 << GC_BLOCK_BITS)
 
#define gc_collector_mark_gray(parent, gobj)
 "Color" objects gray by adding them to the mark stack for further processing. More...
 
#define gc_free_chunk_size   (sizeof(gc_free_list))
 
#define gc_heap_align(n)   gc_align(n, GC_BLOCK_BITS)
 
#define gc_heap_end(h)   ((object)((char*)h->data + h->size))
 
#define gc_heap_first_block(h)   ((object)(h->data + gc_heap_align(gc_free_chunk_size)))
 
#define gc_heap_last_block(h)   ((object)((char*)h->data + h->size - gc_heap_align(gc_free_chunk_size)))
 
#define gc_heap_pad_size(s)   (sizeof(struct gc_heap_t) + (s) + gc_heap_align(1))
 
#define gc_mark_black(obj)
 

Functions

void * collector_main (void *arg)
 
void Cyc_apply_from_buf (void *data, int argc, object prim, object *buf)
 
void debug_dump_globals ()
 
void gc_add_mutator (gc_thread_data *thd)
 Add data for a new mutator that is starting to run. More...
 
void gc_add_new_unrunning_mutator (gc_thread_data *thd)
 Add data for a new mutator that is not yet scheduled to run. This is done so there is a record in the system even if the thread is not running, to prevent race conditions for any functions (EG: thread-join!) that need to access the thread. More...
 
void * gc_alloc (gc_heap_root *hrt, size_t size, char *obj, gc_thread_data *thd, int *heap_grown)
 Allocate memory on the heap for an object. More...
 
void * gc_alloc_bignum (gc_thread_data *data)
 A convenience function for allocating bignums. More...
 
void * gc_alloc_from_bignum (gc_thread_data *data, bignum_type *src)
 A helper function to create a heap-allocated copy of a bignum. More...
 
size_t gc_allocated_bytes (object obj, gc_free_list *q, gc_free_list *r)
 Get the number of bytes that will be allocated for obj. More...
 
void gc_collector ()
 Main collector function. More...
 
void gc_collector_sweep ()
 A convenient front-end to the actual gc_sweep function. More...
 
void gc_collector_trace ()
 The collector's tracing algorithm. More...
 
char * gc_copy_obj (object dest, char *obj, gc_thread_data *thd)
 Copy given object into given heap object. More...
 
void gc_empty_collector_stack ()
 Empty the collector's mark stack. More...
 
void gc_free_old_thread_data ()
 Free thread data for all terminated mutators. More...
 
gc_heapgc_grow_heap (gc_heap *h, size_t size, gc_thread_data *thd)
 Grow a heap by allocating a new page. More...
 
void gc_handshake (gc_status_type s)
 Called by the collector thread to perform a handshake with all of the mutators. More...
 
gc_heapgc_heap_create (int heap_type, size_t size, gc_thread_data *thd)
 Create a new heap page. The caller must hold the necessary locks. More...
 
gc_heapgc_heap_free (gc_heap *page, gc_heap *prev_page)
 Free a page of the heap. More...
 
uint64_t gc_heap_free_size (gc_heap *h)
 Return the amount of free space on the heap. More...
 
gc_heapgc_heap_last (gc_heap *h)
 Get the heap's last page. More...
 
void gc_heap_merge (gc_heap *hdest, gc_heap *hsrc)
 Merge one heap into another. More...
 
void gc_init_fixed_size_free_list (gc_heap *h)
 Initialize free lists within a single heap page. Assumes that there is no data currently on the heap page! More...
 
void gc_initialize (void)
 Perform one-time initialization before mutators can be executed. More...
 
int gc_is_mutator_active (gc_thread_data *thd)
 Determine if the given mutator is in the list of active threads. More...
 
int gc_is_mutator_new (gc_thread_data *thd)
 Determine if the given mutator is in the list of new threads. More...
 
void gc_mark_globals (object globals, object global_table)
 Mark globals as part of the tracing collector. More...
 
void gc_mark_gray (gc_thread_data *thd, object obj)
 Mark the given object gray if it is on the heap. More...
 
void gc_mark_gray2 (gc_thread_data *thd, object obj)
 Add a pending write to the mark buffer. More...
 
void gc_merge_all_heaps (gc_thread_data *dest, gc_thread_data *src)
 Merge all thread heaps into another. More...
 
void gc_mut_cooperate (gc_thread_data *thd, int buf_len)
 Called by a mutator to cooperate with the collector thread. More...
 
void gc_mut_update (gc_thread_data *thd, object old_obj, object value)
 Write barrier for updates to heap-allocated objects. More...
 
void gc_mutator_thread_blocked (gc_thread_data *thd, object cont)
 Called explicitly from a mutator thread to let the collector know it (may) block for an unknown period of time. More...
 
void gc_mutator_thread_runnable (gc_thread_data *thd, object result, object maybe_copied)
 Called explicitly from a mutator thread to let the collector know that it has finished blocking. More...
 
int gc_num_unswept_heaps (gc_heap *h)
 Return number of unswept heaps. More...
 
void gc_post_handshake (gc_status_type s)
 Change GC status to the given type. More...
 
void gc_print_fixed_size_free_list (gc_heap *h)
 Diagnostic function to print all free lists on a fixed-size heap page. More...
 
void gc_print_stats (gc_heap *h)
 Print heap usage information. Before calling this function the current thread must have the heap lock. More...
 
void gc_recopy_obj (object obj, gc_thread_data *thd)
 While a mutator has declared itself blocked, it is possible that an object on its stack may be copied to the heap by the collector. The purpose of this function is to copy such an object again to ensure all fields are updated to their latest values. More...
 
void gc_remove_mutator (gc_thread_data *thd)
 Remove selected mutator from the mutator list. This is done for terminated threads. Note data is queued to be freed, to prevent accidentally freeing it while the collector thread is potentially accessing it. More...
 
void gc_sleep_ms (int ms)
 A high-resolution sleep function. More...
 
void gc_start_collector ()
 Spawn the collector thread. More...
 
void gc_start_major_collection (gc_thread_data *thd)
 
void gc_sum_pending_writes (gc_thread_data *thd, int locked)
 Move pending writes to 'last_write'. More...
 
gc_heapgc_sweep (gc_heap *h, gc_thread_data *thd)
 Sweep portion of the GC algorithm. More...
 
void gc_thr_grow_move_buffer (gc_thread_data *d)
 Increase the size of the mutator's move buffer. More...
 
void gc_thread_data_free (gc_thread_data *thd)
 Free all data for the given mutator. More...
 
void gc_thread_data_init (gc_thread_data *thd, int mut_num, char *stack_base, long stack_size)
 Initialize runtime data structures for a thread. More...
 
void * gc_try_alloc (gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
 Attempt to allocate a new heap slot for the given object. More...
 
void * gc_try_alloc_slow (gc_heap *h_passed, gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
 
void * gc_try_alloc_slow_fixed_size (gc_heap *h_passed, gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
 
void gc_wait_handshake ()
 Wait for all mutators to handshake. More...
 
void gc_zero_read_write_counts (gc_thread_data *thd)
 Clear thread data read/write fields. More...
 
vpbuffer_add
void ** vpbuffer_add(void **buf, int *len, int i, void *obj)
Definition: runtime.c:6877
is_object_type
#define is_object_type(x)
Definition: types.h:644
mark
#define mark(x)
Definition: types.h:274