Rizin
unix-like reverse engineering framework and cli tools
extent.h
Go to the documentation of this file.
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
3 
4 typedef struct extent_node_s extent_node_t;
5 
6 #endif /* JEMALLOC_H_TYPES */
7 /******************************************************************************/
8 #ifdef JEMALLOC_H_STRUCTS
9 
10 /* Tree of extents. Use accessor functions for en_* fields. */
11 struct extent_node_s {
12  /* Arena from which this extent came, if any. */
13  arena_t *en_arena;
14 
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  * Serial number (potentially non-unique).
23  *
24  * In principle serial numbers can wrap around on 32-bit systems if
25  * JEMALLOC_MUNMAP is defined, but as long as comparison functions fall
26  * back on address comparison for equal serial numbers, stable (if
27  * imperfect) ordering is maintained.
28  *
29  * Serial numbers may not be unique even in the absence of wrap-around,
30  * e.g. when splitting an extent and assigning the same serial number to
31  * both resulting adjacent extents.
32  */
33  size_t en_sn;
34 
35  /*
36  * The zeroed flag is used by chunk recycling code to track whether
37  * memory is zero-filled.
38  */
39  bool en_zeroed;
40 
41  /*
42  * True if physical memory is committed to the extent, whether
43  * explicitly or implicitly as on a system that overcommits and
44  * satisfies physical memory needs on demand via soft page faults.
45  */
46  bool en_committed;
47 
48  /*
49  * The achunk flag is used to validate that huge allocation lookups
50  * don't return arena chunks.
51  */
52  bool en_achunk;
53 
54  /* Profile counters, used for huge objects. */
55  prof_tctx_t *en_prof_tctx;
56 
57  /* Linkage for arena's runs_dirty and chunks_cache rings. */
58  arena_runs_dirty_link_t rd;
59  qr(extent_node_t) cc_link;
60 
61  union {
62  /* Linkage for the size/sn/address-ordered tree. */
63  rb_node(extent_node_t) szsnad_link;
64 
65  /* Linkage for arena's achunks, huge, and node_cache lists. */
66  ql_elm(extent_node_t) ql_link;
67  };
68 
69  /* Linkage for the address-ordered tree. */
70  rb_node(extent_node_t) ad_link;
71 };
72 typedef rb_tree(extent_node_t) extent_tree_t;
73 
74 #endif /* JEMALLOC_H_STRUCTS */
75 /******************************************************************************/
76 #ifdef JEMALLOC_H_EXTERNS
77 
78 #ifdef JEMALLOC_JET
79 size_t extent_size_quantize_floor(size_t size);
80 #endif
81 size_t extent_size_quantize_ceil(size_t size);
82 
83 rb_proto(, extent_tree_szsnad_, extent_tree_t, extent_node_t)
84 
85 rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t)
86 
87 #endif /* JEMALLOC_H_EXTERNS */
88 /******************************************************************************/
89 #ifdef JEMALLOC_H_INLINES
90 
91 #ifndef JEMALLOC_ENABLE_INLINE
92 arena_t *extent_node_arena_get(const extent_node_t *node);
93 void *extent_node_addr_get(const extent_node_t *node);
94 size_t extent_node_size_get(const extent_node_t *node);
95 size_t extent_node_sn_get(const extent_node_t *node);
96 bool extent_node_zeroed_get(const extent_node_t *node);
97 bool extent_node_committed_get(const extent_node_t *node);
98 bool extent_node_achunk_get(const extent_node_t *node);
99 prof_tctx_t *extent_node_prof_tctx_get(const extent_node_t *node);
100 void extent_node_arena_set(extent_node_t *node, arena_t *arena);
101 void extent_node_addr_set(extent_node_t *node, void *addr);
102 void extent_node_size_set(extent_node_t *node, size_t size);
103 void extent_node_sn_set(extent_node_t *node, size_t sn);
104 void extent_node_zeroed_set(extent_node_t *node, bool zeroed);
105 void extent_node_committed_set(extent_node_t *node, bool committed);
106 void extent_node_achunk_set(extent_node_t *node, bool achunk);
107 void extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx);
108 void extent_node_init(extent_node_t *node, arena_t *arena, void *addr,
109  size_t size, size_t sn, bool zeroed, bool committed);
110 void extent_node_dirty_linkage_init(extent_node_t *node);
111 void extent_node_dirty_insert(extent_node_t *node,
112  arena_runs_dirty_link_t *runs_dirty, extent_node_t *chunks_dirty);
113 void extent_node_dirty_remove(extent_node_t *node);
114 #endif
115 
116 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_EXTENT_C_))
117 JEMALLOC_INLINE arena_t *
118 extent_node_arena_get(const extent_node_t *node)
119 {
120 
121  return (node->en_arena);
122 }
123 
124 JEMALLOC_INLINE void *
125 extent_node_addr_get(const extent_node_t *node)
126 {
127 
128  return (node->en_addr);
129 }
130 
131 JEMALLOC_INLINE size_t
132 extent_node_size_get(const extent_node_t *node)
133 {
134 
135  return (node->en_size);
136 }
137 
138 JEMALLOC_INLINE size_t
139 extent_node_sn_get(const extent_node_t *node)
140 {
141 
142  return (node->en_sn);
143 }
144 
145 JEMALLOC_INLINE bool
146 extent_node_zeroed_get(const extent_node_t *node)
147 {
148 
149  return (node->en_zeroed);
150 }
151 
152 JEMALLOC_INLINE bool
153 extent_node_committed_get(const extent_node_t *node)
154 {
155  if (unlikely(node->en_achunk))
156  return false;
157  return (node->en_committed);
158 }
159 
160 JEMALLOC_INLINE bool
161 extent_node_achunk_get(const extent_node_t *node)
162 {
163 
164  return (node->en_achunk);
165 }
166 
167 JEMALLOC_INLINE prof_tctx_t *
168 extent_node_prof_tctx_get(const extent_node_t *node)
169 {
170 
171  return (node->en_prof_tctx);
172 }
173 
174 JEMALLOC_INLINE void
175 extent_node_arena_set(extent_node_t *node, arena_t *arena)
176 {
177 
178  node->en_arena = arena;
179 }
180 
181 JEMALLOC_INLINE void
182 extent_node_addr_set(extent_node_t *node, void *addr)
183 {
184 
185  node->en_addr = addr;
186 }
187 
188 JEMALLOC_INLINE void
189 extent_node_size_set(extent_node_t *node, size_t size)
190 {
191 
192  node->en_size = size;
193 }
194 
195 JEMALLOC_INLINE void
196 extent_node_sn_set(extent_node_t *node, size_t sn)
197 {
198 
199  node->en_sn = sn;
200 }
201 
202 JEMALLOC_INLINE void
203 extent_node_zeroed_set(extent_node_t *node, bool zeroed)
204 {
205 
206  node->en_zeroed = zeroed;
207 }
208 
209 JEMALLOC_INLINE void
210 extent_node_committed_set(extent_node_t *node, bool committed)
211 {
212 
213  node->en_committed = committed;
214 }
215 
216 JEMALLOC_INLINE void
217 extent_node_achunk_set(extent_node_t *node, bool achunk)
218 {
219 
220  node->en_achunk = achunk;
221 }
222 
223 JEMALLOC_INLINE void
224 extent_node_prof_tctx_set(extent_node_t *node, prof_tctx_t *tctx)
225 {
226 
227  node->en_prof_tctx = tctx;
228 }
229 
230 JEMALLOC_INLINE void
231 extent_node_init(extent_node_t *node, arena_t *arena, void *addr, size_t size,
232  size_t sn, bool zeroed, bool committed)
233 {
234 
235  extent_node_arena_set(node, arena);
236  extent_node_addr_set(node, addr);
237  extent_node_size_set(node, size);
238  extent_node_sn_set(node, sn);
239  extent_node_zeroed_set(node, zeroed);
240  extent_node_committed_set(node, committed);
241  extent_node_achunk_set(node, false);
242  if (config_prof)
244 }
245 
246 JEMALLOC_INLINE void
247 extent_node_dirty_linkage_init(extent_node_t *node)
248 {
249 
250  qr_new(&node->rd, rd_link);
251  qr_new(node, cc_link);
252 }
253 
254 JEMALLOC_INLINE void
255 extent_node_dirty_insert(extent_node_t *node,
256  arena_runs_dirty_link_t *runs_dirty, extent_node_t *chunks_dirty)
257 {
258 
259  qr_meld(runs_dirty, &node->rd, rd_link);
260  qr_meld(chunks_dirty, node, cc_link);
261 }
262 
263 JEMALLOC_INLINE void
264 extent_node_dirty_remove(extent_node_t *node)
265 {
266 
267  qr_remove(&node->rd, rd_link);
268  qr_remove(node, cc_link);
269 }
270 
271 #endif
272 
273 #endif /* JEMALLOC_H_INLINES */
274 /******************************************************************************/
275 
#define rd()
#define NULL
Definition: cris-opc.c:27
voidpf void uLong size
Definition: ioapi.h:138
static const bool config_prof
#define JEMALLOC_INLINE
#define unlikely(expr)
Definition: lz4.c:177
#define extent_node_zeroed_get
#define extent_node_dirty_insert
#define extent_size_quantize_floor
#define extent_node_sn_get
#define extent_node_init
#define extent_node_size_get
#define extent_node_arena_get
#define extent_node_committed_get
#define extent_node_sn_set
#define extent_node_size_set
#define extent_node_dirty_remove
#define extent_size_quantize_ceil
#define extent_node_addr_set
#define extent_node_arena_set
#define extent_node_achunk_get
#define extent_node_zeroed_set
#define extent_node_dirty_linkage_init
#define extent_node_committed_set
#define extent_node_addr_get
#define extent_node_achunk_set
#define extent_node_prof_tctx_get
#define extent_node_prof_tctx_set
#define ql_elm(a_type)
Definition: ql.h:9
#define qr(a_type)
Definition: qr.h:2
#define qr_meld(a_qr_a, a_qr_b, a_field)
Definition: qr.h:34
#define qr_remove(a_qr, a_field)
Definition: qr.h:50
#define qr_new(a_qr, a_field)
Definition: qr.h:9
#define rb_node(a_type)
Definition: rb.h:33
#define rb_tree(a_type)
Definition: rb.h:42
#define rb_proto(a_attr, a_prefix, a_rbt_type, a_type)
Definition: rb.h:163
static int addr
Definition: z80asm.c:58