]> git.proxmox.com Git - rustc.git/blame - src/jemalloc/include/jemalloc/internal/extent.h
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / jemalloc / include / jemalloc / internal / extent.h
CommitLineData
970d7e83
LB
1/******************************************************************************/
2#ifdef JEMALLOC_H_TYPES
3
4typedef struct extent_node_s extent_node_t;
5
6#endif /* JEMALLOC_H_TYPES */
7/******************************************************************************/
8#ifdef JEMALLOC_H_STRUCTS
9
54a0048b 10/* Tree of extents. Use accessor functions for en_* fields. */
970d7e83 11struct extent_node_s {
54a0048b
SL
12 /* Arena from which this extent came, if any. */
13 arena_t *en_arena;
970d7e83 14
54a0048b
SL
15 /* Pointer to the extent that this tree node is responsible for. */
16 void *en_addr;
17
18 /* Total region size. */
19 size_t en_size;
20
21 /*
22 * The zeroed flag is used by chunk recycling code to track whether
23 * memory is zero-filled.
24 */
25 bool en_zeroed;
26
27 /*
28 * True if physical memory is committed to the extent, whether
29 * explicitly or implicitly as on a system that overcommits and
30 * satisfies physical memory needs on demand via soft page faults.
31 */
32 bool en_committed;
33
34 /*
35 * The achunk flag is used to validate that huge allocation lookups
36 * don't return arena chunks.
37 */
38 bool en_achunk;
970d7e83
LB
39
40 /* Profile counters, used for huge objects. */
54a0048b 41 prof_tctx_t *en_prof_tctx;
970d7e83 42
54a0048b
SL
43 /* Linkage for arena's runs_dirty and chunks_cache rings. */
44 arena_runs_dirty_link_t rd;
45 qr(extent_node_t) cc_link;
970d7e83 46
54a0048b
SL
47 union {
48 /* Linkage for the size/address-ordered tree. */
49 rb_node(extent_node_t) szad_link;
970d7e83 50
54a0048b
SL
51 /* Linkage for arena's huge and node_cache lists. */
52 ql_elm(extent_node_t) ql_link;
53 };
1a4d82fc 54
54a0048b
SL
55 /* Linkage for the address-ordered tree. */
56 rb_node(extent_node_t) ad_link;
970d7e83
LB
57};
58typedef rb_tree(extent_node_t) extent_tree_t;
59
60#endif /* JEMALLOC_H_STRUCTS */
61/******************************************************************************/
62#ifdef JEMALLOC_H_EXTERNS
63
64rb_proto(, extent_tree_szad_, extent_tree_t, extent_node_t)
65
66rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t)
67
68#endif /* JEMALLOC_H_EXTERNS */
69/******************************************************************************/
70#ifdef JEMALLOC_H_INLINES
71
54a0048b
SL
72#ifndef JEMALLOC_ENABLE_INLINE
73arena_t *extent_node_arena_get(const extent_node_t *node);
74void *extent_node_addr_get(const extent_node_t *node);
75size_t extent_node_size_get(const extent_node_t *node);
76bool extent_node_zeroed_get(const extent_node_t *node);
77bool extent_node_committed_get(const extent_node_t *node);
78bool extent_node_achunk_get(const extent_node_t *node);
79prof_tctx_t *extent_node_prof_tctx_get(const extent_node_t *node);
80void extent_node_arena_set(extent_node_t *node, arena_t *arena);
81void extent_node_addr_set(extent_node_t *node, void *addr);
82void extent_node_size_set(extent_node_t *node, size_t size);
83void extent_node_zeroed_set(extent_node_t *node, bool zeroed);
84void extent_node_committed_set(extent_node_t *node, bool committed);
85void extent_node_achunk_set(extent_node_t *node, bool achunk);
86void extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx);
87void extent_node_init(extent_node_t *node, arena_t *arena, void *addr,
88 size_t size, bool zeroed, bool committed);
89void extent_node_dirty_linkage_init(extent_node_t *node);
90void extent_node_dirty_insert(extent_node_t *node,
91 arena_runs_dirty_link_t *runs_dirty, extent_node_t *chunks_dirty);
92void extent_node_dirty_remove(extent_node_t *node);
93#endif
94
95#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_EXTENT_C_))
96JEMALLOC_INLINE arena_t *
97extent_node_arena_get(const extent_node_t *node)
98{
99
100 return (node->en_arena);
101}
102
103JEMALLOC_INLINE void *
104extent_node_addr_get(const extent_node_t *node)
105{
106
107 return (node->en_addr);
108}
109
110JEMALLOC_INLINE size_t
111extent_node_size_get(const extent_node_t *node)
112{
113
114 return (node->en_size);
115}
116
117JEMALLOC_INLINE bool
118extent_node_zeroed_get(const extent_node_t *node)
119{
120
121 return (node->en_zeroed);
122}
123
124JEMALLOC_INLINE bool
125extent_node_committed_get(const extent_node_t *node)
126{
127
128 assert(!node->en_achunk);
129 return (node->en_committed);
130}
131
132JEMALLOC_INLINE bool
133extent_node_achunk_get(const extent_node_t *node)
134{
135
136 return (node->en_achunk);
137}
138
139JEMALLOC_INLINE prof_tctx_t *
140extent_node_prof_tctx_get(const extent_node_t *node)
141{
142
143 return (node->en_prof_tctx);
144}
145
146JEMALLOC_INLINE void
147extent_node_arena_set(extent_node_t *node, arena_t *arena)
148{
149
150 node->en_arena = arena;
151}
152
153JEMALLOC_INLINE void
154extent_node_addr_set(extent_node_t *node, void *addr)
155{
156
157 node->en_addr = addr;
158}
159
160JEMALLOC_INLINE void
161extent_node_size_set(extent_node_t *node, size_t size)
162{
163
164 node->en_size = size;
165}
166
167JEMALLOC_INLINE void
168extent_node_zeroed_set(extent_node_t *node, bool zeroed)
169{
170
171 node->en_zeroed = zeroed;
172}
173
174JEMALLOC_INLINE void
175extent_node_committed_set(extent_node_t *node, bool committed)
176{
177
178 node->en_committed = committed;
179}
180
181JEMALLOC_INLINE void
182extent_node_achunk_set(extent_node_t *node, bool achunk)
183{
184
185 node->en_achunk = achunk;
186}
187
188JEMALLOC_INLINE void
189extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx)
190{
191
192 node->en_prof_tctx = tctx;
193}
194
195JEMALLOC_INLINE void
196extent_node_init(extent_node_t *node, arena_t *arena, void *addr, size_t size,
197 bool zeroed, bool committed)
198{
199
200 extent_node_arena_set(node, arena);
201 extent_node_addr_set(node, addr);
202 extent_node_size_set(node, size);
203 extent_node_zeroed_set(node, zeroed);
204 extent_node_committed_set(node, committed);
205 extent_node_achunk_set(node, false);
206 if (config_prof)
207 extent_node_prof_tctx_set(node, NULL);
208}
209
210JEMALLOC_INLINE void
211extent_node_dirty_linkage_init(extent_node_t *node)
212{
213
214 qr_new(&node->rd, rd_link);
215 qr_new(node, cc_link);
216}
217
218JEMALLOC_INLINE void
219extent_node_dirty_insert(extent_node_t *node,
220 arena_runs_dirty_link_t *runs_dirty, extent_node_t *chunks_dirty)
221{
222
223 qr_meld(runs_dirty, &node->rd, rd_link);
224 qr_meld(chunks_dirty, node, cc_link);
225}
226
227JEMALLOC_INLINE void
228extent_node_dirty_remove(extent_node_t *node)
229{
230
231 qr_remove(&node->rd, rd_link);
232 qr_remove(node, cc_link);
233}
234
235#endif
236
970d7e83
LB
237#endif /* JEMALLOC_H_INLINES */
238/******************************************************************************/
239