< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page
rev 10588 : [backport] Check and ensure that Shenandoah-enabled compilations succeed
* * *
[backport] Filter out not compilable methods to avoid false assertion
rev 10592 : [backport] Fix Minimal and Zero builds


  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "compiler/compilerOracle.hpp"
  32 #include "interpreter/linkResolver.hpp"
  33 #include "memory/allocation.inline.hpp"
  34 #include "oops/methodData.hpp"
  35 #include "oops/method.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/nativeLookup.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/compilationPolicy.hpp"
  40 #include "runtime/init.hpp"
  41 #include "runtime/interfaceSupport.hpp"
  42 #include "runtime/javaCalls.hpp"
  43 #include "runtime/os.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/sweeper.hpp"
  46 #include "trace/tracing.hpp"
  47 #include "utilities/dtrace.hpp"
  48 #include "utilities/events.hpp"

  49 #ifdef COMPILER1
  50 #include "c1/c1_Compiler.hpp"
  51 #endif
  52 #ifdef COMPILER2
  53 #include "opto/c2compiler.hpp"
  54 #endif
  55 #ifdef SHARK
  56 #include "shark/sharkCompiler.hpp"
  57 #endif
  58 
  59 #ifdef DTRACE_ENABLED
  60 
  61 // Only bother with this argument setup if dtrace is available
  62 
  63 #ifndef USDT2
  64 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin,
  65   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t);
  66 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
  67   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool);
  68 


1970     ThreadToNativeFromVM ttn(thread);
1971 
1972     ciEnv ci_env(task, system_dictionary_modification_counter);
1973     if (should_break) {
1974       ci_env.set_break_at_compile(true);
1975     }
1976     if (should_log) {
1977       ci_env.set_log(thread->log());
1978     }
1979     assert(thread->env() == &ci_env, "set by ci_env");
1980     // The thread-env() field is cleared in ~CompileTaskWrapper.
1981 
1982     // Cache Jvmti state
1983     ci_env.cache_jvmti_state();
1984 
1985     // Cache DTrace flags
1986     ci_env.cache_dtrace_flags();
1987 
1988     ciMethod* target = ci_env.get_method_from_handle(target_handle);
1989 


1990     TraceTime t1("compilation", &time);
1991     EventCompilation event;
1992 
1993     AbstractCompiler *comp = compiler(task_level);
1994     if (comp == NULL) {
1995       ci_env.record_method_not_compilable("no compiler", !TieredCompilation);
1996     } else {
1997       comp->compile_method(&ci_env, target, osr_bci);
1998     }
1999 
2000     if (!ci_env.failing() && task->code() == NULL) {
2001       //assert(false, "compiler should always document failure");
2002       // The compiler elected, without comment, not to register a result.
2003       // Do not attempt further compilations of this method.
2004       ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
2005     }
2006 
2007     // Copy this bit to the enclosing block:
2008     compilable = ci_env.compilable();
2009 
2010     if (ci_env.failing()) {
2011       task->set_failure_reason(ci_env.failure_reason());
2012       const char* retry_message = ci_env.retry_message();
2013       if (_compilation_log != NULL) {
2014         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
2015       }
2016       if (PrintCompilation) {
2017         FormatBufferResource msg = retry_message != NULL ?
2018             err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) :
2019             err_msg_res("COMPILE SKIPPED: %s",      ci_env.failure_reason());
2020         task->print_compilation(tty, msg);
2021       }








2022     } else {
2023       task->mark_success();
2024       task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes());
2025       if (_compilation_log != NULL) {
2026         nmethod* code = task->code();
2027         if (code != NULL) {
2028           _compilation_log->log_nmethod(thread, code);
2029         }
2030       }
2031     }
2032     // simulate crash during compilation
2033     assert(task->compile_id() != CICrashAt, "just as planned");
2034     if (event.should_commit()) {
2035       event.set_method(target->get_Method());
2036       event.set_compileID(compile_id);
2037       event.set_compileLevel(task->comp_level());
2038       event.set_succeded(task->is_success());
2039       event.set_isOsr(is_osr);
2040       event.set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size());
2041       event.set_inlinedBytes(task->num_inlined_bytecodes());




  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "compiler/compilerOracle.hpp"
  32 #include "interpreter/linkResolver.hpp"
  33 #include "memory/allocation.inline.hpp"
  34 #include "oops/methodData.hpp"
  35 #include "oops/method.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/nativeLookup.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/compilationPolicy.hpp"
  40 #include "runtime/init.hpp"
  41 #include "runtime/interfaceSupport.hpp"
  42 #include "runtime/javaCalls.hpp"
  43 #include "runtime/os.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/sweeper.hpp"
  46 #include "trace/tracing.hpp"
  47 #include "utilities/dtrace.hpp"
  48 #include "utilities/events.hpp"
  49 #include "utilities/macros.hpp"
  50 #ifdef COMPILER1
  51 #include "c1/c1_Compiler.hpp"
  52 #endif
  53 #ifdef COMPILER2
  54 #include "opto/c2compiler.hpp"
  55 #endif
  56 #ifdef SHARK
  57 #include "shark/sharkCompiler.hpp"
  58 #endif
  59 
  60 #ifdef DTRACE_ENABLED
  61 
  62 // Only bother with this argument setup if dtrace is available
  63 
  64 #ifndef USDT2
  65 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin,
  66   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t);
  67 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
  68   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool);
  69 


1971     ThreadToNativeFromVM ttn(thread);
1972 
1973     ciEnv ci_env(task, system_dictionary_modification_counter);
1974     if (should_break) {
1975       ci_env.set_break_at_compile(true);
1976     }
1977     if (should_log) {
1978       ci_env.set_log(thread->log());
1979     }
1980     assert(thread->env() == &ci_env, "set by ci_env");
1981     // The thread-env() field is cleared in ~CompileTaskWrapper.
1982 
1983     // Cache Jvmti state
1984     ci_env.cache_jvmti_state();
1985 
1986     // Cache DTrace flags
1987     ci_env.cache_dtrace_flags();
1988 
1989     ciMethod* target = ci_env.get_method_from_handle(target_handle);
1990 
1991     bool target_compilable = target->can_be_compiled();
1992 
1993     TraceTime t1("compilation", &time);
1994     EventCompilation event;
1995 
1996     AbstractCompiler *comp = compiler(task_level);
1997     if (comp == NULL) {
1998       ci_env.record_method_not_compilable("no compiler", !TieredCompilation);
1999     } else {
2000       comp->compile_method(&ci_env, target, osr_bci);
2001     }
2002 
2003     if (!ci_env.failing() && task->code() == NULL) {
2004       //assert(false, "compiler should always document failure");
2005       // The compiler elected, without comment, not to register a result.
2006       // Do not attempt further compilations of this method.
2007       ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
2008     }
2009 
2010     // Copy this bit to the enclosing block:
2011     compilable = ci_env.compilable();
2012 
2013     if (ci_env.failing()) {
2014       task->set_failure_reason(ci_env.failure_reason());
2015       const char* retry_message = ci_env.retry_message();
2016       if (_compilation_log != NULL) {
2017         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
2018       }
2019       if (PrintCompilation) {
2020         FormatBufferResource msg = retry_message != NULL ?
2021             err_msg_res("COMPILE SKIPPED: %s (%s)", ci_env.failure_reason(), retry_message) :
2022             err_msg_res("COMPILE SKIPPED: %s",      ci_env.failure_reason());
2023         task->print_compilation(tty, msg);
2024       }
2025 
2026 #if INCLUDE_ALL_GCS
2027      guarantee(!UseShenandoahGC || !ShenandoahCompileCheck || !target_compilable || (compilable != ciEnv::MethodCompilable_not_at_tier),
2028                err_msg("Not compilable on level %d due to: %s", task_level, ci_env.failure_reason()));
2029      guarantee(!UseShenandoahGC || !ShenandoahCompileCheck || !target_compilable ||(compilable != ciEnv::MethodCompilable_never || !target_compilable),
2030                err_msg("Never compilable due to: %s", ci_env.failure_reason()));
2031 #endif
2032 
2033     } else {
2034       task->mark_success();
2035       task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes());
2036       if (_compilation_log != NULL) {
2037         nmethod* code = task->code();
2038         if (code != NULL) {
2039           _compilation_log->log_nmethod(thread, code);
2040         }
2041       }
2042     }
2043     // simulate crash during compilation
2044     assert(task->compile_id() != CICrashAt, "just as planned");
2045     if (event.should_commit()) {
2046       event.set_method(target->get_Method());
2047       event.set_compileID(compile_id);
2048       event.set_compileLevel(task->comp_level());
2049       event.set_succeded(task->is_success());
2050       event.set_isOsr(is_osr);
2051       event.set_codeSize((task->code() == NULL) ? 0 : task->code()->total_size());
2052       event.set_inlinedBytes(task->num_inlined_bytecodes());


< prev index next >