src/share/vm/compiler/compileBroker.cpp

Print this page

        

@@ -1590,13 +1590,17 @@
   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();
+      // Iterate over non-profiled and profiled nmethods
+      for (int bti = btMethodNoProfile; bti <= btMethodProfile; ++bti) {
+        CodeBlobType bt = (CodeBlobType)bti;
+        if (CodeCache::is_full(bt)) {
+          // The code heap for this compilation level is really full
+          handle_full_code_cache(bt);
+        }
       }
 
       CompileTask* task = queue->get();
 
       // Give compiler threads an extra quanta.  They tend to be bursty and

@@ -1915,13 +1919,13 @@
 }
 
 // ------------------------------------------------------------------
 // CompileBroker::handle_full_code_cache
 //
-// The CodeCache is full.  Print out warning and disable compilation or
+// The CodeCache is full. Print out warning and delay compilation or
 // try code cache cleaning so compilation can continue later.
-void CompileBroker::handle_full_code_cache() {
+void CompileBroker::handle_full_code_cache(CodeBlobType bt) {
   UseInterpreter = true;
   if (UseCompiler || AlwaysCompileLoopMethods ) {
     if (xtty != NULL) {
       ResourceMark rm;
       stringStream s;

@@ -1933,36 +1937,37 @@
       xtty->begin_elem("code_cache_full");
       xtty->print(s.as_string());
       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();
 
+    CodeCache::report_codemem_full(bt);
 
 #ifndef PRODUCT
     if (CompileTheWorld || ExitOnFullCodeCache) {
       codecache_print(/* detailed= */ true);
       before_exit(JavaThread::current());
       exit_globals(); // will delete tty
       vm_direct_exit(CompileTheWorld ? 0 : 1);
     }
 #endif
     if (UseCodeCacheFlushing) {
+      // Because we now check for each CodeBlobType if the corresponding heap in the
+      // code cache is full and delay compilation if so, it does not make sense anymore
+      // to disable compilation for all CodeBlobTypes at this point.
+      /*
       // Since code cache is full, immediately stop new compiles
       if (CompileBroker::set_should_compile_new_jobs(CompileBroker::stop_compilation)) {
         NMethodSweeper::log_sweep("disable_compiler");
         NMethodSweeper::possibly_sweep();
       }
+      */
     } else {
       UseCompiler               = false;
       AlwaysCompileLoopMethods  = false;
     }
   }
-  codecache_print(/* detailed= */ true);
 }
 
 // ------------------------------------------------------------------
 // CompileBroker::set_last_compile
 //