hotspot/src/share/vm/code/codeCache.cpp
changeset 24440 7c472e3e3c57
parent 24439 252c634b2e1c
parent 24424 2658d7834c6e
child 25486 be44827be5e7
equal deleted inserted replaced
24439:252c634b2e1c 24440:7c472e3e3c57
     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,
   191       // Expansion failed
   191       // Expansion failed
   192       return NULL;
   192       return NULL;
   193     }
   193     }
   194     if (PrintCodeCacheExtension) {
   194     if (PrintCodeCacheExtension) {
   195       ResourceMark rm;
   195       ResourceMark rm;
   196       tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)",
   196       tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)",
   197                     (intptr_t)_heap->low_boundary(), (intptr_t)_heap->high(),
   197                     (intptr_t)_heap->low_boundary(), (intptr_t)_heap->high(),
   198                     (address)_heap->high() - (address)_heap->low_boundary());
   198                     (address)_heap->high() - (address)_heap->low_boundary());
   199     }
   199     }
   200   }
   200   }
   201   maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
   201   maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
   488       while(iter.next()) {
   488       while(iter.next()) {
   489         if (iter.type() == relocInfo::virtual_call_type) {
   489         if (iter.type() == relocInfo::virtual_call_type) {
   490           if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   490           if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   491             CompiledIC *ic = CompiledIC_at(iter.reloc());
   491             CompiledIC *ic = CompiledIC_at(iter.reloc());
   492             if (TraceCompiledIC) {
   492             if (TraceCompiledIC) {
   493               tty->print("noticed icholder " INTPTR_FORMAT " ", ic->cached_icholder());
   493               tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
   494               ic->print();
   494               ic->print();
   495             }
   495             }
   496             assert(ic->cached_icholder() != NULL, "must be non-NULL");
   496             assert(ic->cached_icholder() != NULL, "must be non-NULL");
   497             count++;
   497             count++;
   498           }
   498           }
   742     HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
   742     HeapBlock* heap_block = ((HeapBlock*)cb) - 1;
   743     wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
   743     wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size();
   744   }
   744   }
   745   // Print bytes that are allocated in the freelist
   745   // Print bytes that are allocated in the freelist
   746   ttyLocker ttl;
   746   ttyLocker ttl;
   747   tty->print_cr("Number of elements in freelist: %d",    freelist_length());
   747   tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT,    freelist_length());
   748   tty->print_cr("Allocated in freelist:          %dkB",  bytes_allocated_in_freelist()/K);
   748   tty->print_cr("Allocated in freelist:          " SSIZE_FORMAT "kB",  bytes_allocated_in_freelist()/K);
   749   tty->print_cr("Unused bytes in CodeBlobs:      %dkB",  (int)(wasted_bytes/K));
   749   tty->print_cr("Unused bytes in CodeBlobs:      " SSIZE_FORMAT "kB",  (wasted_bytes/K));
   750   tty->print_cr("Segment map size:               %dkB",  allocated_segments()/K); // 1 byte per segment
   750   tty->print_cr("Segment map size:               " SSIZE_FORMAT "kB",  allocated_segments()/K); // 1 byte per segment
   751 }
   751 }
   752 
   752 
   753 //------------------------------------------------------------------------------------------------
   753 //------------------------------------------------------------------------------------------------
   754 // Non-product version
   754 // Non-product version
   755 
   755 
   757 
   757 
   758 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
   758 void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) {
   759   if (PrintCodeCache2) {  // Need to add a new flag
   759   if (PrintCodeCache2) {  // Need to add a new flag
   760     ResourceMark rm;
   760     ResourceMark rm;
   761     if (size == 0)  size = cb->size();
   761     if (size == 0)  size = cb->size();
   762     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, cb, size);
   762     tty->print_cr("CodeCache %s:  addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size);
   763   }
   763   }
   764 }
   764 }
   765 
   765 
   766 void CodeCache::print_internals() {
   766 void CodeCache::print_internals() {
   767   int nmethodCount = 0;
   767   int nmethodCount = 0;
   927                total/K, (total - unallocated_capacity())/K,
   927                total/K, (total - unallocated_capacity())/K,
   928                maxCodeCacheUsed/K, unallocated_capacity()/K);
   928                maxCodeCacheUsed/K, unallocated_capacity()/K);
   929 
   929 
   930   if (detailed) {
   930   if (detailed) {
   931     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
   931     st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
   932                  _heap->low_boundary(),
   932                  p2i(_heap->low_boundary()),
   933                  _heap->high(),
   933                  p2i(_heap->high()),
   934                  _heap->high_boundary());
   934                  p2i(_heap->high_boundary()));
   935     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
   935     st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
   936                  " adapters=" UINT32_FORMAT,
   936                  " adapters=" UINT32_FORMAT,
   937                  nof_blobs(), nof_nmethods(), nof_adapters());
   937                  nof_blobs(), nof_nmethods(), nof_adapters());
   938     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
   938     st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
   939                  "enabled" : Arguments::mode() == Arguments::_int ?
   939                  "enabled" : Arguments::mode() == Arguments::_int ?