inline void 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) { const int len = array->length(); const int beg_index = index;
assert(beg_index < len || len == 0, "index too large");
const int stride = MIN2(len - beg_index, (int) ObjArrayMarkingStride); const int end_index = beg_index + stride;
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());
}
// 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.