src/share/vm/code/codeCache.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/code

src/share/vm/code/codeCache.cpp

Print this page




 250   return rs;
 251 }
 252 
 253 bool CodeCache::heap_available(int code_blob_type) {
 254   if (!SegmentedCodeCache) {
 255     // No segmentation: use a single code heap
 256     return (code_blob_type == CodeBlobType::All);
 257   } else if (Arguments::mode() == Arguments::_int) {
 258     // Interpreter only: we don't need any method code heaps
 259     return (code_blob_type == CodeBlobType::NonNMethod);
 260   } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) {
 261     // Tiered compilation: use all code heaps
 262     return (code_blob_type < CodeBlobType::All);
 263   } else {
 264     // No TieredCompilation: we only need the non-nmethod and non-profiled code heap
 265     return (code_blob_type == CodeBlobType::NonNMethod) ||
 266            (code_blob_type == CodeBlobType::MethodNonProfiled);
 267   }
 268 }
 269 
















 270 void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type) {
 271   // Check if heap is needed
 272   if (!heap_available(code_blob_type)) {
 273     return;
 274   }
 275 
 276   // Create CodeHeap
 277   CodeHeap* heap = new CodeHeap(name, code_blob_type);
 278   _heaps->append(heap);
 279 
 280   // Reserve Space
 281   size_initial = round_to(size_initial, os::vm_page_size());
 282 
 283   if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) {
 284     vm_exit_during_initialization("Could not reserve enough space for code cache");
 285   }
 286 
 287   // Register the CodeHeap
 288   MemoryService::add_code_heap_memory_pool(heap, name);
 289 }


 994   FOR_ALL_HEAPS(heap) {
 995     (*heap)->verify();
 996     FOR_ALL_BLOBS(cb, *heap) {
 997       if (cb->is_alive()) {
 998         cb->verify();
 999       }
1000     }
1001   }
1002 }
1003 
1004 // A CodeHeap is full. Print out warning and report event.
1005 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1006   // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event
1007   CodeHeap* heap = get_code_heap(code_blob_type);
1008   assert(heap != NULL, "heap is null");
1009 
1010   if (!heap->was_full() || print) {
1011     // Not yet reported for this heap, report
1012     heap->report_full();
1013     if (SegmentedCodeCache) {
1014       warning("%s is full. Compiler has been disabled.", CodeCache::get_code_heap_name(code_blob_type));
1015       warning("Try increasing the code heap size using -XX:%s=",
1016           (code_blob_type == CodeBlobType::MethodNonProfiled) ? "NonProfiledCodeHeapSize" : "ProfiledCodeHeapSize");
1017     } else {
1018       warning("CodeCache is full. Compiler has been disabled.");
1019       warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
1020     }
1021     ResourceMark rm;
1022     stringStream s;
1023     // Dump code cache  into a buffer before locking the tty,
1024     {
1025       MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1026       print_summary(&s);
1027     }
1028     ttyLocker ttyl;
1029     tty->print("%s", s.as_string());
1030   }
1031 
1032   _codemem_full_count++;
1033   EventCodeCacheFull event;
1034   if (event.should_commit()) {
1035     event.set_codeBlobType((u1)code_blob_type);
1036     event.set_startAddress((u8)heap->low_boundary());




 250   return rs;
 251 }
 252 
 253 bool CodeCache::heap_available(int code_blob_type) {
 254   if (!SegmentedCodeCache) {
 255     // No segmentation: use a single code heap
 256     return (code_blob_type == CodeBlobType::All);
 257   } else if (Arguments::mode() == Arguments::_int) {
 258     // Interpreter only: we don't need any method code heaps
 259     return (code_blob_type == CodeBlobType::NonNMethod);
 260   } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) {
 261     // Tiered compilation: use all code heaps
 262     return (code_blob_type < CodeBlobType::All);
 263   } else {
 264     // No TieredCompilation: we only need the non-nmethod and non-profiled code heap
 265     return (code_blob_type == CodeBlobType::NonNMethod) ||
 266            (code_blob_type == CodeBlobType::MethodNonProfiled);
 267   }
 268 }
 269 
 270 const char* CodeCache::get_code_heap_flag_name(int code_blob_type) {
 271   switch(code_blob_type) {
 272   case CodeBlobType::NonNMethod:
 273     return "NonNMethodCodeHeapSize";
 274     break;
 275   case CodeBlobType::MethodNonProfiled:
 276     return "NonProfiledCodeHeapSize";
 277     break;
 278   case CodeBlobType::MethodProfiled:
 279     return "ProfiledCodeHeapSize";
 280     break;
 281   }
 282   ShouldNotReachHere();
 283   return NULL;
 284 }
 285 
 286 void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type) {
 287   // Check if heap is needed
 288   if (!heap_available(code_blob_type)) {
 289     return;
 290   }
 291 
 292   // Create CodeHeap
 293   CodeHeap* heap = new CodeHeap(name, code_blob_type);
 294   _heaps->append(heap);
 295 
 296   // Reserve Space
 297   size_initial = round_to(size_initial, os::vm_page_size());
 298 
 299   if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) {
 300     vm_exit_during_initialization("Could not reserve enough space for code cache");
 301   }
 302 
 303   // Register the CodeHeap
 304   MemoryService::add_code_heap_memory_pool(heap, name);
 305 }


1010   FOR_ALL_HEAPS(heap) {
1011     (*heap)->verify();
1012     FOR_ALL_BLOBS(cb, *heap) {
1013       if (cb->is_alive()) {
1014         cb->verify();
1015       }
1016     }
1017   }
1018 }
1019 
1020 // A CodeHeap is full. Print out warning and report event.
1021 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1022   // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event
1023   CodeHeap* heap = get_code_heap(code_blob_type);
1024   assert(heap != NULL, "heap is null");
1025 
1026   if (!heap->was_full() || print) {
1027     // Not yet reported for this heap, report
1028     heap->report_full();
1029     if (SegmentedCodeCache) {
1030       warning("%s is full. Compiler has been disabled.", get_code_heap_name(code_blob_type));
1031       warning("Try increasing the code heap size using -XX:%s=", get_code_heap_flag_name(code_blob_type));

1032     } else {
1033       warning("CodeCache is full. Compiler has been disabled.");
1034       warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
1035     }
1036     ResourceMark rm;
1037     stringStream s;
1038     // Dump code cache  into a buffer before locking the tty,
1039     {
1040       MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1041       print_summary(&s);
1042     }
1043     ttyLocker ttyl;
1044     tty->print("%s", s.as_string());
1045   }
1046 
1047   _codemem_full_count++;
1048   EventCodeCacheFull event;
1049   if (event.should_commit()) {
1050     event.set_codeBlobType((u1)code_blob_type);
1051     event.set_startAddress((u8)heap->low_boundary());


src/share/vm/code/codeCache.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File