265 // determined by filter. If e is a void* entry in queue's buffer,
266 // filter_out(e) must be a valid expression whose value is convertible
267 // to bool. Entries are removed (filtered out) if the result is true,
268 // retained if false.
269 template<typename Filter>
270 inline void SATBMarkQueueSet::apply_filter(Filter filter_out, SATBMarkQueue& queue) {
271 void** buf = queue.buffer();
272
273 if (buf == nullptr) {
274 // Nothing to do, and avoid pointer arithmetic on nullptr below.
275 return;
276 }
277
278 // Two-fingered compaction toward the end.
279 void** src = buf + queue.index();
280 void** dst = buf + queue.current_capacity();
281 assert(src <= dst, "invariant");
282 for ( ; src < dst; ++src) {
283 // Search low to high for an entry to keep.
284 void* entry = *src;
285 if (!filter_out(entry)) {
286 // Found keeper. Search high to low for an entry to discard.
287 while (src < --dst) {
288 if (filter_out(*dst)) {
289 *dst = entry; // Replace discard with keeper.
290 break;
291 }
292 }
293 // If discard search failed (src == dst), the outer loop will also end.
294 }
295 }
296 // dst points to the lowest retained entry, or the end of the buffer
297 // if all the entries were filtered out.
298 queue.set_index(dst - buf);
299 }
300
301 #endif // SHARE_GC_SHARED_SATBMARKQUEUE_HPP
|
265 // determined by filter. If e is a void* entry in queue's buffer,
266 // filter_out(e) must be a valid expression whose value is convertible
267 // to bool. Entries are removed (filtered out) if the result is true,
268 // retained if false.
269 template<typename Filter>
270 inline void SATBMarkQueueSet::apply_filter(Filter filter_out, SATBMarkQueue& queue) {
271 void** buf = queue.buffer();
272
273 if (buf == nullptr) {
274 // Nothing to do, and avoid pointer arithmetic on nullptr below.
275 return;
276 }
277
278 // Two-fingered compaction toward the end.
279 void** src = buf + queue.index();
280 void** dst = buf + queue.current_capacity();
281 assert(src <= dst, "invariant");
282 for ( ; src < dst; ++src) {
283 // Search low to high for an entry to keep.
284 void* entry = *src;
285 if (entry != nullptr && !filter_out(entry)) {
286 // Found keeper. Search high to low for an entry to discard.
287 while (src < --dst) {
288 if (*dst == nullptr || filter_out(*dst)) {
289 *dst = entry; // Replace discard with keeper.
290 break;
291 }
292 }
293 // If discard search failed (src == dst), the outer loop will also end.
294 }
295 }
296 // dst points to the lowest retained entry, or the end of the buffer
297 // if all the entries were filtered out.
298 queue.set_index(dst - buf);
299 }
300
301 #endif // SHARE_GC_SHARED_SATBMARKQUEUE_HPP
|