src/share/vm/runtime/thread.cpp
Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:
@@ -91,12 +91,10 @@
#include "runtime/vm_version.hpp"
#include "services/attachListener.hpp"
#include "services/management.hpp"
#include "services/memTracker.hpp"
#include "services/threadService.hpp"
-#include "trace/traceMacros.hpp"
-#include "trace/tracing.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/macros.hpp"
#include "utilities/preserveException.hpp"
@@ -117,10 +115,14 @@
#include "opto/idealGraphPrinter.hpp"
#endif
#if INCLUDE_RTM_OPT
#include "runtime/rtmLocking.hpp"
#endif
+#if INCLUDE_TRACE
+#include "trace/traceMacros.hpp"
+#include "trace/tracing.hpp"
+#endif
// Initialization after module runtime initialization
void universe_post_module_init(); // must happen after call_initPhase2
#ifdef DTRACE_ENABLED
@@ -1661,10 +1663,28 @@
FREE_C_HEAP_ARRAY(jlong, _jvmci_counters);
}
#endif // INCLUDE_JVMCI
}
+#if INCLUDE_TRACE
+static void post_thread_start_event(const JavaThread* jt) {
+ assert(jt != NULL, "invariant");
+ EventThreadStart event;
+ if (event.should_commit()) {
+ event.set_thread(THREAD_TRACE_ID(jt));
+ event.commit();
+ }
+}
+
+static void post_thread_end_event(const JavaThread* jt) {
+ EventThreadEnd event;
+ if (event.should_commit()) {
+ event.set_thread(THREAD_TRACE_ID(jt));
+ event.commit();
+ }
+}
+#endif // INCLUDE_TRACE
// The first routine called by a new Java thread
void JavaThread::run() {
// initialize thread-local alloc buffer related fields
this->initialize_tlab();
@@ -1694,15 +1714,11 @@
if (JvmtiExport::should_post_thread_life()) {
JvmtiExport::post_thread_start(this);
}
- EventThreadStart event;
- if (event.should_commit()) {
- event.set_thread(THREAD_TRACE_ID(this));
- event.commit();
- }
+ TRACE_ONLY(post_thread_start_event(this));
// We call another function to do the rest so we are sure that the stack addresses used
// from there will be lower than the stack base just computed
thread_main_inner();
@@ -1799,15 +1815,11 @@
}
}
// Called before the java thread exit since we want to read info
// from java_lang_Thread object
- EventThreadEnd event;
- if (event.should_commit()) {
- event.set_thread(THREAD_TRACE_ID(this));
- event.commit();
- }
+ TRACE_ONLY(post_thread_end_event(this);)
// Call after last event on thread
EVENT_THREAD_EXIT(this);
// Call Thread.exit(). We try 3 times in case we got another Thread.stop during