ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 746ae82 was
200fcb3,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
add auto newline to sout, change endl to nl
|
-
Property mode set to
100644
|
File size:
1.3 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 <fstream.hfa> |
---|
12 | #include <vector> |
---|
13 | |
---|
14 | #include "tools.h" |
---|
15 | |
---|
16 | typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; |
---|
17 | |
---|
18 | struct gc_state |
---|
19 | { |
---|
20 | bool is_initialized; |
---|
21 | uint8_t from_code; |
---|
22 | struct gc_memory_pool* to_space; |
---|
23 | struct gc_memory_pool* from_space; |
---|
24 | |
---|
25 | size_t total_space; |
---|
26 | size_t used_space; |
---|
27 | |
---|
28 | pools_table_t pools_table; |
---|
29 | size_t pools_table_count; |
---|
30 | }; |
---|
31 | |
---|
32 | void ctor(gc_state* const state); |
---|
33 | |
---|
34 | void dtor(gc_state* const state); |
---|
35 | |
---|
36 | gc_state* gc_get_state(); |
---|
37 | |
---|
38 | static inline bool gc_needs_collect(gc_state* state) |
---|
39 | { |
---|
40 | // sout | "Used Space: " | state->used_space | " bytes"; |
---|
41 | return state->used_space * 2 > state->total_space; |
---|
42 | } |
---|
43 | |
---|
44 | void gc_collect(gc_state* const this); |
---|
45 | |
---|
46 | void* gc_try_allocate(gc_state* const this, size_t size); |
---|
47 | |
---|
48 | void gc_allocate_pool(gc_state* const state); |
---|
49 | |
---|
50 | bool gc_is_in_heap(const gc_state* const state, const void* const address); |
---|
51 | |
---|
52 | bool gc_is_in_to_space(const gc_state* const state, const void* const address); |
---|
53 | |
---|
54 | static inline uint8_t gc_from_space_code(const gc_state *const this) |
---|
55 | { |
---|
56 | return this->from_code; |
---|
57 | } |
---|
58 | |
---|
59 | struct gc_object_header* gc_get_object_for_ref(gc_state* state, void*); |
---|
60 | |
---|
61 | static inline void gc_register_allocation(gc_state* state, size_t size) |
---|
62 | { |
---|
63 | state->used_space += size; |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.