author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 55603 | 3868dde58ebb |
child 57658 | 0022b39ae5ae |
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" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
27 |
#include "gc/z/zBarrier.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "gc/z/zGlobals.hpp" |
54095
8b4a1177202d
8219634: ZGC: Rename ZAddressRangeMap to ZGranuleMap
pliden
parents:
54094
diff
changeset
|
29 |
#include "gc/z/zGranuleMap.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
30 |
#include "gc/z/zHeapIterator.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
#include "gc/z/zOop.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
#include "gc/z/zRootsIterator.hpp" |
54331
f0fec71d2fff
8221153: ZGC: Heap iteration and verification pollutes GC statistics
pliden
parents:
54095
diff
changeset
|
33 |
#include "gc/z/zStat.hpp" |
50752 | 34 |
#include "memory/iterator.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
35 |
#include "utilities/bitMap.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
36 |
#include "utilities/stack.inline.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
38 |
class ZHeapIteratorBitMap : public CHeapObj<mtGC> { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
39 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
40 |
CHeapBitMap _map; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
42 |
public: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
43 |
ZHeapIteratorBitMap(size_t size_in_bits) : |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
44 |
_map(size_in_bits) {} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
45 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
46 |
bool try_set_bit(size_t index) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
47 |
if (_map.at(index)) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
48 |
return false; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
49 |
} |
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 |
_map.set_bit(index); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
52 |
return true; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
53 |
} |
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 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
56 |
template <bool Concurrent, bool Weak> |
51803 | 57 |
class ZHeapIteratorRootOopClosure : public ZRootsIteratorClosure { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
58 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
59 |
ZHeapIterator* const _iter; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
60 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
61 |
oop load_oop(oop* p) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
62 |
if (Weak) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
63 |
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
|
64 |
} |
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 |
if (Concurrent) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
67 |
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
|
68 |
} |
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 |
return RawAccess<>::oop_load(p); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
71 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
72 |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
73 |
public: |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
74 |
ZHeapIteratorRootOopClosure(ZHeapIterator* iter) : |
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
75 |
_iter(iter) {} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
76 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
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
|
78 |
const oop obj = load_oop(p); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
79 |
_iter->push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
} |
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 |
virtual void do_oop(narrowOop* p) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
83 |
ShouldNotReachHere(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
} |
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 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
87 |
template <bool VisitReferents> |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
88 |
class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
89 |
private: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
90 |
ZHeapIterator* const _iter; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
91 |
const oop _base; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
92 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
93 |
oop load_oop(oop* p) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
94 |
if (VisitReferents) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
95 |
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
|
96 |
} |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
97 |
|
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
98 |
return HeapAccess<AS_NO_KEEPALIVE>::oop_load(p); |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
99 |
} |
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
100 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
101 |
public: |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
102 |
ZHeapIteratorOopClosure(ZHeapIterator* iter, oop base) : |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
103 |
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other), |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
104 |
_iter(iter), |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
105 |
_base(base) {} |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
106 |
|
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
107 |
virtual ReferenceIterationMode reference_iteration_mode() { |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
108 |
return VisitReferents ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT; |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
109 |
} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
|
50752 | 111 |
virtual void do_oop(oop* p) { |
50871
d283a214f42b
8205923: ZGC: Verification applies load barriers before verification
stefank
parents:
50752
diff
changeset
|
112 |
const oop obj = load_oop(p); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
113 |
_iter->push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
114 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
115 |
|
50752 | 116 |
virtual void do_oop(narrowOop* p) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
117 |
ShouldNotReachHere(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
118 |
} |
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 |
#ifdef ASSERT |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
121 |
virtual bool should_verify_oops() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
return false; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
123 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
124 |
#endif |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
125 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
126 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
127 |
ZHeapIterator::ZHeapIterator() : |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
128 |
_visit_stack(), |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
129 |
_visit_map() {} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
130 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
131 |
ZHeapIterator::~ZHeapIterator() { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
132 |
ZVisitMapIterator iter(&_visit_map); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
133 |
for (ZHeapIteratorBitMap* map; iter.next(&map);) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
delete map; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
135 |
} |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
136 |
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
|
137 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
138 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
139 |
static size_t object_index_max() { |
54094 | 140 |
return ZGranuleSize >> ZObjectAlignmentSmallShift; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
141 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
142 |
|
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
const uintptr_t offset = ZAddress::offset(addr); |
54094 | 146 |
const uintptr_t mask = ZGranuleSize - 1; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
147 |
return (offset & mask) >> ZObjectAlignmentSmallShift; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
148 |
} |
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 |
ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
151 |
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
|
152 |
ZHeapIteratorBitMap* map = _visit_map.get(addr); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
153 |
if (map == NULL) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
154 |
map = new ZHeapIteratorBitMap(object_index_max()); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
155 |
_visit_map.put(addr, map); |
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 |
return map; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
159 |
} |
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 |
void ZHeapIterator::push(oop obj) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
162 |
if (obj == NULL) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
163 |
// Ignore |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
164 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
165 |
} |
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 |
ZHeapIteratorBitMap* const map = object_map(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
168 |
const size_t index = object_index(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
169 |
if (!map->try_set_bit(index)) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
170 |
// Already pushed |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
171 |
return; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
172 |
} |
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 |
// Push |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
175 |
_visit_stack.push(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
176 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
178 |
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
|
179 |
void ZHeapIterator::push_roots() { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
180 |
ZHeapIteratorRootOopClosure<Concurrent, Weak> cl(this); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
181 |
RootsIterator roots; |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
182 |
roots.oops_do(&cl); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
183 |
} |
52617 | 184 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
185 |
template <bool VisitReferents> |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
186 |
void ZHeapIterator::push_fields(oop obj) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
187 |
ZHeapIteratorOopClosure<VisitReferents> cl(this, obj); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
188 |
obj->oop_iterate(&cl); |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
189 |
} |
52617 | 190 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
191 |
class ZHeapIterateConcurrentRootsIterator : public ZConcurrentRootsIterator { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
192 |
public: |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
193 |
ZHeapIterateConcurrentRootsIterator() : |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
194 |
ZConcurrentRootsIterator(ClassLoaderData::_claim_other) {} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
195 |
}; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
196 |
|
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
197 |
template <bool VisitWeaks> |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
198 |
void ZHeapIterator::objects_do(ObjectClosure* cl) { |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
199 |
ZStatTimerDisable disable; |
52617 | 200 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
201 |
// Push roots to visit |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
202 |
push_roots<ZRootsIterator, false /* Concurrent */, false /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
203 |
push_roots<ZHeapIterateConcurrentRootsIterator, true /* Concurrent */, false /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
204 |
if (VisitWeaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
205 |
push_roots<ZWeakRootsIterator, false /* Concurrent */, true /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
206 |
push_roots<ZConcurrentWeakRootsIterator, true /* Concurrent */, true /* Weak */>(); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
207 |
} |
52139
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
208 |
|
5a2af44ecb83
8212181: ZGC: Fix incorrect root iteration in ZHeapIterator
pliden
parents:
51803
diff
changeset
|
209 |
// Drain stack |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
210 |
while (!_visit_stack.is_empty()) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
211 |
const oop obj = _visit_stack.pop(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
212 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
213 |
// Visit object |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
214 |
cl->do_object(obj); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
215 |
|
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
216 |
// Push fields to visit |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
217 |
push_fields<VisitWeaks>(obj); |
50525
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 |
} |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
220 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
221 |
void ZHeapIterator::objects_do(ObjectClosure* cl, bool visit_weaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
222 |
if (visit_weaks) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
223 |
objects_do<true /* VisitWeaks */>(cl); |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
224 |
} else { |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55311
diff
changeset
|
225 |
objects_do<false /* VisitWeaks */>(cl); |
55311
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
226 |
} |
d60b24a09900
8225227: ZGC: Be exact in what load barrier to use in ZHeapIterator
pliden
parents:
54331
diff
changeset
|
227 |
} |