8247808: Move JVMTI strong oops to OopStorage

Remove JVMTI oops_do calls from JVMTI and GCs

Reviewed-by: sspitsyn, stefank, zgu, dholmes, iklam
This commit is contained in:
Coleen Phillimore 2020-07-16 08:29:11 -04:00
parent 1f5e21a16e
commit 749be7e761
24 changed files with 18 additions and 133 deletions

View File

@ -62,7 +62,6 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
_gc_par_phases[ObjectSynchronizerRoots] = new WorkerDataArray<double>("ObjectSynchronizerRoots", "ObjectSynchronizer Roots (ms):", max_gc_threads);
_gc_par_phases[ManagementRoots] = new WorkerDataArray<double>("ManagementRoots", "Management Roots (ms):", max_gc_threads);
_gc_par_phases[CLDGRoots] = new WorkerDataArray<double>("CLDGRoots", "CLDG Roots (ms):", max_gc_threads);
_gc_par_phases[JVMTIRoots] = new WorkerDataArray<double>("JVMTIRoots", "JVMTI Roots (ms):", max_gc_threads);
AOT_ONLY(_gc_par_phases[AOTCodeRoots] = new WorkerDataArray<double>("AOTCodeRoots", "AOT Root Scan (ms):", max_gc_threads);)
_gc_par_phases[CMRefRoots] = new WorkerDataArray<double>("CMRefRoots", "CM RefProcessor Roots (ms):", max_gc_threads);

View File

@ -52,7 +52,6 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
ObjectSynchronizerRoots,
ManagementRoots,
CLDGRoots,
JVMTIRoots,
AOT_ONLY(AOTCodeRoots COMMA)
CMRefRoots,
// For every OopStorage there will be one element in the enum, starting with

View File

@ -203,13 +203,6 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures,
}
}
{
G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_id);
if (_process_strong_tasks.try_claim_task(G1RP_PS_jvmti_oops_do)) {
JvmtiExport::oops_do(strong_roots);
}
}
#if INCLUDE_AOT
if (UseAOT) {
G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_id);

View File

@ -2024,10 +2024,6 @@ static void mark_from_roots_work(ParallelRootType::Value root_type, uint worker_
Management::oops_do(&mark_and_push_closure);
break;
case ParallelRootType::jvmti:
JvmtiExport::oops_do(&mark_and_push_closure);
break;
case ParallelRootType::class_loader_data:
{
CLDToOopClosure cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_strong);
@ -2241,7 +2237,6 @@ void PSParallelCompact::adjust_roots(ParCompactionManager* cm) {
Threads::oops_do(&oop_closure, NULL);
ObjectSynchronizer::oops_do(&oop_closure);
Management::oops_do(&oop_closure);
JvmtiExport::oops_do(&oop_closure);
OopStorageSet::strong_oops_do(&oop_closure);
CLDToOopClosure cld_closure(&oop_closure, ClassLoaderData::_claim_strong);
ClassLoaderDataGraph::cld_do(&cld_closure);

View File

@ -38,7 +38,6 @@ public:
object_synchronizer,
management,
class_loader_data,
jvmti,
code_cache,
//"threads" are handled in parallel as a special case
sentinel

View File

@ -112,10 +112,6 @@ static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_i
Management::oops_do(&roots_closure);
break;
case ParallelRootType::jvmti:
JvmtiExport::oops_do(&roots_closure);
break;
case ParallelRootType::code_cache:
{
MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);

View File

@ -832,9 +832,6 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope,
if (_process_strong_tasks->try_claim_task(GCH_PS_Management_oops_do)) {
Management::oops_do(strong_roots);
}
if (_process_strong_tasks->try_claim_task(GCH_PS_jvmti_oops_do)) {
JvmtiExport::oops_do(strong_roots);
}
#if INCLUDE_AOT
if (UseAOT && _process_strong_tasks->try_claim_task(GCH_PS_aot_oops_do)) {
AOTLoader::oops_do(strong_roots);

View File

@ -107,11 +107,9 @@ protected:
enum GCH_strong_roots_tasks {
GCH_PS_Universe_oops_do,
GCH_PS_ObjectSynchronizer_oops_do,
GCH_PS_FlatProfiler_oops_do,
GCH_PS_Management_oops_do,
GCH_PS_OopStorageSet_oops_do,
GCH_PS_ClassLoaderDataGraph_oops_do,
GCH_PS_jvmti_oops_do,
GCH_PS_CodeCache_oops_do,
AOT_ONLY(GCH_PS_aot_oops_do COMMA)
GCH_PS_younger_gens,

View File

@ -49,7 +49,6 @@ class outputStream;
f(CNT_PREFIX ## ObjectSynchronizerRoots, DESC_PREFIX "Synchronizer Roots") \
f(CNT_PREFIX ## ManagementRoots, DESC_PREFIX "Management Roots") \
f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \
f(CNT_PREFIX ## JVMTIRoots, DESC_PREFIX "JVMTI Roots") \
f(CNT_PREFIX ## StringDedupTableRoots, DESC_PREFIX "Dedup Table Roots") \
f(CNT_PREFIX ## StringDedupQueueRoots, DESC_PREFIX "Dedup Queue Roots") \
f(CNT_PREFIX ## FinishQueues, DESC_PREFIX "Finish Queues") \

View File

@ -57,15 +57,13 @@ void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
ShenandoahSerialRoots::ShenandoahSerialRoots(ShenandoahPhaseTimings::Phase phase) :
_universe_root(&Universe::oops_do, phase, ShenandoahPhaseTimings::UniverseRoots),
_object_synchronizer_root(&ObjectSynchronizer::oops_do, phase, ShenandoahPhaseTimings::ObjectSynchronizerRoots),
_management_root(&Management::oops_do, phase, ShenandoahPhaseTimings::ManagementRoots),
_jvmti_root(&JvmtiExport::oops_do, phase, ShenandoahPhaseTimings::JVMTIRoots) {
_management_root(&Management::oops_do, phase, ShenandoahPhaseTimings::ManagementRoots) {
}
void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
_universe_root.oops_do(cl, worker_id);
_object_synchronizer_root.oops_do(cl, worker_id);
_management_root.oops_do(cl, worker_id);
_jvmti_root.oops_do(cl, worker_id);
}
ShenandoahWeakSerialRoot::ShenandoahWeakSerialRoot(ShenandoahWeakSerialRoot::WeakOopsDo weak_oops_do,

View File

@ -54,7 +54,6 @@ private:
ShenandoahSerialRoot _universe_root;
ShenandoahSerialRoot _object_synchronizer_root;
ShenandoahSerialRoot _management_root;
ShenandoahSerialRoot _jvmti_root;
public:
ShenandoahSerialRoots(ShenandoahPhaseTimings::Phase phase);
void oops_do(OopClosure* cl, uint worker_id);

View File

@ -78,7 +78,6 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
shenandoah_assert_safepoint();
Universe::oops_do(oops);
Management::oops_do(oops);
JvmtiExport::oops_do(oops);
ObjectSynchronizer::oops_do(oops);
}
@ -124,7 +123,6 @@ void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
Universe::oops_do(oops);
Management::oops_do(oops);
JvmtiExport::oops_do(oops);
JNIHandles::oops_do(oops);
ObjectSynchronizer::oops_do(oops);
OopStorageSet::vm_global()->oops_do(oops);
@ -152,7 +150,6 @@ void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
Universe::oops_do(oops);
Management::oops_do(oops);
JvmtiExport::oops_do(oops);
JNIHandles::oops_do(oops);
ObjectSynchronizer::oops_do(oops);
OopStorageSet::vm_global()->oops_do(oops);

View File

@ -61,7 +61,6 @@ static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
static const ZStatSubPhase ZSubPhasePauseRootsVMThread("Pause Roots VM Thread");
static const ZStatSubPhase ZSubPhasePauseRootsJavaThreads("Pause Roots Java Threads");
@ -198,7 +197,6 @@ ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export) :
_universe(this),
_object_synchronizer(this),
_management(this),
_jvmti_export(this),
_jvmti_weak_export(this),
_vm_thread(this),
_java_threads(this),
@ -240,11 +238,6 @@ void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
Management::oops_do(cl);
}
void ZRootsIterator::do_jvmti_export(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);
JvmtiExport::oops_do(cl);
}
void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
AlwaysTrueClosure always_alive;
@ -273,7 +266,6 @@ void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
_universe.oops_do(cl);
_object_synchronizer.oops_do(cl);
_management.oops_do(cl);
_jvmti_export.oops_do(cl);
_vm_thread.oops_do(cl);
_java_threads.oops_do(cl);
if (!ClassUnloading) {

View File

@ -112,7 +112,6 @@ private:
void do_universe(ZRootsIteratorClosure* cl);
void do_object_synchronizer(ZRootsIteratorClosure* cl);
void do_management(ZRootsIteratorClosure* cl);
void do_jvmti_export(ZRootsIteratorClosure* cl);
void do_jvmti_weak_export(ZRootsIteratorClosure* cl);
void do_vm_thread(ZRootsIteratorClosure* cl);
void do_java_threads(ZRootsIteratorClosure* cl);
@ -121,7 +120,6 @@ private:
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe> _universe;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer> _object_synchronizer;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_management> _management;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_export> _jvmti_export;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_weak_export> _jvmti_weak_export;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_vm_thread> _vm_thread;
ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_java_threads> _java_threads;

View File

@ -37,7 +37,6 @@
#include "memory/universe.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/synchronizer.hpp"
#include "runtime/thread.hpp"
#include "services/management.hpp"
@ -75,7 +74,6 @@ void RootSetClosure<Delegate>::process() {
Threads::oops_do(this, NULL);
ObjectSynchronizer::oops_do(this);
Universe::oops_do(this);
JvmtiExport::oops_do(this);
OopStorageSet::strong_oops_do(this);
Management::oops_do(this);
AOTLoader::oops_do(this);

View File

@ -99,7 +99,6 @@ class ReferenceToRootClosure : public StackObj {
bool do_object_synchronizer_roots();
bool do_universe_roots();
bool do_oop_storage_roots();
bool do_jvmti_roots();
bool do_management_roots();
bool do_string_table_roots();
bool do_aot_loader_roots();
@ -165,13 +164,6 @@ bool ReferenceToRootClosure::do_oop_storage_roots() {
return false;
}
bool ReferenceToRootClosure::do_jvmti_roots() {
assert(!complete(), "invariant");
ReferenceLocateClosure rlc(_callback, OldObjectRoot::_jvmti, OldObjectRoot::_global_jni_handle, NULL);
JvmtiExport::oops_do(&rlc);
return rlc.complete();
}
bool ReferenceToRootClosure::do_management_roots() {
assert(!complete(), "invariant");
ReferenceLocateClosure rlc(_callback, OldObjectRoot::_management, OldObjectRoot::_type_undetermined, NULL);
@ -211,11 +203,6 @@ bool ReferenceToRootClosure::do_roots() {
return true;
}
if (do_jvmti_roots()) {
_complete = true;
return true;
}
if (do_management_roots()) {
_complete = true;
return true;

View File

@ -60,8 +60,6 @@ const char* OldObjectRoot::system_description(System system) {
return "Class Loader Data";
case _management:
return "Management";
case _jvmti:
return "JVMTI";
case _code_cache:
return "Code Cache";
case _aot:

View File

@ -39,7 +39,6 @@ class OldObjectRoot : public AllStatic {
_object_synchronizer,
_class_loader_data,
_management,
_jvmti,
_code_cache,
_aot,
JVMCI_ONLY(_jvmci COMMA)

View File

@ -29,6 +29,7 @@
#include "code/nmethod.hpp"
#include "code/pcDesc.hpp"
#include "code/scopeDesc.hpp"
#include "gc/shared/oopStorageSet.hpp"
#include "interpreter/interpreter.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "logging/log.hpp"
@ -39,6 +40,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
#include "oops/oopHandle.inline.hpp"
#include "prims/jvmtiCodeBlobEvents.hpp"
#include "prims/jvmtiEventController.hpp"
#include "prims/jvmtiEventController.inline.hpp"
@ -2599,10 +2601,6 @@ void JvmtiExport::clear_detected_exception(JavaThread* thread) {
}
}
void JvmtiExport::oops_do(OopClosure* f) {
JvmtiObjectAllocEventCollector::oops_do_for_all_threads(f);
}
void JvmtiExport::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
JvmtiTagMap::weak_oops_do(is_alive, f);
}
@ -2828,8 +2826,11 @@ void JvmtiObjectAllocEventCollector::generate_call_for_allocated() {
if (_allocated) {
set_enabled(false);
for (int i = 0; i < _allocated->length(); i++) {
oop obj = _allocated->at(i);
oop obj = _allocated->at(i).resolve();
_post_callback(JavaThread::current(), obj);
// Release OopHandle
_allocated->at(i).release(OopStorageSet::vm_global());
}
delete _allocated, _allocated = NULL;
}
@ -2838,48 +2839,11 @@ void JvmtiObjectAllocEventCollector::generate_call_for_allocated() {
void JvmtiObjectAllocEventCollector::record_allocation(oop obj) {
assert(is_enabled(), "Object alloc event collector is not enabled");
if (_allocated == NULL) {
_allocated = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray<oop>(1, mtServiceability);
_allocated = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray<OopHandle>(1, mtServiceability);
}
_allocated->push(obj);
_allocated->push(OopHandle(OopStorageSet::vm_global(), obj));
}
// GC support.
void JvmtiObjectAllocEventCollector::oops_do(OopClosure* f) {
if (_allocated) {
for(int i = _allocated->length() - 1; i >= 0; i--) {
if (_allocated->at(i) != NULL) {
f->do_oop(_allocated->adr_at(i));
}
}
}
}
void JvmtiObjectAllocEventCollector::oops_do_for_all_threads(OopClosure* f) {
// no-op if jvmti not enabled
if (!JvmtiEnv::environments_might_exist()) {
return;
}
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jthr = jtiwh.next(); ) {
JvmtiThreadState *state = jthr->jvmti_thread_state();
if (state != NULL) {
JvmtiObjectAllocEventCollector *collector;
collector = state->get_vm_object_alloc_event_collector();
while (collector != NULL) {
collector->oops_do(f);
collector = (JvmtiObjectAllocEventCollector*) collector->get_prev();
}
collector = state->get_sampled_object_alloc_event_collector();
while (collector != NULL) {
collector->oops_do(f);
collector = (JvmtiObjectAllocEventCollector*) collector->get_prev();
}
}
}
}
// Disable collection of VMObjectAlloc events
NoJvmtiVMObjectAllocMark::NoJvmtiVMObjectAllocMark() : _collector(NULL) {
// a no-op if VMObjectAlloc event is not enabled

View File

@ -29,6 +29,7 @@
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "oops/oop.hpp"
#include "oops/oopHandle.hpp"
#include "oops/oopsHierarchy.hpp"
#include "runtime/frame.hpp"
#include "runtime/handles.hpp"
@ -394,7 +395,6 @@ class JvmtiExport : public AllStatic {
static void cleanup_thread (JavaThread* thread) NOT_JVMTI_RETURN;
static void clear_detected_exception (JavaThread* thread) NOT_JVMTI_RETURN;
static void oops_do(OopClosure* f) NOT_JVMTI_RETURN;
static void weak_oops_do(BoolObjectClosure* b, OopClosure* f) NOT_JVMTI_RETURN;
static void transition_pending_onload_raw_monitors() NOT_JVMTI_RETURN;
@ -491,24 +491,18 @@ class JvmtiDynamicCodeEventCollector : public JvmtiEventCollector {
//
class JvmtiObjectAllocEventCollector : public JvmtiEventCollector {
protected:
GrowableArray<oop>* _allocated; // field to record collected allocated object oop.
GrowableArray<OopHandle>* _allocated; // field to record collected allocated object oop.
bool _enable; // This flag is enabled in constructor if set up in the thread state
// and disabled in destructor before posting event. To avoid
// collection of objects allocated while running java code inside
// agent post_X_object_alloc() event handler.
void (*_post_callback)(JavaThread*, oop); // what callback to use when destroying the collector.
//GC support
void oops_do(OopClosure* f);
friend class JvmtiExport;
// Record allocated object oop.
inline void record_allocation(oop obj);
//GC support
static void oops_do_for_all_threads(OopClosure* f);
public:
JvmtiObjectAllocEventCollector() NOT_JVMTI_RETURN;

View File

@ -198,35 +198,23 @@ void GrowableCache::clear() {
//
JvmtiBreakpoint::JvmtiBreakpoint(Method* m_method, jlocation location)
: _method(m_method), _bci((int)location), _class_holder(NULL) {
: _method(m_method), _bci((int)location) {
assert(_method != NULL, "No method for breakpoint.");
assert(_bci >= 0, "Negative bci for breakpoint.");
oop class_holder_oop = _method->method_holder()->klass_holder();
_class_holder = OopStorageSet::vm_global()->allocate();
if (_class_holder == NULL) {
vm_exit_out_of_memory(sizeof(oop), OOM_MALLOC_ERROR,
"Cannot create breakpoint oop handle");
}
NativeAccess<>::oop_store(_class_holder, class_holder_oop);
_class_holder = OopHandle(OopStorageSet::vm_global(), class_holder_oop);
}
JvmtiBreakpoint::~JvmtiBreakpoint() {
if (_class_holder != NULL) {
NativeAccess<>::oop_store(_class_holder, (oop)NULL);
OopStorageSet::vm_global()->release(_class_holder);
if (_class_holder.peek() != NULL) {
_class_holder.release(OopStorageSet::vm_global());
}
}
void JvmtiBreakpoint::copy(JvmtiBreakpoint& bp) {
_method = bp._method;
_bci = bp._bci;
_class_holder = OopStorageSet::vm_global()->allocate();
if (_class_holder == NULL) {
vm_exit_out_of_memory(sizeof(oop), OOM_MALLOC_ERROR,
"Cannot create breakpoint oop handle");
}
oop resolved_ch = NativeAccess<>::oop_load(bp._class_holder);
NativeAccess<>::oop_store(_class_holder, resolved_ch);
_class_holder = OopHandle(OopStorageSet::vm_global(), bp._class_holder.resolve());
}
bool JvmtiBreakpoint::equals(JvmtiBreakpoint& bp) {

View File

@ -159,10 +159,10 @@ class JvmtiBreakpoint : public GrowableElement {
private:
Method* _method;
int _bci;
oop* _class_holder; // keeps _method memory from being deallocated
OopHandle _class_holder; // keeps _method memory from being deallocated
public:
JvmtiBreakpoint() : _method(NULL), _bci(0), _class_holder(NULL) {}
JvmtiBreakpoint() : _method(NULL), _bci(0) {}
JvmtiBreakpoint(Method* m_method, jlocation location);
virtual ~JvmtiBreakpoint();
bool equals(JvmtiBreakpoint& bp);

View File

@ -125,7 +125,6 @@ public class TestGCLogMessages {
new LogMessageWithLevel("ObjectSynchronizer Roots", Level.TRACE),
new LogMessageWithLevel("Management Roots", Level.TRACE),
new LogMessageWithLevel("CLDG Roots", Level.TRACE),
new LogMessageWithLevel("JVMTI Roots", Level.TRACE),
new LogMessageWithLevel("CM RefProcessor Roots", Level.TRACE),
new LogMessageWithLevel("JNI Global Roots", Level.TRACE),
new LogMessageWithLevel("VM Global Roots", Level.TRACE),

View File

@ -97,7 +97,6 @@ public class TestG1ParallelPhases {
"VM Global",
"JNI Global",
"CLDGRoots",
"JVMTIRoots",
"CMRefRoots",
"MergeER",
"MergeHCC",