< prev index next >
src/share/vm/oops/instanceMirrorKlass.hpp
Print this page
rev 7183 : autospecialized oop_iterate using SFINAE and templates
@@ -27,10 +27,11 @@
#include "classfile/systemDictionary.hpp"
#include "oops/instanceKlass.hpp"
#include "runtime/handles.hpp"
#include "utilities/macros.hpp"
+#include "utilities/templateIdioms.hpp"
// An InstanceMirrorKlass is a specialized InstanceKlass for
// java.lang.Class instances. These instances are special because
// they contain the static fields of the class in addition to the
// normal fields of Class. This means they are variable sized
@@ -67,15 +68,11 @@
// based on UseCompressedOop for traversal
static HeapWord* start_of_static_fields(oop obj) {
return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
}
- static void init_offset_of_static_fields() {
- // Cache the offset of the static fields in the Class instance
- assert(_offset_of_static_fields == 0, "once");
- _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
- }
+ static void init_offset_of_static_fields();
static int offset_of_static_fields() {
return _offset_of_static_fields;
}
@@ -89,10 +86,30 @@
// Garbage collection
int oop_adjust_pointers(oop obj);
void oop_follow_contents(oop obj);
+private:
+ // Some dispatch functions for auto dispatching
+ template<class OopType, class OopClosureType>
+ void oop_iterate_and_dispatch_helper(oop obj, OopClosureType *closure);
+
+ // Make sure metadata only gets dispatched for ExtendedOopClosure using SFINAE
+ template <class OopClosureType>
+ typename enable_if<is_kind_of<ExtendedOopClosure, OopClosureType>::value, void>::type
+ do_metadata_if_applicable(oop obj, OopClosureType *cl);
+
+ template <class OopClosureType>
+ typename enable_if<!is_kind_of<ExtendedOopClosure, OopClosureType>::value, void>::type
+ do_metadata_if_applicable(oop obj, OopClosureType *cl) {}
+
+public:
+ template<class OopClosureType>
+ int oop_iterate_and_dispatch(oop obj, OopClosureType *cl);
+
+ int get_linear_oop_intervals(oop obj, OopInterval* &start, int &size) { return _instance_mirror_klass; }
+
// Parallel Scavenge and Parallel Old
PARALLEL_GC_DECLS
int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
return oop_oop_iterate_v(obj, blk);
< prev index next >