ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since d41280e was
d67a9a1,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
pool alloc functional
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[d67a9a1] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include <stdint.h> |
---|
| 4 | |
---|
| 5 | #include "tools.h" |
---|
| 6 | |
---|
| 7 | // #include "card_table.h" |
---|
| 8 | #include "collector.h" |
---|
| 9 | #include "globals.h" |
---|
| 10 | |
---|
| 11 | typedef int cardtable_ptr_t; |
---|
| 12 | |
---|
| 13 | struct gc_memory_pool |
---|
| 14 | { |
---|
| 15 | struct memory_pool* mirror; |
---|
| 16 | struct memory_pool* next; |
---|
| 17 | |
---|
| 18 | uint8_t type_code; |
---|
| 19 | |
---|
| 20 | cardtable_ptr_t cards; |
---|
| 21 | |
---|
| 22 | uint8_t* end_p; |
---|
| 23 | uint8_t* free_p; |
---|
| 24 | uint8_t start_p[1]; |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | struct gc_pool_object_iterator |
---|
| 28 | { |
---|
| 29 | |
---|
| 30 | struct gc_object_header* object; |
---|
| 31 | #if _DEBUG |
---|
| 32 | intptr_t lower_limit; |
---|
| 33 | intptr_t upper_limit; |
---|
| 34 | #endif |
---|
| 35 | }; |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | void gc_pool_object_iterator_ctor( |
---|
| 39 | struct gc_object_header* start_object |
---|
| 40 | #if _DEBUG |
---|
| 41 | , intptr_t pool_start |
---|
| 42 | , intptr_t pool_end |
---|
| 43 | #endif |
---|
| 44 | ); |
---|
| 45 | |
---|
| 46 | bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs); |
---|
| 47 | |
---|
| 48 | gc_pool_object_iterator* ++?(gc_pool_object_iterator* it); |
---|
| 49 | |
---|
| 50 | const struct gc_object_header* *?(const gc_pool_object_iterator it); |
---|
| 51 | struct gc_object_header* *?(gc_pool_object_iterator it); |
---|
| 52 | |
---|
| 53 | inline bool gc_pool_is_from_space(const gc_memory_pool* pool) |
---|
| 54 | { |
---|
| 55 | return gc_from_space_code(gc_get_state()) == pool->type_code; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | void gc_reset_pool(gc_memory_pool* pool); |
---|
| 59 | |
---|
| 60 | inline size_t gc_pool_size_total(const gc_memory_pool* pool) |
---|
| 61 | { |
---|
| 62 | return pool->end_p - pool->start_p; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | inline size_t gc_pool_size_left(const gc_memory_pool* pool) |
---|
| 66 | { |
---|
| 67 | return pool->end_p - pool->free_p; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero); |
---|
| 71 | |
---|
| 72 | gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member); |
---|
| 73 | |
---|
| 74 | gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool); |
---|
Note: See
TracBrowser
for help on using the repository browser.