src/share/vm/code/codeCache.cpp

changeset 4037
da91efe96a93
parent 3969
1d7922586cf6
child 4098
8966c2d65d96
     1.1 --- a/src/share/vm/code/codeCache.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/code/codeCache.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -25,7 +25,9 @@
    1.11  #include "precompiled.hpp"
    1.12  #include "code/codeBlob.hpp"
    1.13  #include "code/codeCache.hpp"
    1.14 +#include "code/compiledIC.hpp"
    1.15  #include "code/dependencies.hpp"
    1.16 +#include "code/icBuffer.hpp"
    1.17  #include "code/nmethod.hpp"
    1.18  #include "code/pcDesc.hpp"
    1.19  #include "gc_implementation/shared/markSweep.hpp"
    1.20 @@ -33,7 +35,7 @@
    1.21  #include "memory/gcLocker.hpp"
    1.22  #include "memory/iterator.hpp"
    1.23  #include "memory/resourceArea.hpp"
    1.24 -#include "oops/methodOop.hpp"
    1.25 +#include "oops/method.hpp"
    1.26  #include "oops/objArrayOop.hpp"
    1.27  #include "oops/oop.inline.hpp"
    1.28  #include "runtime/handles.inline.hpp"
    1.29 @@ -54,6 +56,7 @@
    1.30    int stub_size;
    1.31    int relocation_size;
    1.32    int scopes_oop_size;
    1.33 +  int scopes_metadata_size;
    1.34    int scopes_data_size;
    1.35    int scopes_pcs_size;
    1.36  
    1.37 @@ -66,6 +69,7 @@
    1.38      stub_size        = 0;
    1.39      relocation_size  = 0;
    1.40      scopes_oop_size  = 0;
    1.41 +    scopes_metadata_size  = 0;
    1.42      scopes_data_size = 0;
    1.43      scopes_pcs_size  = 0;
    1.44    }
    1.45 @@ -83,6 +87,7 @@
    1.46                    code_size               * 100 / total_size,
    1.47                    stub_size               * 100 / total_size,
    1.48                    scopes_oop_size         * 100 / total_size,
    1.49 +                  scopes_metadata_size    * 100 / total_size,
    1.50                    scopes_data_size        * 100 / total_size,
    1.51                    scopes_pcs_size         * 100 / total_size);
    1.52    }
    1.53 @@ -98,6 +103,7 @@
    1.54        stub_size        += nm->stub_size();
    1.55  
    1.56        scopes_oop_size  += nm->oops_size();
    1.57 +      scopes_metadata_size  += nm->metadata_size();
    1.58        scopes_data_size += nm->scopes_data_size();
    1.59        scopes_pcs_size  += nm->scopes_pcs_size();
    1.60      } else {
    1.61 @@ -284,6 +290,12 @@
    1.62    }
    1.63  }
    1.64  
    1.65 +void CodeCache::alive_nmethods_do(void f(nmethod* nm)) {
    1.66 +  assert_locked_or_safepoint(CodeCache_lock);
    1.67 +  FOR_ALL_ALIVE_NMETHODS(nm) {
    1.68 +    f(nm);
    1.69 +  }
    1.70 +}
    1.71  
    1.72  int CodeCache::alignment_unit() {
    1.73    return (int)_heap->alignment_unit();
    1.74 @@ -448,7 +460,7 @@
    1.75  #endif //PRODUCT
    1.76  
    1.77  
    1.78 -nmethod* CodeCache::find_and_remove_saved_code(methodOop m) {
    1.79 +nmethod* CodeCache::find_and_remove_saved_code(Method* m) {
    1.80    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
    1.81    nmethod* saved = _saved_nmethods;
    1.82    nmethod* prev = NULL;
    1.83 @@ -468,7 +480,7 @@
    1.84        if (LogCompilation && (xtty != NULL)) {
    1.85          ttyLocker ttyl;
    1.86          xtty->begin_elem("nmethod_reconnected compile_id='%3d'", saved->compile_id());
    1.87 -        xtty->method(methodOop(m));
    1.88 +        xtty->method(m);
    1.89          xtty->stamp();
    1.90          xtty->end_elem();
    1.91        }
    1.92 @@ -518,7 +530,7 @@
    1.93    if (LogCompilation && (xtty != NULL)) {
    1.94      ttyLocker ttyl;
    1.95      xtty->begin_elem("nmethod_disconnected compile_id='%3d'", nm->compile_id());
    1.96 -    xtty->method(methodOop(nm->method()));
    1.97 +    xtty->method(nm->method());
    1.98      xtty->stamp();
    1.99      xtty->end_elem();
   1.100    }
   1.101 @@ -548,6 +560,32 @@
   1.102    set_needs_cache_clean(false);
   1.103    prune_scavenge_root_nmethods();
   1.104    assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called");
   1.105 +
   1.106 +#ifdef ASSERT
   1.107 +  // make sure that we aren't leaking icholders
   1.108 +  int count = 0;
   1.109 +  FOR_ALL_BLOBS(cb) {
   1.110 +    if (cb->is_nmethod()) {
   1.111 +      RelocIterator iter((nmethod*)cb);
   1.112 +      while(iter.next()) {
   1.113 +        if (iter.type() == relocInfo::virtual_call_type) {
   1.114 +          if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   1.115 +            CompiledIC *ic = CompiledIC_at(iter.reloc());
   1.116 +            if (TraceCompiledIC) {
   1.117 +              tty->print("noticed icholder " INTPTR_FORMAT " ", ic->cached_icholder());
   1.118 +              ic->print();
   1.119 +            }
   1.120 +            assert(ic->cached_icholder() != NULL, "must be non-NULL");
   1.121 +            count++;
   1.122 +          }
   1.123 +        }
   1.124 +      }
   1.125 +    }
   1.126 +  }
   1.127 +
   1.128 +  assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() ==
   1.129 +         CompiledICHolder::live_count(), "must agree");
   1.130 +#endif
   1.131  }
   1.132  
   1.133  
   1.134 @@ -649,8 +687,8 @@
   1.135  
   1.136    { No_Safepoint_Verifier nsv;
   1.137      for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
   1.138 -      klassOop d = str.klass();
   1.139 -      number_of_marked_CodeBlobs += instanceKlass::cast(d)->mark_dependent_nmethods(changes);
   1.140 +      Klass* d = str.klass();
   1.141 +      number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes);
   1.142      }
   1.143    }
   1.144  
   1.145 @@ -683,10 +721,10 @@
   1.146    int number_of_marked_CodeBlobs = 0;
   1.147  
   1.148    // Deoptimize all methods of the evolving class itself
   1.149 -  objArrayOop old_methods = dependee->methods();
   1.150 +  Array<Method*>* old_methods = dependee->methods();
   1.151    for (int i = 0; i < old_methods->length(); i++) {
   1.152      ResourceMark rm;
   1.153 -    methodOop old_method = (methodOop) old_methods->obj_at(i);
   1.154 +    Method* old_method = old_methods->at(i);
   1.155      nmethod *nm = old_method->code();
   1.156      if (nm != NULL) {
   1.157        nm->mark_for_deoptimization();
   1.158 @@ -702,7 +740,7 @@
   1.159        nm->mark_for_deoptimization();
   1.160        number_of_marked_CodeBlobs++;
   1.161      } else  {
   1.162 -      // flush caches in case they refer to a redefined methodOop
   1.163 +      // flush caches in case they refer to a redefined Method*
   1.164        nm->clear_inline_caches();
   1.165      }
   1.166    }
   1.167 @@ -721,7 +759,7 @@
   1.168  }
   1.169  
   1.170  
   1.171 -int CodeCache::mark_for_deoptimization(methodOop dependee) {
   1.172 +int CodeCache::mark_for_deoptimization(Method* dependee) {
   1.173    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   1.174    int number_of_marked_CodeBlobs = 0;
   1.175  

mercurial