src/share/vm/compiler/compileBroker.cpp

Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:

@@ -48,11 +48,10 @@
 #include "runtime/javaCalls.hpp"
 #include "runtime/os.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/sweeper.hpp"
 #include "runtime/timerTrace.hpp"
-#include "trace/tracing.hpp"
 #include "utilities/dtrace.hpp"
 #include "utilities/events.hpp"
 #ifdef COMPILER1
 #include "c1/c1_Compiler.hpp"
 #endif

@@ -66,10 +65,13 @@
 #include "opto/c2compiler.hpp"
 #endif
 #ifdef SHARK
 #include "shark/sharkCompiler.hpp"
 #endif
+#if INCLUDE_TRACE
+#include "trace/tracing.hpp"
+#endif
 
 #ifdef DTRACE_ENABLED
 
 // Only bother with this argument setup if dtrace is available
 

@@ -1749,12 +1751,14 @@
       remaining_log = eol + 1;
     }
   }
 }
 
-void CompileBroker::post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env) {
-
+void CompileBroker::post_compile(CompilerThread* thread,
+                                 CompileTask* task,
+                                 bool success,
+                                 ciEnv* ci_env) {
   if (success) {
     task->mark_success();
     if (ci_env != NULL) {
       task->set_num_inlined_bytecodes(ci_env->num_inlined_bytecodes());
     }

@@ -1766,21 +1770,32 @@
     }
   }
 
   // simulate crash during compilation
   assert(task->compile_id() != CICrashAt, "just as planned");
-  if (event.should_commit()) {
-    event.set_method(task->method());
-    event.set_compileId(task->compile_id());
-    event.set_compileLevel(task->comp_level());
-    event.set_succeded(task->is_success());
-    event.set_isOsr(task->osr_bci() != CompileBroker::standard_entry_bci);
-    event.set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size());
-    event.set_inlinedBytes(task->num_inlined_bytecodes());
-    event.commit();
+}
+
+#if INCLUDE_TRACE
+static void post_compilation_event(EventCompilation* event,
+                                   CompilerThread* thread,
+                                   CompileTask* task,
+                                   CompilationLog* log,
+                                   bool success,
+                                   ciEnv* ci_env) {
+  assert(event != NULL, "invariant");
+  if (event->should_commit()) {
+    event->set_method(task->method());
+    event->set_compileId(task->compile_id());
+    event->set_compileLevel(task->comp_level());
+    event->set_succeded(task->is_success());
+    event->set_isOsr(task->osr_bci() != CompileBroker::standard_entry_bci);
+    event->set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size());
+    event->set_inlinedBytes(task->num_inlined_bytecodes());
+    event->commit();
   }
 }
+#endif // INCLUDE_TRACE
 
 int DirectivesStack::_depth = 0;
 CompilerDirectives* DirectivesStack::_top = NULL;
 CompilerDirectives* DirectivesStack::_bottom = NULL;
 

@@ -1852,17 +1867,22 @@
 #if INCLUDE_JVMCI
   if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
     JVMCICompiler* jvmci = (JVMCICompiler*) comp;
 
     TraceTime t1("compilation", &time);
-    EventCompilation event;
+    TRACE_ONLY(EventCompilation event;)
 
     JVMCIEnv env(task, system_dictionary_modification_counter);
     methodHandle method(thread, target_handle);
     jvmci->compile_method(method, osr_bci, &env);
-
-    post_compile(thread, task, event, task->code() != NULL, NULL);
+    post_compile(thread, task, task->code() != NULL, NULL);
+    TRACE_ONLY(post_compilation_event(&event,
+                                      thread,
+                                      task,
+                                      _compilation_log,
+                                      task->code() != NULL,
+                                      NULL);)
 
     failure_reason = env.failure_reason();
     if (!env.retryable()) {
       retry_message = "not retryable";
       compilable = ciEnv::MethodCompilable_not_at_tier;

@@ -1891,11 +1911,11 @@
     ci_env.cache_dtrace_flags();
 
     ciMethod* target = ci_env.get_method_from_handle(target_handle);
 
     TraceTime t1("compilation", &time);
-    EventCompilation event;
+    TRACE_ONLY(EventCompilation event;)
 
     if (comp == NULL) {
       ci_env.record_method_not_compilable("no compiler", !TieredCompilation);
     } else {
       if (WhiteBoxAPI && WhiteBox::compilation_locked) {

@@ -1921,11 +1941,17 @@
       failure_reason = ci_env.failure_reason();
       retry_message = ci_env.retry_message();
       ci_env.report_failure(failure_reason);
     }
 
-    post_compile(thread, task, event, !ci_env.failing(), &ci_env);
+    post_compile(thread, task, !ci_env.failing(), &ci_env);
+    TRACE_ONLY(post_compilation_event(&event,
+                                      thread,
+                                      task,
+                                      _compilation_log,
+                                      !ci_env.failing(),
+                                      &ci_env);)
   }
   // Remove the JNI handle block after the ciEnv destructor has run in
   // the previous block.
   pop_jni_handle_block();