< prev index next >

src/share/vm/code/codeCache.cpp

Print this page
rev 13280 : imported patch CollectedHeap_register_nmethod
rev 13281 : [mq]: CollectedHeap_register_nmethod_v2

@@ -681,26 +681,23 @@
   FOR_ALL_ALLOCABLE_HEAPS(heap) {
     FOR_ALL_BLOBS(cb, *heap) {
       if (cb->is_alive()) {
         f->do_code_blob(cb);
 #ifdef ASSERT
-        if (cb->is_nmethod())
-        ((nmethod*)cb)->verify_scavenge_root_oops();
+        if (cb->is_nmethod()) {
+          Universe::heap()->verify_nmethod_roots((nmethod*)cb);
+        }
 #endif //ASSERT
       }
     }
   }
 }
 
 // Walk the list of methods which might contain non-perm oops.
 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
   assert_locked_or_safepoint(CodeCache_lock);
 
-  if (UseG1GC) {
-    return;
-  }
-
   const bool fix_relocations = f->fix_relocations();
   debug_only(mark_scavenge_root_nmethods());
 
   nmethod* prev = NULL;
   nmethod* cur = scavenge_root_nmethods();

@@ -733,16 +730,19 @@
 
   // Check for stray marks.
   debug_only(verify_perm_nmethods(NULL));
 }
 
-void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
+void CodeCache::register_scavenge_root_nmethod(nmethod* nm) {
   assert_locked_or_safepoint(CodeCache_lock);
-
-  if (UseG1GC) {
-    return;
+  if (!nm->on_scavenge_root_list() && nm->detect_scavenge_root_oops()) {
+    add_scavenge_root_nmethod(nm);
   }
+}
+
+void CodeCache::add_scavenge_root_nmethod(nmethod* nm) {
+  assert_locked_or_safepoint(CodeCache_lock);
 
   nm->set_on_scavenge_root_list();
   nm->set_scavenge_root_link(_scavenge_root_nmethods);
   set_scavenge_root_nmethods(nm);
   print_trace("add_scavenge_root", nm);

@@ -752,12 +752,10 @@
   assert_locked_or_safepoint(CodeCache_lock);
 
   assert((prev == NULL && scavenge_root_nmethods() == nm) ||
          (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
 
-  assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
-
   print_trace("unlink_scavenge_root", nm);
   if (prev == NULL) {
     set_scavenge_root_nmethods(nm->scavenge_root_link());
   } else {
     prev->set_scavenge_root_link(nm->scavenge_root_link());

@@ -767,14 +765,10 @@
 }
 
 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
   assert_locked_or_safepoint(CodeCache_lock);
 
-  if (UseG1GC) {
-    return;
-  }
-
   print_trace("drop_scavenge_root", nm);
   nmethod* prev = NULL;
   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
     if (cur == nm) {
       unlink_scavenge_root_nmethod(cur, prev);

@@ -786,14 +780,10 @@
 }
 
 void CodeCache::prune_scavenge_root_nmethods() {
   assert_locked_or_safepoint(CodeCache_lock);
 
-  if (UseG1GC) {
-    return;
-  }
-
   debug_only(mark_scavenge_root_nmethods());
 
   nmethod* last = NULL;
   nmethod* cur = scavenge_root_nmethods();
   while (cur != NULL) {

@@ -818,14 +808,10 @@
   debug_only(verify_perm_nmethods(NULL));
 }
 
 #ifndef PRODUCT
 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) {
-  if (UseG1GC) {
-    return;
-  }
-
   // While we are here, verify the integrity of the list.
   mark_scavenge_root_nmethods();
   for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
     cur->clear_scavenge_root_marked();

@@ -852,11 +838,11 @@
     nmethod* nm = iter.method();
     bool call_f = (f_or_null != NULL);
     assert(nm->scavenge_root_not_marked(), "must be already processed");
     if (nm->on_scavenge_root_list())
       call_f = false;  // don't show this one to the client
-    nm->verify_scavenge_root_oops();
+    Universe::heap()->verify_nmethod_roots(nm);
     if (call_f)  f_or_null->do_code_blob(nm);
   }
 }
 #endif //PRODUCT
 

@@ -1638,6 +1624,5 @@
   st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
             " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
             blob_count(), nmethod_count(), adapter_count(),
             unallocated_capacity());
 }
-
< prev index next >