source: src/examples/gc_no_raii/src/internal/memory_pool.h @ 385c130

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglergc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 385c130 was 385c130, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

pre merge

  • Property mode set to 100644
File size: 1.7 KB
Line 
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
11typedef int cardtable_ptr_t;
12
13struct 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
27void gc_memory_pool_ctor(gc_memory_pool *const this,
28        size_t size,
29        gc_memory_pool* next,
30        gc_memory_pool* mirror,
31     uint8_t type
32        );
33
34struct gc_pool_object_iterator
35{
36
37        struct gc_object_header* object;
38        #if _DEBUG
39                intptr_t lower_limit;
40                intptr_t upper_limit;
41        #endif
42};
43
44
45void gc_pool_object_iterator_ctor(
46                struct gc_object_header* start_object
47                #if _DEBUG
48                        , intptr_t pool_start
49                        , intptr_t pool_end
50                #endif
51        );
52
53bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs);
54
55gc_pool_object_iterator* ++?(gc_pool_object_iterator* it);
56
57const struct gc_object_header* *?(const gc_pool_object_iterator it);
58struct gc_object_header* *?(gc_pool_object_iterator it);
59
60inline bool gc_pool_is_from_space(const gc_memory_pool* pool)
61{
62        return gc_from_space_code(gc_get_state()) == pool->type_code;
63}
64
65void gc_reset_pool(gc_memory_pool* pool);
66
67inline size_t gc_pool_size_used(const gc_memory_pool* pool)
68{
69        return pool->free_p - pool->start_p;
70}
71
72inline size_t gc_pool_size_total(const gc_memory_pool* pool)
73{
74        return pool->end_p - pool->start_p;
75}
76
77inline size_t gc_pool_size_left(const gc_memory_pool* pool)
78{
79        return pool->end_p - pool->free_p;
80}
81
82void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero);
83
84gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member);
85
86gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool);
Note: See TracBrowser for help on using the repository browser.