author | pliden |
Thu, 19 Apr 2018 07:54:50 +0200 | |
changeset 49827 | a4672513d6e3 |
parent 49735 | b3c09ab95c1a |
child 50059 | 10843c8ecd54 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, 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" |
|
30764 | 27 |
#include "gc/serial/markSweep.inline.hpp" |
49735
b3c09ab95c1a
8201217: Split specialized_oop_closures.hpp into GC specific files
stefank
parents:
49722
diff
changeset
|
28 |
#include "gc/serial/serial_specialized_oop_closures.hpp" |
30764 | 29 |
#include "gc/shared/collectedHeap.inline.hpp" |
30 |
#include "gc/shared/gcTimer.hpp" |
|
31 |
#include "gc/shared/gcTrace.hpp" |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
32 |
#include "memory/iterator.inline.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
33 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
34 |
#include "oops/compressedOops.inline.hpp" |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
35 |
#include "oops/instanceClassLoaderKlass.inline.hpp" |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
36 |
#include "oops/instanceKlass.inline.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
37 |
#include "oops/instanceMirrorKlass.inline.hpp" |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
38 |
#include "oops/instanceRefKlass.inline.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
39 |
#include "oops/methodData.hpp" |
7397 | 40 |
#include "oops/objArrayKlass.inline.hpp" |
41 |
#include "oops/oop.inline.hpp" |
|
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35061
diff
changeset
|
42 |
#include "oops/typeArrayOop.inline.hpp" |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
43 |
#include "utilities/macros.hpp" |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
44 |
#include "utilities/stack.inline.hpp" |
1 | 45 |
|
17392
2f967c0e4246
6843347: Boundary values in some public GC options cause crashes
tschatzl
parents:
17105
diff
changeset
|
46 |
uint MarkSweep::_total_invocations = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
47 |
|
13195 | 48 |
Stack<oop, mtGC> MarkSweep::_marking_stack; |
49 |
Stack<ObjArrayTask, mtGC> MarkSweep::_objarray_stack; |
|
1 | 50 |
|
13195 | 51 |
Stack<oop, mtGC> MarkSweep::_preserved_oop_stack; |
52 |
Stack<markOop, mtGC> MarkSweep::_preserved_mark_stack; |
|
1 | 53 |
size_t MarkSweep::_preserved_count = 0; |
54 |
size_t MarkSweep::_preserved_count_max = 0; |
|
55 |
PreservedMark* MarkSweep::_preserved_marks = NULL; |
|
56 |
ReferenceProcessor* MarkSweep::_ref_processor = NULL; |
|
18025 | 57 |
STWGCTimer* MarkSweep::_gc_timer = NULL; |
58 |
SerialOldTracer* MarkSweep::_gc_tracer = NULL; |
|
1 | 59 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
60 |
MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; |
1 | 61 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
62 |
MarkAndPushClosure MarkSweep::mark_and_push_closure; |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
63 |
CLDToOopClosure MarkSweep::follow_cld_closure(&mark_and_push_closure); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
64 |
CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure); |
1 | 65 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
66 |
inline void MarkSweep::mark_object(oop obj) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
67 |
// some marks may contain information we need to preserve so we store them away |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
68 |
// and overwrite the mark. We'll restore it at the end of markSweep. |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
69 |
markOop mark = obj->mark_raw(); |
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
70 |
obj->set_mark_raw(markOopDesc::prototype()->set_marked()); |
1 | 71 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
72 |
if (mark->must_be_preserved(obj)) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
73 |
preserve_mark(obj, mark); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
74 |
} |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
75 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
76 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
77 |
template <class T> inline void MarkSweep::mark_and_push(T* p) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
78 |
T heap_oop = RawAccess<>::oop_load(p); |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
79 |
if (!CompressedOops::is_null(heap_oop)) { |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
80 |
oop obj = CompressedOops::decode_not_null(heap_oop); |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
81 |
if (!obj->mark_raw()->is_marked()) { |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
82 |
mark_object(obj); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
83 |
_marking_stack.push(obj); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
84 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
85 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
86 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
87 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
88 |
inline void MarkSweep::follow_klass(Klass* klass) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
89 |
oop op = klass->klass_holder(); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
90 |
MarkSweep::mark_and_push(&op); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
91 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
92 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
93 |
inline void MarkSweep::follow_cld(ClassLoaderData* cld) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
94 |
MarkSweep::follow_cld_closure.do_cld(cld); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
95 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
96 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
97 |
template <typename T> |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
98 |
inline void MarkAndPushClosure::do_oop_nv(T* p) { MarkSweep::mark_and_push(p); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
99 |
void MarkAndPushClosure::do_oop(oop* p) { do_oop_nv(p); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
100 |
void MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_nv(p); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
101 |
inline bool MarkAndPushClosure::do_metadata_nv() { return true; } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
102 |
bool MarkAndPushClosure::do_metadata() { return do_metadata_nv(); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
103 |
inline void MarkAndPushClosure::do_klass_nv(Klass* k) { MarkSweep::follow_klass(k); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
104 |
void MarkAndPushClosure::do_klass(Klass* k) { do_klass_nv(k); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
105 |
inline void MarkAndPushClosure::do_cld_nv(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
106 |
void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { do_cld_nv(cld); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
107 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
108 |
template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
109 |
mark_and_push(p); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
110 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
111 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
112 |
void MarkSweep::push_objarray(oop obj, size_t index) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
113 |
ObjArrayTask task(obj, index); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
114 |
assert(task.is_valid(), "bad ObjArrayTask"); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
115 |
_objarray_stack.push(task); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
116 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
117 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
118 |
inline void MarkSweep::follow_array(objArrayOop array) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
119 |
MarkSweep::follow_klass(array->klass()); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
120 |
// Don't push empty arrays to avoid unnecessary work. |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
121 |
if (array->length() > 0) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
122 |
MarkSweep::push_objarray(array, 0); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
123 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
124 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
125 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
126 |
inline void MarkSweep::follow_object(oop obj) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
127 |
assert(obj->is_gc_marked(), "should be marked"); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
128 |
if (obj->is_objArray()) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
129 |
// Handle object arrays explicitly to allow them to |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
130 |
// be split into chunks if needed. |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
131 |
MarkSweep::follow_array((objArrayOop)obj); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
132 |
} else { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
133 |
obj->oop_iterate(&mark_and_push_closure); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
134 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
135 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
136 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
137 |
void MarkSweep::follow_array_chunk(objArrayOop array, int index) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
138 |
const int len = array->length(); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
139 |
const int beg_index = index; |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
140 |
assert(beg_index < len || len == 0, "index too large"); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
141 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
142 |
const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
143 |
const int end_index = beg_index + stride; |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
144 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
145 |
array->oop_iterate_range(&mark_and_push_closure, beg_index, end_index); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
146 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
147 |
if (end_index < len) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
148 |
MarkSweep::push_objarray(array, end_index); // Push the continuation. |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
149 |
} |
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29701
diff
changeset
|
150 |
} |
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29701
diff
changeset
|
151 |
|
1 | 152 |
void MarkSweep::follow_stack() { |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
153 |
do { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
154 |
while (!_marking_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
155 |
oop obj = _marking_stack.pop(); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
156 |
assert (obj->is_gc_marked(), "p must be marked"); |
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29701
diff
changeset
|
157 |
follow_object(obj); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
158 |
} |
5080
eff0cc882603
6935839: excessive marking stack growth during full gcs
jcoomes
parents:
5076
diff
changeset
|
159 |
// 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
|
160 |
if (!_objarray_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
161 |
ObjArrayTask task = _objarray_stack.pop(); |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
162 |
follow_array_chunk(objArrayOop(task.obj()), task.index()); |
5076
8b74a4b60b31
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
3919
diff
changeset
|
163 |
} |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
164 |
} while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); |
1 | 165 |
} |
166 |
||
167 |
MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure; |
|
168 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
169 |
void MarkSweep::FollowStackClosure::do_void() { follow_stack(); } |
1 | 170 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
171 |
template <class T> inline void MarkSweep::follow_root(T* p) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
172 |
assert(!Universe::heap()->is_in_reserved(p), |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
173 |
"roots shouldn't be things within the heap"); |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
174 |
T heap_oop = RawAccess<>::oop_load(p); |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
175 |
if (!CompressedOops::is_null(heap_oop)) { |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47897
diff
changeset
|
176 |
oop obj = CompressedOops::decode_not_null(heap_oop); |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
177 |
if (!obj->mark_raw()->is_marked()) { |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
178 |
mark_object(obj); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
179 |
follow_object(obj); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
180 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
181 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
182 |
follow_stack(); |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
183 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
184 |
|
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
185 |
void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
186 |
void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
187 |
|
29701
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
188 |
void PreservedMark::adjust_pointer() { |
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
189 |
MarkSweep::adjust_pointer(&_obj); |
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
190 |
} |
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
191 |
|
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
192 |
void PreservedMark::restore() { |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
193 |
_obj->set_mark_raw(_mark); |
29701
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
194 |
} |
f638fc81a3d0
8075803: Fix GC includes and forward declarations
stefank
parents:
25492
diff
changeset
|
195 |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
196 |
// 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
|
197 |
// 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
|
198 |
// currently at that address but it will be after phase4 |
1 | 199 |
void MarkSweep::preserve_mark(oop obj, markOop mark) { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
200 |
// 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
|
201 |
// 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
|
202 |
// 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
|
203 |
// back to using Stacks to keep track of the overflow. |
1 | 204 |
if (_preserved_count < _preserved_count_max) { |
205 |
_preserved_marks[_preserved_count++].init(obj, mark); |
|
206 |
} else { |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
207 |
_preserved_mark_stack.push(mark); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
208 |
_preserved_oop_stack.push(obj); |
1 | 209 |
} |
210 |
} |
|
211 |
||
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
212 |
void MarkSweep::set_ref_processor(ReferenceProcessor* rp) { |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
213 |
_ref_processor = rp; |
49827 | 214 |
mark_and_push_closure.set_ref_discoverer(_ref_processor); |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
215 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
216 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
35498
diff
changeset
|
217 |
AdjustPointerClosure MarkSweep::adjust_pointer_closure; |
1 | 218 |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29800
diff
changeset
|
219 |
template <typename T> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
35498
diff
changeset
|
220 |
void AdjustPointerClosure::do_oop_nv(T* p) { MarkSweep::adjust_pointer(p); } |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
35498
diff
changeset
|
221 |
void AdjustPointerClosure::do_oop(oop* p) { do_oop_nv(p); } |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
35498
diff
changeset
|
222 |
void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_nv(p); } |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
223 |
|
1 | 224 |
void MarkSweep::adjust_marks() { |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
225 |
assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(), |
1 | 226 |
"inconsistent preserved oop stacks"); |
227 |
||
228 |
// adjust the oops we saved earlier |
|
229 |
for (size_t i = 0; i < _preserved_count; i++) { |
|
230 |
_preserved_marks[i].adjust_pointer(); |
|
231 |
} |
|
232 |
||
233 |
// deal with the overflow stack |
|
13195 | 234 |
StackIterator<oop, mtGC> iter(_preserved_oop_stack); |
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
235 |
while (!iter.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
236 |
oop* p = iter.next_addr(); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
237 |
adjust_pointer(p); |
1 | 238 |
} |
239 |
} |
|
240 |
||
241 |
void MarkSweep::restore_marks() { |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
242 |
assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
1 | 243 |
"inconsistent preserved oop stacks"); |
35061 | 244 |
log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_oop_stack.size()); |
1 | 245 |
|
246 |
// restore the marks we saved earlier |
|
247 |
for (size_t i = 0; i < _preserved_count; i++) { |
|
248 |
_preserved_marks[i].restore(); |
|
249 |
} |
|
250 |
||
251 |
// deal with the overflow |
|
6762
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
252 |
while (!_preserved_oop_stack.is_empty()) { |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
253 |
oop obj = _preserved_oop_stack.pop(); |
f8d1b560700e
6423256: GC stacks should use a better data structure
jcoomes
parents:
5547
diff
changeset
|
254 |
markOop mark = _preserved_mark_stack.pop(); |
49722
a47d1e21b3f1
8199735: Mark word updates need to use Access API
rkennke
parents:
49592
diff
changeset
|
255 |
obj->set_mark_raw(mark); |
1 | 256 |
} |
257 |
} |
|
258 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
259 |
MarkSweep::IsAliveClosure MarkSweep::is_alive; |
1 | 260 |
|
47897
eb3696e0c6d8
8189734: Cleanup MarkSweep when G1 dependency is gone
sjohanss
parents:
47885
diff
changeset
|
261 |
bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } |
1 | 262 |
|
263 |
MarkSweep::KeepAliveClosure MarkSweep::keep_alive; |
|
264 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
|
18025 | 268 |
void marksweep_init() { |
269 |
MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer(); |
|
270 |
MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer(); |
|
271 |
} |
|
1 | 272 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
273 |
// Generate MS specialized oop_oop_iterate functions. |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
31346
diff
changeset
|
274 |
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_MS(ALL_KLASS_OOP_OOP_ITERATE_DEFN) |