Lines Matching refs:ddpa

89    DedupPoolAlloc* ddpa;  in VG_()  local
96 ddpa = alloc_fn(cc, sizeof(*ddpa)); in VG_()
97 VG_(memset)(ddpa, 0, sizeof(*ddpa)); in VG_()
98 ddpa->poolSzB = poolSzB; in VG_()
99 ddpa->fixedSzb = 0; in VG_()
100 ddpa->eltAlign = eltAlign; in VG_()
101 ddpa->alloc_fn = alloc_fn; in VG_()
102 ddpa->cc = cc; in VG_()
103 ddpa->free_fn = free_fn; in VG_()
104 ddpa->pools = VG_(newXA)( alloc_fn, cc, free_fn, sizeof(void*) ); in VG_()
106 ddpa->ht_elements = VG_(HT_construct) (cc); in VG_()
107 ddpa->ht_node_pa = VG_(newPA) ( sizeof(ht_node), in VG_()
112 ddpa->curpool = NULL; in VG_()
113 ddpa->curpool_limit = NULL; in VG_()
114 ddpa->curpool_free = NULL; in VG_()
116 return ddpa; in VG_()
119 void VG_(deleteDedupPA) ( DedupPoolAlloc* ddpa) in VG_()
122 if (ddpa->ht_elements) in VG_()
124 VG_(freezeDedupPA) (ddpa, NULL); in VG_()
125 for (i = 0; i < VG_(sizeXA) (ddpa->pools); i++) in VG_()
126 ddpa->free_fn (*(UWord **)VG_(indexXA) ( ddpa->pools, i )); in VG_()
127 VG_(deleteXA) (ddpa->pools); in VG_()
128 ddpa->free_fn (ddpa); in VG_()
132 UChar* ddpa_align ( DedupPoolAlloc* ddpa, UChar *c ) in ddpa_align() argument
134 return (UChar*)VG_ROUNDUP(c, ddpa->eltAlign); in ddpa_align()
139 static void ddpa_add_new_pool_or_grow ( DedupPoolAlloc* ddpa ) in ddpa_add_new_pool_or_grow() argument
141 vg_assert(ddpa); in ddpa_add_new_pool_or_grow()
143 if (ddpa->fixedSzb > 0 && ddpa->curpool != NULL) { in ddpa_add_new_pool_or_grow()
145 UChar *curpool_align = ddpa_align(ddpa, ddpa->curpool); in ddpa_add_new_pool_or_grow()
146 SizeT curpool_used = ddpa->curpool_free - curpool_align; in ddpa_add_new_pool_or_grow()
147 SizeT curpool_size = ddpa->curpool_limit - ddpa->curpool + 1; in ddpa_add_new_pool_or_grow()
148 UChar *newpool = ddpa->alloc_fn (ddpa->cc, 2 * curpool_size); in ddpa_add_new_pool_or_grow()
149 UChar *newpool_free = ddpa_align (ddpa, newpool); in ddpa_add_new_pool_or_grow()
157 VG_(HT_ResetIter) (ddpa->ht_elements); in ddpa_add_new_pool_or_grow()
158 while ((n = VG_(HT_Next) (ddpa->ht_elements))) { in ddpa_add_new_pool_or_grow()
163 VG_(dropHeadXA) (ddpa->pools, 1); in ddpa_add_new_pool_or_grow()
164 ddpa->free_fn (ddpa->curpool); in ddpa_add_new_pool_or_grow()
165 ddpa->curpool = newpool; in ddpa_add_new_pool_or_grow()
166 ddpa->curpool_free = newpool_free; in ddpa_add_new_pool_or_grow()
167 ddpa->curpool_limit = newpool_limit; in ddpa_add_new_pool_or_grow()
168 VG_(addToXA)( ddpa->pools, &ddpa->curpool); in ddpa_add_new_pool_or_grow()
172 ddpa->curpool = ddpa->alloc_fn( ddpa->cc, ddpa->poolSzB); in ddpa_add_new_pool_or_grow()
173 ddpa->curpool_limit = ddpa->curpool + ddpa->poolSzB - 1; in ddpa_add_new_pool_or_grow()
174 ddpa->curpool_free = ddpa_align (ddpa, ddpa->curpool); in ddpa_add_new_pool_or_grow()
176 VG_(addToXA)( ddpa->pools, &ddpa->curpool ); in ddpa_add_new_pool_or_grow()
201 static void print_stats (DedupPoolAlloc *ddpa) in print_stats() argument
206 ddpa->cc, in print_stats()
207 (long int) ddpa->nr_alloc_calls, in print_stats()
208 VG_(HT_count_nodes)(ddpa->ht_elements), in print_stats()
209 VG_(sizeXA)(ddpa->pools), in print_stats()
210 ddpa->curpool ? in print_stats()
211 (long int) (ddpa->curpool_limit - ddpa->curpool_free + 1) : 0); in print_stats()
212 VG_(HT_print_stats) (ddpa->ht_elements, cmp_pool_elt); in print_stats()
221 void VG_(freezeDedupPA) (DedupPoolAlloc *ddpa, in VG_()
226 print_stats(ddpa); in VG_()
228 vg_assert (!ddpa->fixedSzb || VG_(sizeXA) (ddpa->pools) == 1); in VG_()
229 if (shrink_block && ddpa->curpool_limit > ddpa->curpool_free) in VG_()
230 (*shrink_block)(ddpa->curpool, ddpa->curpool_free - ddpa->curpool); in VG_()
231 VG_(HT_destruct) ( ddpa->ht_elements, htelem_dummyfree); in VG_()
232 ddpa->ht_elements = NULL; in VG_()
233 VG_(deletePA) (ddpa->ht_node_pa); in VG_()
234 ddpa->ht_node_pa = NULL; in VG_()
250 const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB, in VG_()
256 vg_assert(ddpa); in VG_()
257 vg_assert(ddpa->ht_elements); in VG_()
258 vg_assert (eltSzB <= ddpa->poolSzB); in VG_()
260 ddpa->nr_alloc_calls++; in VG_()
267 ht_ins = VG_(HT_gen_lookup) (ddpa->ht_elements, &ht_elt, cmp_pool_elt); in VG_()
275 if (UNLIKELY(ddpa->curpool_free == NULL in VG_()
276 || ddpa->curpool_free + eltSzB - 1 > ddpa->curpool_limit)) { in VG_()
277 ddpa_add_new_pool_or_grow (ddpa); in VG_()
280 elt_ins = ddpa->curpool_free; in VG_()
282 ddpa->curpool_free = ddpa_align(ddpa, ddpa->curpool_free + eltSzB); in VG_()
284 ht_ins = VG_(allocEltPA) (ddpa->ht_node_pa); in VG_()
288 VG_(HT_add_node)(ddpa->ht_elements, ht_ins); in VG_()
293 UInt elt2nr (DedupPoolAlloc *ddpa, const void *dedup_elt) in elt2nr() argument
295 vg_assert (dedup_elt >= (const void *)ddpa->curpool in elt2nr()
296 && dedup_elt < (const void *)ddpa->curpool_free); in elt2nr()
297 return 1 + ((const UChar*)dedup_elt - (const UChar *)ddpa->curpool) in elt2nr()
298 / VG_ROUNDUP(ddpa->fixedSzb, ddpa->eltAlign); in elt2nr()
301 UInt VG_(allocFixedEltDedupPA) (DedupPoolAlloc *ddpa, in VG_()
304 if (ddpa->fixedSzb == 0) { in VG_()
306 vg_assert (ddpa->nr_alloc_calls == 0); in VG_()
308 ddpa->fixedSzb = eltSzB; in VG_()
310 vg_assert (ddpa->fixedSzb == eltSzB); in VG_()
311 const void *dedup_elt = VG_(allocEltDedupPA) (ddpa, eltSzB, elt); in VG_()
312 return elt2nr (ddpa, dedup_elt); in VG_()
315 void* VG_(indexEltNumber) (DedupPoolAlloc *ddpa, in VG_()
320 dedup_elt = ddpa->curpool in VG_()
321 + (eltNr - 1) * VG_ROUNDUP(ddpa->fixedSzb, ddpa->eltAlign); in VG_()
323 vg_assert ((UChar*)dedup_elt >= ddpa->curpool in VG_()
324 && (UChar*)dedup_elt < ddpa->curpool_free); in VG_()
329 UInt VG_(sizeDedupPA) (DedupPoolAlloc *ddpa) in VG_()
331 if (ddpa->curpool == NULL) in VG_()
334 vg_assert (ddpa->fixedSzb); in VG_()
335 return (ddpa->curpool_free - ddpa_align(ddpa, ddpa->curpool)) in VG_()
336 / VG_ROUNDUP(ddpa->fixedSzb, ddpa->eltAlign); in VG_()