hotspot/src/share/vm/memory/iterator.cpp
changeset 3919 b15d85d98b61
parent 3795 6227ff014cfe
parent 3913 e049e6b81e11
child 5686 5435e77aa3df
child 5547 f4b087cbb361
--- a/hotspot/src/share/vm/memory/iterator.cpp	Fri Oct 02 11:26:25 2009 -0700
+++ b/hotspot/src/share/vm/memory/iterator.cpp	Fri Oct 09 15:18:52 2009 -0700
@@ -46,3 +46,42 @@
 }
 #endif
 
+
+MarkingCodeBlobClosure::MarkScope::MarkScope(bool activate)
+  : _active(activate)
+{
+  if (_active)  nmethod::oops_do_marking_prologue();
+}
+
+MarkingCodeBlobClosure::MarkScope::~MarkScope() {
+  if (_active)  nmethod::oops_do_marking_epilogue();
+}
+
+void MarkingCodeBlobClosure::do_code_blob(CodeBlob* cb) {
+  if (!cb->is_nmethod())  return;
+  nmethod* nm = (nmethod*) cb;
+  if (!nm->test_set_oops_do_mark()) {
+    NOT_PRODUCT(if (TraceScavenge)  nm->print_on(tty, "oops_do, 1st visit\n"));
+    do_newly_marked_nmethod(nm);
+  } else {
+    NOT_PRODUCT(if (TraceScavenge)  nm->print_on(tty, "oops_do, skipped on 2nd visit\n"));
+  }
+}
+
+void CodeBlobToOopClosure::do_newly_marked_nmethod(nmethod* nm) {
+  nm->oops_do(_cl, /*do_strong_roots_only=*/ true);
+}
+
+void CodeBlobToOopClosure::do_code_blob(CodeBlob* cb) {
+  if (!_do_marking) {
+    NOT_PRODUCT(if (TraceScavenge && Verbose && cb->is_nmethod())  ((nmethod*)cb)->print_on(tty, "oops_do, unmarked visit\n"));
+    // This assert won't work, since there are lots of mini-passes
+    // (mostly in debug mode) that co-exist with marking phases.
+    //assert(!(cb->is_nmethod() && ((nmethod*)cb)->test_oops_do_mark()), "found marked nmethod during mark-free phase");
+    cb->oops_do(_cl);
+  } else {
+    MarkingCodeBlobClosure::do_code_blob(cb);
+  }
+}
+
+