ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since bee4283 was
bee4283,
checked in by Thierry Delisle <tdelisle@…>, 9 years ago
|
GC files now compile, still working on a compiling example
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | #ifdef __cforall |
---|
4 | extern "C" { |
---|
5 | #endif |
---|
6 | #include <stddef.h> |
---|
7 | #include <stdint.h> |
---|
8 | #ifdef __cforall |
---|
9 | } |
---|
10 | #endif |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | #include "tools.h" |
---|
14 | |
---|
15 | typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; |
---|
16 | |
---|
17 | struct gc_state |
---|
18 | { |
---|
19 | bool is_initialized; |
---|
20 | uint8_t from_code; |
---|
21 | struct gc_memory_pool* to_space; |
---|
22 | struct gc_memory_pool* from_space; |
---|
23 | |
---|
24 | size_t total_space; |
---|
25 | size_t used_space; |
---|
26 | |
---|
27 | pools_table_t pools_table; |
---|
28 | size_t pools_table_count; |
---|
29 | }; |
---|
30 | |
---|
31 | void ctor(gc_state* const state); |
---|
32 | |
---|
33 | void dtor(gc_state* const state); |
---|
34 | |
---|
35 | gc_state* gc_get_state(); |
---|
36 | |
---|
37 | static inline bool gc_needs_collect(gc_state* state) |
---|
38 | { |
---|
39 | return state->used_space * 2 > state->total_space; |
---|
40 | } |
---|
41 | |
---|
42 | void gc_collect(gc_state* const this); |
---|
43 | |
---|
44 | void* gc_try_allocate(gc_state* const this, size_t size); |
---|
45 | |
---|
46 | void gc_allocate_pool(gc_state* const state); |
---|
47 | |
---|
48 | bool gc_is_in_heap(const gc_state* const state, const void* const address); |
---|
49 | |
---|
50 | bool gc_is_in_to_space(const gc_state* const state, const void* const address); |
---|
51 | |
---|
52 | static inline uint8_t gc_from_space_code(const gc_state *const this) |
---|
53 | { |
---|
54 | return this->from_code; |
---|
55 | } |
---|
56 | |
---|
57 | struct gc_object_header* gc_get_object_for_ref(gc_state* state, void*); |
---|
58 | |
---|
59 | static inline void gc_register_allocation(gc_state* state, size_t size) |
---|
60 | { |
---|
61 | state->used_space += size; |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.