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

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

all implemented files compile

  • Property mode set to 100644
File size: 1.8 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 begin(gc_memory_pool* const);
56gc_pool_object_iterator end(gc_memory_pool* const);
57
58gc_pool_object_iterator* ++?(gc_pool_object_iterator* it);
59
60const struct gc_object_header* *?(const gc_pool_object_iterator it);
61struct gc_object_header* *?(gc_pool_object_iterator it);
62
63inline bool gc_pool_is_from_space(const gc_memory_pool* pool)
64{
65        return gc_from_space_code(gc_get_state()) == pool->type_code;
66}
67
68void gc_reset_pool(gc_memory_pool* pool);
69
70inline size_t gc_pool_size_used(const gc_memory_pool* pool)
71{
72        return pool->free_p - pool->start_p;
73}
74
75inline size_t gc_pool_size_total(const gc_memory_pool* pool)
76{
77        return pool->end_p - pool->start_p;
78}
79
80inline size_t gc_pool_size_left(const gc_memory_pool* pool)
81{
82        return pool->end_p - pool->free_p;
83}
84
85void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero);
86
87gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member);
88
89gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool);
Note: See TracBrowser for help on using the repository browser.