@@ -101,10 +101,10 @@ class CodeBlob_sizes {
101101 scopes_pcs_size = 0 ;
102102 }
103103
104- int total () { return total_size; }
105- bool is_empty () { return count == 0 ; }
104+ int total () const { return total_size; }
105+ bool is_empty () const { return count == 0 ; }
106106
107- void print (const char * title) {
107+ void print (const char * title) const {
108108 tty->print_cr (" #%d %s = %dK (hdr %dK, loc %dK, code %dK, stub %dK, [oops %dK, metadata %dK, data %dK, pcs %dK])" ,
109109 count,
110110 title,
@@ -1333,10 +1333,6 @@ void CodeCache::print_internals() {
13331333 int nmethodJava = 0 ;
13341334 int nmethodNative = 0 ;
13351335 int max_nm_size = 0 ;
1336- int runtime_stub_size = 0 ;
1337- int deoptimization_stub_size = 0 ;
1338- int uncommon_trap_stub_size = 0 ;
1339- int buffer_blob_size = 0 ;
13401336 ResourceMark rm;
13411337
13421338 int i = 0 ;
@@ -1372,18 +1368,14 @@ void CodeCache::print_internals() {
13721368 }
13731369 } else if (cb->is_runtime_stub ()) {
13741370 runtimeStubCount++;
1375- runtime_stub_size += cb->size ();
13761371 } else if (cb->is_deoptimization_stub ()) {
13771372 deoptimizationStubCount++;
1378- deoptimization_stub_size += cb->size ();
13791373 } else if (cb->is_uncommon_trap_stub ()) {
13801374 uncommonTrapStubCount++;
1381- uncommon_trap_stub_size += cb->size ();
13821375 } else if (cb->is_adapter_blob ()) {
13831376 adapterCount++;
13841377 } else if (cb->is_buffer_blob ()) {
13851378 bufferBlobCount++;
1386- buffer_blob_size += cb->size ();
13871379 }
13881380 }
13891381 }
@@ -1410,11 +1402,11 @@ void CodeCache::print_internals() {
14101402 tty->print_cr (" \t unloaded: %d" ,nmethodUnloaded);
14111403 tty->print_cr (" \t java: %d" ,nmethodJava);
14121404 tty->print_cr (" \t native: %d" ,nmethodNative);
1413- tty->print_cr (" runtime_stubs: %d (%dkB) " ,runtimeStubCount, ( int )(runtime_stub_size / K) );
1405+ tty->print_cr (" runtime_stubs: %d" ,runtimeStubCount);
14141406 tty->print_cr (" adapters: %d" ,adapterCount);
1415- tty->print_cr (" buffer blobs: %d (%dkB) " ,bufferBlobCount, ( int )(buffer_blob_size / K) );
1416- tty->print_cr (" deoptimization_stubs: %d (%dK) " ,deoptimizationStubCount, ( int )(deoptimization_stub_size / K) );
1417- tty->print_cr (" uncommon_traps: %d (%dkB) " ,uncommonTrapStubCount, ( int )(uncommon_trap_stub_size / K) );
1407+ tty->print_cr (" buffer blobs: %d" ,bufferBlobCount);
1408+ tty->print_cr (" deoptimization_stubs: %d" ,deoptimizationStubCount);
1409+ tty->print_cr (" uncommon_traps: %d" ,uncommonTrapStubCount);
14181410 tty->print_cr (" \n nmethod size distribution (non-zombie java)" );
14191411 tty->print_cr (" -------------------------------------------------" );
14201412
@@ -1438,26 +1430,65 @@ void CodeCache::print() {
14381430#ifndef PRODUCT
14391431 if (!Verbose) return ;
14401432
1441- FOR_ALL_ALLOCABLE_HEAPS (heap) {
1442- CodeBlob_sizes live;
1443- CodeBlob_sizes dead;
1433+ static_assert (0 < CompLevel_simple && CompLevel_simple <= CompLevel_full_optimization, " tier range check" );
1434+ CodeBlob_sizes live[CompLevel_full_optimization];
1435+ CodeBlob_sizes dead[CompLevel_full_optimization];
1436+ CodeBlob_sizes runtimeStub;
1437+ CodeBlob_sizes uncommonTrapStub;
1438+ CodeBlob_sizes deoptimizationStub;
1439+ CodeBlob_sizes adapter;
1440+ CodeBlob_sizes bufferBlob;
14441441
1442+ FOR_ALL_ALLOCABLE_HEAPS (heap) {
14451443 FOR_ALL_BLOBS (cb, *heap) {
1446- if (!cb->is_alive ()) {
1447- dead.add (cb);
1448- } else {
1449- live.add (cb);
1444+ if (cb->is_nmethod ()) {
1445+ const int level = cb->as_nmethod_or_null ()->comp_level ();
1446+ if (CompLevel_simple <= level && level <= CompLevel_full_optimization) {
1447+ if (!cb->is_alive ()) {
1448+ dead[level - 1 ].add (cb);
1449+ } else {
1450+ live[level - 1 ].add (cb);
1451+ }
1452+ }
1453+ } else if (cb->is_runtime_stub ()) {
1454+ runtimeStub.add (cb);
1455+ } else if (cb->is_deoptimization_stub ()) {
1456+ deoptimizationStub.add (cb);
1457+ } else if (cb->is_uncommon_trap_stub ()) {
1458+ uncommonTrapStub.add (cb);
1459+ } else if (cb->is_adapter_blob ()) {
1460+ adapter.add (cb);
1461+ } else if (cb->is_buffer_blob ()) {
1462+ bufferBlob.add (cb);
14501463 }
14511464 }
1465+ }
14521466
1453- tty->print_cr (" %s:" , (*heap)->name ());
1454- tty->print_cr (" nmethod dependency checking time %fs" , dependentCheckTime.seconds ());
1455-
1456- if (!live.is_empty ()) {
1457- live.print (" live" );
1467+ tty->print_cr (" nmethod dependency checking time %fs" , dependentCheckTime.seconds ());
1468+ for (int i = CompLevel_simple; i <= CompLevel_full_optimization; i++) {
1469+ tty->print_cr (" Tier %d:" , i);
1470+ if (!live[i - 1 ].is_empty ()) {
1471+ live[i - 1 ].print (" live" );
1472+ }
1473+ if (!dead[i - 1 ].is_empty ()) {
1474+ dead[i - 1 ].print (" dead" );
14581475 }
1459- if (!dead.is_empty ()) {
1460- dead.print (" dead" );
1476+ }
1477+
1478+ struct {
1479+ const char *name;
1480+ const CodeBlob_sizes *sizes;
1481+ } stubs[] = {
1482+ { " runtime" , &runtimeStub },
1483+ { " uncommon trap" , &uncommonTrapStub },
1484+ { " deoptimization" , &deoptimizationStub },
1485+ { " adapter" , &adapter },
1486+ { " buffer blob" , &bufferBlob },
1487+ };
1488+ tty->print_cr (" Stubs:" );
1489+ for (auto &stub: stubs) {
1490+ if (!stub.sizes ->is_empty ()) {
1491+ stub.sizes ->print (stub.name );
14611492 }
14621493 }
14631494
0 commit comments