--- a/src/hotspot/share/prims/unsafe.cpp Tue May 15 11:28:29 2018 -0700
+++ b/src/hotspot/share/prims/unsafe.cpp Tue May 15 20:24:34 2018 +0200
@@ -27,6 +27,7 @@
#include "jvm.h"
#include "classfile/classFileStream.hpp"
#include "classfile/vmSymbols.hpp"
+#include "jfr/jfrEvents.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "oops/access.inline.hpp"
@@ -45,7 +46,6 @@
#include "runtime/threadSMR.hpp"
#include "runtime/vm_version.hpp"
#include "services/threadService.hpp"
-#include "trace/tracing.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"
#include "utilities/dtrace.hpp"
@@ -926,22 +926,25 @@
}
} UNSAFE_END
+static void post_thread_park_event(EventThreadPark* event, const oop obj, jlong timeout) {
+ assert(event != NULL, "invariant");
+ assert(event->should_commit(), "invariant");
+ event->set_parkedClass((obj != NULL) ? obj->klass() : NULL);
+ event->set_timeout(timeout);
+ event->set_address((obj != NULL) ? (u8)cast_from_oop<uintptr_t>(obj) : 0);
+ event->commit();
+}
+
UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) {
+ HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time);
EventThreadPark event;
- HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time);
JavaThreadParkedState jtps(thread, time != 0);
thread->parker()->park(isAbsolute != 0, time);
-
+ if (event.should_commit()) {
+ post_thread_park_event(&event, thread->current_park_blocker(), time);
+ }
HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker());
-
- if (event.should_commit()) {
- oop obj = thread->current_park_blocker();
- event.set_parkedClass((obj != NULL) ? obj->klass() : NULL);
- event.set_timeout(time);
- event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0);
- event.commit();
- }
} UNSAFE_END
UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) {