Skip to content

Commit

Permalink
8279856: Parallel: Use PreservedMarks to record promotion-failed objects
Browse files Browse the repository at this point in the history
Reviewed-by: sjohanss, tschatzl
  • Loading branch information
albertnetymk committed Feb 1, 2022
1 parent de3113b commit 16ec47d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/hotspot/share/gc/parallel/psPromotionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) {

push_contents(obj);

_preserved_marks->push_if_necessary(obj, obj_mark);
// Save the markWord of promotion-failed objs in _preserved_marks for later
// restoration. This way we don't have to walk the young-gen to locate
// these promotion-failed objs.
_preserved_marks->push_always(obj, obj_mark);
} else {
// We lost, someone else "owns" this object
guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed.");
Expand Down
10 changes: 1 addition & 9 deletions src/hotspot/share/gc/parallel/psScavenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,19 +670,11 @@ bool PSScavenge::invoke_no_policy() {
return !promotion_failure_occurred;
}

// This method iterates over all objects in the young generation,
// removing all forwarding references. It then restores any preserved marks.
void PSScavenge::clean_up_failed_promotion() {
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
PSYoungGen* young_gen = heap->young_gen();

RemoveForwardedPointerClosure remove_fwd_ptr_closure;
young_gen->object_iterate(&remove_fwd_ptr_closure);

PSPromotionManager::restore_preserved_marks();

// Reset the PromotionFailureALot counters.
NOT_PRODUCT(heap->reset_promotion_should_fail();)
NOT_PRODUCT(ParallelScavengeHeap::heap()->reset_promotion_should_fail();)
}

bool PSScavenge::should_attempt_scavenge() {
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/gc/shared/preservedMarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ class RestorePreservedMarksTask : public WorkerTask {

~RestorePreservedMarksTask() {
assert(_total_size == _total_size_before, "total_size = %zu before = %zu", _total_size, _total_size_before);

log_trace(gc)("Restored %zu marks", _total_size);
size_t mem_size = _total_size * (sizeof(oop) + sizeof(markWord));
log_trace(gc)("Restored %zu marks, occupying %zu %s", _total_size,
byte_size_in_proper_unit(mem_size),
proper_unit_for_byte_size(mem_size));
}
};

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shared/preservedMarks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PreservedMarks {
public:
size_t size() const { return _stack.size(); }
inline void push_if_necessary(oop obj, markWord m);
inline void push_always(oop obj, markWord m);
// Iterate over the stack, restore all preserved marks, and
// reclaim the memory taken up by the stack segments.
void restore();
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/gc/shared/preservedMarks.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ inline void PreservedMarks::push_if_necessary(oop obj, markWord m) {
}
}

inline void PreservedMarks::push_always(oop obj, markWord m) {
assert(!m.is_marked(), "precondition");
OopAndMarkWord elem(obj, m);
_stack.push(elem);
}

inline void PreservedMarks::init_forwarded_mark(oop obj) {
obj->init_mark();
}
Expand Down

1 comment on commit 16ec47d

@openjdk-notifier
Copy link

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.