8287805: Shenandoah: consolidate evacuate-update-root closures
Reviewed-by: shade
This commit is contained in:
parent
ea8b75cfe4
commit
b2010a7481
@ -89,42 +89,23 @@ private:
|
||||
inline void do_oop_work(T* p);
|
||||
};
|
||||
|
||||
template <DecoratorSet MO = MO_UNORDERED>
|
||||
class ShenandoahEvacuateUpdateMetadataClosure: public ShenandoahOopClosureBase {
|
||||
private:
|
||||
template <bool concurrent, bool stable_thread>
|
||||
class ShenandoahEvacuateUpdateRootClosureBase : public ShenandoahOopClosureBase {
|
||||
protected:
|
||||
ShenandoahHeap* const _heap;
|
||||
Thread* const _thread;
|
||||
Thread* const _thread;
|
||||
public:
|
||||
inline ShenandoahEvacuateUpdateMetadataClosure();
|
||||
inline ShenandoahEvacuateUpdateRootClosureBase();
|
||||
inline void do_oop(oop* p);
|
||||
inline void do_oop(narrowOop* p);
|
||||
|
||||
private:
|
||||
protected:
|
||||
template <class T>
|
||||
inline void do_oop_work(T* p);
|
||||
};
|
||||
|
||||
// Context free version, cannot cache calling thread
|
||||
class ShenandoahEvacuateUpdateRootsClosure : public ShenandoahOopClosureBase {
|
||||
private:
|
||||
ShenandoahHeap* const _heap;
|
||||
public:
|
||||
inline ShenandoahEvacuateUpdateRootsClosure();
|
||||
inline void do_oop(oop* p);
|
||||
inline void do_oop(narrowOop* p);
|
||||
protected:
|
||||
template <typename T>
|
||||
inline void do_oop_work(T* p, Thread* thr);
|
||||
};
|
||||
|
||||
class ShenandoahContextEvacuateUpdateRootsClosure : public ShenandoahEvacuateUpdateRootsClosure {
|
||||
private:
|
||||
Thread* const _thread;
|
||||
public:
|
||||
inline ShenandoahContextEvacuateUpdateRootsClosure();
|
||||
inline void do_oop(oop* p);
|
||||
inline void do_oop(narrowOop* p);
|
||||
};
|
||||
using ShenandoahEvacuateUpdateMetadataClosure = ShenandoahEvacuateUpdateRootClosureBase<false, true>;
|
||||
using ShenandoahEvacuateUpdateRootsClosure = ShenandoahEvacuateUpdateRootClosureBase<true, false>;
|
||||
using ShenandoahContextEvacuateUpdateRootsClosure = ShenandoahEvacuateUpdateRootClosureBase<true, true>;
|
||||
|
||||
template <bool CONCURRENT, typename IsAlive, typename KeepAlive>
|
||||
class ShenandoahCleanUpdateWeakOopsClosure : public OopClosure {
|
||||
|
@ -109,53 +109,37 @@ void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {
|
||||
void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }
|
||||
void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
|
||||
|
||||
template <DecoratorSet MO>
|
||||
ShenandoahEvacuateUpdateMetadataClosure<MO>::ShenandoahEvacuateUpdateMetadataClosure() :
|
||||
_heap(ShenandoahHeap::heap()), _thread(Thread::current()) {
|
||||
template <bool concurrent, bool stable_thread>
|
||||
ShenandoahEvacuateUpdateRootClosureBase<concurrent, stable_thread>::ShenandoahEvacuateUpdateRootClosureBase() :
|
||||
_heap(ShenandoahHeap::heap()), _thread(stable_thread ? Thread::current() : NULL) {
|
||||
}
|
||||
|
||||
template <DecoratorSet MO>
|
||||
template <class T>
|
||||
void ShenandoahEvacuateUpdateMetadataClosure<MO>::do_oop_work(T* p) {
|
||||
assert(_heap->is_concurrent_weak_root_in_progress() ||
|
||||
_heap->is_concurrent_strong_root_in_progress(),
|
||||
"Only do this in root processing phase");
|
||||
assert(_thread == Thread::current(), "Wrong thread");
|
||||
|
||||
T o = RawAccess<>::oop_load(p);
|
||||
if (! CompressedOops::is_null(o)) {
|
||||
oop obj = CompressedOops::decode_not_null(o);
|
||||
if (_heap->in_collection_set(obj)) {
|
||||
assert(_heap->is_evacuation_in_progress(), "Only do this when evacuation is in progress");
|
||||
shenandoah_assert_marked(p, obj);
|
||||
oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
|
||||
if (resolved == obj) {
|
||||
resolved = _heap->evacuate_object(obj, _thread);
|
||||
}
|
||||
RawAccess<IS_NOT_NULL | MO>::oop_store(p, resolved);
|
||||
}
|
||||
template <bool concurrent, bool stable_thread>
|
||||
void ShenandoahEvacuateUpdateRootClosureBase<concurrent, stable_thread>::do_oop(oop* p) {
|
||||
if (concurrent) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p);
|
||||
} else {
|
||||
do_oop_work(p);
|
||||
}
|
||||
}
|
||||
template <DecoratorSet MO>
|
||||
void ShenandoahEvacuateUpdateMetadataClosure<MO>::do_oop(oop* p) {
|
||||
do_oop_work(p);
|
||||
|
||||
template <bool concurrent, bool stable_thread>
|
||||
void ShenandoahEvacuateUpdateRootClosureBase<concurrent, stable_thread>::do_oop(narrowOop* p) {
|
||||
if (concurrent) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p);
|
||||
} else {
|
||||
do_oop_work(p);
|
||||
}
|
||||
}
|
||||
|
||||
template <DecoratorSet MO>
|
||||
void ShenandoahEvacuateUpdateMetadataClosure<MO>::do_oop(narrowOop* p) {
|
||||
do_oop_work(p);
|
||||
}
|
||||
|
||||
ShenandoahEvacuateUpdateRootsClosure::ShenandoahEvacuateUpdateRootsClosure() :
|
||||
_heap(ShenandoahHeap::heap()) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ShenandoahEvacuateUpdateRootsClosure::do_oop_work(T* p, Thread* t) {
|
||||
template <bool atomic, bool stable_thread>
|
||||
template <class T>
|
||||
void ShenandoahEvacuateUpdateRootClosureBase<atomic, stable_thread>::do_oop_work(T* p) {
|
||||
assert(_heap->is_concurrent_weak_root_in_progress() ||
|
||||
_heap->is_concurrent_strong_root_in_progress(),
|
||||
"Only do this in root processing phase");
|
||||
assert(t == Thread::current(), "Wrong thread");
|
||||
|
||||
T o = RawAccess<>::oop_load(p);
|
||||
if (!CompressedOops::is_null(o)) {
|
||||
@ -165,38 +149,20 @@ void ShenandoahEvacuateUpdateRootsClosure::do_oop_work(T* p, Thread* t) {
|
||||
shenandoah_assert_marked(p, obj);
|
||||
oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
|
||||
if (resolved == obj) {
|
||||
resolved = _heap->evacuate_object(obj, t);
|
||||
Thread* thr = stable_thread ? _thread : Thread::current();
|
||||
assert(thr == Thread::current(), "Wrong thread");
|
||||
|
||||
resolved = _heap->evacuate_object(obj, thr);
|
||||
}
|
||||
if (atomic) {
|
||||
ShenandoahHeap::atomic_update_oop(resolved, p, o);
|
||||
} else {
|
||||
RawAccess<IS_NOT_NULL | MO_UNORDERED>::oop_store(p, resolved);
|
||||
}
|
||||
ShenandoahHeap::atomic_update_oop(resolved, p, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShenandoahEvacuateUpdateRootsClosure::do_oop(oop* p) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p, Thread::current());
|
||||
}
|
||||
|
||||
void ShenandoahEvacuateUpdateRootsClosure::do_oop(narrowOop* p) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p, Thread::current());
|
||||
}
|
||||
|
||||
ShenandoahContextEvacuateUpdateRootsClosure::ShenandoahContextEvacuateUpdateRootsClosure() :
|
||||
ShenandoahEvacuateUpdateRootsClosure(),
|
||||
_thread(Thread::current()) {
|
||||
}
|
||||
|
||||
void ShenandoahContextEvacuateUpdateRootsClosure::do_oop(oop* p) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p, _thread);
|
||||
}
|
||||
|
||||
void ShenandoahContextEvacuateUpdateRootsClosure::do_oop(narrowOop* p) {
|
||||
ShenandoahEvacOOMScope scope;
|
||||
do_oop_work(p, _thread);
|
||||
}
|
||||
|
||||
template <bool CONCURRENT, typename IsAlive, typename KeepAlive>
|
||||
ShenandoahCleanUpdateWeakOopsClosure<CONCURRENT, IsAlive, KeepAlive>::ShenandoahCleanUpdateWeakOopsClosure(IsAlive* is_alive, KeepAlive* keep_alive) :
|
||||
_is_alive(is_alive), _keep_alive(keep_alive) {
|
||||
|
@ -834,7 +834,7 @@ void ShenandoahConcurrentGC::op_class_unloading() {
|
||||
class ShenandoahEvacUpdateCodeCacheClosure : public NMethodClosure {
|
||||
private:
|
||||
BarrierSetNMethod* const _bs;
|
||||
ShenandoahEvacuateUpdateMetadataClosure<> _cl;
|
||||
ShenandoahEvacuateUpdateMetadataClosure _cl;
|
||||
|
||||
public:
|
||||
ShenandoahEvacUpdateCodeCacheClosure() :
|
||||
@ -893,7 +893,7 @@ public:
|
||||
}
|
||||
|
||||
{
|
||||
ShenandoahEvacuateUpdateMetadataClosure<> cl;
|
||||
ShenandoahEvacuateUpdateMetadataClosure cl;
|
||||
CLDToOopClosure clds(&cl, ClassLoaderData::_claim_strong);
|
||||
_cld_roots.cld_do(&clds, worker_id);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Red Hat, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -74,7 +74,7 @@ void ShenandoahNMethod::oops_do(OopClosure* oops, bool fix_relocations) {
|
||||
}
|
||||
|
||||
void ShenandoahNMethod::heal_nmethod_metadata(ShenandoahNMethod* nmethod_data) {
|
||||
ShenandoahEvacuateUpdateMetadataClosure<> cl;
|
||||
ShenandoahEvacuateUpdateMetadataClosure cl;
|
||||
nmethod_data->oops_do(&cl, true /*fix relocation*/);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user