--- old/src/share/vm/compiler/compileBroker.cpp 2013-11-08 14:10:12.506623720 +0100 +++ new/src/share/vm/compiler/compileBroker.cpp 2013-11-08 14:10:12.378623722 +0100 @@ -125,6 +125,7 @@ #endif // ndef DTRACE_ENABLED bool CompileBroker::_initialized = false; +int CompileBroker::_compilation_warning_counter = -1; volatile bool CompileBroker::_should_block = false; volatile jint CompileBroker::_should_compile_new_jobs = run_compilation; @@ -2027,11 +2028,10 @@ #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. +/** + * 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 ) { @@ -2048,8 +2048,18 @@ xtty->stamp(); xtty->end_elem(); } - warning("CodeCache is full. Compiler has been disabled."); - warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); + + // Increase counter only if compilation is enabled. + if (should_compile_new_jobs()) { + _compilation_warning_counter++; + } + + if (should_print_compiler_warning()) { + warning("CodeCache is full. Compiler has been disabled."); + warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); + warning("(Printing one such message for every 10th event)"); + codecache_print(/* detailed= */ true); + } CodeCache::report_codemem_full(); @@ -2066,17 +2076,15 @@ // Since code cache is full, immediately stop new compiles if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) { NMethodSweeper::log_sweep("disable_compiler"); - - // Switch to 'vm_state'. This ensures that possibly_sweep() can be called - // without having to consider the state in which the current thread is. - ThreadInVMfromUnknown in_vm; - NMethodSweeper::possibly_sweep(); } + // Switch to 'vm_state'. This ensures that possibly_sweep() can be called + // without having to consider the state in which the current thread is. + ThreadInVMfromUnknown in_vm; + NMethodSweeper::possibly_sweep(); } else { disable_compilation_forever(); } } - codecache_print(/* detailed= */ true); } // ------------------------------------------------------------------