Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/shared/concurrentGCBreakpoints.hpp
40957 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
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_SHARED_CONCURRENTGCBREAKPOINTS_HPP
26
#define SHARE_GC_SHARED_CONCURRENTGCBREAKPOINTS_HPP
27
28
#include "gc/shared/gcCause.hpp"
29
#include "memory/allocation.hpp"
30
#include "utilities/globalDefinitions.hpp"
31
32
class Monitor;
33
34
class ConcurrentGCBreakpoints : public AllStatic {
35
static const char* _run_to;
36
static bool _want_idle;
37
static bool _is_stopped;
38
static bool _is_idle;
39
40
static void reset_request_state();
41
static void run_to_idle_impl(bool acquiring_control);
42
43
public:
44
// Monitor used by this facility.
45
static Monitor* monitor();
46
47
// Returns true if this facility is controlling concurrent collections,
48
// e.g. there has been an acquire_control() without a matching
49
// release_control().
50
//
51
// precondition: Must be at a safepoint or have the monitor locked.
52
// note: Does not lock the monitor.
53
static bool is_controlled();
54
55
///////////
56
// Functions for use by the application / mutator threads.
57
// All of these functions lock the monitor.
58
// All of these functions may safepoint.
59
60
// Take control of the concurrent collector. If a collection is in
61
// progress, wait until it completes. On return the concurrent collector
62
// will be idle and will remain so until a subsequent run_to() or
63
// release_control().
64
//
65
// precondition: Calling thread must be a Java thread.
66
// precondition: !is_controlled().
67
// postcondition: is_controlled().
68
static void acquire_control();
69
70
// Release control of the concurrent collector, cancelling any preceeding
71
// run_to() or run_to_idle() request.
72
//
73
// precondition: Calling thread must be a Java thread.
74
// precondition: Must not be a concurrent request operation.
75
// postcondiiton: !is_controlled().
76
static void release_control();
77
78
// Requests the concurrent collector to be idle. Cancels any preceeding
79
// run_to() request. No new concurrent collections will be started while
80
// the request is active. If a collection is already in progress, it is
81
// allowed to complete before this function returns.
82
//
83
// precondition: Calling thread must be a Java thread.
84
// precondition: Must not be a concurrent request or release operation.
85
// precondition: is_controlled().
86
// postcondition: is_controlled().
87
static void run_to_idle();
88
89
// Requests the concurrent collector to run until the named breakpoint is
90
// reached. Cancels any preceeding run_to_idle(). If the collector is
91
// presently idle, starts a collection with cause GCCause::_wb_breakpoint.
92
// If the collector is presently stopped at a breakpoint, the previous
93
// request is replaced by the new request and the collector is allowed to
94
// resume. Waits for a subsequent matching call to at(), or a call to
95
// notify_active_to_idle().
96
//
97
// Returns true if a subsequent matching call to at() was reached.
98
// Returns false if a collection cycle completed and idled
99
// (notify_active_to_idle()) without reaching a matching at().
100
//
101
// precondition: Calling thread must be a Java thread.
102
// precondition: Must not be a concurrent request or release operation.
103
// precondition: is_controlled().
104
// postcondition: is_controlled().
105
static bool run_to(const char* breakpoint);
106
107
///////////
108
// Notification functions, for use by the garbage collector.
109
// Unless stated otherwise, all of these functions lock the monitor.
110
// None of these functions safepoint.
111
112
// Indicates the concurrent collector has reached the designated point
113
// in its execution. If a matching run_to() is active then notifies the
114
// request and blocks until the request is cancelled.
115
//
116
// precondition: Calling thread must be a ConcurrentGC thread.
117
// precondition: Must not be a concurrent notification.
118
static void at(const char* breakpoint);
119
120
// Indicates the concurrent collector has completed a cycle. If there is
121
// an active run_to_idle() request, it is notified of completion. If
122
// there is an active run_to() request, it is replaced by a run_to_idle()
123
// request, and notified of completion.
124
//
125
// precondition: Must not be a concurrent notification.
126
static void notify_active_to_idle();
127
128
// Indicates a concurrent collection has been initiated. Does not lock
129
// the monitor.
130
//
131
// precondition: Must not be a concurrent notification.
132
// precondition: Must be at a safepoint or have the monitor locked.
133
static void notify_idle_to_active();
134
};
135
136
#endif // SHARE_GC_SHARED_CONCURRENTGCBREAKPOINTS_HPP
137
138