--- old/src/hotspot/share/gc/shared/taskqueue.hpp 2020-01-30 17:11:14.242625951 +0100 +++ new/src/hotspot/share/gc/shared/taskqueue.hpp 2020-01-30 17:11:13.450614613 +0100 @@ -443,89 +443,6 @@ virtual bool should_exit_termination() = 0; }; -// A class to aid in the termination of a set of parallel tasks using -// TaskQueueSet's for work stealing. - -#undef TRACESPINNING - -class ParallelTaskTerminator: public CHeapObj { -protected: - uint _n_threads; - TaskQueueSetSuper* _queue_set; - - DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0); - volatile uint _offered_termination; - DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile uint)); - -#ifdef TRACESPINNING - static uint _total_yields; - static uint _total_spins; - static uint _total_peeks; -#endif - - bool peek_in_queue_set(); -protected: - virtual void yield(); - void sleep(uint millis); - - // Called when exiting termination is requested. - // When the request is made, terminator may have already terminated - // (e.g. all threads are arrived and offered termination). In this case, - // it should ignore the request and complete the termination. - // Return true if termination is completed. Otherwise, return false. - bool complete_or_exit_termination(); -public: - - // "n_threads" is the number of threads to be terminated. "queue_set" is a - // queue sets of work queues of other threads. - ParallelTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set); - virtual ~ParallelTaskTerminator(); - - // The current thread has no work, and is ready to terminate if everyone - // else is. If returns "true", all threads are terminated. If returns - // "false", available work has been observed in one of the task queues, - // so the global task is not complete. - bool offer_termination() { - return offer_termination(NULL); - } - - // As above, but it also terminates if the should_exit_termination() - // method of the terminator parameter returns true. If terminator is - // NULL, then it is ignored. - virtual bool offer_termination(TerminatorTerminator* terminator); - - // Reset the terminator, so that it may be reused again. - // The caller is responsible for ensuring that this is done - // in an MT-safe manner, once the previous round of use of - // the terminator is finished. - void reset_for_reuse(); - // Same as above but the number of parallel threads is set to the - // given number. - void reset_for_reuse(uint n_threads); - -#ifdef TRACESPINNING - static uint total_yields() { return _total_yields; } - static uint total_spins() { return _total_spins; } - static uint total_peeks() { return _total_peeks; } - static void print_termination_counts(); -#endif -}; - -class TaskTerminator : public StackObj { -private: - ParallelTaskTerminator* _terminator; - - NONCOPYABLE(TaskTerminator); - -public: - TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set); - ~TaskTerminator(); - - ParallelTaskTerminator* terminator() const { - return _terminator; - } -}; - typedef GenericTaskQueue OopTaskQueue; typedef GenericTaskQueueSet OopTaskQueueSet;