diff src/share/vm/compiler/compileBroker.cpp @ 13074:78da3894b86f

8027593: performance drop with constrained codecache starting with hs25 b111 Summary: Fixed proper sweeping of small code cache sizes Reviewed-by: kvn, iveresov
author anoll
date Tue, 12 Nov 2013 09:32:50 +0100
parents a196f1aaec86
children 096c224171c4 7c0122ed05fb da862781b584 5656140324ed
line wrap: on
line diff
--- a/src/share/vm/compiler/compileBroker.cpp	Mon Nov 11 11:53:33 2013 -0800
+++ b/src/share/vm/compiler/compileBroker.cpp	Tue Nov 12 09:32:50 2013 +0100
@@ -126,6 +126,7 @@
 
 bool CompileBroker::_initialized = false;
 volatile bool CompileBroker::_should_block = false;
+volatile jint CompileBroker::_print_compilation_warning = 0;
 volatile jint CompileBroker::_should_compile_new_jobs = run_compilation;
 
 // The installed compiler(s)
@@ -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,12 +2048,9 @@
       xtty->stamp();
       xtty->end_elem();
     }
-    warning("CodeCache is full. Compiler has been disabled.");
-    warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
 
     CodeCache::report_codemem_full();
 
-
 #ifndef PRODUCT
     if (CompileTheWorld || ExitOnFullCodeCache) {
       codecache_print(/* detailed= */ true);
@@ -2066,17 +2063,22 @@
       // 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();
     }
+
+    // Print warning only once
+    if (should_print_compiler_warning()) {
+      warning("CodeCache is full. Compiler has been disabled.");
+      warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
+      codecache_print(/* detailed= */ true);
+    }
   }
-  codecache_print(/* detailed= */ true);
 }
 
 // ------------------------------------------------------------------