8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
authorthartmann
Mon, 24 Nov 2014 08:48:15 +0100
changeset 27706 3f10f4ac2bd6
parent 27705 a81a28a9bc8a
child 27707 f7d26e5b8b5d
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure' Summary: CompilerFailure JFR event should be triggered in ciEnv. Reviewed-by: kvn
hotspot/src/share/vm/ci/ciEnv.cpp
hotspot/src/share/vm/ci/ciEnv.hpp
hotspot/src/share/vm/compiler/compileBroker.cpp
hotspot/src/share/vm/opto/c2compiler.cpp
hotspot/src/share/vm/opto/compile.cpp
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Sat Nov 22 03:10:33 2014 +0000
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Nov 24 08:48:15 2014 +0100
@@ -53,6 +53,7 @@
 #include "runtime/reflection.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
+#include "trace/tracing.hpp"
 #include "utilities/dtrace.hpp"
 #include "utilities/macros.hpp"
 #ifdef COMPILER1
@@ -1141,6 +1142,16 @@
   }
 }
 
+void ciEnv::report_failure(const char* reason) {
+  // Create and fire JFR event
+  EventCompilerFailure event;
+  if (event.should_commit()) {
+    event.set_compileID(compile_id());
+    event.set_failure(reason);
+    event.commit();
+  }
+}
+
 // ------------------------------------------------------------------
 // ciEnv::record_method_not_compilable()
 void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) {
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Sat Nov 22 03:10:33 2014 +0000
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Nov 24 08:48:15 2014 +0100
@@ -450,7 +450,8 @@
   // Check for changes to the system dictionary during compilation
   bool system_dictionary_modification_counter_changed();
 
-  void record_failure(const char* reason);
+  void record_failure(const char* reason);      // Record failure and report later
+  void report_failure(const char* reason);      // Report failure immediately
   void record_method_not_compilable(const char* reason, bool all_tiers = true);
   void record_out_of_memory_failure();
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Sat Nov 22 03:10:33 2014 +0000
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Nov 24 08:48:15 2014 +0100
@@ -1985,6 +1985,7 @@
 
     if (ci_env.failing()) {
       task->set_failure_reason(ci_env.failure_reason());
+      ci_env.report_failure(ci_env.failure_reason());
       const char* retry_message = ci_env.retry_message();
       if (_compilation_log != NULL) {
         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Sat Nov 22 03:10:33 2014 +0000
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Mon Nov 24 08:48:15 2014 +0100
@@ -102,23 +102,25 @@
     // Attempt to compile while subsuming loads into machine instructions.
     Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
 
-
     // Check result and retry if appropriate.
     if (C.failure_reason() != NULL) {
       if (C.failure_reason_is(retry_no_subsuming_loads())) {
         assert(subsume_loads, "must make progress");
         subsume_loads = false;
+        env->report_failure(C.failure_reason());
         continue;  // retry
       }
       if (C.failure_reason_is(retry_no_escape_analysis())) {
         assert(do_escape_analysis, "must make progress");
         do_escape_analysis = false;
+        env->report_failure(C.failure_reason());
         continue;  // retry
       }
       if (C.has_boxed_value()) {
         // Recompile without boxing elimination regardless failure reason.
         assert(eliminate_boxing, "must make progress");
         eliminate_boxing = false;
+        env->report_failure(C.failure_reason());
         continue;  // retry
       }
       // Pass any other failure reason up to the ciEnv.
--- a/hotspot/src/share/vm/opto/compile.cpp	Sat Nov 22 03:10:33 2014 +0000
+++ b/hotspot/src/share/vm/opto/compile.cpp	Mon Nov 24 08:48:15 2014 +0100
@@ -67,7 +67,6 @@
 #include "runtime/signature.hpp"
 #include "runtime/stubRoutines.hpp"
 #include "runtime/timer.hpp"
-#include "trace/tracing.hpp"
 #include "utilities/copy.hpp"
 
 
@@ -3542,13 +3541,6 @@
     _failure_reason = reason;
   }
 
-  EventCompilerFailure event;
-  if (event.should_commit()) {
-    event.set_compileID(Compile::compile_id());
-    event.set_failure(reason);
-    event.commit();
-  }
-
   if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) {
     C->print_method(PHASE_FAILURE);
   }