< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp

Print this page

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
 27 
 28 #include "gc/shared/taskTerminator.hpp"
 29 #include "gc/shared/taskqueue.hpp"
 30 #include "gc/shenandoah/shenandoahPadding.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "runtime/atomic.hpp"
 33 #include "runtime/javaThread.hpp"
 34 #include "runtime/mutex.hpp"
 35 #include "utilities/debug.hpp"
 36 


 37 template<class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
 38 class BufferedOverflowTaskQueue: public OverflowTaskQueue<E, F, N>
 39 {
 40 public:
 41   typedef OverflowTaskQueue<E, F, N> taskqueue_t;
 42 
 43   BufferedOverflowTaskQueue() : _buf_empty(true) {};
 44 
 45   TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;)
 46 
 47   // Push task t into the queue. Returns true on success.
 48   inline bool push(E t);
 49 
 50   // Attempt to pop from the queue. Returns true on success.
 51   inline bool pop(E &t);
 52 
 53   inline void clear();
 54 
 55   inline bool is_empty()        const {
 56     return _buf_empty && taskqueue_t::is_empty();

335 
336   if (_claimed_index >= size) {
337     return nullptr;
338   }
339 
340   jint index = Atomic::add(&_claimed_index, 1, memory_order_relaxed);
341 
342   if (index <= size) {
343     return GenericTaskQueueSet<T, F>::queue((uint)index - 1);
344   } else {
345     return nullptr;
346   }
347 }
348 
349 class ShenandoahObjToScanQueueSet: public ParallelClaimableQueueSet<ShenandoahObjToScanQueue, mtGC> {
350 public:
351   ShenandoahObjToScanQueueSet(int n) : ParallelClaimableQueueSet<ShenandoahObjToScanQueue, mtGC>(n) {}
352 
353   bool is_empty();
354   void clear();
355 
356 #if TASKQUEUE_STATS
357   static void print_taskqueue_stats_hdr(outputStream* const st);
358   void print_taskqueue_stats() const;
359   void reset_taskqueue_stats();
360 #endif // TASKQUEUE_STATS
361 };
362 
363 class ShenandoahTerminatorTerminator : public TerminatorTerminator {
364 private:
365   ShenandoahHeap* _heap;
366 public:
367   ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
368   virtual bool should_exit_termination();
369 };
370 
371 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
 27 
 28 #include "gc/shared/taskTerminator.hpp"
 29 #include "gc/shared/taskqueue.hpp"
 30 #include "gc/shenandoah/shenandoahPadding.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "runtime/atomic.hpp"
 33 #include "runtime/javaThread.hpp"
 34 #include "runtime/mutex.hpp"
 35 #include "utilities/debug.hpp"
 36 
 37 class ShenandoahHeap;
 38 
 39 template<class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
 40 class BufferedOverflowTaskQueue: public OverflowTaskQueue<E, F, N>
 41 {
 42 public:
 43   typedef OverflowTaskQueue<E, F, N> taskqueue_t;
 44 
 45   BufferedOverflowTaskQueue() : _buf_empty(true) {};
 46 
 47   TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;)
 48 
 49   // Push task t into the queue. Returns true on success.
 50   inline bool push(E t);
 51 
 52   // Attempt to pop from the queue. Returns true on success.
 53   inline bool pop(E &t);
 54 
 55   inline void clear();
 56 
 57   inline bool is_empty()        const {
 58     return _buf_empty && taskqueue_t::is_empty();

337 
338   if (_claimed_index >= size) {
339     return nullptr;
340   }
341 
342   jint index = Atomic::add(&_claimed_index, 1, memory_order_relaxed);
343 
344   if (index <= size) {
345     return GenericTaskQueueSet<T, F>::queue((uint)index - 1);
346   } else {
347     return nullptr;
348   }
349 }
350 
351 class ShenandoahObjToScanQueueSet: public ParallelClaimableQueueSet<ShenandoahObjToScanQueue, mtGC> {
352 public:
353   ShenandoahObjToScanQueueSet(int n) : ParallelClaimableQueueSet<ShenandoahObjToScanQueue, mtGC>(n) {}
354 
355   bool is_empty();
356   void clear();






357 };
358 
359 class ShenandoahTerminatorTerminator : public TerminatorTerminator {
360 private:
361   ShenandoahHeap* _heap;
362 public:
363   ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
364   virtual bool should_exit_termination();
365 };
366 
367 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
< prev index next >