Skip to content
Permalink
Browse files
8271951: Consolidate preserved marks overflow stack in SerialGC
Reviewed-by: tschatzl, kbarrett
  • Loading branch information
rkennke committed Aug 19, 2021
1 parent 7eccbd4 commit b40e8f0f9e719f28cf128d74d834233860e4ab67
Showing 3 changed files with 13 additions and 27 deletions.
@@ -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();
};

1 comment on commit b40e8f0

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b40e8f0 Aug 19, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.