Skip to content
Permalink
Browse files

JFR infrastructure for Loom

  • Loading branch information
mgronlun committed Feb 2, 2020
1 parent 50b2668 commit ce6ad9b96de2e3406ebd2484bb9dbe47ce27b182
Showing with 1,119 additions and 451 deletions.
  1. +1 −1 src/hotspot/share/c1/c1_Compiler.cpp
  2. +4 −0 src/hotspot/share/c1/c1_LIRGenerator.cpp
  3. +1 −1 src/hotspot/share/c1/c1_LIRGenerator.hpp
  4. +10 −8 src/hotspot/share/classfile/javaClasses.cpp
  5. +10 −3 src/hotspot/share/classfile/javaClasses.hpp
  6. +10 −1 src/hotspot/share/classfile/javaClasses.inline.hpp
  7. +2 −1 src/hotspot/share/classfile/vmSymbols.hpp
  8. +10 −1 src/hotspot/share/jfr/jfr.cpp
  9. +2 −0 src/hotspot/share/jfr/jfr.hpp
  10. +71 −46 src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
  11. +17 −6 src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
  12. +3 −3 src/hotspot/share/jfr/leakprofiler/checkpoint/eventEmitter.cpp
  13. +5 −5 src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp
  14. +2 −3 src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp
  15. +31 −19 src/hotspot/share/jfr/leakprofiler/sampling/objectSample.hpp
  16. +36 −12 src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
  17. +3 −3 src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.hpp
  18. +3 −0 src/hotspot/share/jfr/metadata/metadata.xml
  19. +5 −6 src/hotspot/share/jfr/periodic/jfrThreadCPULoadEvent.cpp
  20. +14 −12 src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp
  21. +4 −4 src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
  22. +5 −3 src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.hpp
  23. +11 −3 src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp
  24. +25 −13 src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadState.cpp
  25. +4 −4 src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadState.hpp
  26. +26 −18 src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
  27. +4 −2 src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
  28. +12 −14 src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
  29. +4 −3 src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp
  30. +44 −0 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrOopTraceId.hpp
  31. +83 −0 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrOopTraceId.inline.hpp
  32. +14 −5 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp
  33. +1 −0 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp
  34. +3 −1 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp
  35. +10 −1 src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp
  36. +11 −1 src/hotspot/share/jfr/recorder/jfrRecorder.cpp
  37. +1 −0 src/hotspot/share/jfr/recorder/jfrRecorder.hpp
  38. +1 −1 src/hotspot/share/jfr/recorder/service/jfrEvent.hpp
  39. +163 −84 src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp
  40. +5 −4 src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.hpp
  41. +14 −12 src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
  42. +4 −4 src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp
  43. +1 −1 src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp
  44. +3 −1 src/hotspot/share/jfr/support/jfrEpochSynchronization.hpp
  45. +4 −1 src/hotspot/share/jfr/support/jfrIntrinsics.hpp
  46. +4 −2 src/hotspot/share/jfr/support/jfrThreadId.hpp
  47. +112 −34 src/hotspot/share/jfr/support/jfrThreadLocal.cpp
  48. +18 −11 src/hotspot/share/jfr/support/jfrThreadLocal.hpp
  49. +131 −0 src/hotspot/share/jfr/support/jfrVirtualThread.cpp
  50. +47 −0 src/hotspot/share/jfr/support/jfrVirtualThread.hpp
  51. +4 −1 src/hotspot/share/jfr/utilities/jfrTypes.hpp
  52. +22 −34 src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp
  53. +2 −2 src/hotspot/share/opto/c2compiler.cpp
  54. +7 −3 src/hotspot/share/opto/library_call.cpp
  55. +9 −4 src/hotspot/share/prims/jvm.cpp
  56. +48 −43 src/hotspot/share/runtime/continuation.cpp
  57. +12 −1 src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedThread.java
  58. +2 −1 src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
  59. +2 −2 src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java
  60. +2 −2 test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java
@@ -228,7 +228,7 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
case vmIntrinsics::_Continuation_runLevel:
#ifdef JFR_HAVE_INTRINSICS
case vmIntrinsics::_counterTime:
case vmIntrinsics::_getEventWriter:
//case vmIntrinsics::_getEventWriter:
#if defined(_LP64) || !defined(TRACE_ID_SHIFT)
case vmIntrinsics::_getClassId:
#endif
@@ -2964,6 +2964,7 @@ void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
__ move(id, rlock_result(x));
}

/*
void LIRGenerator::do_getEventWriter(Intrinsic* x) {
LabelObj* L_end = new LabelObj();
@@ -2981,6 +2982,7 @@ void LIRGenerator::do_getEventWriter(Intrinsic* x) {
__ branch_destination(L_end->label());
}
*/

#endif

@@ -3013,9 +3015,11 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) {
case vmIntrinsics::_getClassId:
do_ClassIDIntrinsic(x);
break;
/*
case vmIntrinsics::_getEventWriter:
do_getEventWriter(x);
break;
*/
case vmIntrinsics::_counterTime:
do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
break;
@@ -478,7 +478,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure {

#ifdef JFR_HAVE_INTRINSICS
void do_ClassIDIntrinsic(Intrinsic* x);
void do_getEventWriter(Intrinsic* x);
// void do_getEventWriter(Intrinsic* x);
#endif

void do_RuntimeCall(address routine, Intrinsic* x);
@@ -2028,13 +2028,13 @@ void java_lang_ThreadGroup::serialize_offsets(SerializeClosure* f) {


// java_lang_VirtualThread

int java_lang_VirtualThread::static_notify_jvmti_events_offset = 0;
int java_lang_VirtualThread::_carrierThread_offset = 0;
int java_lang_VirtualThread::_continuation_offset = 0;
int java_lang_VirtualThread::_state_offset = 0;
int java_lang_VirtualThread::_jfrTraceId_offset = 0;

#define FIBER_FIELDS_DO(macro) \
#define VTHREAD_FIELDS_DO(macro) \
macro(static_notify_jvmti_events_offset, k, "notifyJvmtiEvents", bool_signature, true); \
macro(_carrierThread_offset, k, "carrierThread", thread_signature, false); \
macro(_continuation_offset, k, "cont", continuation_signature, false); \
@@ -2044,7 +2044,8 @@ static jboolean vthread_notify_jvmti_events = JNI_FALSE;

void java_lang_VirtualThread::compute_offsets() {
InstanceKlass* k = SystemDictionary::VirtualThread_klass();
FIBER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
VTHREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
VTHREAD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
}

void java_lang_VirtualThread::init_static_notify_jvmti_events() {
@@ -2063,7 +2064,7 @@ oop java_lang_VirtualThread::carrier_thread(oop vthread) {
oop thread = vthread->obj_field(_carrierThread_offset);
return thread;
}

oop java_lang_VirtualThread::continuation(oop vthread) {
oop cont = vthread->obj_field(_continuation_offset);
return cont;
@@ -2101,7 +2102,8 @@ java_lang_Thread::ThreadStatus java_lang_VirtualThread::map_state_to_thread_stat

#if INCLUDE_CDS
void java_lang_VirtualThread::serialize_offsets(SerializeClosure* f) {
FIBER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
VTHREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
VTHREAD_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
}
#endif

@@ -2282,7 +2284,7 @@ class BacktraceBuilder: public StackObj {
_has_hidden_top_frame = get_has_hidden_top_frame(backtrace);
assert(_methods->length() == _bcis->length() &&
_methods->length() == _mirrors->length() &&
_mirrors->length() == _names->length() &&
_mirrors->length() == _names->length() &&
_names->length() == _conts->length(),
"method and source information arrays should match");

@@ -2857,7 +2859,7 @@ void java_lang_Throwable::get_stack_trace_elements(Handle throwable,
method,
bte._version,
bte._bci,
bte._name,
bte._name,
bte._cont,
CHECK);
}
@@ -4865,7 +4867,7 @@ bool java_lang_Continuation::on_local_stack(oop ref, address adr) {
void* base = s->base(T_INT);
return adr >= base && (char*)adr < ((char*)base + (s->length() * 4));
}

bool java_lang_Continuation::is_mounted(oop ref) {
return ref->bool_field(_mounted_offset) != 0;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. 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
@@ -576,13 +576,17 @@ class java_lang_ThreadGroup : AllStatic {

// Interface to java.lang.VirtualThread objects

#define VTHREAD_INJECTED_FIELDS(macro) \
macro(java_lang_VirtualThread, jfrTraceId, long_signature, false)

class java_lang_VirtualThread : AllStatic {
private:
static int static_notify_jvmti_events_offset;
static int _carrierThread_offset;
static int _continuation_offset;
static int _state_offset;
// keep in sync with java.lang.VirtualThread
static int _jfrTraceId_offset;
enum {
NEW = 0,
STARTED = 1,
@@ -610,6 +614,8 @@ class java_lang_VirtualThread : AllStatic {
static java_lang_Thread::ThreadStatus map_state_to_thread_status(jshort state);
static void set_notify_jvmti_events(jboolean enable);
static void init_static_notify_jvmti_events();
static jlong jfrTraceId(oop vthread);
static jlong set_jfrTraceId(oop vthread, jlong id);
};


@@ -1076,7 +1082,7 @@ class java_lang_ContinuationScope: AllStatic {

static inline oop name(oop ref);
};

// Interface to java.lang.Continuation objects
class java_lang_Continuation: AllStatic {
friend class JavaClasses;
@@ -1937,7 +1943,8 @@ class InjectedField {
MEMBERNAME_INJECTED_FIELDS(macro) \
CALLSITECONTEXT_INJECTED_FIELDS(macro) \
STACKFRAMEINFO_INJECTED_FIELDS(macro) \
MODULE_INJECTED_FIELDS(macro)
MODULE_INJECTED_FIELDS(macro) \
VTHREAD_INJECTED_FIELDS(macro)

// Interface to hard-coded offset checking

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. 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
@@ -292,6 +292,15 @@ inline bool java_lang_Continuation::done(oop ref) {
return ref->bool_field(_done_offset);
}

inline jlong java_lang_VirtualThread::jfrTraceId(oop ref) {
return ref->long_field(_jfrTraceId_offset);
}

inline jlong java_lang_VirtualThread::set_jfrTraceId(oop ref, jlong id) {
ref->long_field_put(_jfrTraceId_offset, id);
return id;
}

inline oop jdk_internal_misc_StackChunk::parent(oop ref) {
return ref->obj_field(_parent_offset);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. 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
@@ -403,6 +403,7 @@
template(done_name, "done") \
template(mounted_name, "mounted") \
template(numInterpretedFrames_name, "numInterpretedFrames") \
template(jfrTraceId_name, "jfrTraceId") \
template(fp_name, "fp") \
template(sp_name, "sp") \
template(pc_name, "pc") \
@@ -24,6 +24,7 @@

#include "precompiled.hpp"
#include "jfr/jfr.hpp"
#include "jfr/jni/jfrJavaSupport.hpp"
#include "jfr/leakprofiler/leakProfiler.hpp"
#include "jfr/periodic/sampling/jfrThreadSampler.hpp"
#include "jfr/recorder/jfrRecorder.hpp"
@@ -73,10 +74,18 @@ void Jfr::on_thread_start(Thread* t) {
JfrThreadLocal::on_start(t);
}

void Jfr::on_thread_start(jthread carrier_thread, jthread vthread) {
JfrThreadLocal::on_vthread_start(JfrJavaSupport::java_thread(carrier_thread), vthread);
}

void Jfr::on_thread_exit(Thread* t) {
JfrThreadLocal::on_exit(t);
}

void Jfr::on_thread_exit(jthread carrier_thread, jthread vthread) {
JfrThreadLocal::on_vthread_exit(JfrJavaSupport::java_thread(carrier_thread), vthread);
}

void Jfr::exclude_thread(Thread* t) {
JfrThreadLocal::exclude(t);
}
@@ -91,7 +100,7 @@ bool Jfr::is_excluded(Thread* t) {

void Jfr::on_java_thread_dismantle(JavaThread* jt) {
if (JfrRecorder::is_recording()) {
JfrCheckpointManager::write_thread_checkpoint(jt);
JfrCheckpointManager::write_checkpoint(jt);
}
}

@@ -48,7 +48,9 @@ class Jfr : AllStatic {
static void on_create_vm_3();
static void on_unloading_classes();
static void on_thread_start(Thread* thread);
static void on_thread_start(jthread carrier_thread, jthread vthread);
static void on_thread_exit(Thread* thread);
static void on_thread_exit(jthread carrier_thread, jthread vthread);
static void on_java_thread_dismantle(JavaThread* jt);
static void on_vm_shutdown(bool exception_handler = false);
static bool on_flight_recorder_option(const JavaVMOption** option, char* delimiter);

0 comments on commit ce6ad9b

Please sign in to comment.
You can’t perform that action at this time.