Skip to content
Permalink
Browse files
8210100: ParallelGC should use parallel WeakProcessor
Reviewed-by: kbarrett, tschatzl, sjohanss
  • Loading branch information
albertnetymk committed Mar 8, 2021
1 parent 679faa6 commit 0da889edf3bd18be6fd1c6a5487bc3a19db0315f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
@@ -32,6 +32,26 @@
#include "oops/oop.inline.hpp"
#include "utilities/globalDefinitions.hpp"

class PSAdjustWeakRootsClosure final: public OopClosure {
public:
virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }

virtual void do_oop(oop* p) {
if (PSScavenge::should_scavenge(p)) {
oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
assert(o->is_forwarded(), "Objects are already forwarded before weak processing");
oop new_obj = o->forwardee();
if (log_develop_is_enabled(Trace, gc, scavenge)) {
ResourceMark rm; // required by internal_name()
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
"forwarding",
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
}
RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
}
}
};

template <bool promote_immediately>
class PSRootsClosure: public OopClosure {
private:
@@ -52,7 +52,7 @@
#include "gc/shared/scavengableNMethods.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "gc/shared/weakProcessor.hpp"
#include "gc/shared/weakProcessor.inline.hpp"
#include "gc/shared/workerPolicy.hpp"
#include "gc/shared/workgroup.hpp"
#include "memory/iterator.hpp"
@@ -520,11 +520,10 @@ bool PSScavenge::invoke_no_policy() {

assert(promotion_manager->stacks_empty(),"stacks should be empty at this point");

PSScavengeRootsClosure root_closure(promotion_manager);

{
GCTraceTime(Debug, gc, phases) tm("Weak Processing", &_gc_timer);
WeakProcessor::weak_oops_do(&_is_alive_closure, &root_closure);
PSAdjustWeakRootsClosure root_closure;
WeakProcessor::weak_oops_do(&ParallelScavengeHeap::heap()->workers(), &_is_alive_closure, &root_closure, 1);
}

// Verify that usage of root_closure didn't copy any objects.

0 comments on commit 0da889e

Please sign in to comment.