Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8271951: Consolidate preserved marks overflow stack in SerialGC #5022

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -167,8 +167,7 @@ void GenMarkSweep::deallocate_stacks() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
gch->release_scratch();

_preserved_mark_stack.clear(true);
_preserved_oop_stack.clear(true);
_preserved_overflow_stack.clear(true);
_marking_stack.clear();
_objarray_stack.clear(true);
}
@@ -49,8 +49,7 @@ uint MarkSweep::_total_invocations = 0;
Stack<oop, mtGC> MarkSweep::_marking_stack;
Stack<ObjArrayTask, mtGC> MarkSweep::_objarray_stack;

Stack<oop, mtGC> MarkSweep::_preserved_oop_stack;
Stack<markWord, mtGC> MarkSweep::_preserved_mark_stack;
Stack<PreservedMark, mtGC> MarkSweep::_preserved_overflow_stack;
size_t MarkSweep::_preserved_count = 0;
size_t MarkSweep::_preserved_count_max = 0;
PreservedMark* MarkSweep::_preserved_marks = NULL;
@@ -161,10 +160,9 @@ void MarkSweep::preserve_mark(oop obj, markWord mark) {
// 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++].init(obj, mark);
_preserved_marks[_preserved_count++] = PreservedMark(obj, mark);
} else {
_preserved_mark_stack.push(mark);
_preserved_oop_stack.push(obj);
_preserved_overflow_stack.push(PreservedMark(obj, mark));
}
}

@@ -176,37 +174,31 @@ void MarkSweep::set_ref_processor(ReferenceProcessor* rp) {
AdjustPointerClosure MarkSweep::adjust_pointer_closure;

void MarkSweep::adjust_marks() {
assert( _preserved_oop_stack.size() == _preserved_mark_stack.size(),
"inconsistent preserved oop stacks");

// 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<oop, mtGC> iter(_preserved_oop_stack);
StackIterator<PreservedMark, mtGC> iter(_preserved_overflow_stack);
while (!iter.is_empty()) {
oop* p = iter.next_addr();
adjust_pointer(p);
PreservedMark* p = iter.next_addr();
p->adjust_pointer();
}
}

void MarkSweep::restore_marks() {
assert(_preserved_oop_stack.size() == _preserved_mark_stack.size(),
"inconsistent preserved oop stacks");
log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_oop_stack.size());
log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_overflow_stack.size());

// restore the marks we saved earlier
for (size_t i = 0; i < _preserved_count; i++) {
_preserved_marks[i].restore();
}

// deal with the overflow
while (!_preserved_oop_stack.is_empty()) {
oop obj = _preserved_oop_stack.pop();
markWord mark = _preserved_mark_stack.pop();
obj->set_mark(mark);
while (!_preserved_overflow_stack.is_empty()) {
PreservedMark p = _preserved_overflow_stack.pop();
p.restore();
}
}

@@ -100,8 +100,7 @@ class MarkSweep : AllStatic {
static Stack<ObjArrayTask, mtGC> _objarray_stack;

// Space for storing/restoring mark word
static Stack<markWord, mtGC> _preserved_mark_stack;
static Stack<oop, mtGC> _preserved_oop_stack;
static Stack<PreservedMark, mtGC> _preserved_overflow_stack;
static size_t _preserved_count;
static size_t _preserved_count_max;
static PreservedMark* _preserved_marks;
@@ -199,11 +198,7 @@ class PreservedMark {
markWord _mark;

public:
void init(oop obj, markWord mark) {
_obj = obj;
_mark = mark;
}

PreservedMark(oop obj, markWord mark) : _obj(obj), _mark(mark) {}
void adjust_pointer();
void restore();
};