hotspot/src/share/vm/code/codeCache.cpp
changeset 24424 2658d7834c6e
parent 23214 b6426873cb37
child 24440 7c472e3e3c57
equal deleted inserted replaced
24358:8528b67f6562 24424:2658d7834c6e
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    79 
    79 
    80   int total()                                    { return total_size; }
    80   int total()                                    { return total_size; }
    81   bool is_empty()                                { return count == 0; }
    81   bool is_empty()                                { return count == 0; }
    82 
    82 
    83   void print(const char* title) {
    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%%])",
    84     tty->print_cr(" #%d %s = %dK (hdr %d%%,  loc %d%%, code %d%%, stub %d%%, [oops %d%%, metadata %d%%, data %d%%, pcs %d%%])",
    85                   count,
    85                   count,
    86                   title,
    86                   title,
    87                   total() / K,
    87                   (int)(total() / K),
    88                   header_size             * 100 / total_size,
    88                   header_size             * 100 / total_size,
    89                   relocation_size         * 100 / total_size,
    89                   relocation_size         * 100 / total_size,
    90                   code_size               * 100 / total_size,
    90                   code_size               * 100 / total_size,
    91                   stub_size               * 100 / total_size,
    91                   stub_size               * 100 / total_size,
    92                   scopes_oop_size         * 100 / total_size,
    92                   scopes_oop_size         * 100 / total_size,
   189       // Expansion failed
   189       // Expansion failed
   190       return NULL;
   190       return NULL;
   191     }
   191     }
   192     if (PrintCodeCacheExtension) {
   192     if (PrintCodeCacheExtension) {
   193       ResourceMark rm;
   193       ResourceMark rm;
   194       tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)",
   194       tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)",
   195                     (intptr_t)_heap->low_boundary(), (intptr_t)_heap->high(),
   195                     (intptr_t)_heap->low_boundary(), (intptr_t)_heap->high(),
   196                     (address)_heap->high() - (address)_heap->low_boundary());
   196                     (address)_heap->high() - (address)_heap->low_boundary());
   197     }
   197     }
   198   }
   198   }
   199   maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
   199   maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
   485       while(iter.next()) {
   485       while(iter.next()) {
   486         if (iter.type() == relocInfo::virtual_call_type) {
   486         if (iter.type() == relocInfo::virtual_call_type) {
   487           if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   487           if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   488             CompiledIC *ic = CompiledIC_at(iter.reloc());
   488             CompiledIC *ic = CompiledIC_at(iter.reloc());
   489             if (TraceCompiledIC) {
   489             if (TraceCompiledIC) {
   490               tty->print("noticed icholder " INTPTR_FORMAT " ", ic->cached_icholder());
   490               tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
   491               ic->print();
   491               ic->print();
   492             }
   492             }
   493             assert(ic->cached_icholder() != NULL, "must be non-NULL");
   493             assert(ic->cached_icholder() != NULL, "must be non-NULL");
   494             count++;
   494             count++;
   495           }
   495           }
   739     HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
   739     HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
   740     wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
   740     wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
   741   }
   741   }
   742   // Print bytes that are allocated in the freelist
   742   // Print bytes that are allocated in the freelist
   743   ttyLocker ttl;
   743   ttyLocker ttl;
   744   tty->print_cr("Number of elements in freelist: %d",    freelist_length());
   744   tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT,    freelist_length());
   745   tty->print_cr("Allocated in freelist:          %dkB",  bytes_allocated_in_freelist()/K);
   745   tty->print_cr("Allocated in freelist:          " SSIZE_FORMAT "kB",  bytes_allocated_in_freelist()/K);
   746   tty->print_cr("Unused bytes in CodeBlobs:      %dkB",  (int)(wasted_bytes/K));
   746   tty->print_cr("Unused bytes in CodeBlobs:      " SSIZE_FORMAT "kB",  (wasted_bytes/K));
   747   tty->print_cr("Segment map size:               %dkB",  allocated_segments()/K); // 1 byte per segment
   747   tty->print_cr("Segment map size:               " SSIZE_FORMAT "kB",  allocated_segments()/K); // 1 byte per segment
   748 }
   748 }
   749 
   749 
   750 //------------------------------------------------------------------------------------------------
   750 //------------------------------------------------------------------------------------------------
   751 // Non-product version
   751 // Non-product version
   752 
   752 
   754 
   754 
   755 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
   755 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
   756   if (PrintCodeCache2) {  // Need to add a new flag
   756   if (PrintCodeCache2) {  // Need to add a new flag
   757     ResourceMark rm;
   757     ResourceMark rm;
   758     if (size == 0)  size = cb->size();
   758     if (size == 0)  size = cb->size();
   759     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, cb, size);
   759     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size);
   760   }
   760   }
   761 }
   761 }
   762 
   762 
   763 void CodeCache::print_internals() {
   763 void CodeCache::print_internals() {
   764   int nmethodCount = 0;
   764   int nmethodCount = 0;
   924                total/K, (total - unallocated_capacity())/K,
   924                total/K, (total - unallocated_capacity())/K,
   925                maxCodeCacheUsed/K, unallocated_capacity()/K);
   925                maxCodeCacheUsed/K, unallocated_capacity()/K);
   926 
   926 
   927   if (detailed) {
   927   if (detailed) {
   928     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
   928     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
   929                  _heap->low_boundary(),
   929                  p2i(_heap->low_boundary()),
   930                  _heap->high(),
   930                  p2i(_heap->high()),
   931                  _heap->high_boundary());
   931                  p2i(_heap->high_boundary()));
   932     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
   932     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
   933                  " adapters=" UINT32_FORMAT,
   933                  " adapters=" UINT32_FORMAT,
   934                  nof_blobs(), nof_nmethods(), nof_adapters());
   934                  nof_blobs(), nof_nmethods(), nof_adapters());
   935     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
   935     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
   936                  "enabled" : Arguments::mode() == Arguments::_int ?
   936                  "enabled" : Arguments::mode() == Arguments::_int ?