// Returns true if m must be compiled before executing it // This is intended to force compiles for methods (usually for // debugging) that would otherwise be interpreted for some reason. bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) { if (m->has_compiled_code()) return false; // already compiled if (!can_be_compiled(m, comp_level)) return false; return !UseInterpreter || // must compile all methods (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods }
// Returns true if m must be compiled before executing it // This is intended to force compiles for methods (usually for // debugging) that would otherwise be interpreted for some reason. bool CompilationPolicy::mustBeCompiled(methodHandle m) { if (m->has_compiled_code()) return false; // already compiled if (!canBeCompiled(m)) return false; return !UseInterpreter || // must compile all methods (UseCompiler && AlwaysCompileLoopMethods && m->has_loops()); // eagerly compile loop methods }
// Check if the method can be compiled, change level if necessary void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { assert(level <= TieredStopAtLevel, "Invalid compilation level"); if (level == CompLevel_none) { return; } if (level == CompLevel_aot) { if (mh->has_aot_code()) { if (PrintTieredEvents) { print_event(COMPILE, mh, mh, bci, level); } MutexLocker ml(Compile_lock); NoSafepointVerifier nsv; if (mh->has_aot_code() && mh->code() != mh->aot_code()) { mh->aot_code()->make_entrant(); if (mh->has_compiled_code()) { mh->code()->make_not_entrant(); } Method::set_code(mh, mh->aot_code()); } } return; } // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling // in the interpreter and then compile with C2 (the transition function will request that, // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with // pure C1. if (!can_be_compiled(mh, level)) { if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { compile(mh, bci, CompLevel_simple, thread); } return; } if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { return; } if (!CompileBroker::compilation_is_in_queue(mh)) { if (PrintTieredEvents) { print_event(COMPILE, mh, mh, bci, level); } submit_compile(mh, bci, level, thread); } }