src/share/vm/prims/jvm.cpp
Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:
@@ -70,11 +70,10 @@
#include "runtime/vm_operations.hpp"
#include "runtime/vm_version.hpp"
#include "services/attachListener.hpp"
#include "services/management.hpp"
#include "services/threadService.hpp"
-#include "trace/tracing.hpp"
#include "utilities/copy.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/histogram.hpp"
@@ -82,11 +81,13 @@
#include "utilities/utf8.hpp"
#if INCLUDE_CDS
#include "classfile/sharedClassUtil.hpp"
#include "classfile/systemDictionaryShared.hpp"
#endif
-
+#if INCLUDE_TRACE
+#include "trace/tracing.hpp"
+#endif
#include <errno.h>
/*
NOTE about use of any ctor or function call that can trigger a safepoint/GC:
such ctors and calls MUST NOT come between an oop declaration/init and its
@@ -2968,10 +2969,19 @@
if (os::dont_yield()) return;
HOTSPOT_THREAD_YIELD();
os::naked_yield();
JVM_END
+#if INCLUDE_TRACE
+static void post_thread_sleep_event(EventThreadSleep* event, jlong millis) {
+ assert(event != NULL, "invariant");
+ if (event->should_commit()) {
+ event->set_time(millis);
+ event->commit();
+ }
+}
+#endif
JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis))
JVMWrapper("JVM_Sleep");
if (millis < 0) {
@@ -2985,39 +2995,32 @@
// Save current thread state and restore it at the end of this block.
// And set new thread state to SLEEPING.
JavaThreadSleepState jtss(thread);
HOTSPOT_THREAD_SLEEP_BEGIN(millis);
-
- EventThreadSleep event;
+ TRACE_ONLY(EventThreadSleep event;)
if (millis == 0) {
os::naked_yield();
} else {
ThreadState old_state = thread->osthread()->get_state();
thread->osthread()->set_state(SLEEPING);
if (os::sleep(thread, millis, true) == OS_INTRPT) {
// An asynchronous exception (e.g., ThreadDeathException) could have been thrown on
// us while we were sleeping. We do not overwrite those.
if (!HAS_PENDING_EXCEPTION) {
- if (event.should_commit()) {
- event.set_time(millis);
- event.commit();
- }
+ TRACE_ONLY(post_thread_sleep_event(&event, millis);)
HOTSPOT_THREAD_SLEEP_END(1);
// TODO-FIXME: THROW_MSG returns which means we will not call set_state()
// to properly restore the thread state. That's likely wrong.
THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted");
}
}
thread->osthread()->set_state(old_state);
}
- if (event.should_commit()) {
- event.set_time(millis);
- event.commit();
- }
+ TRACE_ONLY(post_thread_sleep_event(&event, millis);)
HOTSPOT_THREAD_SLEEP_END(0);
JVM_END
JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass))
JVMWrapper("JVM_CurrentThread");