< prev index next > src/hotspot/share/opto/c2compiler.cpp
Print this page
* questions.
*
*/
#include "classfile/vmClasses.hpp"
+ #include "code/aotCodeCache.hpp"
#include "compiler/compilationMemoryStatistic.hpp"
#include "compiler/compilerDefinitions.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "jfr/support/jfrIntrinsics.hpp"
#include "opto/c2compiler.hpp"
Compile::pd_compiler2_init();
CompilerThread* thread = CompilerThread::current();
HandleMark handle_mark(thread);
! return OptoRuntime::generate(thread->env());
}
void C2Compiler::initialize() {
assert(!CompilerConfig::is_c1_or_interpreter_only_no_jvmci(), "C2 compiler is launched, it's not c1/interpreter only mode");
// The first compiler thread that gets here will initialize the
Compile::pd_compiler2_init();
CompilerThread* thread = CompilerThread::current();
HandleMark handle_mark(thread);
! bool success = OptoRuntime::generate(thread->env());
+ if (success) {
+ AOTCodeCache::init_c2_table();
+ }
+ return success;
}
void C2Compiler::initialize() {
assert(!CompilerConfig::is_c1_or_interpreter_only_no_jvmci(), "C2 compiler is launched, it's not c1/interpreter only mode");
// The first compiler thread that gets here will initialize the
}
}
void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive) {
assert(is_initialized(), "Compiler thread must be initialized");
-
CompilationMemoryStatisticMark cmsm(directive);
bool subsume_loads = SubsumeLoads;
bool do_escape_analysis = DoEscapeAnalysis;
bool do_iterative_escape_analysis = DoEscapeAnalysis;
bool do_reduce_allocation_merges = ReduceAllocationMerges && EliminateAllocations;
bool eliminate_boxing = EliminateAutoBox;
bool do_locks_coarsening = EliminateLocks;
bool do_superword = UseSuperWord;
!
while (!env->failing()) {
ResourceMark rm;
// Attempt to compile while subsuming loads into machine instructions.
Options options(subsume_loads,
do_escape_analysis,
do_iterative_escape_analysis,
do_reduce_allocation_merges,
eliminate_boxing,
do_locks_coarsening,
do_superword,
install_code);
Compile C(env, target, entry_bci, options, directive);
// Check result and retry if appropriate.
if (C.failure_reason() != nullptr) {
}
}
void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive) {
assert(is_initialized(), "Compiler thread must be initialized");
CompilationMemoryStatisticMark cmsm(directive);
+ CompileTask* task = env->task();
+ if (install_code && task->is_aot_load()) {
+ bool success = AOTCodeCache::load_nmethod(env, target, entry_bci, this, CompLevel_full_optimization);
+ if (success) {
+ assert(task->is_success(), "sanity");
+ return;
+ }
+ AOTCodeCache::invalidate(task->aot_code_entry()); // mark aot_code_entry as not entrant
+ if (AOTCodeCache::is_code_load_thread_on()) {
+ // Bail out if AOT code load failed in AOT Code loading thread
+ // when UseAOTCodeLoadThread flag is on.
+ // We want this thread go quickly through AOT code load requests
+ // instead of spending time on normal compilation.
+ // TODO: pass this task to normal compilation thread.
+ env->record_failure("Failed to load AOT code");
+ return;
+ } else {
+ task->clear_aot();
+ }
+ }
bool subsume_loads = SubsumeLoads;
bool do_escape_analysis = DoEscapeAnalysis;
bool do_iterative_escape_analysis = DoEscapeAnalysis;
bool do_reduce_allocation_merges = ReduceAllocationMerges && EliminateAllocations;
bool eliminate_boxing = EliminateAutoBox;
bool do_locks_coarsening = EliminateLocks;
bool do_superword = UseSuperWord;
! bool gen_preload = (task->compile_reason() == CompileTask::Reason_PrecompileForPreload);
+ assert(!gen_preload || (AOTCodeCache::is_dumping_code() && (ClassInitBarrierMode > 0)), "sanity");
while (!env->failing()) {
ResourceMark rm;
// Attempt to compile while subsuming loads into machine instructions.
Options options(subsume_loads,
do_escape_analysis,
do_iterative_escape_analysis,
do_reduce_allocation_merges,
eliminate_boxing,
do_locks_coarsening,
do_superword,
+ gen_preload,
install_code);
Compile C(env, target, entry_bci, options, directive);
// Check result and retry if appropriate.
if (C.failure_reason() != nullptr) {
int C2Compiler::initial_code_buffer_size(int const_size) {
// See Compile::init_scratch_buffer_blob
int locs_size = sizeof(relocInfo) * PhaseOutput::MAX_locs_size;
int slop = 2 * CodeSection::end_slop(); // space between sections
! return PhaseOutput::MAX_inst_size + PhaseOutput::MAX_stubs_size + const_size + slop + locs_size;
}
int C2Compiler::initial_code_buffer_size(int const_size) {
// See Compile::init_scratch_buffer_blob
int locs_size = sizeof(relocInfo) * PhaseOutput::MAX_locs_size;
int slop = 2 * CodeSection::end_slop(); // space between sections
! return PhaseOutput::max_inst_size() + PhaseOutput::MAX_stubs_size + const_size + slop + locs_size;
}
< prev index next >