--- old/src/hotspot/share/gc/shared/taskTerminator.hpp 2020-07-24 12:37:52.542761210 +0200 +++ new/src/hotspot/share/gc/shared/taskTerminator.hpp 2020-07-24 12:37:52.426759385 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved. * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,11 +26,12 @@ #define SHARE_GC_SHARED_TASKTERMINATOR_HPP #include "memory/allocation.hpp" +#include "memory/padded.hpp" #include "runtime/mutex.hpp" -#include "runtime/thread.hpp" class TaskQueueSetSuper; class TerminatorTerminator; +class Thread; /* * Provides a task termination protocol. @@ -50,6 +51,16 @@ * for stealing and termination condition. */ class TaskTerminator : public CHeapObj { + struct DelayContext { + uint _yield_count; + // Number of hard spin loops done since last yield + uint _hard_spin_count; + // Number of iterations in the hard spin loop. + uint _hard_spin_limit; + + DelayContext(); + }; + uint _n_threads; TaskQueueSetSuper* _queue_set; @@ -59,19 +70,21 @@ void assert_queue_set_empty() const NOT_DEBUG_RETURN; - void yield(); + Monitor _blocker; + Thread* _spin_master; - Monitor* _blocker; - Thread* _spin_master; + // Prepare for return from offer_termination. Gives up the spin master token + // and wakes up up to tasks threads waiting on _blocker (the default value + // means to wake up everyone). + void prepare_for_return(Thread* this_thread, size_t tasks = SIZE_MAX); // If we should exit current termination protocol bool exit_termination(size_t tasks, TerminatorTerminator* terminator); size_t tasks_in_queue_set() const; - // Perform spin-master task. - // Return true if termination condition is detected, otherwise return false - bool do_spin_master_work(TerminatorTerminator* terminator); + // Perform one iteration of spin-master work. + bool do_delay_step(DelayContext& delay_context); NONCOPYABLE(TaskTerminator);