diff src/share/vm/code/nmethod.cpp @ 2375:d673ef06fe96

7028374: race in fix_oop_relocations for scavengeable nmethods Reviewed-by: kvn
author never
date Fri, 18 Mar 2011 15:52:42 -0700
parents fc5ebbb2d1a8
children c7f3d0b4570f
line wrap: on
line diff
--- a/src/share/vm/code/nmethod.cpp	Fri Mar 18 09:03:43 2011 -0700
+++ b/src/share/vm/code/nmethod.cpp	Fri Mar 18 15:52:42 2011 -0700
@@ -1105,6 +1105,20 @@
 }
 
 
+void nmethod::verify_oop_relocations() {
+  // Ensure sure that the code matches the current oop values
+  RelocIterator iter(this, NULL, NULL);
+  while (iter.next()) {
+    if (iter.type() == relocInfo::oop_type) {
+      oop_Relocation* reloc = iter.oop_reloc();
+      if (!reloc->oop_is_immediate()) {
+        reloc->verify_oop_relocation();
+      }
+    }
+  }
+}
+
+
 ScopeDesc* nmethod::scope_desc_at(address pc) {
   PcDesc* pd = pc_desc_at(pc);
   guarantee(pd != NULL, "scope must be present");
@@ -1823,6 +1837,7 @@
     assert(cur != NULL, "not NULL-terminated");
     nmethod* next = cur->_oops_do_mark_link;
     cur->_oops_do_mark_link = NULL;
+    cur->fix_oop_relocations();
     NOT_PRODUCT(if (TraceScavenge)  cur->print_on(tty, "oops_do, unmark\n"));
     cur = next;
   }