Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/shared/markSweep.cpp @ 4709:fd2b426c30db
7119908: G1: Cache CSet start region for each worker for subsequent reuse
Summary: Cache workers' calculated starting heap region, used for parallel iteration over the collcection set, for subsequent reuse.
Reviewed-by: tonyp, brutisso
author | johnc |
---|---|
date | Wed, 14 Dec 2011 17:43:55 -0800 |
parents | 1d1603768966 |
children | d2a62e0f25eb |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1315
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1315
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1315
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "compiler/compileBroker.hpp" | |
27 #include "gc_implementation/shared/markSweep.inline.hpp" | |
28 #include "gc_interface/collectedHeap.inline.hpp" | |
29 #include "oops/methodDataOop.hpp" | |
30 #include "oops/objArrayKlass.inline.hpp" | |
31 #include "oops/oop.inline.hpp" | |
0 | 32 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
33 Stack<oop> MarkSweep::_marking_stack; |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
34 Stack<DataLayout*> MarkSweep::_revisit_mdo_stack; |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
35 Stack<Klass*> MarkSweep::_revisit_klass_stack; |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
36 Stack<ObjArrayTask> MarkSweep::_objarray_stack; |
0 | 37 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
38 Stack<oop> MarkSweep::_preserved_oop_stack; |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
39 Stack<markOop> MarkSweep::_preserved_mark_stack; |
0 | 40 size_t MarkSweep::_preserved_count = 0; |
41 size_t MarkSweep::_preserved_count_max = 0; | |
42 PreservedMark* MarkSweep::_preserved_marks = NULL; | |
43 ReferenceProcessor* MarkSweep::_ref_processor = NULL; | |
44 | |
45 #ifdef VALIDATE_MARK_SWEEP | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
46 GrowableArray<void*>* MarkSweep::_root_refs_stack = NULL; |
0 | 47 GrowableArray<oop> * MarkSweep::_live_oops = NULL; |
48 GrowableArray<oop> * MarkSweep::_live_oops_moved_to = NULL; | |
49 GrowableArray<size_t>* MarkSweep::_live_oops_size = NULL; | |
50 size_t MarkSweep::_live_oops_index = 0; | |
51 size_t MarkSweep::_live_oops_index_at_perm = 0; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
52 GrowableArray<void*>* MarkSweep::_other_refs_stack = NULL; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
53 GrowableArray<void*>* MarkSweep::_adjusted_pointers = NULL; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
54 bool MarkSweep::_pointer_tracking = false; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
55 bool MarkSweep::_root_tracking = true; |
0 | 56 |
57 GrowableArray<HeapWord*>* MarkSweep::_cur_gc_live_oops = NULL; | |
58 GrowableArray<HeapWord*>* MarkSweep::_cur_gc_live_oops_moved_to = NULL; | |
59 GrowableArray<size_t> * MarkSweep::_cur_gc_live_oops_size = NULL; | |
60 GrowableArray<HeapWord*>* MarkSweep::_last_gc_live_oops = NULL; | |
61 GrowableArray<HeapWord*>* MarkSweep::_last_gc_live_oops_moved_to = NULL; | |
62 GrowableArray<size_t> * MarkSweep::_last_gc_live_oops_size = NULL; | |
63 #endif | |
64 | |
65 void MarkSweep::revisit_weak_klass_link(Klass* k) { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
66 _revisit_klass_stack.push(k); |
0 | 67 } |
68 | |
69 void MarkSweep::follow_weak_klass_links() { | |
70 // All klasses on the revisit stack are marked at this point. | |
71 // Update and follow all subklass, sibling and implementor links. | |
941 | 72 if (PrintRevisitStats) { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
73 gclog_or_tty->print_cr("#classes in system dictionary = %d", |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
74 SystemDictionary::number_of_classes()); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
75 gclog_or_tty->print_cr("Revisit klass stack size = " SIZE_FORMAT, |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
76 _revisit_klass_stack.size()); |
941 | 77 } |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
78 while (!_revisit_klass_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
79 Klass* const k = _revisit_klass_stack.pop(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
80 k->follow_weak_klass_links(&is_alive, &keep_alive); |
0 | 81 } |
82 follow_stack(); | |
83 } | |
84 | |
941 | 85 void MarkSweep::revisit_mdo(DataLayout* p) { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
86 _revisit_mdo_stack.push(p); |
941 | 87 } |
88 | |
89 void MarkSweep::follow_mdo_weak_refs() { | |
90 // All strongly reachable oops have been marked at this point; | |
91 // we can visit and clear any weak references from MDO's which | |
92 // we memoized during the strong marking phase. | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
93 assert(_marking_stack.is_empty(), "Marking stack should be empty"); |
941 | 94 if (PrintRevisitStats) { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
95 gclog_or_tty->print_cr("#classes in system dictionary = %d", |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
96 SystemDictionary::number_of_classes()); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
97 gclog_or_tty->print_cr("Revisit MDO stack size = " SIZE_FORMAT, |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
98 _revisit_mdo_stack.size()); |
941 | 99 } |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
100 while (!_revisit_mdo_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
101 _revisit_mdo_stack.pop()->follow_weak_refs(&is_alive); |
941 | 102 } |
103 follow_stack(); | |
104 } | |
105 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
106 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
196
diff
changeset
|
107 CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); |
0 | 108 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
110 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } |
0 | 111 |
112 MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure; | |
113 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
114 void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { assert(*p == NULL || (*p)->is_oop(), ""); mark_and_push(p); } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
115 void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); } |
0 | 116 |
117 void MarkSweep::follow_stack() { | |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
118 do { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
119 while (!_marking_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
120 oop obj = _marking_stack.pop(); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
121 assert (obj->is_gc_marked(), "p must be marked"); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
122 obj->follow_contents(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
123 } |
1315
c385bf94cfb8
6935839: excessive marking stack growth during full gcs
jcoomes
parents:
1311
diff
changeset
|
124 // Process ObjArrays one at a time to avoid marking stack bloat. |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
125 if (!_objarray_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
126 ObjArrayTask task = _objarray_stack.pop(); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
127 objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
128 k->oop_follow_contents(task.obj(), task.index()); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
129 } |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
130 } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); |
0 | 131 } |
132 | |
133 MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure; | |
134 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
135 void MarkSweep::FollowStackClosure::do_void() { follow_stack(); } |
0 | 136 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
137 // We preserve the mark which should be replaced at the end and the location |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
138 // that it will go. Note that the object that this markOop belongs to isn't |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
139 // currently at that address but it will be after phase4 |
0 | 140 void MarkSweep::preserve_mark(oop obj, markOop mark) { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
141 // We try to store preserved marks in the to space of the new generation since |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
142 // this is storage which should be available. Most of the time this should be |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
143 // sufficient space for the marks we need to preserve but if it isn't we fall |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
144 // back to using Stacks to keep track of the overflow. |
0 | 145 if (_preserved_count < _preserved_count_max) { |
146 _preserved_marks[_preserved_count++].init(obj, mark); | |
147 } else { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
148 _preserved_mark_stack.push(mark); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
149 _preserved_oop_stack.push(obj); |
0 | 150 } |
151 } | |
152 | |
153 MarkSweep::AdjustPointerClosure MarkSweep::adjust_root_pointer_closure(true); | |
154 MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure(false); | |
155 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
156 void MarkSweep::AdjustPointerClosure::do_oop(oop* p) { adjust_pointer(p, _is_root); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
157 void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p, _is_root); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
158 |
0 | 159 void MarkSweep::adjust_marks() { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
160 assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(), |
0 | 161 "inconsistent preserved oop stacks"); |
162 | |
163 // adjust the oops we saved earlier | |
164 for (size_t i = 0; i < _preserved_count; i++) { | |
165 _preserved_marks[i].adjust_pointer(); | |
166 } | |
167 | |
168 // deal with the overflow stack | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
169 StackIterator<oop> iter(_preserved_oop_stack); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
170 while (!iter.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
171 oop* p = iter.next_addr(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
172 adjust_pointer(p); |
0 | 173 } |
174 } | |
175 | |
176 void MarkSweep::restore_marks() { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
177 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
0 | 178 "inconsistent preserved oop stacks"); |
179 if (PrintGC && Verbose) { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
180 gclog_or_tty->print_cr("Restoring %d marks", |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
181 _preserved_count + _preserved_oop_stack.size()); |
0 | 182 } |
183 | |
184 // restore the marks we saved earlier | |
185 for (size_t i = 0; i < _preserved_count; i++) { | |
186 _preserved_marks[i].restore(); | |
187 } | |
188 | |
189 // deal with the overflow | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
190 while (!_preserved_oop_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
191 oop obj = _preserved_oop_stack.pop(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
192 markOop mark = _preserved_mark_stack.pop(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
193 obj->set_mark(mark); |
0 | 194 } |
195 } | |
196 | |
197 #ifdef VALIDATE_MARK_SWEEP | |
198 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
199 void MarkSweep::track_adjusted_pointer(void* p, bool isroot) { |
0 | 200 if (!ValidateMarkSweep) |
201 return; | |
202 | |
203 if (!isroot) { | |
204 if (_pointer_tracking) { | |
205 guarantee(_adjusted_pointers->contains(p), "should have seen this pointer"); | |
206 _adjusted_pointers->remove(p); | |
207 } | |
208 } else { | |
209 ptrdiff_t index = _root_refs_stack->find(p); | |
210 if (index != -1) { | |
211 int l = _root_refs_stack->length(); | |
212 if (l > 0 && l - 1 != index) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
213 void* last = _root_refs_stack->pop(); |
0 | 214 assert(last != p, "should be different"); |
215 _root_refs_stack->at_put(index, last); | |
216 } else { | |
217 _root_refs_stack->remove(p); | |
218 } | |
219 } | |
220 } | |
221 } | |
222 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
223 void MarkSweep::check_adjust_pointer(void* p) { |
0 | 224 _adjusted_pointers->push(p); |
225 } | |
226 | |
227 class AdjusterTracker: public OopClosure { | |
228 public: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
229 AdjusterTracker() {} |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
230 void do_oop(oop* o) { MarkSweep::check_adjust_pointer(o); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
231 void do_oop(narrowOop* o) { MarkSweep::check_adjust_pointer(o); } |
0 | 232 }; |
233 | |
234 void MarkSweep::track_interior_pointers(oop obj) { | |
235 if (ValidateMarkSweep) { | |
236 _adjusted_pointers->clear(); | |
237 _pointer_tracking = true; | |
238 | |
239 AdjusterTracker checker; | |
240 obj->oop_iterate(&checker); | |
241 } | |
242 } | |
243 | |
244 void MarkSweep::check_interior_pointers() { | |
245 if (ValidateMarkSweep) { | |
246 _pointer_tracking = false; | |
247 guarantee(_adjusted_pointers->length() == 0, "should have processed the same pointers"); | |
248 } | |
249 } | |
250 | |
251 void MarkSweep::reset_live_oop_tracking(bool at_perm) { | |
252 if (ValidateMarkSweep) { | |
253 guarantee((size_t)_live_oops->length() == _live_oops_index, "should be at end of live oops"); | |
254 _live_oops_index = at_perm ? _live_oops_index_at_perm : 0; | |
255 } | |
256 } | |
257 | |
258 void MarkSweep::register_live_oop(oop p, size_t size) { | |
259 if (ValidateMarkSweep) { | |
260 _live_oops->push(p); | |
261 _live_oops_size->push(size); | |
262 _live_oops_index++; | |
263 } | |
264 } | |
265 | |
266 void MarkSweep::validate_live_oop(oop p, size_t size) { | |
267 if (ValidateMarkSweep) { | |
268 oop obj = _live_oops->at((int)_live_oops_index); | |
269 guarantee(obj == p, "should be the same object"); | |
270 guarantee(_live_oops_size->at((int)_live_oops_index) == size, "should be the same size"); | |
271 _live_oops_index++; | |
272 } | |
273 } | |
274 | |
275 void MarkSweep::live_oop_moved_to(HeapWord* q, size_t size, | |
276 HeapWord* compaction_top) { | |
277 assert(oop(q)->forwardee() == NULL || oop(q)->forwardee() == oop(compaction_top), | |
278 "should be moved to forwarded location"); | |
279 if (ValidateMarkSweep) { | |
280 MarkSweep::validate_live_oop(oop(q), size); | |
281 _live_oops_moved_to->push(oop(compaction_top)); | |
282 } | |
283 if (RecordMarkSweepCompaction) { | |
284 _cur_gc_live_oops->push(q); | |
285 _cur_gc_live_oops_moved_to->push(compaction_top); | |
286 _cur_gc_live_oops_size->push(size); | |
287 } | |
288 } | |
289 | |
290 void MarkSweep::compaction_complete() { | |
291 if (RecordMarkSweepCompaction) { | |
292 GrowableArray<HeapWord*>* _tmp_live_oops = _cur_gc_live_oops; | |
293 GrowableArray<HeapWord*>* _tmp_live_oops_moved_to = _cur_gc_live_oops_moved_to; | |
294 GrowableArray<size_t> * _tmp_live_oops_size = _cur_gc_live_oops_size; | |
295 | |
296 _cur_gc_live_oops = _last_gc_live_oops; | |
297 _cur_gc_live_oops_moved_to = _last_gc_live_oops_moved_to; | |
298 _cur_gc_live_oops_size = _last_gc_live_oops_size; | |
299 _last_gc_live_oops = _tmp_live_oops; | |
300 _last_gc_live_oops_moved_to = _tmp_live_oops_moved_to; | |
301 _last_gc_live_oops_size = _tmp_live_oops_size; | |
302 } | |
303 } | |
304 | |
305 void MarkSweep::print_new_location_of_heap_address(HeapWord* q) { | |
306 if (!RecordMarkSweepCompaction) { | |
307 tty->print_cr("Requires RecordMarkSweepCompaction to be enabled"); | |
308 return; | |
309 } | |
310 | |
311 if (_last_gc_live_oops == NULL) { | |
312 tty->print_cr("No compaction information gathered yet"); | |
313 return; | |
314 } | |
315 | |
316 for (int i = 0; i < _last_gc_live_oops->length(); i++) { | |
317 HeapWord* old_oop = _last_gc_live_oops->at(i); | |
318 size_t sz = _last_gc_live_oops_size->at(i); | |
319 if (old_oop <= q && q < (old_oop + sz)) { | |
320 HeapWord* new_oop = _last_gc_live_oops_moved_to->at(i); | |
321 size_t offset = (q - old_oop); | |
322 tty->print_cr("Address " PTR_FORMAT, q); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
323 tty->print_cr(" Was in oop " PTR_FORMAT ", size " SIZE_FORMAT ", at offset " SIZE_FORMAT, old_oop, sz, offset); |
0 | 324 tty->print_cr(" Now in oop " PTR_FORMAT ", actual address " PTR_FORMAT, new_oop, new_oop + offset); |
325 return; | |
326 } | |
327 } | |
328 | |
329 tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); | |
330 } | |
331 #endif //VALIDATE_MARK_SWEEP | |
332 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
333 MarkSweep::IsAliveClosure MarkSweep::is_alive; |
0 | 334 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
335 void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
336 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } |
0 | 337 |
338 MarkSweep::KeepAliveClosure MarkSweep::keep_alive; | |
339 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
340 void MarkSweep::KeepAliveClosure::do_oop(oop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
341 void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
342 |
0 | 343 void marksweep_init() { /* empty */ } |
344 | |
345 #ifndef PRODUCT | |
346 | |
347 void MarkSweep::trace(const char* msg) { | |
348 if (TraceMarkSweep) | |
349 gclog_or_tty->print("%s", msg); | |
350 } | |
351 | |
352 #endif |