mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
Reviewed-by: brutisso, coleenp, kbarrett, sjohanss
This commit is contained in:
parent
c0af548c2b
commit
232a59cb40
48 changed files with 2281 additions and 1867 deletions
|
@ -28,6 +28,12 @@
|
|||
#include "classfile/classLoaderData.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "oops/klass.hpp"
|
||||
#include "oops/instanceKlass.inline.hpp"
|
||||
#include "oops/instanceMirrorKlass.inline.hpp"
|
||||
#include "oops/instanceClassLoaderKlass.inline.hpp"
|
||||
#include "oops/instanceRefKlass.inline.hpp"
|
||||
#include "oops/objArrayKlass.inline.hpp"
|
||||
#include "oops/typeArrayKlass.inline.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
|
||||
inline void MetadataAwareOopClosure::do_class_loader_data(ClassLoaderData* cld) {
|
||||
|
@ -44,4 +50,63 @@ inline void MetadataAwareOopClosure::do_klass_nv(Klass* k) {
|
|||
|
||||
inline void MetadataAwareOopClosure::do_klass(Klass* k) { do_klass_nv(k); }
|
||||
|
||||
#ifdef ASSERT
|
||||
// This verification is applied to all visited oops.
|
||||
// The closures can turn is off by overriding should_verify_oops().
|
||||
template <typename T>
|
||||
void ExtendedOopClosure::verify(T* p) {
|
||||
if (should_verify_oops()) {
|
||||
T heap_oop = oopDesc::load_heap_oop(p);
|
||||
if (!oopDesc::is_null(heap_oop)) {
|
||||
oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
|
||||
assert(Universe::heap()->is_in_closed_subset(o),
|
||||
err_msg("should be in closed *p " PTR_FORMAT " " PTR_FORMAT, p2i(p), p2i(o)));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Implementation of the non-virtual do_oop dispatch.
|
||||
|
||||
template <class OopClosureType, typename T>
|
||||
inline void Devirtualizer<true>::do_oop(OopClosureType* closure, T* p) {
|
||||
debug_only(closure->verify(p));
|
||||
closure->do_oop_nv(p);
|
||||
}
|
||||
template <class OopClosureType>
|
||||
inline void Devirtualizer<true>::do_klass(OopClosureType* closure, Klass* k) {
|
||||
closure->do_klass_nv(k);
|
||||
}
|
||||
template <class OopClosureType>
|
||||
inline bool Devirtualizer<true>::do_metadata(OopClosureType* closure) {
|
||||
// Make sure the non-virtual and the virtual versions match.
|
||||
assert(closure->do_metadata_nv() == closure->do_metadata(), "Inconsistency in do_metadata");
|
||||
return closure->do_metadata_nv();
|
||||
}
|
||||
|
||||
// Implementation of the virtual do_oop dispatch.
|
||||
|
||||
template <class OopClosureType, typename T>
|
||||
void Devirtualizer<false>::do_oop(OopClosureType* closure, T* p) {
|
||||
debug_only(closure->verify(p));
|
||||
closure->do_oop(p);
|
||||
}
|
||||
template <class OopClosureType>
|
||||
void Devirtualizer<false>::do_klass(OopClosureType* closure, Klass* k) {
|
||||
closure->do_klass(k);
|
||||
}
|
||||
template <class OopClosureType>
|
||||
bool Devirtualizer<false>::do_metadata(OopClosureType* closure) {
|
||||
return closure->do_metadata();
|
||||
}
|
||||
|
||||
// The list of all "specializable" oop_oop_iterate function definitions.
|
||||
#define ALL_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
|
||||
ALL_INSTANCE_KLASS_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix) \
|
||||
ALL_INSTANCE_REF_KLASS_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix) \
|
||||
ALL_INSTANCE_MIRROR_KLASS_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix) \
|
||||
ALL_INSTANCE_CLASS_LOADER_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
|
||||
ALL_OBJ_ARRAY_KLASS_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix) \
|
||||
ALL_TYPE_ARRAY_KLASS_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix)
|
||||
|
||||
#endif // SHARE_VM_MEMORY_ITERATOR_INLINE_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue