Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8235573: Move JFR ObjectSample oop into OopStorage
Reviewed-by: mgronlun, dholmes, kbarrett
  • Loading branch information
coleenp committed Aug 5, 2020
1 parent ceb4ae8 commit f9e00a2600fe390b35b541394404159ae5800072
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 134 deletions.
@@ -38,7 +38,7 @@ class OopStorageSet : public AllStatic {
public:
// Must be updated when new OopStorages are introduced
static const uint strong_count = 2;
static const uint weak_count = 4;
static const uint weak_count = 4 JFR_ONLY(+ 1);
static const uint all_count = strong_count + weak_count;

private:
@@ -27,19 +27,15 @@
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"

#if INCLUDE_JFR
#include "jfr/jfr.hpp"
#endif // INCLUDE_JFR

#if INCLUDE_JVMTI
#include "prims/jvmtiExport.hpp"
#endif // INCLUDE_JVMTI

// serial_phase_count is 0 if JFR and JVMTI are both not built,
// serial_phase_count is 0 if JVMTI is not built,
// requiring some code to be careful to avoid tautological checks
// that some compilers warn about.

#define HAVE_SERIAL_PHASES (INCLUDE_JVMTI || INCLUDE_JFR)
#define HAVE_SERIAL_PHASES INCLUDE_JVMTI

WeakProcessorPhases::Phase WeakProcessorPhases::serial_phase(uint value) {
#if HAVE_SERIAL_PHASES
@@ -109,7 +105,6 @@ void WeakProcessorPhases::Iterator::verify_dereferenceable() const {
const char* WeakProcessorPhases::description(Phase phase) {
switch (phase) {
JVMTI_ONLY(case jvmti: return "JVMTI weak processing";)
JFR_ONLY(case jfr: return "JFR weak processing";)
default:
ShouldNotReachHere();
return "Invalid serial weak processing phase";
@@ -119,7 +114,6 @@ const char* WeakProcessorPhases::description(Phase phase) {
WeakProcessorPhases::Processor WeakProcessorPhases::processor(Phase phase) {
switch (phase) {
JVMTI_ONLY(case jvmti: return &JvmtiExport::weak_oops_do;)
JFR_ONLY(case jfr: return &Jfr::weak_oops_do;)
default:
ShouldNotReachHere();
return NULL;
@@ -41,15 +41,14 @@ class WeakProcessorPhases : AllStatic {
typedef void (*Processor)(BoolObjectClosure*, OopClosure*);

enum Phase {
// Serial phases.
JVMTI_ONLY(jvmti JFR_ONLY(COMMA))
JFR_ONLY(jfr)
// Serial phase.
JVMTI_ONLY(jvmti)

// Additional implicit phase values follow for oopstorages.
};

static const uint serial_phase_start = 0;
static const uint serial_phase_count = 0 JVMTI_ONLY(+ 1) JFR_ONLY(+ 1);
static const uint serial_phase_count = 0 JVMTI_ONLY(+ 1);
static const uint oopstorage_phase_start = serial_phase_count;
static const uint oopstorage_phase_count = OopStorageSet::weak_count;
static const uint phase_count = serial_phase_count + oopstorage_phase_count;
@@ -25,7 +25,6 @@
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHPHASETIMINGS_HPP
#define SHARE_GC_SHENANDOAH_SHENANDOAHPHASETIMINGS_HPP

#include "jfr/jfrEvents.hpp"
#include "gc/shenandoah/shenandoahNumberSeq.hpp"
#include "gc/shared/workerDataArray.hpp"
#include "memory/allocation.hpp"
@@ -43,7 +42,6 @@ class outputStream;
f(CNT_PREFIX ## ObjectSynchronizerRoots, DESC_PREFIX "Synchronizer Roots") \
f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \
f(CNT_PREFIX ## JVMTIWeakRoots, DESC_PREFIX "JVMTI Weak Roots") \
f(CNT_PREFIX ## JFRWeakRoots, DESC_PREFIX "JFR Weak 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") \
@@ -35,7 +35,6 @@
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "gc/shenandoah/shenandoahStringDedup.hpp"
#include "gc/shenandoah/shenandoahVMOperations.hpp"
#include "jfr/jfr.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
@@ -81,15 +80,8 @@ ShenandoahJVMTIWeakRoot::ShenandoahJVMTIWeakRoot(ShenandoahPhaseTimings::Phase p
}
#endif // INCLUDE_JVMTI

#if INCLUDE_JFR
ShenandoahJFRWeakRoot::ShenandoahJFRWeakRoot(ShenandoahPhaseTimings::Phase phase) :
ShenandoahWeakSerialRoot(&Jfr::weak_oops_do, phase, ShenandoahPhaseTimings::JFRWeakRoots) {
}
#endif // INCLUDE_JFR

void ShenandoahSerialWeakRoots::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id) {
JVMTI_ONLY(_jvmti_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);)
JFR_ONLY(_jfr_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);)
}

void ShenandoahSerialWeakRoots::weak_oops_do(OopClosure* cl, uint worker_id) {
@@ -79,21 +79,12 @@ class ShenandoahJVMTIWeakRoot : public ShenandoahWeakSerialRoot {
};
#endif // INCLUDE_JVMTI

#if INCLUDE_JFR
class ShenandoahJFRWeakRoot : public ShenandoahWeakSerialRoot {
public:
ShenandoahJFRWeakRoot(ShenandoahPhaseTimings::Phase phase);
};
#endif // INCLUDE_JFR

class ShenandoahSerialWeakRoots {
private:
JVMTI_ONLY(ShenandoahJVMTIWeakRoot _jvmti_weak_roots;)
JFR_ONLY(ShenandoahJFRWeakRoot _jfr_weak_roots;)
public:
ShenandoahSerialWeakRoots(ShenandoahPhaseTimings::Phase phase)
JVMTI_ONLY(: _jvmti_weak_roots(phase))
JFR_ONLY(NOT_JVMTI(:) JVMTI_ONLY(COMMA) _jfr_weak_roots(phase))
{};

void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id);
@@ -50,9 +50,6 @@
#include "runtime/thread.hpp"
#include "runtime/vmThread.hpp"
#include "utilities/debug.hpp"
#if INCLUDE_JFR
#include "jfr/jfr.hpp"
#endif

static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
@@ -74,7 +71,6 @@ static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"
static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");

static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsOopStorageSet("Concurrent Weak Roots OopStorageSet");
@@ -295,8 +291,7 @@ void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
}

ZWeakRootsIterator::ZWeakRootsIterator() :
_jvmti_weak_export(this),
_jfr_weak(this) {
_jvmti_weak_export(this) {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
}
@@ -310,17 +305,9 @@ void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRoot
JvmtiExport::weak_oops_do(is_alive, cl);
}

void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
#if INCLUDE_JFR
ZStatTimer timer(ZSubPhasePauseWeakRootsJFRWeak);
Jfr::weak_oops_do(is_alive, cl);
#endif
}

void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseWeakRoots);
_jvmti_weak_export.weak_oops_do(is_alive, cl);
_jfr_weak.weak_oops_do(is_alive, cl);
}

void ZWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
@@ -170,10 +170,8 @@ class ZConcurrentRootsIteratorClaimNone : public ZConcurrentRootsIterator {
class ZWeakRootsIterator {
private:
void do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
void do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);

ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export> _jvmti_weak_export;
ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak> _jfr_weak;

public:
ZWeakRootsIterator();
@@ -102,12 +102,6 @@ void Jfr::on_vm_error_report(outputStream* st) {
}
}

void Jfr::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
if (LeakProfiler::is_running()) {
LeakProfiler::weak_oops_do(is_alive, f);
}
}

bool Jfr::on_flight_recorder_option(const JavaVMOption** option, char* delimiter) {
return JfrOptionSet::parse_flight_recorder_option(option, delimiter);
}
@@ -28,9 +28,7 @@
#include "jni.h"
#include "memory/allocation.hpp"

class BoolObjectClosure;
class JavaThread;
class OopClosure;
class Thread;

extern "C" void JNICALL jfr_register_natives(JNIEnv*, jclass);
@@ -53,7 +51,6 @@ class Jfr : AllStatic {
static bool on_flight_recorder_option(const JavaVMOption** option, char* delimiter);
static bool on_start_flight_recording_option(const JavaVMOption** option, char* delimiter);
static void on_vm_error_report(outputStream* st);
static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
static void exclude_thread(Thread* thread);
static bool is_excluded(Thread* thread);
static void include_thread(Thread* thread);
@@ -89,14 +89,6 @@ void LeakProfiler::emit_events(int64_t cutoff_ticks, bool emit_all, bool skip_bf
ObjectSampler::release();
}

void LeakProfiler::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
assert(SafepointSynchronize::is_at_safepoint(),
"Leak Profiler::oops_do(...) may only be called during safepoint");
if (is_running()) {
ObjectSampler::weak_oops_do(is_alive, f);
}
}

void LeakProfiler::sample(HeapWord* object, size_t size, JavaThread* thread) {
assert(is_running(), "invariant");
assert(thread != NULL, "invariant");
@@ -27,8 +27,6 @@

#include "memory/allocation.hpp"

class BoolObjectClosure;
class OopClosure;
class JavaThread;

class LeakProfiler : public AllStatic {
@@ -39,9 +37,6 @@ class LeakProfiler : public AllStatic {

static void emit_events(int64_t cutoff_ticks, bool emit_all, bool skip_bfs);
static void sample(HeapWord* object, size_t size, JavaThread* thread);

// Called by GC
static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
};

#endif // SHARE_JFR_LEAKPROFILER_LEAKPROFILER_HPP
@@ -23,16 +23,36 @@
*/
#include "precompiled.hpp"
#include "jfr/leakprofiler/sampling/objectSample.hpp"
#include "oops/access.inline.hpp"
#include "jfr/leakprofiler/sampling/objectSampler.hpp"
#include "oops/weakHandle.inline.hpp"
#include "runtime/handles.inline.hpp"

void ObjectSample::reset() {
release();
set_stack_trace_id(0);
set_stack_trace_hash(0);
release_references();
}

const oop ObjectSample::object() const {
return NativeAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(&_object);
return _object.resolve();
}

bool ObjectSample::is_dead() const {
return _object.peek() == NULL;
}

const oop ObjectSample::object_raw() const {
return RawAccess<>::oop_load(&_object);
const oop* ObjectSample::object_addr() const {
return _object.ptr_raw();
}

void ObjectSample::set_object(oop object) {
NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(&_object, object);
assert(_object.is_empty(), "should be empty");
Handle h(Thread::current(), object);
_object = WeakHandle(ObjectSampler::oop_storage(), h);
}

void ObjectSample::release() {
_object.release(ObjectSampler::oop_storage());
_object = WeakHandle();
}
@@ -31,6 +31,7 @@
#include "jfr/utilities/jfrTypes.hpp"
#include "memory/allocation.hpp"
#include "oops/oop.hpp"
#include "oops/weakHandle.hpp"
#include "utilities/ticks.hpp"

/*
@@ -48,7 +49,7 @@ class ObjectSample : public JfrCHeapObj {
JfrBlobHandle _stacktrace;
JfrBlobHandle _thread;
JfrBlobHandle _type_set;
oop _object;
WeakHandle _object;
Ticks _allocation_time;
traceid _stack_trace_id;
traceid _thread_id;
@@ -64,20 +65,14 @@ class ObjectSample : public JfrCHeapObj {
_type_set.~JfrBlobHandle();
}

void reset() {
_object = NULL;
set_stack_trace_id(0);
set_stack_trace_hash(0);
release_references();
}
void reset();

public:
ObjectSample() : _next(NULL),
_previous(NULL),
_stacktrace(),
_thread(),
_type_set(),
_object(NULL),
_allocation_time(),
_stack_trace_id(0),
_thread_id(0),
@@ -103,17 +98,14 @@ class ObjectSample : public JfrCHeapObj {
_previous = prev;
}

bool is_dead() const {
return object() == NULL;
}
bool is_dead() const;

const oop object() const;
const oop object_raw() const;
void set_object(oop object);

const oop* object_addr() const {
return &_object;
}
const oop* object_addr() const;

void release();

int index() const {
return _index;

0 comments on commit f9e00a2

Please sign in to comment.