Path: blob/master/src/hotspot/share/gc/shared/concurrentGCBreakpoints.hpp
40957 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_SHARED_CONCURRENTGCBREAKPOINTS_HPP25#define SHARE_GC_SHARED_CONCURRENTGCBREAKPOINTS_HPP2627#include "gc/shared/gcCause.hpp"28#include "memory/allocation.hpp"29#include "utilities/globalDefinitions.hpp"3031class Monitor;3233class ConcurrentGCBreakpoints : public AllStatic {34static const char* _run_to;35static bool _want_idle;36static bool _is_stopped;37static bool _is_idle;3839static void reset_request_state();40static void run_to_idle_impl(bool acquiring_control);4142public:43// Monitor used by this facility.44static Monitor* monitor();4546// Returns true if this facility is controlling concurrent collections,47// e.g. there has been an acquire_control() without a matching48// release_control().49//50// precondition: Must be at a safepoint or have the monitor locked.51// note: Does not lock the monitor.52static bool is_controlled();5354///////////55// Functions for use by the application / mutator threads.56// All of these functions lock the monitor.57// All of these functions may safepoint.5859// Take control of the concurrent collector. If a collection is in60// progress, wait until it completes. On return the concurrent collector61// will be idle and will remain so until a subsequent run_to() or62// release_control().63//64// precondition: Calling thread must be a Java thread.65// precondition: !is_controlled().66// postcondition: is_controlled().67static void acquire_control();6869// Release control of the concurrent collector, cancelling any preceeding70// run_to() or run_to_idle() request.71//72// precondition: Calling thread must be a Java thread.73// precondition: Must not be a concurrent request operation.74// postcondiiton: !is_controlled().75static void release_control();7677// Requests the concurrent collector to be idle. Cancels any preceeding78// run_to() request. No new concurrent collections will be started while79// the request is active. If a collection is already in progress, it is80// allowed to complete before this function returns.81//82// precondition: Calling thread must be a Java thread.83// precondition: Must not be a concurrent request or release operation.84// precondition: is_controlled().85// postcondition: is_controlled().86static void run_to_idle();8788// Requests the concurrent collector to run until the named breakpoint is89// reached. Cancels any preceeding run_to_idle(). If the collector is90// presently idle, starts a collection with cause GCCause::_wb_breakpoint.91// If the collector is presently stopped at a breakpoint, the previous92// request is replaced by the new request and the collector is allowed to93// resume. Waits for a subsequent matching call to at(), or a call to94// notify_active_to_idle().95//96// Returns true if a subsequent matching call to at() was reached.97// Returns false if a collection cycle completed and idled98// (notify_active_to_idle()) without reaching a matching at().99//100// precondition: Calling thread must be a Java thread.101// precondition: Must not be a concurrent request or release operation.102// precondition: is_controlled().103// postcondition: is_controlled().104static bool run_to(const char* breakpoint);105106///////////107// Notification functions, for use by the garbage collector.108// Unless stated otherwise, all of these functions lock the monitor.109// None of these functions safepoint.110111// Indicates the concurrent collector has reached the designated point112// in its execution. If a matching run_to() is active then notifies the113// request and blocks until the request is cancelled.114//115// precondition: Calling thread must be a ConcurrentGC thread.116// precondition: Must not be a concurrent notification.117static void at(const char* breakpoint);118119// Indicates the concurrent collector has completed a cycle. If there is120// an active run_to_idle() request, it is notified of completion. If121// there is an active run_to() request, it is replaced by a run_to_idle()122// request, and notified of completion.123//124// precondition: Must not be a concurrent notification.125static void notify_active_to_idle();126127// Indicates a concurrent collection has been initiated. Does not lock128// the monitor.129//130// precondition: Must not be a concurrent notification.131// precondition: Must be at a safepoint or have the monitor locked.132static void notify_idle_to_active();133};134135#endif // SHARE_GC_SHARED_CONCURRENTGCBREAKPOINTS_HPP136137138