src/share/vm/oops/cpCacheOop.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -573,10 +573,27 @@
   }
 
   return false;
 }
 
+// a constant pool cache entry should never contain old or obsolete methods
+bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() {
+  if (is_vfinal()) {
+    methodOop m = (methodOop)_f2;
+    // Return false if _f2 refers to an old or an obsolete method.
+    // _f2 == NULL || !m->is_method() are just as unexpected here.
+    return (m != NULL && m->is_method() && !m->is_old() && !m->is_obsolete());
+  } else if ((oop)_f1 == NULL || !((oop)_f1)->is_method()) {
+    // _f1 == NULL || !_f1->is_method() are OK here
+    return true;
+  }
+
+  methodOop m = (methodOop)_f1;
+  // return false if _f1 refers to an old or an obsolete method
+  return (!m->is_old() && !m->is_obsolete());
+}
+
 bool ConstantPoolCacheEntry::is_interesting_method_entry(klassOop k) {
   if (!is_method_entry()) {
     // not a method entry so not interesting by default
     return false;
   }

@@ -596,11 +613,11 @@
     }
     m = f1_as_method();
   }
 
   assert(m != NULL && m->is_method(), "sanity check");
-  if (m == NULL || !m->is_method() || m->method_holder() != k) {
+  if (m == NULL || !m->is_method() || (k != NULL && m->method_holder() != k)) {
     // robustness for above sanity checks or method is not in
     // the interesting class
     return false;
   }
 

@@ -608,20 +625,29 @@
   return true;
 }
 
 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   // print separator
-  if (index == 0) st->print_cr("                 -------------");
+  if (index == 0) {
+    // adds a searchable prefix when RedefineClasses() tracing is enabled
+    RC_TRACE_NO_CR(0x00004000, (""));
+    st->print_cr("                 -------------");
+  }
   // print entry
+  RC_TRACE_NO_CR(0x00004000, (""));
   st->print("%3d  ("PTR_FORMAT")  ", index, (intptr_t)this);
   if (is_secondary_entry())
     st->print_cr("[%5d|secondary]", main_entry_index());
   else
     st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
+  RC_TRACE_NO_CR(0x00004000, (""));
   st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)(oop)_f1);
+  RC_TRACE_NO_CR(0x00004000, (""));
   st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_f2);
+  RC_TRACE_NO_CR(0x00004000, (""));
   st->print_cr("                 [   "PTR_FORMAT"]", (intptr_t)_flags);
+  RC_TRACE_NO_CR(0x00004000, (""));
   st->print_cr("                 -------------");
 }
 
 void ConstantPoolCacheEntry::verify(outputStream* st) const {
   // not implemented yet

@@ -680,6 +706,27 @@
         // break out and get to the next interesting entry if there one
         break;
       }
     }
   }
+}
+
+// the constant pool cache should never contain old or obsolete methods
+bool constantPoolCacheOopDesc::check_no_old_or_obsolete_entries() {
+  for (int i = 1; i < length(); i++) {
+    if (entry_at(i)->is_interesting_method_entry(NULL) &&
+        !entry_at(i)->check_no_old_or_obsolete_entries()) {
+      return false;
+    }
+  }
+  return true;
+}
+
+void constantPoolCacheOopDesc::dump_cache() {
+  for (int i = 1; i < length(); i++) {
+    if (entry_at(i)->is_interesting_method_entry(NULL)) {
+      // adds a searchable prefix when RedefineClasses() tracing is enabled
+      RC_TRACE_NO_CR(0x00004000, (""));
+      entry_at(i)->print(tty, i);
+    }
+  }
 }