Lines Matching refs:quarantine
5 * Quarantine pointers close to NULL are used to encode state information that
15 static quarantine_t *quarantine_grow(tsd_t *tsd, quarantine_t *quarantine);
16 static void quarantine_drain_one(tsdn_t *tsdn, quarantine_t *quarantine);
17 static void quarantine_drain(tsdn_t *tsdn, quarantine_t *quarantine,
25 quarantine_t *quarantine;
30 quarantine = (quarantine_t *)iallocztm(tsdn, size, size2index(size),
32 if (quarantine == NULL)
34 quarantine->curbytes = 0;
35 quarantine->curobjs = 0;
36 quarantine->first = 0;
37 quarantine->lg_maxobjs = lg_maxobjs;
39 return (quarantine);
45 quarantine_t *quarantine;
50 quarantine = quarantine_init(tsd_tsdn(tsd), LG_MAXOBJS_INIT);
52 * Check again whether quarantine has been initialized, because
56 tsd_quarantine_set(tsd, quarantine);
58 idalloctm(tsd_tsdn(tsd), quarantine, NULL, true, true);
62 quarantine_grow(tsd_t *tsd, quarantine_t *quarantine)
66 ret = quarantine_init(tsd_tsdn(tsd), quarantine->lg_maxobjs + 1);
68 quarantine_drain_one(tsd_tsdn(tsd), quarantine);
69 return (quarantine);
72 ret->curbytes = quarantine->curbytes;
73 ret->curobjs = quarantine->curobjs;
74 if (quarantine->first + quarantine->curobjs <= (ZU(1) <<
75 quarantine->lg_maxobjs)) {
77 memcpy(ret->objs, &quarantine->objs[quarantine->first],
78 quarantine->curobjs * sizeof(quarantine_obj_t));
81 size_t ncopy_a = (ZU(1) << quarantine->lg_maxobjs) -
82 quarantine->first;
83 size_t ncopy_b = quarantine->curobjs - ncopy_a;
85 memcpy(ret->objs, &quarantine->objs[quarantine->first], ncopy_a
87 memcpy(&ret->objs[ncopy_a], quarantine->objs, ncopy_b *
90 idalloctm(tsd_tsdn(tsd), quarantine, NULL, true, true);
97 quarantine_drain_one(tsdn_t *tsdn, quarantine_t *quarantine)
99 quarantine_obj_t *obj = &quarantine->objs[quarantine->first];
102 quarantine->curbytes -= obj->usize;
103 quarantine->curobjs--;
104 quarantine->first = (quarantine->first + 1) & ((ZU(1) <<
105 quarantine->lg_maxobjs) - 1);
109 quarantine_drain(tsdn_t *tsdn, quarantine_t *quarantine, size_t upper_bound)
112 while (quarantine->curbytes > upper_bound && quarantine->curobjs > 0)
113 quarantine_drain_one(tsdn, quarantine);
117 quarantine(tsd_t *tsd, void *ptr)
119 quarantine_t *quarantine;
125 if ((quarantine = tsd_quarantine_get(tsd)) == NULL) {
130 * Drain one or more objects if the quarantine size limit would be
133 if (quarantine->curbytes + usize > opt_quarantine) {
136 quarantine_drain(tsd_tsdn(tsd), quarantine, upper_bound);
138 /* Grow the quarantine ring buffer if it's full. */
139 if (quarantine->curobjs == (ZU(1) << quarantine->lg_maxobjs))
140 quarantine = quarantine_grow(tsd, quarantine);
142 assert(quarantine->curobjs < (ZU(1) << quarantine->lg_maxobjs));
143 /* Append ptr if its size doesn't exceed the quarantine size. */
144 if (quarantine->curbytes + usize <= opt_quarantine) {
145 size_t offset = (quarantine->first + quarantine->curobjs) &
146 ((ZU(1) << quarantine->lg_maxobjs) - 1);
147 quarantine_obj_t *obj = &quarantine->objs[offset];
150 quarantine->curbytes += usize;
151 quarantine->curobjs++;
164 assert(quarantine->curbytes == 0);
172 quarantine_t *quarantine;
177 quarantine = tsd_quarantine_get(tsd);
178 if (quarantine != NULL) {
179 quarantine_drain(tsd_tsdn(tsd), quarantine, 0);
180 idalloctm(tsd_tsdn(tsd), quarantine, NULL, true, true);