/* * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
inlinevoid MarkSweep::follow_object(oop obj) {
assert(obj->is_gc_marked(), "should be marked"); if (obj->is_objArray()) { // Handle object arrays explicitly to allow them to // be split into chunks if needed.
MarkSweep::follow_array((objArrayOop)obj);
} else {
obj->oop_iterate(&mark_and_push_closure);
}
}
void MarkSweep::follow_array_chunk(objArrayOop array, int index) { constint len = array->length(); constint beg_index = index;
assert(beg_index < len || len == 0, "index too large");
if (end_index < len) {
MarkSweep::push_objarray(array, end_index); // Push the continuation.
}
}
void MarkSweep::follow_stack() { do { while (!_marking_stack.is_empty()) {
oop obj = _marking_stack.pop();
assert (obj->is_gc_marked(), "p must be marked");
follow_object(obj);
} // Process ObjArrays one at a time to avoid marking stack bloat. if (!_objarray_stack.is_empty()) {
ObjArrayTask task = _objarray_stack.pop();
follow_array_chunk(objArrayOop(task.obj()), task.index());
}
} while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
}
template <class T> inlinevoid MarkSweep::follow_root(T* p) {
assert(!Universe::heap()->is_in(p), "roots shouldn't be things within the heap");
T heap_oop = RawAccess<>::oop_load(p); if (!CompressedOops::is_null(heap_oop)) {
oop obj = CompressedOops::decode_not_null(heap_oop); if (!obj->mark().is_marked()) {
mark_object(obj);
follow_object(obj);
}
}
follow_stack();
}
// We preserve the mark which should be replaced at the end and the location // that it will go. Note that the object that this markWord belongs to isn't // currently at that address but it will be after phase4 void MarkSweep::preserve_mark(oop obj, markWord mark) { // We try to store preserved marks in the to space of the new generation since // this is storage which should be available. Most of the time this should be // sufficient space for the marks we need to preserve but if it isn't we fall // back to using Stacks to keep track of the overflow. if (_preserved_count < _preserved_count_max) {
_preserved_marks[_preserved_count++] = PreservedMark(obj, mark);
} else {
_preserved_overflow_stack.push(PreservedMark(obj, mark));
}
}
void MarkSweep::adjust_marks() { // adjust the oops we saved earlier for (size_t i = 0; i < _preserved_count; i++) {
_preserved_marks[i].adjust_pointer();
}
// deal with the overflow stack
StackIterator<PreservedMark, mtGC> iter(_preserved_overflow_stack); while (!iter.is_empty()) {
PreservedMark* p = iter.next_addr();
p->adjust_pointer();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.