void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { if (!is_initialized()) { initialize(); } // invoke compilation #ifdef TIERED // We are thread in native here... CompilerThread* thread = CompilerThread::current(); { ThreadInVMfromNative tv(thread); MutexLocker only_one (C1_lock, thread); while ( _compiling) { C1_lock->wait(); } _compiling = true; } #endif // TIERED { // We are nested here because we need for the destructor // of Compilation to occur before we release the any // competing compiler thread ResourceMark rm; Compilation c(this, env, method, entry_bci); } #ifdef TIERED { ThreadInVMfromNative tv(thread); MutexLocker only_one (C1_lock, thread); _compiling = false; C1_lock->notify(); } #endif // TIERED }
bool AbstractCompiler::should_perform_shutdown() { // Since this method can be called by multiple threads, the lock ensures atomicity of // decrementing '_num_compiler_threads' and the following operations. MutexLocker only_one(CompileThread_lock); _num_compiler_threads--; assert (CompileBroker::is_compilation_disabled_forever(), "Must be set, otherwise thread waits forever"); // Only the last thread will perform shutdown operations if (_num_compiler_threads == 0) { return true; } return false; }
bool AbstractCompiler::should_perform_init() { if (_compiler_state != initialized) { MutexLocker only_one(CompileThread_lock); if (_compiler_state == uninitialized) { _compiler_state = initializing; return true; } else { while (_compiler_state == initializing) { CompileThread_lock->wait(); } } } return false; }
void AbstractCompiler::set_state(int state) { // Ensure that ste is only set by one thread at a time MutexLocker only_one(CompileThread_lock); _compiler_state = state; CompileThread_lock->notify_all(); }