--- a/hotspot/src/share/vm/memory/iterator.cpp Tue Sep 15 11:09:34 2009 -0700
+++ b/hotspot/src/share/vm/memory/iterator.cpp Tue Sep 15 21:53:47 2009 -0700
@@ -32,3 +32,42 @@
void VoidClosure::do_void() {
ShouldNotCallThis();
}
+
+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(CodeBlob* cb) {
+ cb->oops_do(_cl);
+}
+
+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);
+ }
+}
+
+