src/share/vm/code/codeCache.cpp

changeset 6992
2c6ef90f030a
parent 6991
882004b9e7e1
child 7146
aff6ccb506cb
     1.1 --- a/src/share/vm/code/codeCache.cpp	Tue Jul 01 09:03:55 2014 +0200
     1.2 +++ b/src/share/vm/code/codeCache.cpp	Mon Jul 07 10:12:40 2014 +0200
     1.3 @@ -337,6 +337,11 @@
     1.4  // Walk the list of methods which might contain non-perm oops.
     1.5  void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
     1.6    assert_locked_or_safepoint(CodeCache_lock);
     1.7 +
     1.8 +  if (UseG1GC) {
     1.9 +    return;
    1.10 +  }
    1.11 +
    1.12    debug_only(mark_scavenge_root_nmethods());
    1.13  
    1.14    for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
    1.15 @@ -362,6 +367,11 @@
    1.16  
    1.17  void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
    1.18    assert_locked_or_safepoint(CodeCache_lock);
    1.19 +
    1.20 +  if (UseG1GC) {
    1.21 +    return;
    1.22 +  }
    1.23 +
    1.24    nm->set_on_scavenge_root_list();
    1.25    nm->set_scavenge_root_link(_scavenge_root_nmethods);
    1.26    set_scavenge_root_nmethods(nm);
    1.27 @@ -370,6 +380,11 @@
    1.28  
    1.29  void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
    1.30    assert_locked_or_safepoint(CodeCache_lock);
    1.31 +
    1.32 +  if (UseG1GC) {
    1.33 +    return;
    1.34 +  }
    1.35 +
    1.36    print_trace("drop_scavenge_root", nm);
    1.37    nmethod* last = NULL;
    1.38    nmethod* cur = scavenge_root_nmethods();
    1.39 @@ -391,6 +406,11 @@
    1.40  
    1.41  void CodeCache::prune_scavenge_root_nmethods() {
    1.42    assert_locked_or_safepoint(CodeCache_lock);
    1.43 +
    1.44 +  if (UseG1GC) {
    1.45 +    return;
    1.46 +  }
    1.47 +
    1.48    debug_only(mark_scavenge_root_nmethods());
    1.49  
    1.50    nmethod* last = NULL;
    1.51 @@ -423,6 +443,10 @@
    1.52  
    1.53  #ifndef PRODUCT
    1.54  void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
    1.55 +  if (UseG1GC) {
    1.56 +    return;
    1.57 +  }
    1.58 +
    1.59    // While we are here, verify the integrity of the list.
    1.60    mark_scavenge_root_nmethods();
    1.61    for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
    1.62 @@ -463,9 +487,36 @@
    1.63  }
    1.64  #endif //PRODUCT
    1.65  
    1.66 +void CodeCache::verify_clean_inline_caches() {
    1.67 +#ifdef ASSERT
    1.68 +  FOR_ALL_ALIVE_BLOBS(cb) {
    1.69 +    if (cb->is_nmethod()) {
    1.70 +      nmethod* nm = (nmethod*)cb;
    1.71 +      assert(!nm->is_unloaded(), "Tautology");
    1.72 +      nm->verify_clean_inline_caches();
    1.73 +      nm->verify();
    1.74 +    }
    1.75 +  }
    1.76 +#endif
    1.77 +}
    1.78 +
    1.79 +void CodeCache::verify_icholder_relocations() {
    1.80 +#ifdef ASSERT
    1.81 +  // make sure that we aren't leaking icholders
    1.82 +  int count = 0;
    1.83 +  FOR_ALL_BLOBS(cb) {
    1.84 +    if (cb->is_nmethod()) {
    1.85 +      nmethod* nm = (nmethod*)cb;
    1.86 +      count += nm->verify_icholder_relocations();
    1.87 +    }
    1.88 +  }
    1.89 +
    1.90 +  assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() ==
    1.91 +         CompiledICHolder::live_count(), "must agree");
    1.92 +#endif
    1.93 +}
    1.94  
    1.95  void CodeCache::gc_prologue() {
    1.96 -  assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_epilogue must be called");
    1.97  }
    1.98  
    1.99  void CodeCache::gc_epilogue() {
   1.100 @@ -478,41 +529,15 @@
   1.101          nm->cleanup_inline_caches();
   1.102        }
   1.103        DEBUG_ONLY(nm->verify());
   1.104 -      nm->fix_oop_relocations();
   1.105 +      DEBUG_ONLY(nm->verify_oop_relocations());
   1.106      }
   1.107    }
   1.108    set_needs_cache_clean(false);
   1.109    prune_scavenge_root_nmethods();
   1.110 -  assert(!nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called");
   1.111  
   1.112 -#ifdef ASSERT
   1.113 -  // make sure that we aren't leaking icholders
   1.114 -  int count = 0;
   1.115 -  FOR_ALL_BLOBS(cb) {
   1.116 -    if (cb->is_nmethod()) {
   1.117 -      RelocIterator iter((nmethod*)cb);
   1.118 -      while(iter.next()) {
   1.119 -        if (iter.type() == relocInfo::virtual_call_type) {
   1.120 -          if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) {
   1.121 -            CompiledIC *ic = CompiledIC_at(&iter);
   1.122 -            if (TraceCompiledIC) {
   1.123 -              tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder()));
   1.124 -              ic->print();
   1.125 -            }
   1.126 -            assert(ic->cached_icholder() != NULL, "must be non-NULL");
   1.127 -            count++;
   1.128 -          }
   1.129 -        }
   1.130 -      }
   1.131 -    }
   1.132 -  }
   1.133 -
   1.134 -  assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() ==
   1.135 -         CompiledICHolder::live_count(), "must agree");
   1.136 -#endif
   1.137 +  verify_icholder_relocations();
   1.138  }
   1.139  
   1.140 -
   1.141  void CodeCache::verify_oops() {
   1.142    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   1.143    VerifyOopClosure voc;

mercurial