src/share/vm/code/codeCache.cpp

Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:


  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "compiler/compileBroker.hpp"
  35 #include "gc/shared/gcLocker.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "oops/method.hpp"
  40 #include "oops/objArrayOop.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "oops/verifyOopClosure.hpp"
  43 #include "runtime/arguments.hpp"
  44 #include "runtime/compilationPolicy.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/icache.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/mutexLocker.hpp"
  50 #include "runtime/sweeper.hpp"
  51 #include "services/memoryService.hpp"
  52 #include "trace/tracing.hpp"
  53 #include "utilities/xmlstream.hpp"
  54 #ifdef COMPILER1
  55 #include "c1/c1_Compilation.hpp"
  56 #include "c1/c1_Compiler.hpp"
  57 #endif
  58 #ifdef COMPILER2
  59 #include "opto/c2compiler.hpp"
  60 #include "opto/compile.hpp"
  61 #include "opto/node.hpp"
  62 #endif



  63 
  64 // Helper class for printing in CodeCache
  65 class CodeBlob_sizes {
  66  private:
  67   int count;
  68   int total_size;
  69   int header_size;
  70   int code_size;
  71   int stub_size;
  72   int relocation_size;
  73   int scopes_oop_size;
  74   int scopes_metadata_size;
  75   int scopes_data_size;
  76   int scopes_pcs_size;
  77 
  78  public:
  79   CodeBlob_sizes() {
  80     count            = 0;
  81     total_size       = 0;
  82     header_size      = 0;


1338       const char *msg2 = "Try increasing the code cache size using -XX:ReservedCodeCacheSize=";
1339 
1340       log_warning(codecache)(msg1);
1341       log_warning(codecache)(msg2);
1342       warning(msg1);
1343       warning(msg2);
1344     }
1345     ResourceMark rm;
1346     stringStream s;
1347     // Dump code cache  into a buffer before locking the tty,
1348     {
1349       MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1350       print_summary(&s);
1351     }
1352     ttyLocker ttyl;
1353     tty->print("%s", s.as_string());
1354   }
1355 
1356   heap->report_full();
1357 

1358   EventCodeCacheFull event;
1359   if (event.should_commit()) {
1360     event.set_codeBlobType((u1)code_blob_type);
1361     event.set_startAddress((u8)heap->low_boundary());
1362     event.set_commitedTopAddress((u8)heap->high());
1363     event.set_reservedTopAddress((u8)heap->high_boundary());
1364     event.set_entryCount(heap->blob_count());
1365     event.set_methodCount(heap->nmethod_count());
1366     event.set_adaptorCount(heap->adapter_count());
1367     event.set_unallocatedCapacity(heap->unallocated_capacity());
1368     event.set_fullCount(heap->full_count());
1369     event.commit();

1370   }
1371 }
1372 PRAGMA_DIAG_POP
1373 
1374 void CodeCache::print_memory_overhead() {
1375   size_t wasted_bytes = 0;
1376   FOR_ALL_NMETHOD_HEAPS(heap) {
1377       CodeHeap* curr_heap = *heap;
1378       for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
1379         HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
1380         wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
1381       }
1382   }
1383   // Print bytes that are allocated in the freelist
1384   ttyLocker ttl;
1385   tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT,       freelists_length());
1386   tty->print_cr("Allocated in freelist:          " SSIZE_FORMAT "kB",  bytes_allocated_in_freelists()/K);
1387   tty->print_cr("Unused bytes in CodeBlobs:      " SSIZE_FORMAT "kB",  (wasted_bytes/K));
1388   tty->print_cr("Segment map size:               " SSIZE_FORMAT "kB",  allocated_segments()/K); // 1 byte per segment
1389 }


1607     ResourceMark rm;
1608     char *method_name = nm->method()->name_and_sig_as_C_string();
1609     st->print_cr("%d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]",
1610                  nm->compile_id(), nm->comp_level(), method_name, (intptr_t)nm->header_begin(),
1611                  (intptr_t)nm->code_begin(), (intptr_t)nm->code_end());
1612   }
1613 }
1614 
1615 void CodeCache::print_layout(outputStream* st) {
1616   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1617   ResourceMark rm;
1618   print_summary(st, true);
1619 }
1620 
1621 void CodeCache::log_state(outputStream* st) {
1622   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1623             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1624             blob_count(), nmethod_count(), adapter_count(),
1625             unallocated_capacity());
1626 }
1627 


  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "compiler/compileBroker.hpp"
  35 #include "gc/shared/gcLocker.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "oops/method.hpp"
  40 #include "oops/objArrayOop.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "oops/verifyOopClosure.hpp"
  43 #include "runtime/arguments.hpp"
  44 #include "runtime/compilationPolicy.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/icache.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/mutexLocker.hpp"
  50 #include "runtime/sweeper.hpp"
  51 #include "services/memoryService.hpp"

  52 #include "utilities/xmlstream.hpp"
  53 #ifdef COMPILER1
  54 #include "c1/c1_Compilation.hpp"
  55 #include "c1/c1_Compiler.hpp"
  56 #endif
  57 #ifdef COMPILER2
  58 #include "opto/c2compiler.hpp"
  59 #include "opto/compile.hpp"
  60 #include "opto/node.hpp"
  61 #endif
  62 #if INCLUDE_TRACE
  63 #include "trace/tracing.hpp"
  64 #endif
  65 
  66 // Helper class for printing in CodeCache
  67 class CodeBlob_sizes {
  68  private:
  69   int count;
  70   int total_size;
  71   int header_size;
  72   int code_size;
  73   int stub_size;
  74   int relocation_size;
  75   int scopes_oop_size;
  76   int scopes_metadata_size;
  77   int scopes_data_size;
  78   int scopes_pcs_size;
  79 
  80  public:
  81   CodeBlob_sizes() {
  82     count            = 0;
  83     total_size       = 0;
  84     header_size      = 0;


1340       const char *msg2 = "Try increasing the code cache size using -XX:ReservedCodeCacheSize=";
1341 
1342       log_warning(codecache)(msg1);
1343       log_warning(codecache)(msg2);
1344       warning(msg1);
1345       warning(msg2);
1346     }
1347     ResourceMark rm;
1348     stringStream s;
1349     // Dump code cache  into a buffer before locking the tty,
1350     {
1351       MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1352       print_summary(&s);
1353     }
1354     ttyLocker ttyl;
1355     tty->print("%s", s.as_string());
1356   }
1357 
1358   heap->report_full();
1359 
1360 #if INCLUDE_TRACE
1361   EventCodeCacheFull event;
1362   if (event.should_commit()) {
1363     event.set_codeBlobType((u1)code_blob_type);
1364     event.set_startAddress((u8)heap->low_boundary());
1365     event.set_commitedTopAddress((u8)heap->high());
1366     event.set_reservedTopAddress((u8)heap->high_boundary());
1367     event.set_entryCount(heap->blob_count());
1368     event.set_methodCount(heap->nmethod_count());
1369     event.set_adaptorCount(heap->adapter_count());
1370     event.set_unallocatedCapacity(heap->unallocated_capacity());
1371     event.set_fullCount(heap->full_count());
1372     event.commit();
1373 #endif
1374   }
1375 }
1376 PRAGMA_DIAG_POP
1377 
1378 void CodeCache::print_memory_overhead() {
1379   size_t wasted_bytes = 0;
1380   FOR_ALL_NMETHOD_HEAPS(heap) {
1381       CodeHeap* curr_heap = *heap;
1382       for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) {
1383         HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
1384         wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
1385       }
1386   }
1387   // Print bytes that are allocated in the freelist
1388   ttyLocker ttl;
1389   tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT,       freelists_length());
1390   tty->print_cr("Allocated in freelist:          " SSIZE_FORMAT "kB",  bytes_allocated_in_freelists()/K);
1391   tty->print_cr("Unused bytes in CodeBlobs:      " SSIZE_FORMAT "kB",  (wasted_bytes/K));
1392   tty->print_cr("Segment map size:               " SSIZE_FORMAT "kB",  allocated_segments()/K); // 1 byte per segment
1393 }


1611     ResourceMark rm;
1612     char *method_name = nm->method()->name_and_sig_as_C_string();
1613     st->print_cr("%d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]",
1614                  nm->compile_id(), nm->comp_level(), method_name, (intptr_t)nm->header_begin(),
1615                  (intptr_t)nm->code_begin(), (intptr_t)nm->code_end());
1616   }
1617 }
1618 
1619 void CodeCache::print_layout(outputStream* st) {
1620   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1621   ResourceMark rm;
1622   print_summary(st, true);
1623 }
1624 
1625 void CodeCache::log_state(outputStream* st) {
1626   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1627             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1628             blob_count(), nmethod_count(), adapter_count(),
1629             unallocated_capacity());
1630 }