author | pliden |
Tue, 29 Jan 2019 10:23:38 +0100 | |
changeset 53541 | 4e325f8b50ce |
parent 53540 | 9f75dc382445 |
child 54163 | 790679f86a51 |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
53540
9f75dc382445
8217857: ZGC: Move SvcGCMarker to ZServiceabilityTracer
pliden
parents:
52877
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
4 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
8 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
13 |
* accompanied this code). |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
14 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
18 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
21 |
* questions. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
22 |
*/ |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
23 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
25 |
#include "gc/shared/gcId.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
26 |
#include "gc/shared/gcLocker.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
27 |
#include "gc/shared/isGCActiveMark.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "gc/z/zCollectedHeap.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "gc/z/zDriver.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
30 |
#include "gc/z/zHeap.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
#include "gc/z/zMessagePort.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
#include "gc/z/zServiceability.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
#include "gc/z/zStat.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
34 |
#include "logging/log.hpp" |
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
35 |
#include "memory/universe.hpp" |
52877
9e041366c764
8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents:
52876
diff
changeset
|
36 |
#include "runtime/vmOperations.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
#include "runtime/vmThread.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
38 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
39 |
static const ZStatPhaseCycle ZPhaseCycle("Garbage Collection Cycle"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
40 |
static const ZStatPhasePause ZPhasePauseMarkStart("Pause Mark Start"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
static const ZStatPhaseConcurrent ZPhaseConcurrentMark("Concurrent Mark"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
42 |
static const ZStatPhaseConcurrent ZPhaseConcurrentMarkContinue("Concurrent Mark Continue"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
43 |
static const ZStatPhasePause ZPhasePauseMarkEnd("Pause Mark End"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
44 |
static const ZStatPhaseConcurrent ZPhaseConcurrentProcessNonStrongReferences("Concurrent Process Non-Strong References"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
45 |
static const ZStatPhaseConcurrent ZPhaseConcurrentResetRelocationSet("Concurrent Reset Relocation Set"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
46 |
static const ZStatPhaseConcurrent ZPhaseConcurrentDestroyDetachedPages("Concurrent Destroy Detached Pages"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
47 |
static const ZStatPhaseConcurrent ZPhaseConcurrentSelectRelocationSet("Concurrent Select Relocation Set"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
48 |
static const ZStatPhaseConcurrent ZPhaseConcurrentPrepareRelocationSet("Concurrent Prepare Relocation Set"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
49 |
static const ZStatPhasePause ZPhasePauseRelocateStart("Pause Relocate Start"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
50 |
static const ZStatPhaseConcurrent ZPhaseConcurrentRelocated("Concurrent Relocate"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
51 |
static const ZStatCriticalPhase ZCriticalPhaseGCLockerStall("GC Locker Stall", false /* verbose */); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
52 |
static const ZStatSampler ZSamplerJavaThreads("System", "Java Threads", ZStatUnitThreads); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
53 |
|
53541 | 54 |
class VM_ZOperation : public VM_Operation { |
55 |
private: |
|
56 |
const uint _gc_id; |
|
57 |
bool _gc_locked; |
|
58 |
bool _success; |
|
59 |
||
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
60 |
public: |
53541 | 61 |
VM_ZOperation() : |
62 |
_gc_id(GCId::current()), |
|
63 |
_gc_locked(false), |
|
64 |
_success(false) {} |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
65 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
66 |
virtual bool needs_inactive_gc_locker() const { |
53541 | 67 |
// An inactive GC locker is needed in operations where we change the bad |
68 |
// mask or move objects. Changing the bad mask will invalidate all oops, |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
69 |
// which makes it conceptually the same thing as moving all objects. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
70 |
return false; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
71 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
72 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
73 |
virtual bool do_operation() = 0; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
74 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
75 |
virtual bool doit_prologue() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
76 |
Heap_lock->lock(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
78 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
79 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
virtual void doit() { |
53541 | 81 |
// Abort if GC locker state is incompatible |
82 |
if (needs_inactive_gc_locker() && GCLocker::check_active_before_gc()) { |
|
83 |
_gc_locked = true; |
|
84 |
return; |
|
85 |
} |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
86 |
|
53541 | 87 |
// Setup GC id and active marker |
88 |
GCIdMark gc_id_mark(_gc_id); |
|
89 |
IsGCActiveMark gc_active_mark; |
|
90 |
||
91 |
// Execute operation |
|
92 |
_success = do_operation(); |
|
93 |
||
94 |
// Update statistics |
|
95 |
ZStatSample(ZSamplerJavaThreads, Threads::number_of_threads()); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
96 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
97 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
98 |
virtual void doit_epilogue() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
99 |
Heap_lock->unlock(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
100 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
101 |
|
53541 | 102 |
bool gc_locked() const { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
103 |
return _gc_locked; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
104 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
105 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
106 |
bool success() const { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
107 |
return _success; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
108 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
109 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
|
50582
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
111 |
static bool should_clear_soft_references() { |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
112 |
// Clear if one or more allocations have stalled |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
113 |
const bool stalled = ZHeap::heap()->is_alloc_stalled(); |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
114 |
if (stalled) { |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
115 |
// Clear |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
116 |
return true; |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
117 |
} |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
118 |
|
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
119 |
// Clear if implied by the GC cause |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
120 |
const GCCause::Cause cause = ZCollectedHeap::heap()->gc_cause(); |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
121 |
if (cause == GCCause::_wb_full_gc || |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
122 |
cause == GCCause::_metadata_GC_clear_soft_refs) { |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
123 |
// Clear |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
124 |
return true; |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
125 |
} |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
126 |
|
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
127 |
// Don't clear |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
128 |
return false; |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
129 |
} |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
130 |
|
50583
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
131 |
static bool should_boost_worker_threads() { |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
132 |
// Boost worker threads if one or more allocations have stalled |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
133 |
const bool stalled = ZHeap::heap()->is_alloc_stalled(); |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
134 |
if (stalled) { |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
135 |
// Boost |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
136 |
return true; |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
137 |
} |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
138 |
|
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
139 |
// Boost worker threads if implied by the GC cause |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
140 |
const GCCause::Cause cause = ZCollectedHeap::heap()->gc_cause(); |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
141 |
if (cause == GCCause::_wb_full_gc || |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
142 |
cause == GCCause::_java_lang_system_gc || |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
143 |
cause == GCCause::_metadata_GC_clear_soft_refs) { |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
144 |
// Boost |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
145 |
return true; |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
146 |
} |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
147 |
|
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
148 |
// Don't boost |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
149 |
return false; |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
150 |
} |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
151 |
|
53541 | 152 |
class VM_ZMarkStart : public VM_ZOperation { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
153 |
public: |
53541 | 154 |
virtual VMOp_Type type() const { |
155 |
return VMOp_ZMarkStart; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
156 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
157 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
158 |
virtual bool needs_inactive_gc_locker() const { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
159 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
160 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
161 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
162 |
virtual bool do_operation() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
163 |
ZStatTimer timer(ZPhasePauseMarkStart); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
164 |
ZServiceabilityMarkStartTracer tracer; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
165 |
|
50875
2217b2fc29ea
8205993: ZGC: Fix typos and incorrect indentations
pliden
parents:
50583
diff
changeset
|
166 |
// Set up soft reference policy |
50582
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
167 |
const bool clear = should_clear_soft_references(); |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
168 |
ZHeap::heap()->set_soft_reference_policy(clear); |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
169 |
|
50875
2217b2fc29ea
8205993: ZGC: Fix typos and incorrect indentations
pliden
parents:
50583
diff
changeset
|
170 |
// Set up boost mode |
50583
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
171 |
const bool boost = should_boost_worker_threads(); |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
172 |
ZHeap::heap()->set_boost_worker_threads(boost); |
f0ff230e2546
8205024: ZGC: Worker threads boost mode not always enabled when is should be
pliden
parents:
50582
diff
changeset
|
173 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
174 |
ZCollectedHeap::heap()->increment_total_collections(true /* full */); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
175 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
176 |
ZHeap::heap()->mark_start(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
178 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
179 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
180 |
|
53541 | 181 |
class VM_ZMarkEnd : public VM_ZOperation { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
182 |
public: |
53541 | 183 |
virtual VMOp_Type type() const { |
184 |
return VMOp_ZMarkEnd; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
185 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
186 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
187 |
virtual bool do_operation() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
188 |
ZStatTimer timer(ZPhasePauseMarkEnd); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
189 |
ZServiceabilityMarkEndTracer tracer; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
190 |
return ZHeap::heap()->mark_end(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
191 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
192 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
193 |
|
53541 | 194 |
class VM_ZRelocateStart : public VM_ZOperation { |
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
195 |
public: |
53541 | 196 |
virtual VMOp_Type type() const { |
197 |
return VMOp_ZRelocateStart; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
198 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
199 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
200 |
virtual bool needs_inactive_gc_locker() const { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
201 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
202 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
203 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
204 |
virtual bool do_operation() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
205 |
ZStatTimer timer(ZPhasePauseRelocateStart); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
206 |
ZServiceabilityRelocateStartTracer tracer; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
207 |
ZHeap::heap()->relocate_start(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
208 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
209 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
210 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
211 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
212 |
ZDriver::ZDriver() : |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
213 |
_gc_cycle_port(), |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
214 |
_gc_locker_port() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
215 |
set_name("ZDriver"); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
216 |
create_and_start(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
217 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
218 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
219 |
void ZDriver::collect(GCCause::Cause cause) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
220 |
switch (cause) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
221 |
case GCCause::_wb_young_gc: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
222 |
case GCCause::_wb_conc_mark: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
223 |
case GCCause::_wb_full_gc: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
224 |
case GCCause::_dcmd_gc_run: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
225 |
case GCCause::_java_lang_system_gc: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
226 |
case GCCause::_full_gc_alot: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
227 |
case GCCause::_scavenge_alot: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
228 |
case GCCause::_jvmti_force_gc: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
229 |
case GCCause::_metadata_GC_clear_soft_refs: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
230 |
// Start synchronous GC |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
231 |
_gc_cycle_port.send_sync(cause); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
232 |
break; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
233 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
234 |
case GCCause::_z_timer: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
235 |
case GCCause::_z_warmup: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
236 |
case GCCause::_z_allocation_rate: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
237 |
case GCCause::_z_allocation_stall: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
238 |
case GCCause::_z_proactive: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
239 |
case GCCause::_metadata_GC_threshold: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
240 |
// Start asynchronous GC |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
241 |
_gc_cycle_port.send_async(cause); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
242 |
break; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
243 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
244 |
case GCCause::_gc_locker: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
245 |
// Restart VM operation previously blocked by the GC locker |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
246 |
_gc_locker_port.signal(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
247 |
break; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
248 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
249 |
default: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
250 |
// Other causes not supported |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
251 |
fatal("Unsupported GC cause (%s)", GCCause::to_string(cause)); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
252 |
break; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
253 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
254 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
255 |
|
53541 | 256 |
template <typename T> |
257 |
bool ZDriver::pause() { |
|
258 |
for (;;) { |
|
259 |
T op; |
|
260 |
VMThread::execute(&op); |
|
261 |
if (op.gc_locked()) { |
|
262 |
// Wait for GC to become unlocked and restart the VM operation |
|
263 |
ZStatTimer timer(ZCriticalPhaseGCLockerStall); |
|
264 |
_gc_locker_port.wait(); |
|
265 |
continue; |
|
266 |
} |
|
267 |
||
268 |
// Notify VM operation completed |
|
269 |
_gc_locker_port.ack(); |
|
270 |
||
271 |
return op.success(); |
|
272 |
} |
|
273 |
} |
|
274 |
||
275 |
void ZDriver::pause_mark_start() { |
|
276 |
pause<VM_ZMarkStart>(); |
|
277 |
} |
|
278 |
||
279 |
void ZDriver::concurrent_mark() { |
|
280 |
ZStatTimer timer(ZPhaseConcurrentMark); |
|
281 |
ZHeap::heap()->mark(true /* initial */); |
|
282 |
} |
|
283 |
||
284 |
bool ZDriver::pause_mark_end() { |
|
285 |
return pause<VM_ZMarkEnd>(); |
|
286 |
} |
|
287 |
||
288 |
void ZDriver::concurrent_mark_continue() { |
|
289 |
ZStatTimer timer(ZPhaseConcurrentMarkContinue); |
|
290 |
ZHeap::heap()->mark(false /* initial */); |
|
291 |
} |
|
292 |
||
293 |
void ZDriver::concurrent_process_non_strong_references() { |
|
294 |
ZStatTimer timer(ZPhaseConcurrentProcessNonStrongReferences); |
|
295 |
ZHeap::heap()->process_non_strong_references(); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
296 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
297 |
|
53541 | 298 |
void ZDriver::concurrent_reset_relocation_set() { |
299 |
ZStatTimer timer(ZPhaseConcurrentResetRelocationSet); |
|
300 |
ZHeap::heap()->reset_relocation_set(); |
|
301 |
} |
|
302 |
||
303 |
void ZDriver::concurrent_destroy_detached_pages() { |
|
304 |
ZStatTimer timer(ZPhaseConcurrentDestroyDetachedPages); |
|
305 |
ZHeap::heap()->destroy_detached_pages(); |
|
306 |
} |
|
307 |
||
308 |
void ZDriver::pause_verify() { |
|
309 |
if (VerifyBeforeGC || VerifyDuringGC || VerifyAfterGC) { |
|
310 |
VM_Verify op; |
|
311 |
VMThread::execute(&op); |
|
312 |
} |
|
313 |
} |
|
314 |
||
315 |
void ZDriver::concurrent_select_relocation_set() { |
|
316 |
ZStatTimer timer(ZPhaseConcurrentSelectRelocationSet); |
|
317 |
ZHeap::heap()->select_relocation_set(); |
|
318 |
} |
|
319 |
||
320 |
void ZDriver::concurrent_prepare_relocation_set() { |
|
321 |
ZStatTimer timer(ZPhaseConcurrentPrepareRelocationSet); |
|
322 |
ZHeap::heap()->prepare_relocation_set(); |
|
323 |
} |
|
324 |
||
325 |
void ZDriver::pause_relocate_start() { |
|
326 |
pause<VM_ZRelocateStart>(); |
|
327 |
} |
|
328 |
||
329 |
void ZDriver::concurrent_relocate() { |
|
330 |
ZStatTimer timer(ZPhaseConcurrentRelocated); |
|
331 |
ZHeap::heap()->relocate(); |
|
332 |
} |
|
333 |
||
334 |
void ZDriver::check_out_of_memory() { |
|
335 |
ZHeap::heap()->check_out_of_memory(); |
|
336 |
} |
|
337 |
||
338 |
class ZDriverGCScope : public StackObj { |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
339 |
private: |
50582
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
340 |
GCIdMark _gc_id; |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
341 |
GCCauseSetter _gc_cause_setter; |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
342 |
ZStatTimer _timer; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
343 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
344 |
public: |
53541 | 345 |
ZDriverGCScope(GCCause::Cause cause) : |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
346 |
_gc_id(), |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
347 |
_gc_cause_setter(ZCollectedHeap::heap(), cause), |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
348 |
_timer(ZPhaseCycle) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
349 |
// Update statistics |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
350 |
ZStatCycle::at_start(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
351 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
352 |
|
53541 | 353 |
~ZDriverGCScope() { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
354 |
// Calculate boost factor |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
355 |
const double boost_factor = (double)ZHeap::heap()->nconcurrent_worker_threads() / |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
356 |
(double)ZHeap::heap()->nconcurrent_no_boost_worker_threads(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
357 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
358 |
// Update statistics |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
359 |
ZStatCycle::at_end(boost_factor); |
50582
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
360 |
|
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
361 |
// Update data used by soft reference policy |
6464882498b5
8205022: ZGC: SoftReferences not always cleared before throwing OOME
pliden
parents:
50525
diff
changeset
|
362 |
Universe::update_heap_info_at_gc(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
363 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
364 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
365 |
|
53541 | 366 |
void ZDriver::gc(GCCause::Cause cause) { |
367 |
ZDriverGCScope scope(cause); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
368 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
369 |
// Phase 1: Pause Mark Start |
53541 | 370 |
pause_mark_start(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
371 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
372 |
// Phase 2: Concurrent Mark |
53541 | 373 |
concurrent_mark(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
374 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
375 |
// Phase 3: Pause Mark End |
53541 | 376 |
while (!pause_mark_end()) { |
377 |
// Phase 3.5: Concurrent Mark Continue |
|
378 |
concurrent_mark_continue(); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
379 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
380 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
381 |
// Phase 4: Concurrent Process Non-Strong References |
53541 | 382 |
concurrent_process_non_strong_references(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
383 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
384 |
// Phase 5: Concurrent Reset Relocation Set |
53541 | 385 |
concurrent_reset_relocation_set(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
386 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
387 |
// Phase 6: Concurrent Destroy Detached Pages |
53541 | 388 |
concurrent_destroy_detached_pages(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
389 |
|
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
390 |
// Phase 7: Pause Verify |
53541 | 391 |
pause_verify(); |
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
392 |
|
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
393 |
// Phase 8: Concurrent Select Relocation Set |
53541 | 394 |
concurrent_select_relocation_set(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
395 |
|
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
396 |
// Phase 9: Concurrent Prepare Relocation Set |
53541 | 397 |
concurrent_prepare_relocation_set(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
398 |
|
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
399 |
// Phase 10: Pause Relocate Start |
53541 | 400 |
pause_relocate_start(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
401 |
|
52382
2e280ecec246
8212921: ZGC: Move verification to after resurrection unblocked
pliden
parents:
52140
diff
changeset
|
402 |
// Phase 11: Concurrent Relocate |
53541 | 403 |
concurrent_relocate(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
404 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
405 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
406 |
void ZDriver::run_service() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
407 |
// Main loop |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
408 |
while (!should_terminate()) { |
53541 | 409 |
// Wait for GC request |
410 |
const GCCause::Cause cause = _gc_cycle_port.receive(); |
|
411 |
if (cause == GCCause::_no_gc) { |
|
412 |
continue; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
413 |
} |
53541 | 414 |
|
415 |
// Run GC |
|
416 |
gc(cause); |
|
417 |
||
418 |
// Notify GC completed |
|
419 |
_gc_cycle_port.ack(); |
|
420 |
||
421 |
// Check for out of memory condition |
|
422 |
check_out_of_memory(); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
423 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
424 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
425 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
426 |
void ZDriver::stop_service() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
427 |
_gc_cycle_port.send_async(GCCause::_no_gc); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
428 |
} |