< prev index next >

src/hotspot/share/gc/shared/satbMarkQueue.hpp

Print this page

169 // determined by filter. If e is a void* entry in queue's buffer,
170 // filter_out(e) must be a valid expression whose value is convertible
171 // to bool. Entries are removed (filtered out) if the result is true,
172 // retained if false.
173 template<typename Filter>
174 inline void SATBMarkQueueSet::apply_filter(Filter filter_out, SATBMarkQueue& queue) {
175   void** buf = queue.buffer();
176 
177   if (buf == nullptr) {
178     // Nothing to do, and avoid pointer arithmetic on nullptr below.
179     return;
180   }
181 
182   // Two-fingered compaction toward the end.
183   void** src = buf + queue.index();
184   void** dst = buf + queue.current_capacity();
185   assert(src <= dst, "invariant");
186   for ( ; src < dst; ++src) {
187     // Search low to high for an entry to keep.
188     void* entry = *src;
189     if (!filter_out(entry)) {
190       // Found keeper.  Search high to low for an entry to discard.
191       while (src < --dst) {
192         if (filter_out(*dst)) {
193           *dst = entry;         // Replace discard with keeper.
194           break;
195         }
196       }
197       // If discard search failed (src == dst), the outer loop will also end.
198     }
199   }
200   // dst points to the lowest retained entry, or the end of the buffer
201   // if all the entries were filtered out.
202   queue.set_index(dst - buf);
203 }
204 
205 #endif // SHARE_GC_SHARED_SATBMARKQUEUE_HPP

169 // determined by filter. If e is a void* entry in queue's buffer,
170 // filter_out(e) must be a valid expression whose value is convertible
171 // to bool. Entries are removed (filtered out) if the result is true,
172 // retained if false.
173 template<typename Filter>
174 inline void SATBMarkQueueSet::apply_filter(Filter filter_out, SATBMarkQueue& queue) {
175   void** buf = queue.buffer();
176 
177   if (buf == nullptr) {
178     // Nothing to do, and avoid pointer arithmetic on nullptr below.
179     return;
180   }
181 
182   // Two-fingered compaction toward the end.
183   void** src = buf + queue.index();
184   void** dst = buf + queue.current_capacity();
185   assert(src <= dst, "invariant");
186   for ( ; src < dst; ++src) {
187     // Search low to high for an entry to keep.
188     void* entry = *src;
189     if (entry != nullptr && !filter_out(entry)) {
190       // Found keeper.  Search high to low for an entry to discard.
191       while (src < --dst) {
192         if (*dst == nullptr || filter_out(*dst)) {
193           *dst = entry;         // Replace discard with keeper.
194           break;
195         }
196       }
197       // If discard search failed (src == dst), the outer loop will also end.
198     }
199   }
200   // dst points to the lowest retained entry, or the end of the buffer
201   // if all the entries were filtered out.
202   queue.set_index(dst - buf);
203 }
204 
205 #endif // SHARE_GC_SHARED_SATBMARKQUEUE_HPP
< prev index next >