Skip to content


8210100: ParallelGC should use parallel WeakProcessor
Browse files Browse the repository at this point in the history
Reviewed-by: kbarrett, tschatzl, sjohanss
  • Loading branch information
albertnetymk committed Mar 8, 2021
1 parent 679faa6 commit 0da889e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/hotspot/share/gc/parallel/psClosure.inline.hpp
Expand Up @@ -32,6 +32,26 @@
#include "oops/oop.inline.hpp"
#include "utilities/globalDefinitions.hpp"

class PSAdjustWeakRootsClosure final: public OopClosure {
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)}",
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 {
Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/gc/parallel/psScavenge.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

1 comment on commit 0da889e

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.