Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/shared/markSweep.cpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | 52b4284cb496 2c6ef90f030a |
children |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13417
diff
changeset
|
2 * Copyright (c) 1997, 2014, 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" | |
10405 | 27 #include "gc_implementation/shared/gcTimer.hpp" |
28 #include "gc_implementation/shared/gcTrace.hpp" | |
1972 | 29 #include "gc_implementation/shared/markSweep.inline.hpp" |
30 #include "gc_interface/collectedHeap.inline.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
31 #include "oops/methodData.hpp" |
1972 | 32 #include "oops/objArrayKlass.inline.hpp" |
33 #include "oops/oop.inline.hpp" | |
0 | 34 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13417
diff
changeset
|
35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13417
diff
changeset
|
36 |
10287
12f651e29f6b
6843347: Boundary values in some public GC options cause crashes
tschatzl
parents:
10179
diff
changeset
|
37 uint MarkSweep::_total_invocations = 0; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
38 |
6197 | 39 Stack<oop, mtGC> MarkSweep::_marking_stack; |
40 Stack<ObjArrayTask, mtGC> MarkSweep::_objarray_stack; | |
0 | 41 |
6197 | 42 Stack<oop, mtGC> MarkSweep::_preserved_oop_stack; |
43 Stack<markOop, mtGC> MarkSweep::_preserved_mark_stack; | |
0 | 44 size_t MarkSweep::_preserved_count = 0; |
45 size_t MarkSweep::_preserved_count_max = 0; | |
46 PreservedMark* MarkSweep::_preserved_marks = NULL; | |
47 ReferenceProcessor* MarkSweep::_ref_processor = NULL; | |
10405 | 48 STWGCTimer* MarkSweep::_gc_timer = NULL; |
49 SerialOldTracer* MarkSweep::_gc_tracer = NULL; | |
0 | 50 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
51 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; |
0 | 52 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
53 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
|
54 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } |
0 | 55 |
56 MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure; | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20257
diff
changeset
|
57 CLDToOopClosure MarkSweep::follow_cld_closure(&mark_and_push_closure); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20257
diff
changeset
|
58 CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure); |
0 | 59 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
60 void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(p); } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
61 void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); } |
0 | 62 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
63 void MarkSweep::follow_class_loader(ClassLoaderData* cld) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20257
diff
changeset
|
64 MarkSweep::follow_cld_closure.do_cld(cld); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
65 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
66 |
0 | 67 void MarkSweep::follow_stack() { |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
68 do { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
69 while (!_marking_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
70 oop obj = _marking_stack.pop(); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
71 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
|
72 obj->follow_contents(); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
73 } |
1315
c385bf94cfb8
6935839: excessive marking stack growth during full gcs
jcoomes
parents:
1311
diff
changeset
|
74 // 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
|
75 if (!_objarray_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
76 ObjArrayTask task = _objarray_stack.pop(); |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
10179
diff
changeset
|
77 ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass(); |
1311
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
78 k->oop_follow_contents(task.obj(), task.index()); |
2a1472c30599
4396719: Mark Sweep stack overflow on deeply nested Object arrays
jcoomes
parents:
1000
diff
changeset
|
79 } |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
80 } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); |
0 | 81 } |
82 | |
83 MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure; | |
84 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
85 void MarkSweep::FollowStackClosure::do_void() { follow_stack(); } |
0 | 86 |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
87 // 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
|
88 // 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
|
89 // currently at that address but it will be after phase4 |
0 | 90 void MarkSweep::preserve_mark(oop obj, markOop mark) { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
91 // 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
|
92 // 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
|
93 // 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
|
94 // back to using Stacks to keep track of the overflow. |
0 | 95 if (_preserved_count < _preserved_count_max) { |
96 _preserved_marks[_preserved_count++].init(obj, mark); | |
97 } else { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
98 _preserved_mark_stack.push(mark); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
99 _preserved_oop_stack.push(obj); |
0 | 100 } |
101 } | |
102 | |
10179
a08c80e9e1e5
8012687: Remove unused is_root checks and closures
stefank
parents:
7448
diff
changeset
|
103 MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure; |
0 | 104 |
10179
a08c80e9e1e5
8012687: Remove unused is_root checks and closures
stefank
parents:
7448
diff
changeset
|
105 void MarkSweep::AdjustPointerClosure::do_oop(oop* p) { adjust_pointer(p); } |
a08c80e9e1e5
8012687: Remove unused is_root checks and closures
stefank
parents:
7448
diff
changeset
|
106 void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p); } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
107 |
0 | 108 void MarkSweep::adjust_marks() { |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
109 assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(), |
0 | 110 "inconsistent preserved oop stacks"); |
111 | |
112 // adjust the oops we saved earlier | |
113 for (size_t i = 0; i < _preserved_count; i++) { | |
114 _preserved_marks[i].adjust_pointer(); | |
115 } | |
116 | |
117 // deal with the overflow stack | |
6197 | 118 StackIterator<oop, mtGC> iter(_preserved_oop_stack); |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
119 while (!iter.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
120 oop* p = iter.next_addr(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
121 adjust_pointer(p); |
0 | 122 } |
123 } | |
124 | |
125 void MarkSweep::restore_marks() { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
126 assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(), |
0 | 127 "inconsistent preserved oop stacks"); |
128 if (PrintGC && Verbose) { | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
129 gclog_or_tty->print_cr("Restoring %d marks", |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
130 _preserved_count + _preserved_oop_stack.size()); |
0 | 131 } |
132 | |
133 // restore the marks we saved earlier | |
134 for (size_t i = 0; i < _preserved_count; i++) { | |
135 _preserved_marks[i].restore(); | |
136 } | |
137 | |
138 // deal with the overflow | |
1836
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
139 while (!_preserved_oop_stack.is_empty()) { |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
140 oop obj = _preserved_oop_stack.pop(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
141 markOop mark = _preserved_mark_stack.pop(); |
894b1d7c7e01
6423256: GC stacks should use a better data structure
jcoomes
parents:
1552
diff
changeset
|
142 obj->set_mark(mark); |
0 | 143 } |
144 } | |
145 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
146 MarkSweep::IsAliveClosure MarkSweep::is_alive; |
0 | 147 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
148 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } |
0 | 149 |
150 MarkSweep::KeepAliveClosure MarkSweep::keep_alive; | |
151 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
152 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
|
153 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
|
154 |
10405 | 155 void marksweep_init() { |
156 MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer(); | |
157 MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer(); | |
158 } | |
0 | 159 |
160 #ifndef PRODUCT | |
161 | |
162 void MarkSweep::trace(const char* msg) { | |
163 if (TraceMarkSweep) | |
164 gclog_or_tty->print("%s", msg); | |
165 } | |
166 | |
167 #endif |