source: src/examples/gc_no_raii/src/internal/memory_pool.h @ d67a9a1

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

pool alloc functional

  • Property mode set to 100644
File size: 1.5 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
27struct 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
38void 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
46bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs);
47
48gc_pool_object_iterator* ++?(gc_pool_object_iterator* it);
49
50const struct gc_object_header* *?(const gc_pool_object_iterator it);
51struct gc_object_header* *?(gc_pool_object_iterator it);
52
53inline 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
58void gc_reset_pool(gc_memory_pool* pool);
59
60inline size_t gc_pool_size_total(const gc_memory_pool* pool)
61{
62        return pool->end_p - pool->start_p;
63}
64
65inline size_t gc_pool_size_left(const gc_memory_pool* pool)
66{
67        return pool->end_p - pool->free_p;
68}
69
70void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero);
71
72gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member);
73
74gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool);
Note: See TracBrowser for help on using the repository browser.