--- old/src/hotspot/share/compiler/compileBroker.cpp 2019-04-10 18:49:48.276902500 -0400 +++ new/src/hotspot/share/compiler/compileBroker.cpp 2019-04-10 18:49:47.372812100 -0400 @@ -135,6 +135,11 @@ volatile jint CompileBroker::_compilation_id = 0; volatile jint CompileBroker::_osr_compilation_id = 0; +// Debugging information +int CompileBroker::_last_compile_type = no_compile; +int CompileBroker::_last_compile_level = CompLevel_none; +char CompileBroker::_last_method_compiled[CompileBroker::name_buffer_length]; + // Performance counters PerfCounter* CompileBroker::_perf_total_compilation = NULL; PerfCounter* CompileBroker::_perf_osr_compilation = NULL; @@ -572,6 +577,8 @@ // // Initialize the Compilation object void CompileBroker::compilation_init_phase1(TRAPS) { + _last_method_compiled[0] = '\0'; + // No need to initialize compilation system if we do not use it. if (!UseCompiler) { return; @@ -2025,10 +2032,8 @@ // Look up matching directives directive = DirectivesStack::getMatchingDirective(method, comp); - // Update compile information when using perfdata. - if (UsePerfData) { - update_compile_perf_data(thread, method, is_osr); - } + // Save information about this method in case of failure. + set_last_compile(thread, method, is_osr, task_level); DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, compiler_name(task_level)); } @@ -2259,49 +2264,58 @@ } // ------------------------------------------------------------------ -// CompileBroker::update_compile_perf_data +// CompileBroker::set_last_compile // // Record this compilation for debugging purposes. -void CompileBroker::update_compile_perf_data(CompilerThread* thread, const methodHandle& method, bool is_osr) { +void CompileBroker::set_last_compile(CompilerThread* thread, const methodHandle& method, bool is_osr, int comp_level) { ResourceMark rm; char* method_name = method->name()->as_C_string(); + strncpy(_last_method_compiled, method_name, CompileBroker::name_buffer_length); + _last_method_compiled[CompileBroker::name_buffer_length - 1] = '\0'; // ensure null terminated char current_method[CompilerCounters::cmname_buffer_length]; size_t maxLen = CompilerCounters::cmname_buffer_length; - const char* class_name = method->method_holder()->name()->as_C_string(); + if (UsePerfData) { + const char* class_name = method->method_holder()->name()->as_C_string(); - size_t s1len = strlen(class_name); - size_t s2len = strlen(method_name); + size_t s1len = strlen(class_name); + size_t s2len = strlen(method_name); - // check if we need to truncate the string - if (s1len + s2len + 2 > maxLen) { + // check if we need to truncate the string + if (s1len + s2len + 2 > maxLen) { - // the strategy is to lop off the leading characters of the - // class name and the trailing characters of the method name. + // the strategy is to lop off the leading characters of the + // class name and the trailing characters of the method name. - if (s2len + 2 > maxLen) { - // lop of the entire class name string, let snprintf handle - // truncation of the method name. - class_name += s1len; // null string - } - else { - // lop off the extra characters from the front of the class name - class_name += ((s1len + s2len + 2) - maxLen); + if (s2len + 2 > maxLen) { + // lop of the entire class name string, let snprintf handle + // truncation of the method name. + class_name += s1len; // null string + } + else { + // lop off the extra characters from the front of the class name + class_name += ((s1len + s2len + 2) - maxLen); + } } - } - jio_snprintf(current_method, maxLen, "%s %s", class_name, method_name); + jio_snprintf(current_method, maxLen, "%s %s", class_name, method_name); + } - int last_compile_type = normal_compile; if (CICountOSR && is_osr) { - last_compile_type = osr_compile; + _last_compile_type = osr_compile; + } else { + _last_compile_type = normal_compile; } + _last_compile_level = comp_level; - CompilerCounters* counters = thread->counters(); - counters->set_current_method(current_method); - counters->set_compile_type((jlong) last_compile_type); + if (UsePerfData) { + CompilerCounters* counters = thread->counters(); + counters->set_current_method(current_method); + counters->set_compile_type((jlong)_last_compile_type); + } } + // ------------------------------------------------------------------ // CompileBroker::push_jni_handle_block // @@ -2604,6 +2618,21 @@ tty->print_cr(" nmethod total size : %8d bytes", nmethods_size); } +// Debugging output for failure +void CompileBroker::print_last_compile() { + if (_last_compile_level != CompLevel_none && + compiler(_last_compile_level) != NULL && + _last_compile_type != no_compile) { + if (_last_compile_type == osr_compile) { + tty->print_cr("Last parse: [osr]%d+++(%d) %s", + _osr_compilation_id, _last_compile_level, _last_method_compiled); + } else { + tty->print_cr("Last parse: %d+++(%d) %s", + _compilation_id, _last_compile_level, _last_method_compiled); + } + } +} + // Print general/accumulated JIT information. void CompileBroker::print_info(outputStream *out) { if (out == NULL) out = tty;