Debian Codegraph @

src/util/pm_constant_pool.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/util/pm_constant_pool.c`/include "prism/util/pm_constant_pool.h"cxx . . $ `<file>/include/prism/util/pm_constant_pool.h`/
2
3 /**
4 * Initialize a list of constant ids.
5 */
6 void
7 pm_constant_id_list_initcxx . . $ pm_constant_id_list_init(29dd568c180bfcb).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list) {
8 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
9 list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size. = 0;
10 list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity. = 0;
11 }
12
13 /**
14 * Initialize a list of constant ids with a given capacity.
15 */
16 void
17 pm_constant_id_list_init_capacitycxx . . $ pm_constant_id_list_init_capacity(dd333c89e3e5ae76).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list, size_t capacity) {
18 if (capacity) {
19 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. = xcalloccxx . . $ `include/prism/defines.h:195:17`!(capacity, sizeof(pm_constant_id_tcxx . . $ pm_constant_id_t#));
20 if (list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) abortcxx . . $ abort(8df32a62017fbbf6).();
21 } else {
22 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
23 }
24
25 list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size. = 0;
26 list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity. = capacity;
27 }
28
29 /**
30 * Append a constant id to a list of constant ids. Returns false if any
31 * potential reallocations fail.
32 */
33 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
34 pm_constant_id_list_appendcxx . . $ pm_constant_id_list_append(44ebcd91f774aab0).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list, pm_constant_id_tcxx . . $ pm_constant_id_t# id) {
35 if (list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size. >= list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity.) {
36 list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity. = list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity. == 0 ? 8 : list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity. * 2;
37 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. = (pm_constant_id_tcxx . . $ pm_constant_id_t# *) xrealloccxx . . $ `include/prism/defines.h:187:17`!(list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids., sizeof(pm_constant_id_tcxx . . $ pm_constant_id_t#) * list->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#capacity.);
38 if (list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
39 }
40
41 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids.[list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size.++] = id;
42 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
43 }
44
45 /**
46 * Insert a constant id into a list of constant ids at the specified index.
47 */
48 void
49 pm_constant_id_list_insertcxx . . $ pm_constant_id_list_insert(2d113c4da006c8e3).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list, size_t index, pm_constant_id_tcxx . . $ pm_constant_id_t# id) {
50 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(index < list->capacity);
51 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(list->ids[index] == PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!);
52
53 list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids.[index] = id;
54 list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size.++;
55 }
56
57 /**
58 * Checks if the current constant id list includes the given constant id.
59 */
60 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
61 pm_constant_id_list_includescxx . . $ pm_constant_id_list_includes(44ebcd91f774aab0).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list, pm_constant_id_tcxx . . $ pm_constant_id_t# id) {
62 for (size_t index = 0; index < list->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#size.; index++) {
63 if (list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids.[index] == id) return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
64 }
65 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
66 }
67
68 /**
69 * Free the memory associated with a list of constant ids.
70 */
71 void
72 pm_constant_id_list_freecxx . . $ pm_constant_id_list_free(29dd568c180bfcb).(pm_constant_id_list_tcxx . . $ pm_constant_id_list_t# *list) {
73 if (list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
74 xfreecxx . . $ `include/prism/defines.h:203:17`!(list->idscxx . . $ $anonymous_type_13cf0b34c7f15a1b_0#ids.);
75 }
76 }
77
78 /**
79 * A relatively simple hash function (djb2) that is used to hash strings. We are
80 * optimizing here for simplicity and speed.
81 */
82 static inline uint32_tcxx . . $ uint32_t#
83 pm_constant_pool_hashcxx . . $ pm_constant_pool_hash(13d9c8ea4fc589cf).(const uint8_tcxx . . $ uint8_t# *start, size_t length) {
84 // This is a prime number used as the initial value for the hash function.
85 uint32_tcxx . . $ uint32_t# value = 5381;
86
87 for (size_t index = 0; index < length; index++) {
88 value = ((value << 5) + value) + start[index];
89 }
90
91 return value;
92 }
93
94 /**
95 * https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
96 */
97 static uint32_tcxx . . $ uint32_t#
98 next_power_of_twocxx . . $ next_power_of_two(2141b656ce2cc063).(uint32_tcxx . . $ uint32_t# v) {
99 // Avoid underflow in subtraction on next line.
100 if (v == 0) {
101 // 1 is the nearest power of 2 to 0 (2^0)
102 return 1;
103 }
104 v--;
105 v |= v >> 1;
106 v |= v >> 2;
107 v |= v >> 4;
108 v |= v >> 8;
109 v |= v >> 16;
110 v++;
111 return v;
112 }
113
114 #ifndef NDEBUG
115 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
116 is_power_of_twocxx . . $ is_power_of_two(dfa6e707f7696010).(uint32_tcxx . . $ uint32_t# size) {
117 return (size & (size - 1)) == 0;
118 }
119 #endif
120
121 /**
122 * Resize a constant pool to a given capacity.
123 */
124 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
125 pm_constant_pool_resizecxx . . $ pm_constant_pool_resize(f18f56c900284ecf).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool) {
126 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(is_power_of_two(pool->capacity));
127
128 uint32_tcxx . . $ uint32_t# next_capacity = pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. * 2;
129 if (next_capacity < pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity.) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
130
131 const uint32_tcxx . . $ uint32_t# mask = next_capacity - 1;
132 const size_t element_size = sizeof(pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t#) + sizeof(pm_constant_tcxx . . $ pm_constant_t#);
133
134 void *next = xcalloccxx . . $ `include/prism/defines.h:195:17`!(next_capacity, element_size);
135 if (next == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
136
137 pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t# *next_buckets = next;
138 pm_constant_tcxx . . $ pm_constant_t# *next_constants = (void *)(((char *) next) + next_capacity * sizeof(pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t#));
139
140 // For each bucket in the current constant pool, find the index in the
141 // next constant pool, and insert it.
142 for (uint32_tcxx . . $ uint32_t# index = 0; index < pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity.; index++) {
143 pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t# *bucket = &pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.[index];
144
145 // If an id is set on this constant, then we know we have content here.
146 // In this case we need to insert it into the next constant pool.
147 if (bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!) {
148 uint32_tcxx . . $ uint32_t# next_index = bucket->hashcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#hash. & mask;
149
150 // This implements linear scanning to find the next available slot
151 // in case this index is already taken. We don't need to bother
152 // comparing the values since we know that the hash is unique.
153 while (next_buckets[next_index].idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!) {
154 next_index = (next_index + 1) & mask;
155 }
156
157 // Here we copy over the entire bucket, which includes the id so
158 // that they are consistent between resizes.
159 next_buckets[next_index] = *bucket;
160 }
161 }
162
163 // The constants are stable with respect to hash table resizes.
164 memcpycxx . . $ memcpy(cc817cb175f282d).(next_constants, pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants., pool->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#size. * sizeof(pm_constant_tcxx . . $ pm_constant_t#));
165
166 // pool->constants and pool->buckets are allocated out of the same chunk
167 // of memory, with the buckets coming first.
168 xfreecxx . . $ `include/prism/defines.h:203:17`!(pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.);
169 pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants. = next_constants;
170 pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets. = next_buckets;
171 pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. = next_capacity;
172 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
173 }
174
175 /**
176 * Initialize a new constant pool with a given capacity.
177 */
178 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
179 pm_constant_pool_initcxx . . $ pm_constant_pool_init(623db788e4f57937).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, uint32_tcxx . . $ uint32_t# capacity) {
180 const uint32_tcxx . . $ uint32_t# maximum = (~((uint32_tcxx . . $ uint32_t#) 0));
181 if (capacity >= ((maximum / 2) + 1)) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
182
183 capacity = next_power_of_twocxx . . $ next_power_of_two(2141b656ce2cc063).(capacity);
184 const size_t element_size = sizeof(pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t#) + sizeof(pm_constant_tcxx . . $ pm_constant_t#);
185 void *memory = xcalloccxx . . $ `include/prism/defines.h:195:17`!(capacity, element_size);
186 if (memory == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
187
188 pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets. = memory;
189 pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants. = (void *)(((char *)memory) + capacity * sizeof(pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t#));
190 pool->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#size. = 0;
191 pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. = capacity;
192 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
193 }
194
195 /**
196 * Return a pointer to the constant indicated by the given constant id.
197 */
198 pm_constant_tcxx . . $ pm_constant_t# *
199 pm_constant_pool_id_to_constantcxx . . $ pm_constant_pool_id_to_constant(152889a4d6977c9f).(const pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, pm_constant_id_tcxx . . $ pm_constant_id_t# constant_id) {
200 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(constant_id != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`! && constant_id <= pool->size);
201 return &pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants.[constant_id - 1];
202 }
203
204 /**
205 * Find a constant in a constant pool. Returns the id of the constant, or 0 if
206 * the constant is not found.
207 */
208 pm_constant_id_tcxx . . $ pm_constant_id_t#
209 pm_constant_pool_findcxx . . $ pm_constant_pool_find(c5d2d6ccac7c7781).(const pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, const uint8_tcxx . . $ uint8_t# *start, size_t length) {
210 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(is_power_of_two(pool->capacity));
211 const uint32_tcxx . . $ uint32_t# mask = pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. - 1;
212
213 uint32_tcxx . . $ uint32_t# hash = pm_constant_pool_hashcxx . . $ pm_constant_pool_hash(13d9c8ea4fc589cf).(start, length);
214 uint32_tcxx . . $ uint32_t# index = hash & mask;
215 pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t# *bucket;
216
217 while (bucket = &pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.[index], bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!) {
218 pm_constant_tcxx . . $ pm_constant_t# *constant = &pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants.[bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. - 1];
219 if ((constant->lengthcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#length. == length) && memcmpcxx . . $ memcmp(36f949851efa3055).(constant->startcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#start., start, length) == 0) {
220 return bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id.;
221 }
222
223 index = (index + 1) & mask;
224 }
225
226 return PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!;
227 }
228
229 /**
230 * Insert a constant into a constant pool and return its index in the pool.
231 */
232 static inline pm_constant_id_tcxx . . $ pm_constant_id_t#
233 pm_constant_pool_insertcxx . . $ pm_constant_pool_insert(aab8a51ca9a970bb).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, const uint8_tcxx . . $ uint8_t# *start, size_t length, pm_constant_pool_bucket_type_tcxx . . $ pm_constant_pool_bucket_type_t# type) {
234 if (pool->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#size. >= (pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. / 4 * 3)) {
235 if (!pm_constant_pool_resizecxx . . $ pm_constant_pool_resize(f18f56c900284ecf).(pool)) return PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!;
236 }
237
238 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(is_power_of_two(pool->capacity));
239 const uint32_tcxx . . $ uint32_t# mask = pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity. - 1;
240
241 uint32_tcxx . . $ uint32_t# hash = pm_constant_pool_hashcxx . . $ pm_constant_pool_hash(13d9c8ea4fc589cf).(start, length);
242 uint32_tcxx . . $ uint32_t# index = hash & mask;
243 pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t# *bucket;
244
245 while (bucket = &pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.[index], bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`!) {
246 // If there is a collision, then we need to check if the content is the
247 // same as the content we are trying to insert. If it is, then we can
248 // return the id of the existing constant.
249 pm_constant_tcxx . . $ pm_constant_t# *constant = &pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants.[bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. - 1];
250
251 if ((constant->lengthcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#length. == length) && memcmpcxx . . $ memcmp(36f949851efa3055).(constant->startcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#start., start, length) == 0) {
252 // Since we have found a match, we need to check if this is
253 // attempting to insert a shared or an owned constant. We want to
254 // prefer shared constants since they don't require allocations.
255 if (type == PM_CONSTANT_POOL_BUCKET_OWNEDcxx . . $ PM_CONSTANT_POOL_BUCKET_OWNED.) {
256 // If we're attempting to insert an owned constant and we have
257 // an existing constant, then either way we don't want the given
258 // memory. Either it's duplicated with the existing constant or
259 // it's not necessary because we have a shared version.
260 xfreecxx . . $ `include/prism/defines.h:203:17`!((void *) start);
261 } else if (bucket->typecxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#type. == PM_CONSTANT_POOL_BUCKET_OWNEDcxx . . $ PM_CONSTANT_POOL_BUCKET_OWNED.) {
262 // If we're attempting to insert a shared constant and the
263 // existing constant is owned, then we can free the owned
264 // constant and replace it with the shared constant.
265 xfreecxx . . $ `include/prism/defines.h:203:17`!((void *) constant->startcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#start.);
266 constant->startcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#start. = start;
267 bucket->typecxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#type. = (unsigned int) (type & 0x3);
268 }
269
270 return bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id.;
271 }
272
273 index = (index + 1) & mask;
274 }
275
276 // IDs are allocated starting at 1, since the value 0 denotes a non-existent
277 // constant.
278 uint32_tcxx . . $ uint32_t# id = ++pool->sizecxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#size.;
279 assertcxx . . $ `<external>/4398592474888995393/assert.h:108:11`!(pool->size < ((uint32_t) (1 << 30)));
280
281 *bucket = (pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t#) {
282 .id = (unsigned int) (id & 0x3fffffff),
283 .type = (unsigned int) (type & 0x3),
284 .hash = hash
285 };
286
287 pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants.[id - 1] = (pm_constant_tcxx . . $ pm_constant_t#) {
288 .start = start,
289 .length = length,
290 };
291
292 return id;
293 }
294
295 /**
296 * Insert a constant into a constant pool. Returns the id of the constant, or
297 * PM_CONSTANT_ID_UNSET if any potential calls to resize fail.
298 */
299 pm_constant_id_tcxx . . $ pm_constant_id_t#
300 pm_constant_pool_insert_sharedcxx . . $ pm_constant_pool_insert_shared(9c21faf08e05bda3).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, const uint8_tcxx . . $ uint8_t# *start, size_t length) {
301 return pm_constant_pool_insertcxx . . $ pm_constant_pool_insert(aab8a51ca9a970bb).(pool, start, length, PM_CONSTANT_POOL_BUCKET_DEFAULTcxx . . $ PM_CONSTANT_POOL_BUCKET_DEFAULT.);
302 }
303
304 /**
305 * Insert a constant into a constant pool from memory that is now owned by the
306 * constant pool. Returns the id of the constant, or PM_CONSTANT_ID_UNSET if any
307 * potential calls to resize fail.
308 */
309 pm_constant_id_tcxx . . $ pm_constant_id_t#
310 pm_constant_pool_insert_ownedcxx . . $ pm_constant_pool_insert_owned(488f2ad32ee21d44).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, uint8_tcxx . . $ uint8_t# *start, size_t length) {
311 return pm_constant_pool_insertcxx . . $ pm_constant_pool_insert(aab8a51ca9a970bb).(pool, start, length, PM_CONSTANT_POOL_BUCKET_OWNEDcxx . . $ PM_CONSTANT_POOL_BUCKET_OWNED.);
312 }
313
314 /**
315 * Insert a constant into a constant pool from memory that is constant. Returns
316 * the id of the constant, or PM_CONSTANT_ID_UNSET if any potential calls to
317 * resize fail.
318 */
319 pm_constant_id_tcxx . . $ pm_constant_id_t#
320 pm_constant_pool_insert_constantcxx . . $ pm_constant_pool_insert_constant(9c21faf08e05bda3).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool, const uint8_tcxx . . $ uint8_t# *start, size_t length) {
321 return pm_constant_pool_insertcxx . . $ pm_constant_pool_insert(aab8a51ca9a970bb).(pool, start, length, PM_CONSTANT_POOL_BUCKET_CONSTANTcxx . . $ PM_CONSTANT_POOL_BUCKET_CONSTANT.);
322 }
323
324 /**
325 * Free the memory associated with a constant pool.
326 */
327 void
328 pm_constant_pool_freecxx . . $ pm_constant_pool_free(7fc013cdbc0a409a).(pm_constant_pool_tcxx . . $ pm_constant_pool_t# *pool) {
329 // For each constant in the current constant pool, free the contents if the
330 // contents are owned.
331 for (uint32_tcxx . . $ uint32_t# index = 0; index < pool->capacitycxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#capacity.; index++) {
332 pm_constant_pool_bucket_tcxx . . $ pm_constant_pool_bucket_t# *bucket = &pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.[index];
333
334 // If an id is set on this constant, then we know we have content here.
335 if (bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. != PM_CONSTANT_ID_UNSETcxx . . $ `include/prism/util/pm_constant_pool.h:26:9`! && bucket->typecxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#type. == PM_CONSTANT_POOL_BUCKET_OWNEDcxx . . $ PM_CONSTANT_POOL_BUCKET_OWNED.) {
336 pm_constant_tcxx . . $ pm_constant_t# *constant = &pool->constantscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#constants.[bucket->idcxx . . $ $anonymous_type_13cf0b34c7f15a1b_1#id. - 1];
337 xfreecxx . . $ `include/prism/defines.h:203:17`!((void *) constant->startcxx . . $ $anonymous_type_13cf0b34c7f15a1b_2#start.);
338 }
339 }
340
341 xfreecxx . . $ `include/prism/defines.h:203:17`!(pool->bucketscxx . . $ $anonymous_type_13cf0b34c7f15a1b_3#buckets.);
342 }