diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index ec16b8da1ee7de9e5ab0d5a3ae8a8410922c0da5..5c6e12e5e75212b443cc30e470a02638fc228ed3 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -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::record_failure(const char* reason) { } } +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) { diff --git a/hotspot/src/share/vm/ci/ciEnv.hpp b/hotspot/src/share/vm/ci/ciEnv.hpp index ced8d895207123e7f2a0c33fd4e50eb9e215027e..29e52c352afa6aa74f0d6f49d00310da7ee91a93 100644 --- a/hotspot/src/share/vm/ci/ciEnv.hpp +++ b/hotspot/src/share/vm/ci/ciEnv.hpp @@ -450,7 +450,8 @@ public: // 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(); diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 2fa80c675dd22b98923af8ee01ce72027c28d8f6..079d0835883f4dcda79604ef4f6de960b0ea4c77 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1985,6 +1985,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { 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); diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index 472ab4a8c220f3ffeff31a9c7dc6b682ab6ad923..71e2a0bbbab0084b1200ac7ec6080eff35d7428c 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -102,23 +102,25 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { // 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. diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index ec74d5ef4a1ee8ab9eb45d07b7756c36d06beb83..c2943720c60978e00d338c55d651e7490b9a5fea 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -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 @@ void Compile::record_failure(const char* reason) { _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); }