author | eosterlund |
Tue, 12 Nov 2019 20:01:23 +0000 | |
changeset 59038 | b9a42ca342db |
parent 58810 | 3aba4a42d8ad |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
54094 | 2 |
* Copyright (c) 2017, 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" |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
25 |
#include "classfile/classLoaderData.hpp" |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
26 |
#include "classfile/classLoaderDataGraph.hpp" |
58810 | 27 |
#include "gc/z/zAddress.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "gc/z/zBarrier.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "gc/z/zGlobals.hpp" |
54095
8b4a1177202d
8219634: ZGC: Rename ZAddressRangeMap to ZGranuleMap
pliden
parents:
54094
diff
changeset
|
30 |
#include "gc/z/zGranuleMap.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
#include "gc/z/zHeapIterator.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
#include "gc/z/zOop.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
#include "gc/z/zRootsIterator.hpp" |
54331
f0fec71d2fff
8221153: ZGC: Heap iteration and verification pollutes GC statistics
pliden
parents:
54095
diff
changeset
|
34 |
#include "gc/z/zStat.hpp" |
50752 | 35 |
#include "memory/iterator.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
36 |
#include "utilities/bitMap.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
#include "utilities/stack.inline.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 |
class ZHeapIteratorBitMap : public CHeapObj<mtGC> { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
40 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
CHeapBitMap _map; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
42 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
43 |
public: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
44 |
ZHeapIteratorBitMap(size_t size_in_bits) : |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
45 |
_map(size_in_bits) {} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
46 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
47 |
bool try_set_bit(size_t index) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
48 |
if (_map.at(index)) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
49 |
return false; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
50 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
51 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
52 |
_map.set_bit(index); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
53 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
54 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
55 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
56 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
57 |
template <bool Concurrent, bool Weak> |
51803 | 58 |
class ZHeapIteratorRootOopClosure : public ZRootsIteratorClosure { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
59 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
60 |
ZHeapIterator* const _iter; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
61 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
62 |
oop load_oop(oop* p) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
63 |
if (Weak) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
64 |
return NativeAccess<AS_NO_KEEPALIVE | ON_PHANTOM_OOP_REF>::oop_load(p); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
65 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
66 |
|
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
67 |
if (Concurrent) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
68 |
return NativeAccess<AS_NO_KEEPALIVE>::oop_load(p); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
69 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
70 |
|
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
71 |
return RawAccess<>::oop_load(p); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
72 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
73 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
74 |
public: |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
75 |
ZHeapIteratorRootOopClosure(ZHeapIterator* iter) : |
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
76 |
_iter(iter) {} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
78 |
virtual void do_oop(oop* p) { |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
79 |
const oop obj = load_oop(p); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
_iter->push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
81 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
82 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
83 |
virtual void do_oop(narrowOop* p) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
ShouldNotReachHere(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
85 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
86 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
87 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
88 |
template <bool VisitReferents> |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
89 |
class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
90 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
91 |
ZHeapIterator* const _iter; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
92 |
const oop _base; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
93 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
94 |
oop load_oop(oop* p) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
95 |
if (VisitReferents) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
96 |
return HeapAccess<AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF>::oop_load_at(_base, _base->field_offset(p)); |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
97 |
} |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
98 |
|
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
99 |
return HeapAccess<AS_NO_KEEPALIVE>::oop_load(p); |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
100 |
} |
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
101 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
102 |
public: |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
103 |
ZHeapIteratorOopClosure(ZHeapIterator* iter, oop base) : |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
104 |
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other), |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
105 |
_iter(iter), |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
106 |
_base(base) {} |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
107 |
|
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
108 |
virtual ReferenceIterationMode reference_iteration_mode() { |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
109 |
return VisitReferents ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT; |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
110 |
} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
111 |
|
50752 | 112 |
virtual void do_oop(oop* p) { |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
113 |
const oop obj = load_oop(p); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
114 |
_iter->push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
115 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
116 |
|
50752 | 117 |
virtual void do_oop(narrowOop* p) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
118 |
ShouldNotReachHere(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
119 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
120 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
121 |
#ifdef ASSERT |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
virtual bool should_verify_oops() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
123 |
return false; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
124 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
125 |
#endif |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
126 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
127 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
128 |
ZHeapIterator::ZHeapIterator() : |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
129 |
_visit_stack(), |
58809
44dc3d796110
8232601: ZGC: Parameterize the ZGranuleMap table size
stefank
parents:
58066
diff
changeset
|
130 |
_visit_map(ZAddressOffsetMax) {} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
131 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
132 |
ZHeapIterator::~ZHeapIterator() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
133 |
ZVisitMapIterator iter(&_visit_map); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
for (ZHeapIteratorBitMap* map; iter.next(&map);) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
135 |
delete map; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
136 |
} |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
137 |
ClassLoaderDataGraph::clear_claimed_marks(ClassLoaderData::_claim_other); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
138 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
139 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
140 |
static size_t object_index_max() { |
54094 | 141 |
return ZGranuleSize >> ZObjectAlignmentSmallShift; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
142 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
143 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
144 |
static size_t object_index(oop obj) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
145 |
const uintptr_t addr = ZOop::to_address(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
146 |
const uintptr_t offset = ZAddress::offset(addr); |
54094 | 147 |
const uintptr_t mask = ZGranuleSize - 1; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
148 |
return (offset & mask) >> ZObjectAlignmentSmallShift; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
149 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
150 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
151 |
ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) { |
58810 | 152 |
const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj)); |
153 |
ZHeapIteratorBitMap* map = _visit_map.get(offset); |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
154 |
if (map == NULL) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
155 |
map = new ZHeapIteratorBitMap(object_index_max()); |
58810 | 156 |
_visit_map.put(offset, map); |
50525
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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
159 |
return map; |
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 |
void ZHeapIterator::push(oop obj) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
163 |
if (obj == NULL) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
164 |
// Ignore |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
165 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
166 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
167 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
168 |
ZHeapIteratorBitMap* const map = object_map(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
169 |
const size_t index = object_index(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
170 |
if (!map->try_set_bit(index)) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
171 |
// Already pushed |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
172 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
173 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
174 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
175 |
// Push |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
176 |
_visit_stack.push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
178 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
179 |
template <typename RootsIterator, bool Concurrent, bool Weak> |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
180 |
void ZHeapIterator::push_roots() { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
181 |
ZHeapIteratorRootOopClosure<Concurrent, Weak> cl(this); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
182 |
RootsIterator roots; |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
183 |
roots.oops_do(&cl); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
184 |
} |
52617 | 185 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
186 |
template <bool VisitReferents> |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
187 |
void ZHeapIterator::push_fields(oop obj) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
188 |
ZHeapIteratorOopClosure<VisitReferents> cl(this, obj); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
189 |
obj->oop_iterate(&cl); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
190 |
} |
52617 | 191 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
192 |
template <bool VisitWeaks> |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
193 |
void ZHeapIterator::objects_do(ObjectClosure* cl) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
194 |
ZStatTimerDisable disable; |
52617 | 195 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
196 |
// Push roots to visit |
58066
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
197 |
push_roots<ZRootsIterator, false /* Concurrent */, false /* Weak */>(); |
57658 | 198 |
push_roots<ZConcurrentRootsIteratorClaimOther, true /* Concurrent */, false /* Weak */>(); |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
199 |
if (VisitWeaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
200 |
push_roots<ZWeakRootsIterator, false /* Concurrent */, true /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
201 |
push_roots<ZConcurrentWeakRootsIterator, true /* Concurrent */, true /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
202 |
} |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
203 |
|
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
204 |
// Drain stack |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
205 |
while (!_visit_stack.is_empty()) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
206 |
const oop obj = _visit_stack.pop(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
207 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
208 |
// Visit object |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
209 |
cl->do_object(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
210 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
211 |
// Push fields to visit |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
212 |
push_fields<VisitWeaks>(obj); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
213 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
214 |
} |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
215 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
216 |
void ZHeapIterator::objects_do(ObjectClosure* cl, bool visit_weaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
217 |
if (visit_weaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
218 |
objects_do<true /* VisitWeaks */>(cl); |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
219 |
} else { |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
220 |
objects_do<false /* VisitWeaks */>(cl); |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
221 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
222 |
} |