src/share/vm/compiler/compileBroker.cpp

Print this page
rev 1083 : code cache unloading for webrev 091214
rev 1084 : This rev fixes all the print format stuff and resets less counters as recommended by Vladimir.
rev 1085 : checkpoint unloading changes on 100107
rev 1087 : use enum for passing compiler on/off state

*** 67,76 **** --- 67,77 ---- #endif // ndef DTRACE_ENABLED bool CompileBroker::_initialized = false; volatile bool CompileBroker::_should_block = false; + volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; // The installed compiler(s) AbstractCompiler* CompileBroker::_compilers[2]; // These counters are used for assigning id's to each compilation
*** 461,471 **** // Get the next CompileTask from a CompileQueue CompileTask* CompileQueue::get() { MutexLocker locker(lock()); // Wait for an available CompileTask. ! while (_first == NULL) { // There is no work to be done right now. Wait. lock()->wait(); } CompileTask* task = _first; --- 462,472 ---- // Get the next CompileTask from a CompileQueue CompileTask* CompileQueue::get() { MutexLocker locker(lock()); // Wait for an available CompileTask. ! while ((_first == NULL) || (!CompileBroker::should_compile_new_jobs())) { // There is no work to be done right now. Wait. lock()->wait(); } CompileTask* task = _first;
*** 1323,1352 **** while (true) { { // We need this HandleMark to avoid leaking VM handles. HandleMark hm(thread); if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { ! // The CodeCache is full. Print out warning and disable compilation. ! UseInterpreter = true; ! if (UseCompiler || AlwaysCompileLoopMethods ) { ! if (log != NULL) { ! log->begin_elem("code_cache_full"); ! log->stamp(); ! log->end_elem(); ! } ! #ifndef PRODUCT ! warning("CodeCache is full. Compiler has been disabled"); ! if (CompileTheWorld || ExitOnFullCodeCache) { ! before_exit(thread); ! exit_globals(); // will delete tty ! vm_direct_exit(CompileTheWorld ? 0 : 1); ! } ! #endif ! UseCompiler = false; ! AlwaysCompileLoopMethods = false; ! } } CompileTask* task = queue->get(); // Give compiler threads an extra quanta. They tend to be bursty and --- 1324,1340 ---- while (true) { { // We need this HandleMark to avoid leaking VM handles. HandleMark hm(thread); + if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) { ! // the code cache is really full ! handle_full_code_cache(); ! } else if (UseCodeCacheFlushing && (CodeCache::unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace)) { ! // Attempt to start cleaning the code cache while there is still a little headroom ! NMethodSweeper::handle_full_code_cache(false); } CompileTask* task = queue->get(); // Give compiler threads an extra quanta. They tend to be bursty and
*** 1367,1377 **** (methodOop)JNIHandles::resolve(task->method_handle())); // Never compile a method if breakpoints are present in it if (method()->number_of_breakpoints() == 0) { // Compile the method. ! if (UseCompiler || AlwaysCompileLoopMethods) { #ifdef COMPILER1 // Allow repeating compilations for the purpose of benchmarking // compile speed. This is not useful for customers. if (CompilationRepeat != 0) { int compile_count = CompilationRepeat; --- 1355,1365 ---- (methodOop)JNIHandles::resolve(task->method_handle())); // Never compile a method if breakpoints are present in it if (method()->number_of_breakpoints() == 0) { // Compile the method. ! if ((UseCompiler || AlwaysCompileLoopMethods) && CompileBroker::should_compile_new_jobs()) { #ifdef COMPILER1 // Allow repeating compilations for the purpose of benchmarking // compile speed. This is not useful for customers. if (CompilationRepeat != 0) { int compile_count = CompilationRepeat;
*** 1612,1621 **** --- 1600,1634 ---- #endif } // ------------------------------------------------------------------ + // CompileBroker::handle_full_code_cache + // + // The CodeCache is full. Print out warning and disable compilation or + // try code cache cleaning so compilation can continue later. + void CompileBroker::handle_full_code_cache() { + UseInterpreter = true; + if (UseCompiler || AlwaysCompileLoopMethods ) { + #ifndef PRODUCT + warning("CodeCache is full. Compiler has been disabled"); + if (CompileTheWorld || ExitOnFullCodeCache) { + before_exit(JavaThread::current()); + exit_globals(); // will delete tty + vm_direct_exit(CompileTheWorld ? 0 : 1); + } + #endif + if (UseCodeCacheFlushing) { + NMethodSweeper::handle_full_code_cache(true); + } else { + UseCompiler = false; + AlwaysCompileLoopMethods = false; + } + } + } + + // ------------------------------------------------------------------ // CompileBroker::set_last_compile // // Record this compilation for debugging purposes. void CompileBroker::set_last_compile(CompilerThread* thread, methodHandle method, bool is_osr, int comp_level) { ResourceMark rm;