src/share/vm/memory/iterator.hpp
Print this page
@@ -68,12 +68,12 @@
// The virtual (without suffix) and the non-virtual (with _nv suffix) need
// to be updated together, or else the devirtualization will break.
//
// Providing default implementations of the _nv functions unfortunately
// removes the compile-time safeness, but reduces the clutter for the
- // ExtendedOopClosures that don't need to walk the metadata. Currently,
- // only CMS needs these.
+ // ExtendedOopClosures that don't need to walk the metadata.
+ // Currently, only CMS and G1 need these.
virtual bool do_metadata() { return do_metadata_nv(); }
bool do_metadata_v() { return do_metadata(); }
bool do_metadata_nv() { return false; }
@@ -124,12 +124,13 @@
void initialize(OopClosure* oop_closure) {
assert(_oop_closure == NULL, "Should only be called once");
_oop_closure = oop_closure;
}
-public:
+ public:
KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
+
virtual void do_klass(Klass* k);
};
class CLDToOopClosure : public CLDClosure {
OopClosure* _oop_closure;
@@ -143,10 +144,27 @@
_must_claim_cld(must_claim_cld) {}
void do_cld(ClassLoaderData* cld);
};
+class CLDToKlassAndOopClosure : public CLDClosure {
+ friend class SharedHeap;
+ friend class G1CollectedHeap;
+ protected:
+ OopClosure* _oop_closure;
+ KlassClosure* _klass_closure;
+ bool _must_claim_cld;
+ public:
+ CLDToKlassAndOopClosure(KlassClosure* klass_closure,
+ OopClosure* oop_closure,
+ bool must_claim_cld) :
+ _oop_closure(oop_closure),
+ _klass_closure(klass_closure),
+ _must_claim_cld(must_claim_cld) {}
+ void do_cld(ClassLoaderData* cld);
+};
+
// The base class for all concurrent marking closures,
// that participates in class unloading.
// It's used to proxy through the metadata to the oops defined in them.
class MetadataAwareOopClosure: public ExtendedOopClosure {
KlassToOopClosure _klass_closure;
@@ -244,18 +262,30 @@
public:
// Called for each code blob.
virtual void do_code_blob(CodeBlob* cb) = 0;
};
+// Applies an oop closure to all ref fields in code blobs
+// iterated over in an object iteration.
+class CodeBlobToOopClosure : public CodeBlobClosure {
+ OopClosure* _cl;
+ bool _fix_relocations;
+ protected:
+ void do_nmethod(nmethod* nm);
+ public:
+ CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
+ virtual void do_code_blob(CodeBlob* cb);
+
+ const static bool FixRelocations = true;
+};
-class MarkingCodeBlobClosure : public CodeBlobClosure {
+class MarkingCodeBlobClosure : public CodeBlobToOopClosure {
public:
+ MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {}
// Called for each code blob, but at most once per unique blob.
- virtual void do_newly_marked_nmethod(nmethod* nm) = 0;
virtual void do_code_blob(CodeBlob* cb);
- // = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); }
class MarkScope : public StackObj {
protected:
bool _active;
public:
@@ -264,27 +294,10 @@
~MarkScope();
// = { if (active) nmethod::oops_do_marking_epilogue(); }
};
};
-
-// Applies an oop closure to all ref fields in code blobs
-// iterated over in an object iteration.
-class CodeBlobToOopClosure: public MarkingCodeBlobClosure {
- OopClosure* _cl;
- bool _do_marking;
-public:
- virtual void do_newly_marked_nmethod(nmethod* cb);
- // = { cb->oops_do(_cl); }
- virtual void do_code_blob(CodeBlob* cb);
- // = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); }
- CodeBlobToOopClosure(OopClosure* cl, bool do_marking)
- : _cl(cl), _do_marking(do_marking) {}
-};
-
-
-
// MonitorClosure is used for iterating over monitors in the monitors cache
class ObjectMonitor;
class MonitorClosure : public StackObj {