author | kbarrett |
Tue, 12 Jun 2018 18:12:59 -0400 | |
changeset 50532 | a18c60527166 |
parent 49668 | 8263950638ed |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
49659
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
1 |
/* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
4 |
* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
8 |
* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
13 |
* accompanied this code). |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
14 |
* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
18 |
* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
21 |
* questions. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
22 |
* |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
23 |
*/ |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
24 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1CONCURRENTMARKTHREAD_HPP |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1CONCURRENTMARKTHREAD_HPP |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
27 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
28 |
#include "gc/shared/concurrentGCPhaseManager.hpp" |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
29 |
#include "gc/shared/concurrentGCThread.hpp" |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
30 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
31 |
class G1ConcurrentMark; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
32 |
class G1Policy; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
33 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
34 |
// The concurrent mark thread triggers the various steps of the concurrent marking |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
35 |
// cycle, including various marking cleanup. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
36 |
class G1ConcurrentMarkThread: public ConcurrentGCThread { |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
37 |
friend class VMStructs; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
38 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
39 |
double _vtime_start; // Initial virtual time. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
40 |
double _vtime_accum; // Accumulated virtual time. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
41 |
double _vtime_mark_accum; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
42 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
43 |
G1ConcurrentMark* _cm; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
44 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
45 |
enum State { |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
46 |
Idle, |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
47 |
Started, |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
48 |
InProgress |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
49 |
}; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
50 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
51 |
volatile State _state; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
52 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
53 |
// WhiteBox testing support. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
54 |
ConcurrentGCPhaseManager::Stack _phase_manager_stack; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
55 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
56 |
void sleep_before_next_cycle(); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
57 |
// Delay marking to meet MMU. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
58 |
void delay_to_keep_mmu(G1Policy* g1_policy, bool remark); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
59 |
double mmu_sleep_time(G1Policy* g1_policy, bool remark); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
60 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
61 |
void run_service(); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
62 |
void stop_service(); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
63 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
64 |
public: |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
65 |
// Constructor |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
66 |
G1ConcurrentMarkThread(G1ConcurrentMark* cm); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
67 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
68 |
// Total virtual time so far for this thread and concurrent marking tasks. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
69 |
double vtime_accum(); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
70 |
// Marking virtual time so far this thread and concurrent marking tasks. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
71 |
double vtime_mark_accum(); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
72 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
73 |
G1ConcurrentMark* cm() { return _cm; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
74 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
75 |
void set_idle() { assert(_state != Started, "must not be starting a new cycle"); _state = Idle; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
76 |
bool idle() { return _state == Idle; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
77 |
void set_started() { assert(_state == Idle, "cycle in progress"); _state = Started; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
78 |
bool started() { return _state == Started; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
79 |
void set_in_progress() { assert(_state == Started, "must be starting a cycle"); _state = InProgress; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
80 |
bool in_progress() { return _state == InProgress; } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
81 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
82 |
// Returns true from the moment a marking cycle is |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
83 |
// initiated (during the initial-mark pause when started() is set) |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
84 |
// to the moment when the cycle completes (just after the next |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
85 |
// marking bitmap has been cleared and in_progress() is |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
86 |
// cleared). While during_cycle() is true we will not start another cycle |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
87 |
// so that cycles do not overlap. We cannot use just in_progress() |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
88 |
// as the CM thread might take some time to wake up before noticing |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
89 |
// that started() is set and set in_progress(). |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
90 |
bool during_cycle() { return !idle(); } |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
91 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
92 |
// WhiteBox testing support. |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
93 |
const char* const* concurrent_phases() const; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
94 |
bool request_concurrent_phase(const char* phase); |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
95 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
96 |
ConcurrentGCPhaseManager::Stack* phase_manager_stack() { |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
97 |
return &_phase_manager_stack; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
98 |
} |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
99 |
}; |
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
100 |
|
0ed1370f52bb
8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff
changeset
|
101 |
#endif // SHARE_VM_GC_G1_G1CONCURRENTMARKTHREAD_HPP |