Skip to content

Commit 4afe252

Browse files
committed
Changed name to CHUNK_ROTATION_MONITOR and made some other rearrangements
1 parent ff74940 commit 4afe252

File tree

6 files changed

+33
-25
lines changed

6 files changed

+33
-25
lines changed

src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static jobject install_chunk_monitor(JavaThread* thread) {
3838
// read static field
3939
HandleMark hm(thread);
4040
static const char klass[] = "jdk/jfr/internal/JVM";
41-
static const char field[] = "FILE_DELTA_CHANGE";
41+
static const char field[] = "CHUNK_ROTATION_MONITOR";
4242
static const char signature[] = "Ljava/lang/Object;";
4343
JavaValue result(T_OBJECT);
4444
JfrJavaArguments field_args(&result, klass, field, signature, thread);

src/hotspot/share/jfr/support/jfrIntrinsics.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class JfrIntrinsicSupport : AllStatic {
5252
template(getEventWriter_signature, "()Ljdk/jfr/internal/event/EventWriter;") \
5353
template(eventConfiguration_name, "eventConfiguration") \
5454
template(commit_name, "commit") \
55+
template(jfr_chunk_rotation_monitor, "jdk/jfr/internal/JVM$ChunkRotationMonitor") \
5556

5657
#define JFR_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias) \
5758
do_intrinsic(_counterTime, jdk_jfr_internal_JVM, counterTime_name, void_long_signature, F_SN) \

src/hotspot/share/runtime/objectMonitor.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,31 +1416,32 @@ bool ObjectMonitor::check_owner(TRAPS) {
14161416
"current thread is not owner", false);
14171417
}
14181418

1419+
static inline bool is_excluded(const Klass* monitor_klass) {
1420+
assert(monitor_klass != nullptr, "invariant");
1421+
NOT_JFR_RETURN_(false);
1422+
JFR_ONLY(return vmSymbols::jfr_chunk_rotation_monitor() == monitor_klass->name());
1423+
}
1424+
14191425
static void post_monitor_wait_event(EventJavaMonitorWait* event,
14201426
ObjectMonitor* monitor,
14211427
uint64_t notifier_tid,
14221428
jlong timeout,
14231429
bool timedout) {
1424-
bool includeEvent = true;
1425-
Klass* objectMonitorClass;
14261430
assert(event != NULL, "invariant");
14271431
assert(monitor != NULL, "invariant");
1428-
objectMonitorClass = monitor->object()->klass();
1429-
if (objectMonitorClass != NULL &&
1430-
objectMonitorClass->name()->equals("jdk/jfr/internal/FileDeltaChangeLockObject")) {
1431-
includeEvent = false;
1432-
}
1433-
if (includeEvent) {
1434-
event->set_monitorClass(objectMonitorClass);
1435-
event->set_timeout(timeout);
1436-
// Set an address that is 'unique enough', such that events close in
1437-
// time and with the same address are likely (but not guaranteed) to
1438-
// belong to the same object.
1439-
event->set_address((uintptr_t)monitor);
1440-
event->set_notifier(notifier_tid);
1441-
event->set_timedOut(timedout);
1442-
event->commit();
1432+
const Klass* monitor_klass = monitor->object()->klass();
1433+
if (is_excluded(monitor_klass)) {
1434+
return;
14431435
}
1436+
event->set_monitorClass(monitor_klass);
1437+
event->set_timeout(timeout);
1438+
// Set an address that is 'unique enough', such that events close in
1439+
// time and with the same address are likely (but not guaranteed) to
1440+
// belong to the same object.
1441+
event->set_address((uintptr_t)monitor);
1442+
event->set_notifier(notifier_tid);
1443+
event->set_timedOut(timedout);
1444+
event->commit();
14441445
}
14451446

14461447
// -----------------------------------------------------------------------------

src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@
3939
public final class JVM {
4040
private static final JVM jvm = new JVM();
4141

42-
// JVM signals file changes by doing Object#notify on this object
43-
static final Object FILE_DELTA_CHANGE = new FileDeltaChangeLockObject();
44-
4542
static final long RESERVED_CLASS_ID_LIMIT = 500;
4643

44+
private static class ChunkRotationMonitor {}
45+
46+
/*
47+
* The JVM uses the chunk rotation monitor to notify Java that a rotation is warranted.
48+
* The monitor type is used to exclude jdk.JavaMonitorWait events from being generated
49+
* when Object.wait() is called on this monitor.
50+
*/
51+
static final Object CHUNK_ROTATION_MONITOR = new ChunkRotationMonitor();
52+
4753
private volatile boolean nativeOK;
4854

4955
private static native void registerNatives();

src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ private boolean isToDisk() {
520520

521521
private void takeNap(long duration) {
522522
try {
523-
synchronized (JVM.FILE_DELTA_CHANGE) {
524-
JVM.FILE_DELTA_CHANGE.wait(duration < 10 ? 10 : duration);
523+
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
524+
JVM.CHUNK_ROTATION_MONITOR.wait(duration < 10 ? 10 : duration);
525525
}
526526
} catch (InterruptedException e) {
527527
// Ignore

src/jdk.jfr/share/classes/jdk/jfr/internal/RequestEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ static void setFlushInterval(long millis) {
302302
boolean needNotify = interval < flushInterval;
303303
flushInterval = interval;
304304
if (needNotify) {
305-
synchronized (JVM.FILE_DELTA_CHANGE) {
306-
JVM.FILE_DELTA_CHANGE.notifyAll();
305+
synchronized (JVM.CHUNK_ROTATION_MONITOR) {
306+
JVM.CHUNK_ROTATION_MONITOR.notifyAll();
307307
}
308308
}
309309
}

0 commit comments

Comments
 (0)