8279063: Consolidate push and push_if_necessary in PreservedMarks
Reviewed-by: rkennke, mli, tschatzl
This commit is contained in:
parent
d0ea7c9db9
commit
3f41fdecdb
@ -54,12 +54,10 @@ inline bool G1FullGCMarker::mark_object(oop obj) {
|
||||
}
|
||||
|
||||
// Marked by us, preserve if needed.
|
||||
markWord mark = obj->mark();
|
||||
if (obj->mark_must_be_preserved(mark) &&
|
||||
// It is not necessary to preserve marks for objects in regions we do not
|
||||
// compact because we do not change their headers (i.e. forward them).
|
||||
_collector->is_compacting(obj)) {
|
||||
preserved_stack()->push(obj, mark);
|
||||
if (_collector->is_compacting(obj)) {
|
||||
// It is not necessary to preserve marks for objects in regions we do not
|
||||
// compact because we do not change their headers (i.e. forward them).
|
||||
preserved_stack()->push_if_necessary(obj, obj->mark());
|
||||
}
|
||||
|
||||
// Check if deduplicatable string.
|
||||
|
@ -56,7 +56,6 @@ private:
|
||||
|
||||
public:
|
||||
size_t size() const { return _stack.size(); }
|
||||
inline void push(oop obj, markWord m);
|
||||
inline void push_if_necessary(oop obj, markWord m);
|
||||
// Iterate over the stack, restore all preserved marks, and
|
||||
// reclaim the memory taken up by the stack segments.
|
||||
|
@ -35,15 +35,10 @@ inline bool PreservedMarks::should_preserve_mark(oop obj, markWord m) const {
|
||||
return obj->mark_must_be_preserved(m);
|
||||
}
|
||||
|
||||
inline void PreservedMarks::push(oop obj, markWord m) {
|
||||
assert(should_preserve_mark(obj, m), "pre-condition");
|
||||
OopAndMarkWord elem(obj, m);
|
||||
_stack.push(elem);
|
||||
}
|
||||
|
||||
inline void PreservedMarks::push_if_necessary(oop obj, markWord m) {
|
||||
if (should_preserve_mark(obj, m)) {
|
||||
push(obj, m);
|
||||
OopAndMarkWord elem(obj, m);
|
||||
_stack.push(elem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ TEST_VM(PreservedMarks, iterate_and_restore) {
|
||||
ASSERT_MARK_WORD_EQ(o2.mark(), FakeOop::changedMark());
|
||||
|
||||
// Push o1 and o2 to have their marks preserved.
|
||||
pm.push(o1.get_oop(), o1.mark());
|
||||
pm.push(o2.get_oop(), o2.mark());
|
||||
pm.push_if_necessary(o1.get_oop(), o1.mark());
|
||||
pm.push_if_necessary(o2.get_oop(), o2.mark());
|
||||
|
||||
// Fake a move from o1->o3 and o2->o4.
|
||||
o1.forward_to(o3.get_oop());
|
||||
|
Loading…
Reference in New Issue
Block a user