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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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;
@@ -163,8 +162,7 @@ void MarkSweep::preserve_mark(oop obj, markWord mark) {
if (_preserved_count < _preserved_count_max) {
_preserved_marks[_preserved_count++].init(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,6 +198,8 @@ class PreservedMark {
markWord _mark;

public:
PreservedMark(oop obj, markWord mark) : _obj(obj), _mark(mark) {}

void init(oop obj, markWord mark) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need this init function anymore? Even if such an assignment is still needed, it could just use assignment from a newly constructed object, e.g. pm = PreservedMark(obj, mark);. The only place I found where it is used is preserve_marks, which can use the assignment form instead.

_obj = obj;
_mark = mark;