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/macros.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 #if INCLUDE_TRACE
  64 #include "trace/tracing.hpp"
  65 #endif
  66 
  67 // Helper class for printing in CodeCache
  68 class CodeBlob_sizes {
  69  private:
  70   int count;
  71   int total_size;
  72   int header_size;
  73   int code_size;
  74   int stub_size;
  75   int relocation_size;
  76   int scopes_oop_size;
  77   int scopes_metadata_size;
  78   int scopes_data_size;
  79   int scopes_pcs_size;
  80 
  81  public:
  82   CodeBlob_sizes() {
  83     count            = 0;
  84     total_size       = 0;
  85     header_size      = 0;


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


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