src/share/vm/code/codeCache.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeBlob.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/compiledIC.hpp"
  29 #include "code/dependencies.hpp"
  30 #include "code/icBuffer.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "code/pcDesc.hpp"
  33 #include "compiler/compileBroker.hpp"
  34 #include "gc_implementation/shared/markSweep.hpp"

  35 #include "memory/allocation.inline.hpp"
  36 #include "memory/gcLocker.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 "runtime/handles.inline.hpp"
  43 #include "runtime/arguments.hpp"
  44 #include "runtime/icache.hpp"
  45 #include "runtime/java.hpp"
  46 #include "runtime/mutexLocker.hpp"
  47 #include "services/memoryService.hpp"
  48 #include "trace/tracing.hpp"
  49 #include "utilities/xmlstream.hpp"
  50 
  51 // Helper class for printing in CodeCache
  52 
  53 class CodeBlob_sizes {
  54  private:
  55   int count;
  56   int total_size;
  57   int header_size;
  58   int code_size;
  59   int stub_size;
  60   int relocation_size;
  61   int scopes_oop_size;
  62   int scopes_metadata_size;
  63   int scopes_data_size;
  64   int scopes_pcs_size;
  65 
  66  public:
  67   CodeBlob_sizes() {
  68     count            = 0;
  69     total_size       = 0;
  70     header_size      = 0;
  71     code_size        = 0;
  72     stub_size        = 0;
  73     relocation_size  = 0;
  74     scopes_oop_size  = 0;
  75     scopes_metadata_size  = 0;
  76     scopes_data_size = 0;
  77     scopes_pcs_size  = 0;
  78   }
  79 
  80   int total()                                    { return total_size; }

  81   bool is_empty()                                { return count == 0; }
  82 
  83   void print(const char* title) {
  84     tty->print_cr(" #%d %s = %dK (hdr %d%%,  loc %d%%, code %d%%, stub %d%%, [oops %d%%, data %d%%, pcs %d%%])",



  85                   count,
  86                   title,
  87                   total() / K,
  88                   header_size             * 100 / total_size,
  89                   relocation_size         * 100 / total_size,
  90                   code_size               * 100 / total_size,
  91                   stub_size               * 100 / total_size,
  92                   scopes_oop_size         * 100 / total_size,
  93                   scopes_metadata_size    * 100 / total_size,
  94                   scopes_data_size        * 100 / total_size,
  95                   scopes_pcs_size         * 100 / total_size);
  96   }

  97 
  98   void add(CodeBlob* cb) {
  99     count++;
 100     total_size       += cb->size();
 101     header_size      += cb->header_size();
 102     relocation_size  += cb->relocation_size();
 103     if (cb->is_nmethod()) {
 104       nmethod* nm = cb->as_nmethod_or_null();
 105       code_size        += nm->insts_size();
 106       stub_size        += nm->stub_size();
 107 
 108       scopes_oop_size  += nm->oops_size();
 109       scopes_metadata_size  += nm->metadata_size();
 110       scopes_data_size += nm->scopes_data_size();
 111       scopes_pcs_size  += nm->scopes_pcs_size();
 112     } else {
 113       code_size        += cb->code_size();
 114     }
 115   }
 116 };


 841     event.set_methodCount(nof_nmethods());
 842     event.set_adaptorCount(nof_adapters());
 843     event.set_unallocatedCapacity(unallocated_capacity()/K);
 844     event.set_fullCount(_codemem_full_count);
 845     event.commit();
 846   }
 847 }
 848 
 849 //------------------------------------------------------------------------------------------------
 850 // Non-product version
 851 
 852 #ifndef PRODUCT
 853 
 854 void CodeCache::verify_if_often() {
 855   if (VerifyCodeCacheOften) {
 856     _heap->verify();
 857   }
 858 }
 859 
 860 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
 861   if (PrintCodeCache2) {  // Need to add a new flag
 862     ResourceMark rm;
 863     if (size == 0)  size = cb->size();
 864     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, cb, size);
 865   }
 866 }
 867 
 868 void CodeCache::print_internals() {
 869   int nmethodCount = 0;
 870   int runtimeStubCount = 0;
 871   int adapterCount = 0;
 872   int deoptimizationStubCount = 0;
 873   int uncommonTrapStubCount = 0;
 874   int bufferBlobCount = 0;
 875   int total = 0;
 876   int nmethodAlive = 0;
 877   int nmethodNotEntrant = 0;
 878   int nmethodZombie = 0;
 879   int nmethodUnloaded = 0;
 880   int nmethodJava = 0;
 881   int nmethodNative = 0;
 882   int maxCodeSize = 0;



 883   ResourceMark rm;
 884 
 885   CodeBlob *cb;
 886   for (cb = first(); cb != NULL; cb = next(cb)) {
 887     total++;
 888     if (cb->is_nmethod()) {
 889       nmethod* nm = (nmethod*)cb;
 890 
 891       if (Verbose && nm->method() != NULL) {
 892         ResourceMark rm;
 893         char *method_name = nm->method()->name_and_sig_as_C_string();
 894         tty->print("%s", method_name);
 895         if(nm->is_alive()) { tty->print_cr(" alive"); }
 896         if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); }
 897         if(nm->is_zombie()) { tty->print_cr(" zombie"); }
 898       }
 899 
 900       nmethodCount++;
 901 
 902       if(nm->is_alive()) { nmethodAlive++; }
 903       if(nm->is_not_entrant()) { nmethodNotEntrant++; }
 904       if(nm->is_zombie()) { nmethodZombie++; }
 905       if(nm->is_unloaded()) { nmethodUnloaded++; }
 906       if(nm->is_native_method()) { nmethodNative++; }
 907 
 908       if(nm->method() != NULL && nm->is_java_method()) {
 909         nmethodJava++;
 910         if (nm->insts_size() > maxCodeSize) {
 911           maxCodeSize = nm->insts_size();













 912         }
 913       }
 914     } else if (cb->is_runtime_stub()) {
 915       runtimeStubCount++;
 916     } else if (cb->is_deoptimization_stub()) {
 917       deoptimizationStubCount++;
 918     } else if (cb->is_uncommon_trap_stub()) {
 919       uncommonTrapStubCount++;
 920     } else if (cb->is_adapter_blob()) {
 921       adapterCount++;
 922     } else if (cb->is_buffer_blob()) {
 923       bufferBlobCount++;


 924     }
 925   }
 926 





























 927   int bucketSize = 512;
 928   int bucketLimit = maxCodeSize / bucketSize + 1;
 929   int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode);
 930   memset(buckets,0,sizeof(int) * bucketLimit);
 931 
 932   for (cb = first(); cb != NULL; cb = next(cb)) {
 933     if (cb->is_nmethod()) {
 934       nmethod* nm = (nmethod*)cb;
 935       if(nm->is_java_method()) {
 936         buckets[nm->insts_size() / bucketSize]++;
 937       }
 938     }
 939   }
 940   tty->print_cr("Code Cache Entries (total of %d)",total);
 941   tty->print_cr("-------------------------------------------------");
 942   tty->print_cr("nmethods: %d",nmethodCount);
 943   tty->print_cr("\talive: %d",nmethodAlive);
 944   tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant);
 945   tty->print_cr("\tzombie: %d",nmethodZombie);
 946   tty->print_cr("\tunloaded: %d",nmethodUnloaded);
 947   tty->print_cr("\tjava: %d",nmethodJava);
 948   tty->print_cr("\tnative: %d",nmethodNative);
 949   tty->print_cr("runtime_stubs: %d",runtimeStubCount);
 950   tty->print_cr("adapters: %d",adapterCount);
 951   tty->print_cr("buffer blobs: %d",bufferBlobCount);
 952   tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount);
 953   tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount);
 954   tty->print_cr("\nnmethod size distribution (non-zombie java)");
 955   tty->print_cr("-------------------------------------------------");
 956 
 957   for(int i=0; i<bucketLimit; i++) {
 958     if(buckets[i] != 0) {
 959       tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize);
 960       tty->fill_to(40);
 961       tty->print_cr("%d",buckets[i]);
 962     }
 963   }
 964 
 965   FREE_C_HEAP_ARRAY(int, buckets, mtCode);
 966 }
 967 
 968 #endif // !PRODUCT
 969 
 970 void CodeCache::print() {
 971   print_summary(tty);
 972 
 973 #ifndef PRODUCT
 974   if (!Verbose) return;
 975 
 976   CodeBlob_sizes live;
 977   CodeBlob_sizes dead;
 978 
 979   FOR_ALL_BLOBS(p) {
 980     if (!p->is_alive()) {
 981       dead.add(p);
 982     } else {
 983       live.add(p);
 984     }
 985   }
 986 
 987   tty->print_cr("CodeCache:");
 988 
 989   tty->print_cr("nmethod dependency checking time %f", dependentCheckTime.seconds(),
 990                 dependentCheckTime.seconds() / dependentCheckCount);
 991 
 992   if (!live.is_empty()) {
 993     live.print("live");
 994   }
 995   if (!dead.is_empty()) {
 996     dead.print("dead");
 997   }
 998 






 999 
1000   if (WizardMode) {
1001      // print the oop_map usage
1002     int code_size = 0;
1003     int number_of_blobs = 0;
1004     int number_of_oop_maps = 0;
1005     int map_size = 0;
1006     FOR_ALL_BLOBS(p) {
1007       if (p->is_alive()) {
1008         number_of_blobs++;
1009         code_size += p->code_size();
1010         OopMapSet* set = p->oop_maps();
1011         if (set != NULL) {
1012           number_of_oop_maps += set->size();
1013           map_size           += set->heap_size();
1014         }
1015       }
1016     }
1017     tty->print_cr("OopMaps");
1018     tty->print_cr("  #blobs    = %d", number_of_blobs);
1019     tty->print_cr("  code size = %d", code_size);
1020     tty->print_cr("  #oop_maps = %d", number_of_oop_maps);
1021     tty->print_cr("  map size  = %d", map_size);
1022   }
1023 
1024 #endif // !PRODUCT
1025 }
1026 
1027 void CodeCache::print_summary(outputStream* st, bool detailed) {
1028   size_t total = (_heap->high_boundary() - _heap->low_boundary());
1029   st->print_cr("CodeCache: size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT
1030                "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb",
1031                total/K, (total - unallocated_capacity())/K,
1032                maxCodeCacheUsed/K, unallocated_capacity()/K);
1033 

1034   if (detailed) {






























1035     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
1036                  _heap->low_boundary(),
1037                  _heap->high(),
1038                  _heap->high_boundary());
1039     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
1040                  " adapters=" UINT32_FORMAT,
1041                  nof_blobs(), nof_nmethods(), nof_adapters());
1042     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
1043                  "enabled" : Arguments::mode() == Arguments::_int ?
1044                  "disabled (interpreter mode)" :
1045                  "disabled (not enough contiguous free space left)");
1046   }
1047 }
1048 
1049 void CodeCache::log_state(outputStream* st) {
1050   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1051             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1052             nof_blobs(), nof_nmethods(), nof_adapters(),
1053             unallocated_capacity());
1054 }
1055 


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeBlob.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/compiledIC.hpp"
  29 #include "code/dependencies.hpp"
  30 #include "code/icBuffer.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "code/pcDesc.hpp"
  33 #include "compiler/compileBroker.hpp"
  34 #include "gc_implementation/shared/markSweep.hpp"
  35 #include "interpreter/abstractInterpreter.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/gcLocker.hpp"
  38 #include "memory/iterator.hpp"
  39 #include "memory/resourceArea.hpp"
  40 #include "oops/method.hpp"
  41 #include "oops/objArrayOop.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "runtime/handles.inline.hpp"
  44 #include "runtime/arguments.hpp"
  45 #include "runtime/icache.hpp"
  46 #include "runtime/java.hpp"
  47 #include "runtime/mutexLocker.hpp"
  48 #include "services/memoryService.hpp"
  49 #include "trace/tracing.hpp"
  50 #include "utilities/xmlstream.hpp"
  51 
  52 // Helper class for printing in CodeCache
  53 
  54 class CodeBlob_sizes {
  55  private:
  56   size_t count;
  57   size_t total_size;
  58   size_t header_size;
  59   size_t code_size;
  60   size_t stub_size;
  61   size_t relocation_size;
  62   size_t scopes_oop_size;
  63   size_t scopes_metadata_size;
  64   size_t scopes_data_size;
  65   size_t scopes_pcs_size;
  66 
  67  public:
  68   CodeBlob_sizes() {
  69     count                = 0;
  70     total_size           = 0;
  71     header_size          = 0;
  72     code_size            = 0;
  73     stub_size            = 0;
  74     relocation_size      = 0;
  75     scopes_oop_size      = 0;
  76     scopes_metadata_size = 0;
  77     scopes_data_size     = 0;
  78     scopes_pcs_size      = 0;
  79   }
  80 
  81   size_t get_total_size()  { return total_size; }
  82   size_t get_total_count() { return count; }
  83   bool is_empty()   { return count == 0; }
  84 
  85   void print(const char* title) {
  86     if (count == 0) {
  87       tty->print_cr("  #%u %s", count, title);
  88     } else {
  89       tty->print_cr("  #%d %s = %dkB (hdr %u%%,  loc %u%%, code %u%%, stub %u%%, [oops %u%%, data %u%%, pcs %u%%])",
  90                     count,
  91                     title,
  92                     total_size / K,
  93                     header_size             * 100 / total_size,
  94                     relocation_size         * 100 / total_size,
  95                     code_size               * 100 / total_size,
  96                     stub_size               * 100 / total_size,
  97                     scopes_oop_size         * 100 / total_size,
  98                     scopes_metadata_size    * 100 / total_size,
  99                     scopes_data_size        * 100 / total_size,
 100                     scopes_pcs_size         * 100 / total_size);
 101         }
 102   }
 103 
 104   void add(CodeBlob* cb) {
 105     count++;
 106     total_size       += cb->size();
 107     header_size      += cb->header_size();
 108     relocation_size  += cb->relocation_size();
 109     if (cb->is_nmethod()) {
 110       nmethod* nm = cb->as_nmethod_or_null();
 111       code_size        += nm->insts_size();
 112       stub_size        += nm->stub_size();
 113 
 114       scopes_oop_size  += nm->oops_size();
 115       scopes_metadata_size  += nm->metadata_size();
 116       scopes_data_size += nm->scopes_data_size();
 117       scopes_pcs_size  += nm->scopes_pcs_size();
 118     } else {
 119       code_size        += cb->code_size();
 120     }
 121   }
 122 };


 847     event.set_methodCount(nof_nmethods());
 848     event.set_adaptorCount(nof_adapters());
 849     event.set_unallocatedCapacity(unallocated_capacity()/K);
 850     event.set_fullCount(_codemem_full_count);
 851     event.commit();
 852   }
 853 }
 854 
 855 //------------------------------------------------------------------------------------------------
 856 // Non-product version
 857 
 858 #ifndef PRODUCT
 859 
 860 void CodeCache::verify_if_often() {
 861   if (VerifyCodeCacheOften) {
 862     _heap->verify();
 863   }
 864 }
 865 
 866 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
 867   if (PrintCodeCacheAllocation) {  // Need to add a new flag
 868     ResourceMark rm;
 869     if (size == 0)  size = cb->size();
 870     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: %dB", event, cb, size);
 871   }
 872 }
 873 
 874 void CodeCache::print_details() {
 875   size_t total_entries = 0;
 876   size_t max_code_size = 0;
 877 
 878   CodeBlob_sizes runtime_stubs;
 879   CodeBlob_sizes adapters;
 880   CodeBlob_sizes deoptimization_stubs;
 881   CodeBlob_sizes uncommon_trap_stubs;
 882   CodeBlob_sizes buffer_blobs;
 883   CodeBlob_sizes in_use;
 884   CodeBlob_sizes not_entrant;
 885   CodeBlob_sizes zombie;
 886   CodeBlob_sizes unloaded;
 887   CodeBlob_sizes java_methods;
 888   CodeBlob_sizes native_methods;
 889   CodeBlob_sizes other_entries;
 890   CodeBlob_sizes tiers[CompLevel_full_optimization + 1];
 891 
 892   ResourceMark rm;
 893 
 894   FOR_ALL_BLOBS(cb) {
 895     total_entries++;

 896     if (cb->is_nmethod()) {
 897       nmethod* nm = (nmethod*)cb;
 898 
 899       if (Verbose && nm->method() != NULL) {
 900         ResourceMark rm;
 901         char *method_name = nm->method()->name_and_sig_as_C_string();
 902         tty->print("%s", method_name);
 903         if (nm->is_in_use()) {
 904           tty->print_cr(" in-use");
 905         } else if (nm->is_not_entrant()) {
 906           tty->print_cr(" not-entrant");
 907         } else if (nm->is_zombie()) {
 908           tty->print_cr(" zombie");
 909         }
 910       }
 911 
 912       if (nm->is_in_use()) {
 913         in_use.add(nm);
 914       } else if (nm->is_not_entrant()) {
 915         not_entrant.add(nm);
 916       } else if (nm->is_zombie()) {
 917         zombie.add(nm);
 918       } else if (nm->is_unloaded()) {
 919         unloaded.add(nm);
 920       }
 921 
 922       if(nm->is_native_method()) {
 923         native_methods.add(nm);
 924       }
 925 
 926       // Native methods are Tier 0
 927       tiers[nm->comp_level()].add(nm);
 928 
 929       if (nm->method() != NULL && nm->is_java_method()) {
 930         java_methods.add(nm);
 931         if ((size_t)nm->insts_size() > max_code_size) {
 932           max_code_size = nm->insts_size();
 933         }
 934       }
 935     } else if (cb->is_runtime_stub()) {
 936       runtime_stubs.add(cb);
 937     } else if (cb->is_deoptimization_stub()) {
 938       deoptimization_stubs.add(cb);
 939     } else if (cb->is_uncommon_trap_stub()) {
 940       uncommon_trap_stubs.add(cb);
 941     } else if (cb->is_adapter_blob()) {
 942       adapters.add(cb);
 943     } else if (cb->is_buffer_blob()) {
 944       buffer_blobs.add(cb);
 945     } else {
 946       other_entries.add(cb);
 947     }
 948   }
 949 
 950   tty->print_cr("\nCode cache entries: (total of #%u)", total_entries);
 951   size_t total_nm_count = tiers[0].get_total_count() + tiers[1].get_total_count() + tiers[2].get_total_count() +
 952                                   tiers[3].get_total_count() + tiers[4].get_total_count();
 953   size_t total_nm_size =  tiers[0].get_total_size() + tiers[1].get_total_size() + tiers[2].get_total_size() +
 954                                   tiers[3].get_total_size() + tiers[4].get_total_size();
 955   tty->print_cr("nmethods:\t#%u\t%ukB",  total_nm_count, total_nm_size / K);
 956   tty->print_cr("  Java:\t\t#%u\t%ukB",  java_methods.get_total_count(), java_methods.get_total_size() / K);
 957   tty->print_cr("   Tier 1:\t#%u\t%ukB", tiers[1].get_total_count(), tiers[1].get_total_size() / K);
 958   tty->print_cr("   Tier 2:\t#%u\t%ukB", tiers[2].get_total_count(), tiers[2].get_total_size() / K);
 959   tty->print_cr("   Tier 3:\t#%u\t%ukB", tiers[3].get_total_count(), tiers[3].get_total_size() / K);
 960   tty->print_cr("   Tier 4:\t#%u\t%ukB", tiers[4].get_total_count(), tiers[4].get_total_size() / K);
 961   tty->print_cr("  Native:\t#%u\t%ukB",  native_methods.get_total_count(), native_methods.get_total_size() / K);
 962 
 963   tty->print_cr("runtime-stubs:\t#%u\t%ukB",  runtime_stubs.get_total_count(), runtime_stubs.get_total_size() / K);
 964   tty->print_cr("adapters:\t#%u\t%ukB",       adapters.get_total_count(), adapters.get_total_size() / K);
 965   tty->print_cr("buffer blobs:\t#%u\t%ukB",   buffer_blobs.get_total_count(), buffer_blobs.get_total_size() / K);
 966   tty->print_cr("deopt-stubs:\t#%u\t%ukB",    deoptimization_stubs.get_total_count(), deoptimization_stubs.get_total_size() / K);
 967   tty->print_cr("uncommon-traps:\t#%u\t%ukB", uncommon_trap_stubs.get_total_count(), uncommon_trap_stubs.get_total_size() / K);
 968   tty->print_cr("others:\t\t#%u\t%ukB\n",     other_entries.get_total_count(), other_entries.get_total_size() / K);
 969 
 970   tty->print_cr("nmethod state distribution");
 971   tty->print_cr("  in-use:\t#%u\t%ukB",       in_use.get_total_count(), in_use.get_total_size() / K);
 972   tty->print_cr("  not-entrant:\t#%u\t%ukB",  not_entrant.get_total_count(), not_entrant.get_total_size() / K);
 973   tty->print_cr("  zombie:\t#%u\t%ukB",       zombie.get_total_count(), zombie.get_total_size() / K);
 974   tty->print_cr("  unloaded:\t#%u\t%ukB",     unloaded.get_total_count(), unloaded.get_total_size() / K);
 975 
 976   if (Verbose) {
 977     tty->print_cr("\nnmethod size distribution (non-zombie java)");
 978 
 979     int bucketSize = 512;
 980     int bucketLimit = max_code_size / bucketSize + 1;
 981     int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode);
 982     memset(buckets, 0, sizeof(int) * bucketLimit);
 983 
 984     FOR_ALL_BLOBS(cb) {
 985       if (cb->is_nmethod()) {
 986         nmethod* nm = (nmethod*)cb;
 987         if(nm->is_java_method()) {
 988           buckets[nm->insts_size() / bucketSize]++;
 989         }
 990       }
 991     }
















 992 
 993     for(int i=0; i<bucketLimit; i++) {
 994       if (buckets[i] != 0) {
 995         tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize);
 996         tty->fill_to(40);
 997         tty->print_cr("%d",buckets[i]);
 998       }
 999     }
1000 
1001     FREE_C_HEAP_ARRAY(int, buckets, mtCode);






1002 
1003 #ifndef PRODUCT















1004     tty->print_cr("nmethod dependency checking time %f", dependentCheckTime.seconds(),
1005                   dependentCheckTime.seconds() / dependentCheckCount);
1006 #endif





1007   }
1008 
1009 }
1010 
1011 #endif // !PRODUCT
1012 
1013 void CodeCache::print() {
1014   print_summary(tty);
1015 
1016   if (WizardMode) {
1017      // print the oop_map usage
1018     int code_size = 0;
1019     int number_of_blobs = 0;
1020     int number_of_oop_maps = 0;
1021     int map_size = 0;
1022     FOR_ALL_BLOBS(p) {
1023       if (p->is_alive()) {
1024         number_of_blobs++;
1025         code_size += p->code_size();
1026         OopMapSet* set = p->oop_maps();
1027         if (set != NULL) {
1028           number_of_oop_maps += set->size();
1029           map_size           += set->heap_size();
1030         }
1031       }
1032     }
1033     tty->print_cr("OopMaps");
1034     tty->print_cr("  #blobs    = %d", number_of_blobs);
1035     tty->print_cr("  code size = %d", code_size);
1036     tty->print_cr("  #oop_maps = %d", number_of_oop_maps);
1037     tty->print_cr("  map size  = %d", map_size);
1038   }


1039 }
1040 
1041 void CodeCache::print_summary(outputStream* st, bool detailed) {
1042   size_t total = (_heap->high_boundary() - _heap->low_boundary());
1043   st->print_cr("CodeCache: size=" SIZE_FORMAT "kB used=" SIZE_FORMAT
1044                "kB max_used=" SIZE_FORMAT "kB free=" SIZE_FORMAT "kB",
1045                total/K, (total - unallocated_capacity())/K,
1046                maxCodeCacheUsed/K, unallocated_capacity()/K);
1047 
1048 
1049   if (detailed) {
1050     size_t interpreter_size = AbstractInterpreter::code()->total_space() / K;
1051     CodeBlob_sizes live_nm;
1052     CodeBlob_sizes dead_nm;
1053     CodeBlob_sizes stubs;
1054     CodeBlob_sizes adapters;
1055     size_t total_size = 0;
1056 
1057     FOR_ALL_BLOBS(p) {
1058       total_size += p->size();
1059       // live or not-entrant methods
1060       if (p->is_nmethod()) {
1061         if (p->is_alive()) {
1062           live_nm.add(p);
1063         } else {
1064           dead_nm.add(p);
1065         }
1066       } else {
1067         if (p->is_adapter_blob()) {
1068           adapters.add(p);
1069         } else {
1070           stubs.add(p);
1071         }
1072       }
1073     }
1074     st->print_cr(" Interpreter=%ukB live_nmethods=%u(%ukB) dead_nmethods=%u(%ukB) stubs=%u(%ukB) adapters=%u(%ukB)",
1075                        interpreter_size, live_nm.get_total_count(), live_nm.get_total_size() / K,
1076                        dead_nm.get_total_count(), dead_nm.get_total_size() / K,
1077                        stubs.get_total_count(), stubs.get_total_size() / K,
1078                        adapters.get_total_count(), adapters.get_total_size() / K);
1079 
1080     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
1081                  _heap->low_boundary(),
1082                  _heap->high(),
1083                  _heap->high_boundary());
1084 


1085     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
1086                  "enabled" : Arguments::mode() == Arguments::_int ?
1087                  "disabled (interpreter mode)" :
1088                  "disabled (not enough contiguous free space left)");
1089   }
1090 }
1091 
1092 void CodeCache::log_state(outputStream* st) {
1093   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
1094             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
1095             nof_blobs(), nof_nmethods(), nof_adapters(),
1096             unallocated_capacity());
1097 }
1098