Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1OopClosures.hpp @ 14518:d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
author | twisti |
---|---|
date | Tue, 11 Mar 2014 18:45:59 -0700 |
parents | 97300b6165f8 |
children | 4ca6dc0799b6 bc22cbb8b45a |
comparison
equal
deleted
inserted
replaced
14141:f97c5ec83832 | 14518:d8041d695d19 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
36 class CMTask; | 36 class CMTask; |
37 class ReferenceProcessor; | 37 class ReferenceProcessor; |
38 | 38 |
39 // A class that scans oops in a given heap region (much as OopsInGenClosure | 39 // A class that scans oops in a given heap region (much as OopsInGenClosure |
40 // scans oops in a generation.) | 40 // scans oops in a generation.) |
41 class OopsInHeapRegionClosure: public OopsInGenClosure { | 41 class OopsInHeapRegionClosure: public ExtendedOopClosure { |
42 protected: | 42 protected: |
43 HeapRegion* _from; | 43 HeapRegion* _from; |
44 public: | 44 public: |
45 void set_region(HeapRegion* from) { _from = from; } | 45 void set_region(HeapRegion* from) { _from = from; } |
46 }; | 46 }; |
47 | 47 |
48 class G1ParClosureSuper : public OopsInHeapRegionClosure { | 48 class G1ParClosureSuper : public OopsInHeapRegionClosure { |
49 protected: | 49 protected: |
50 G1CollectedHeap* _g1; | 50 G1CollectedHeap* _g1; |
51 G1RemSet* _g1_rem; | |
52 ConcurrentMark* _cm; | |
53 G1ParScanThreadState* _par_scan_state; | 51 G1ParScanThreadState* _par_scan_state; |
54 uint _worker_id; | 52 uint _worker_id; |
55 bool _during_initial_mark; | |
56 bool _mark_in_progress; | |
57 public: | 53 public: |
58 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); | 54 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
59 bool apply_to_weak_ref_discovered_field() { return true; } | 55 bool apply_to_weak_ref_discovered_field() { return true; } |
60 }; | 56 }; |
61 | 57 |
84 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | 80 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
85 }; | 81 }; |
86 | 82 |
87 #define G1_PARTIAL_ARRAY_MASK 0x2 | 83 #define G1_PARTIAL_ARRAY_MASK 0x2 |
88 | 84 |
89 template <class T> inline bool has_partial_array_mask(T* ref) { | 85 inline bool has_partial_array_mask(oop* ref) { |
90 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; | 86 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; |
91 } | 87 } |
92 | 88 |
93 template <class T> inline T* set_partial_array_mask(T obj) { | 89 // We never encode partial array oops as narrowOop*, so return false immediately. |
90 // This allows the compiler to create optimized code when popping references from | |
91 // the work queue. | |
92 inline bool has_partial_array_mask(narrowOop* ref) { | |
93 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); | |
94 return false; | |
95 } | |
96 | |
97 // Only implement set_partial_array_mask() for regular oops, not for narrowOops. | |
98 // We always encode partial arrays as regular oop, to allow the | |
99 // specialization for has_partial_array_mask() for narrowOops above. | |
100 // This means that unintentional use of this method with narrowOops are caught | |
101 // by the compiler. | |
102 inline oop* set_partial_array_mask(oop obj) { | |
94 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); | 103 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); |
95 return (T*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); | 104 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); |
96 } | 105 } |
97 | 106 |
98 template <class T> inline oop clear_partial_array_mask(T* ref) { | 107 template <class T> inline oop clear_partial_array_mask(T* ref) { |
99 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); | 108 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); |
100 } | 109 } |
118 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | 127 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
119 }; | 128 }; |
120 | 129 |
121 // Add back base class for metadata | 130 // Add back base class for metadata |
122 class G1ParCopyHelper : public G1ParClosureSuper { | 131 class G1ParCopyHelper : public G1ParClosureSuper { |
132 protected: | |
123 Klass* _scanned_klass; | 133 Klass* _scanned_klass; |
124 | 134 ConcurrentMark* _cm; |
125 public: | 135 |
126 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : | |
127 _scanned_klass(NULL), | |
128 G1ParClosureSuper(g1, par_scan_state) {} | |
129 | |
130 void set_scanned_klass(Klass* k) { _scanned_klass = k; } | |
131 template <class T> void do_klass_barrier(T* p, oop new_obj); | |
132 }; | |
133 | |
134 template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_object> | |
135 class G1ParCopyClosure : public G1ParCopyHelper { | |
136 G1ParScanClosure _scanner; | |
137 template <class T> void do_oop_work(T* p); | |
138 | |
139 protected: | |
140 // Mark the object if it's not already marked. This is used to mark | 136 // Mark the object if it's not already marked. This is used to mark |
141 // objects pointed to by roots that are guaranteed not to move | 137 // objects pointed to by roots that are guaranteed not to move |
142 // during the GC (i.e., non-CSet objects). It is MT-safe. | 138 // during the GC (i.e., non-CSet objects). It is MT-safe. |
143 void mark_object(oop obj); | 139 void mark_object(oop obj); |
144 | 140 |
145 // Mark the object if it's not already marked. This is used to mark | 141 // Mark the object if it's not already marked. This is used to mark |
146 // objects pointed to by roots that have been forwarded during a | 142 // objects pointed to by roots that have been forwarded during a |
147 // GC. It is MT-safe. | 143 // GC. It is MT-safe. |
148 void mark_forwarded_object(oop from_obj, oop to_obj); | 144 void mark_forwarded_object(oop from_obj, oop to_obj); |
149 | 145 public: |
150 oop copy_to_survivor_space(oop obj); | 146 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
147 | |
148 void set_scanned_klass(Klass* k) { _scanned_klass = k; } | |
149 template <class T> void do_klass_barrier(T* p, oop new_obj); | |
150 }; | |
151 | |
152 template <G1Barrier barrier, bool do_mark_object> | |
153 class G1ParCopyClosure : public G1ParCopyHelper { | |
154 private: | |
155 template <class T> void do_oop_work(T* p); | |
151 | 156 |
152 public: | 157 public: |
153 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, | 158 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, |
154 ReferenceProcessor* rp) : | 159 ReferenceProcessor* rp) : |
155 _scanner(g1, par_scan_state, rp), | |
156 G1ParCopyHelper(g1, par_scan_state) { | 160 G1ParCopyHelper(g1, par_scan_state) { |
157 assert(_ref_processor == NULL, "sanity"); | 161 assert(_ref_processor == NULL, "sanity"); |
158 } | 162 } |
159 | 163 |
160 G1ParScanClosure* scanner() { return &_scanner; } | 164 template <class T> void do_oop_nv(T* p) { do_oop_work(p); } |
161 | |
162 template <class T> void do_oop_nv(T* p) { | |
163 do_oop_work(p); | |
164 } | |
165 virtual void do_oop(oop* p) { do_oop_nv(p); } | 165 virtual void do_oop(oop* p) { do_oop_nv(p); } |
166 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } | 166 virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
167 }; | 167 }; |
168 | 168 |
169 typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure; | 169 typedef G1ParCopyClosure<G1BarrierNone, false> G1ParScanExtRootClosure; |
170 typedef G1ParCopyClosure<false, G1BarrierKlass, false> G1ParScanMetadataClosure; | 170 typedef G1ParCopyClosure<G1BarrierKlass, false> G1ParScanMetadataClosure; |
171 | 171 |
172 | 172 |
173 typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; | 173 typedef G1ParCopyClosure<G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; |
174 typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkClosure; | 174 typedef G1ParCopyClosure<G1BarrierKlass, true> G1ParScanAndMarkMetadataClosure; |
175 typedef G1ParCopyClosure<false, G1BarrierKlass, true> G1ParScanAndMarkMetadataClosure; | |
176 | |
177 // The following closure types are no longer used but are retained | |
178 // for historical reasons: | |
179 // typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure; | |
180 // typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure; | |
181 | 175 |
182 // The following closure type is defined in g1_specialized_oop_closures.hpp: | 176 // The following closure type is defined in g1_specialized_oop_closures.hpp: |
183 // | 177 // |
184 // typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure; | 178 // typedef G1ParCopyClosure<G1BarrierEvac, false> G1ParScanHeapEvacClosure; |
185 | 179 |
186 // We use a separate closure to handle references during evacuation | 180 // We use a separate closure to handle references during evacuation |
187 // failure processing. | 181 // failure processing. |
188 // We could have used another instance of G1ParScanHeapEvacClosure | 182 // We could have used another instance of G1ParScanHeapEvacClosure |
189 // (since that closure no longer assumes that the references it | 183 // (since that closure no longer assumes that the references it |
190 // handles point into the collection set). | 184 // handles point into the collection set). |
191 | 185 |
192 typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; | 186 typedef G1ParCopyClosure<G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; |
193 | 187 |
194 class FilterIntoCSClosure: public ExtendedOopClosure { | 188 class FilterIntoCSClosure: public ExtendedOopClosure { |
195 G1CollectedHeap* _g1; | 189 G1CollectedHeap* _g1; |
196 OopClosure* _oc; | 190 OopClosure* _oc; |
197 DirtyCardToOopClosure* _dcto_cl; | 191 DirtyCardToOopClosure* _dcto_cl; |