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@…>, 8 years ago
|
GC files now compile, still working on a compiling example
|
-
Property mode set to
100644
|
File size:
1.8 KB
|
Rev | Line | |
---|
[d67a9a1] | 1 | #pragma once |
---|
| 2 | |
---|
[16cfd8c] | 3 | extern "C" { |
---|
| 4 | #include <stdbool.h> |
---|
[bee4283] | 5 | #include <stddef.h> |
---|
[d67a9a1] | 6 | #include <stdint.h> |
---|
[16cfd8c] | 7 | } |
---|
[d67a9a1] | 8 | |
---|
| 9 | #include "tools.h" |
---|
| 10 | |
---|
[16cfd8c] | 11 | #include "card_table.h" |
---|
[d67a9a1] | 12 | #include "globals.h" |
---|
[16cfd8c] | 13 | #include "state.h" |
---|
[d67a9a1] | 14 | |
---|
| 15 | struct gc_memory_pool |
---|
| 16 | { |
---|
| 17 | struct memory_pool* mirror; |
---|
| 18 | struct memory_pool* next; |
---|
| 19 | |
---|
| 20 | uint8_t type_code; |
---|
| 21 | |
---|
[16cfd8c] | 22 | card_table_t* cards; |
---|
[d67a9a1] | 23 | |
---|
| 24 | uint8_t* end_p; |
---|
| 25 | uint8_t* free_p; |
---|
| 26 | uint8_t start_p[1]; |
---|
| 27 | }; |
---|
| 28 | |
---|
[16cfd8c] | 29 | void ctor( gc_memory_pool *const this, |
---|
| 30 | size_t size, |
---|
| 31 | gc_memory_pool* next, |
---|
| 32 | gc_memory_pool* mirror, |
---|
| 33 | uint8_t type |
---|
[385c130] | 34 | ); |
---|
| 35 | |
---|
[16cfd8c] | 36 | void dtor(gc_memory_pool *const this); |
---|
| 37 | |
---|
[d67a9a1] | 38 | struct gc_pool_object_iterator |
---|
| 39 | { |
---|
| 40 | struct gc_object_header* object; |
---|
| 41 | #if _DEBUG |
---|
| 42 | intptr_t lower_limit; |
---|
| 43 | intptr_t upper_limit; |
---|
| 44 | #endif |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | |
---|
[16cfd8c] | 48 | void ctor( |
---|
| 49 | gc_pool_object_iterator* const this, |
---|
[d67a9a1] | 50 | struct gc_object_header* start_object |
---|
| 51 | #if _DEBUG |
---|
| 52 | , intptr_t pool_start |
---|
| 53 | , intptr_t pool_end |
---|
| 54 | #endif |
---|
| 55 | ); |
---|
| 56 | |
---|
| 57 | bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs); |
---|
| 58 | |
---|
[16cfd8c] | 59 | gc_pool_object_iterator begin(gc_memory_pool* const this); |
---|
[df4aea7] | 60 | gc_pool_object_iterator end(gc_memory_pool* const); |
---|
| 61 | |
---|
[d67a9a1] | 62 | gc_pool_object_iterator* ++?(gc_pool_object_iterator* it); |
---|
| 63 | |
---|
| 64 | const struct gc_object_header* *?(const gc_pool_object_iterator it); |
---|
| 65 | struct gc_object_header* *?(gc_pool_object_iterator it); |
---|
| 66 | |
---|
[16cfd8c] | 67 | static inline bool gc_pool_is_from_space(const gc_memory_pool* pool) |
---|
[d67a9a1] | 68 | { |
---|
| 69 | return gc_from_space_code(gc_get_state()) == pool->type_code; |
---|
| 70 | } |
---|
| 71 | |
---|
[16cfd8c] | 72 | void gc_reset_pool(gc_memory_pool* const pool); |
---|
[d67a9a1] | 73 | |
---|
[16cfd8c] | 74 | static inline size_t gc_pool_size_used(const gc_memory_pool* pool) |
---|
[385c130] | 75 | { |
---|
| 76 | return pool->free_p - pool->start_p; |
---|
| 77 | } |
---|
| 78 | |
---|
[16cfd8c] | 79 | static inline size_t gc_pool_size_total(const gc_memory_pool* pool) |
---|
[d67a9a1] | 80 | { |
---|
| 81 | return pool->end_p - pool->start_p; |
---|
| 82 | } |
---|
| 83 | |
---|
[16cfd8c] | 84 | static inline size_t gc_pool_size_left(const gc_memory_pool* pool) |
---|
[d67a9a1] | 85 | { |
---|
| 86 | return pool->end_p - pool->free_p; |
---|
| 87 | } |
---|
| 88 | |
---|
[16cfd8c] | 89 | void* gc_pool_allocate(gc_memory_pool* const pool, size_t size, bool zero); |
---|
[d67a9a1] | 90 | |
---|
[16cfd8c] | 91 | gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* const pool, void* member); |
---|
Note: See
TracBrowser
for help on using the repository browser.