Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / marksweep.h
blobd78b5e31e53a8d5aefbadbf8eb88ccd4f122c60e
1 #ifndef RBS_MARKSWEEP_H
2 #define RBS_MARKSWEEP_H
4 #include <time.h>
6 struct ms_header;
8 struct ms_entry {
9 int bytes;
10 int fields;
11 int marked;
12 struct ms_header *object;
15 struct ms_header {
16 struct ms_entry *entry;
19 struct ms_chunk;
21 struct ms_chunk {
22 int size;
23 int num_entries;
24 int next_entry;
25 struct ms_entry *entries;
26 struct ms_chunk *next;
29 typedef struct ms_chunk ms_chunk;
31 struct _mark_sweep_gc {
32 struct ms_chunk *chunks;
33 void *extreme_min;
34 void *extreme_max;
35 ptr_array remember_set;
36 int enlarged;
37 int num_chunks;
38 OBJECT become_from, become_to;
39 ptr_array seen_weak_refs;
40 ms_chunk *current;
42 int last_freed;
43 int last_marked;
44 unsigned int allocated_bytes;
45 int next_collection_objects;
46 unsigned int last_allocated;
47 unsigned int allocated_objects;
48 int next_collection_bytes;
50 clock_t last_clock;
51 OBJECT track;
53 struct ms_entry *free_list;
56 typedef struct _mark_sweep_gc *mark_sweep_gc;
58 #define MS_CHUNKSIZE 0x20000
59 #define MS_COLLECTION_FREQUENCY 500 // 500 fields
61 mark_sweep_gc mark_sweep_new();
62 void mark_sweep_adjust_extremes(mark_sweep_gc ms, ms_chunk *new);
63 void mark_sweep_add_chunk(mark_sweep_gc ms);
64 void mark_sweep_free_chunk(mark_sweep_gc ms, ms_chunk *chunk);
65 OBJECT mark_sweep_allocate(mark_sweep_gc ms, int obj_fields);
66 void mark_sweep_free(mark_sweep_gc ms, OBJECT obj);
67 void mark_sweep_free_fast(STATE, mark_sweep_gc ms, OBJECT obj);
68 int mark_sweep_contains_p(mark_sweep_gc ms, OBJECT obj);
69 void mark_sweep_mark_phase(STATE, mark_sweep_gc ms, ptr_array roots);
70 void mark_sweep_sweep_phase(STATE, mark_sweep_gc ms);
71 void mark_sweep_collect(STATE, mark_sweep_gc ms, ptr_array roots);
72 void mark_sweep_describe(mark_sweep_gc ms);
73 void mark_sweep_collect_references(STATE, mark_sweep_gc ms, OBJECT mark, ptr_array refs);
74 void mark_sweep_mark_context(STATE, mark_sweep_gc ms, OBJECT iobj);
75 void mark_sweep_clear_mark(STATE, OBJECT iobj);
76 void mark_sweep_destroy(mark_sweep_gc ms);
78 #endif /* __MARKSWEEP_H__ */