author | coleenp |
Sat, 29 Sep 2012 06:40:00 -0400 | |
changeset 13952 | e3cf184080bc |
parent 13759 | 67f8a9de4cdd |
child 15088 | 8875e774f1a3 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5080
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5080
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5080
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "compiler/compileBroker.hpp" |
|
27 |
#include "gc_implementation/shared/markSweep.inline.hpp" |
|
28 |
#include "gc_interface/collectedHeap.inline.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
29 |
#include "oops/methodData.hpp" |
7397 | 30 |
#include "oops/objArrayKlass.inline.hpp" |
31 |
#include "oops/oop.inline.hpp" |
|
1 | 32 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
33 |
unsigned int MarkSweep::_total_invocations = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
34 |
|
13195 | 35 |
Stack<oop, mtGC> MarkSweep::_marking_stack; |
36 |
Stack<ObjArrayTask, mtGC> MarkSweep::_objarray_stack; |
|
1 | 37 |
|
13195 | 38 |
Stack<oop, mtGC> MarkSweep::_preserved_oop_stack; |
39 |
Stack<markOop, mtGC> MarkSweep::_preserved_mark_stack; |
|
1 | 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 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
46 |
GrowableArray<void*>* MarkSweep::_root_refs_stack = NULL; |
1 | 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; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
52 |
GrowableArray<void*>* MarkSweep::_other_refs_stack = NULL; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
53 |
GrowableArray<void*>* MarkSweep::_adjusted_pointers = NULL; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
54 |
bool MarkSweep::_pointer_tracking = false; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
55 |
bool MarkSweep::_root_tracking = true; |
1 | 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 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
65 |
MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
66 |
CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); |
1 | 67 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
68 |
void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
69 |
void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } |
1 | 70 |
|
71 |
MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
72 |
MarkSweep::FollowKlassClosure MarkSweep::follow_klass_closure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
73 |
MarkSweep::AdjustKlassClosure MarkSweep::adjust_klass_closure; |
1 | 74 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
75 |
void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(p); } |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
76 |
void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); } |
1 | 77 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
78 |
void MarkSweep::FollowKlassClosure::do_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
79 |
klass->oops_do(&MarkSweep::mark_and_push_closure); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
80 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
81 |
void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
82 |
klass->oops_do(&MarkSweep::adjust_pointer_closure); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
83 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
84 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
85 |
void MarkSweep::follow_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
86 |
ClassLoaderData* cld = klass->class_loader_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
87 |
// The actual processing of the klass is done when we |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
88 |
// traverse the list of Klasses in the class loader data. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
89 |
MarkSweep::follow_class_loader(cld); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
90 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
91 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
92 |
void MarkSweep::adjust_klass(Klass* klass) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
93 |
ClassLoaderData* cld = klass->class_loader_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
94 |
// The actual processing of the klass is done when we |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
95 |
// traverse the list of Klasses in the class loader data. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
96 |
MarkSweep::adjust_class_loader(cld); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
97 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
98 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
99 |
void MarkSweep::follow_class_loader(ClassLoaderData* cld) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
100 |
cld->oops_do(&MarkSweep::mark_and_push_closure, &MarkSweep::follow_klass_closure, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
101 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
102 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
103 |
void MarkSweep::adjust_class_loader(ClassLoaderData* cld) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
104 |
cld->oops_do(&MarkSweep::adjust_root_pointer_closure, &MarkSweep::adjust_klass_closure, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
105 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
106 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
107 |
|
1 | 108 |
void MarkSweep::follow_stack() { |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
109 |
do { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
110 |
while (!_marking_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
111 |
oop obj = _marking_stack.pop(); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
112 |
assert (obj->is_gc_marked(), "p must be marked"); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
113 |
obj->follow_contents(); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
114 |
} |
5080
eff0cc882603
6935839: excessive marking stack growth during full gcs
jcoomes
parents:
5076
diff
changeset
|
115 |
// Process ObjArrays one at a time to avoid marking stack bloat. |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
116 |
if (!_objarray_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
117 |
ObjArrayTask task = _objarray_stack.pop(); |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13759
diff
changeset
|
118 |
ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
119 |
k->oop_follow_contents(task.obj(), task.index()); |
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
120 |
} |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
121 |
} while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); |
1 | 122 |
} |
123 |
||
124 |
MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure; |
|
125 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
126 |
void MarkSweep::FollowStackClosure::do_void() { follow_stack(); } |
1 | 127 |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
128 |
// We preserve the mark which should be replaced at the end and the location |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
129 |
// that it will go. Note that the object that this markOop belongs to isn't |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
130 |
// currently at that address but it will be after phase4 |
1 | 131 |
void MarkSweep::preserve_mark(oop obj, markOop mark) { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
132 |
// We try to store preserved marks in the to space of the new generation since |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
133 |
// this is storage which should be available. Most of the time this should be |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
134 |
// sufficient space for the marks we need to preserve but if it isn't we fall |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
135 |
// back to using Stacks to keep track of the overflow. |
1 | 136 |
if (_preserved_count < _preserved_count_max) { |
137 |
_preserved_marks[_preserved_count++].init(obj, mark); |
|
138 |
} else { |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
139 |
_preserved_mark_stack.push(mark); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
140 |
_preserved_oop_stack.push(obj); |
1 | 141 |
} |
142 |
} |
|
143 |
||
144 |
MarkSweep::AdjustPointerClosure MarkSweep::adjust_root_pointer_closure(true); |
|
145 |
MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure(false); |
|
146 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
147 |
void MarkSweep::AdjustPointerClosure::do_oop(oop* p) { adjust_pointer(p, _is_root); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
148 |
void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p, _is_root); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
149 |
|
1 | 150 |
void MarkSweep::adjust_marks() { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
151 |
assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(), |
1 | 152 |
"inconsistent preserved oop stacks"); |
153 |
||
154 |
// adjust the oops we saved earlier |
|
155 |
for (size_t i = 0; i < _preserved_count; i++) { |
|
156 |
_preserved_marks[i].adjust_pointer(); |
|
157 |
} |
|
158 |
||
159 |
// deal with the overflow stack |
|
13195 | 160 |
StackIterator<oop, mtGC> iter(_preserved_oop_stack); |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
161 |
while (!iter.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
162 |
oop* p = iter.next_addr(); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
163 |
adjust_pointer(p); |
1 | 164 |
} |
165 |
} |
|
166 |
||
167 |
void MarkSweep::restore_marks() { |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
168 |
assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
1 | 169 |
"inconsistent preserved oop stacks"); |
170 |
if (PrintGC && Verbose) { |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
171 |
gclog_or_tty->print_cr("Restoring %d marks", |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
172 |
_preserved_count + _preserved_oop_stack.size()); |
1 | 173 |
} |
174 |
||
175 |
// restore the marks we saved earlier |
|
176 |
for (size_t i = 0; i < _preserved_count; i++) { |
|
177 |
_preserved_marks[i].restore(); |
|
178 |
} |
|
179 |
||
180 |
// deal with the overflow |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
181 |
while (!_preserved_oop_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
182 |
oop obj = _preserved_oop_stack.pop(); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
183 |
markOop mark = _preserved_mark_stack.pop(); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
184 |
obj->set_mark(mark); |
1 | 185 |
} |
186 |
} |
|
187 |
||
188 |
#ifdef VALIDATE_MARK_SWEEP |
|
189 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
190 |
void MarkSweep::track_adjusted_pointer(void* p, bool isroot) { |
1 | 191 |
if (!ValidateMarkSweep) |
192 |
return; |
|
193 |
||
194 |
if (!isroot) { |
|
195 |
if (_pointer_tracking) { |
|
196 |
guarantee(_adjusted_pointers->contains(p), "should have seen this pointer"); |
|
197 |
_adjusted_pointers->remove(p); |
|
198 |
} |
|
199 |
} else { |
|
200 |
ptrdiff_t index = _root_refs_stack->find(p); |
|
201 |
if (index != -1) { |
|
202 |
int l = _root_refs_stack->length(); |
|
203 |
if (l > 0 && l - 1 != index) { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
204 |
void* last = _root_refs_stack->pop(); |
1 | 205 |
assert(last != p, "should be different"); |
206 |
_root_refs_stack->at_put(index, last); |
|
207 |
} else { |
|
208 |
_root_refs_stack->remove(p); |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
214 |
void MarkSweep::check_adjust_pointer(void* p) { |
1 | 215 |
_adjusted_pointers->push(p); |
216 |
} |
|
217 |
||
218 |
class AdjusterTracker: public OopClosure { |
|
219 |
public: |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
220 |
AdjusterTracker() {} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
221 |
void do_oop(oop* o) { MarkSweep::check_adjust_pointer(o); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
222 |
void do_oop(narrowOop* o) { MarkSweep::check_adjust_pointer(o); } |
1 | 223 |
}; |
224 |
||
225 |
void MarkSweep::track_interior_pointers(oop obj) { |
|
226 |
if (ValidateMarkSweep) { |
|
227 |
_adjusted_pointers->clear(); |
|
228 |
_pointer_tracking = true; |
|
229 |
||
230 |
AdjusterTracker checker; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
231 |
obj->oop_iterate_no_header(&checker); |
1 | 232 |
} |
233 |
} |
|
234 |
||
235 |
void MarkSweep::check_interior_pointers() { |
|
236 |
if (ValidateMarkSweep) { |
|
237 |
_pointer_tracking = false; |
|
238 |
guarantee(_adjusted_pointers->length() == 0, "should have processed the same pointers"); |
|
239 |
} |
|
240 |
} |
|
241 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
242 |
void MarkSweep::reset_live_oop_tracking() { |
1 | 243 |
if (ValidateMarkSweep) { |
244 |
guarantee((size_t)_live_oops->length() == _live_oops_index, "should be at end of live oops"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
245 |
_live_oops_index = 0; |
1 | 246 |
} |
247 |
} |
|
248 |
||
249 |
void MarkSweep::register_live_oop(oop p, size_t size) { |
|
250 |
if (ValidateMarkSweep) { |
|
251 |
_live_oops->push(p); |
|
252 |
_live_oops_size->push(size); |
|
253 |
_live_oops_index++; |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
void MarkSweep::validate_live_oop(oop p, size_t size) { |
|
258 |
if (ValidateMarkSweep) { |
|
259 |
oop obj = _live_oops->at((int)_live_oops_index); |
|
260 |
guarantee(obj == p, "should be the same object"); |
|
261 |
guarantee(_live_oops_size->at((int)_live_oops_index) == size, "should be the same size"); |
|
262 |
_live_oops_index++; |
|
263 |
} |
|
264 |
} |
|
265 |
||
266 |
void MarkSweep::live_oop_moved_to(HeapWord* q, size_t size, |
|
267 |
HeapWord* compaction_top) { |
|
268 |
assert(oop(q)->forwardee() == NULL || oop(q)->forwardee() == oop(compaction_top), |
|
269 |
"should be moved to forwarded location"); |
|
270 |
if (ValidateMarkSweep) { |
|
271 |
MarkSweep::validate_live_oop(oop(q), size); |
|
272 |
_live_oops_moved_to->push(oop(compaction_top)); |
|
273 |
} |
|
274 |
if (RecordMarkSweepCompaction) { |
|
275 |
_cur_gc_live_oops->push(q); |
|
276 |
_cur_gc_live_oops_moved_to->push(compaction_top); |
|
277 |
_cur_gc_live_oops_size->push(size); |
|
278 |
} |
|
279 |
} |
|
280 |
||
281 |
void MarkSweep::compaction_complete() { |
|
282 |
if (RecordMarkSweepCompaction) { |
|
283 |
GrowableArray<HeapWord*>* _tmp_live_oops = _cur_gc_live_oops; |
|
284 |
GrowableArray<HeapWord*>* _tmp_live_oops_moved_to = _cur_gc_live_oops_moved_to; |
|
285 |
GrowableArray<size_t> * _tmp_live_oops_size = _cur_gc_live_oops_size; |
|
286 |
||
287 |
_cur_gc_live_oops = _last_gc_live_oops; |
|
288 |
_cur_gc_live_oops_moved_to = _last_gc_live_oops_moved_to; |
|
289 |
_cur_gc_live_oops_size = _last_gc_live_oops_size; |
|
290 |
_last_gc_live_oops = _tmp_live_oops; |
|
291 |
_last_gc_live_oops_moved_to = _tmp_live_oops_moved_to; |
|
292 |
_last_gc_live_oops_size = _tmp_live_oops_size; |
|
293 |
} |
|
294 |
} |
|
295 |
||
296 |
void MarkSweep::print_new_location_of_heap_address(HeapWord* q) { |
|
297 |
if (!RecordMarkSweepCompaction) { |
|
298 |
tty->print_cr("Requires RecordMarkSweepCompaction to be enabled"); |
|
299 |
return; |
|
300 |
} |
|
301 |
||
302 |
if (_last_gc_live_oops == NULL) { |
|
303 |
tty->print_cr("No compaction information gathered yet"); |
|
304 |
return; |
|
305 |
} |
|
306 |
||
307 |
for (int i = 0; i < _last_gc_live_oops->length(); i++) { |
|
308 |
HeapWord* old_oop = _last_gc_live_oops->at(i); |
|
309 |
size_t sz = _last_gc_live_oops_size->at(i); |
|
310 |
if (old_oop <= q && q < (old_oop + sz)) { |
|
311 |
HeapWord* new_oop = _last_gc_live_oops_moved_to->at(i); |
|
312 |
size_t offset = (q - old_oop); |
|
313 |
tty->print_cr("Address " PTR_FORMAT, q); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
314 |
tty->print_cr(" Was in oop " PTR_FORMAT ", size " SIZE_FORMAT ", at offset " SIZE_FORMAT, old_oop, sz, offset); |
1 | 315 |
tty->print_cr(" Now in oop " PTR_FORMAT ", actual address " PTR_FORMAT, new_oop, new_oop + offset); |
316 |
return; |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); |
|
321 |
} |
|
322 |
#endif //VALIDATE_MARK_SWEEP |
|
323 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
324 |
MarkSweep::IsAliveClosure MarkSweep::is_alive; |
1 | 325 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
326 |
void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
327 |
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } |
1 | 328 |
|
329 |
MarkSweep::KeepAliveClosure MarkSweep::keep_alive; |
|
330 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
331 |
void MarkSweep::KeepAliveClosure::do_oop(oop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
332 |
void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
333 |
|
1 | 334 |
void marksweep_init() { /* empty */ } |
335 |
||
336 |
#ifndef PRODUCT |
|
337 |
||
338 |
void MarkSweep::trace(const char* msg) { |
|
339 |
if (TraceMarkSweep) |
|
340 |
gclog_or_tty->print("%s", msg); |
|
341 |
} |
|
342 |
||
343 |
#endif |