35 #include "utilities/macros.hpp"
36
37 template <typename T, class OopClosureType>
38 void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) {
39 T* p = (T*)start_of_static_fields(obj);
40 T* const end = p + java_lang_Class::static_oop_field_count_raw(obj);
41
42 for (; p < end; ++p) {
43 Devirtualizer::do_oop(closure, p);
44 }
45 }
46
47 template <typename T, class OopClosureType>
48 void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
49 InstanceKlass::oop_oop_iterate<T>(obj, closure);
50
51 if (Devirtualizer::do_metadata(closure)) {
52 Klass* klass = java_lang_Class::as_Klass_raw(obj);
53 // We'll get NULL for primitive mirrors.
54 if (klass != NULL) {
55 if (klass->is_instance_klass() && klass->class_loader_data()->has_class_mirror_holder()) {
56 // A non-strong hidden class or an unsafe anonymous class doesn't have its own class loader,
57 // so when handling the java mirror for the class we need to make sure its class
58 // loader data is claimed, this is done by calling do_cld explicitly.
59 // For non-anonymous classes the call to do_cld is made when the class
60 // loader itself is handled.
61 Devirtualizer::do_cld(closure, klass->class_loader_data());
62 } else {
63 Devirtualizer::do_klass(closure, klass);
64 }
65 } else {
66 // We would like to assert here (as below) that if klass has been NULL, then
67 // this has been a mirror for a primitive type that we do not need to follow
68 // as they are always strong roots.
69 // However, we might get across a klass that just changed during CMS concurrent
70 // marking if allocation occurred in the old generation.
71 // This is benign here, as we keep alive all CLDs that were loaded during the
72 // CMS concurrent phase in the class loading, i.e. they will be iterated over
73 // and kept alive during remark.
74 // assert(java_lang_Class::is_primitive(obj), "Sanity check");
75 }
|
35 #include "utilities/macros.hpp"
36
37 template <typename T, class OopClosureType>
38 void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) {
39 T* p = (T*)start_of_static_fields(obj);
40 T* const end = p + java_lang_Class::static_oop_field_count_raw(obj);
41
42 for (; p < end; ++p) {
43 Devirtualizer::do_oop(closure, p);
44 }
45 }
46
47 template <typename T, class OopClosureType>
48 void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
49 InstanceKlass::oop_oop_iterate<T>(obj, closure);
50
51 if (Devirtualizer::do_metadata(closure)) {
52 Klass* klass = java_lang_Class::as_Klass_raw(obj);
53 // We'll get NULL for primitive mirrors.
54 if (klass != NULL) {
55 if (klass->class_loader_data() == NULL) {
56 // This is a mirror that belongs to a shared class that has not be loaded yet.
57 // It's only reachable via HeapShared::roots(). All of its fields should be zero
58 // so there's no need to scan.
59 assert(klass->is_shared(), "must be");
60 return;
61 } else if (klass->is_instance_klass() && klass->class_loader_data()->has_class_mirror_holder()) {
62 // A non-strong hidden class or an unsafe anonymous class doesn't have its own class loader,
63 // so when handling the java mirror for the class we need to make sure its class
64 // loader data is claimed, this is done by calling do_cld explicitly.
65 // For non-anonymous classes the call to do_cld is made when the class
66 // loader itself is handled.
67 Devirtualizer::do_cld(closure, klass->class_loader_data());
68 } else {
69 Devirtualizer::do_klass(closure, klass);
70 }
71 } else {
72 // We would like to assert here (as below) that if klass has been NULL, then
73 // this has been a mirror for a primitive type that we do not need to follow
74 // as they are always strong roots.
75 // However, we might get across a klass that just changed during CMS concurrent
76 // marking if allocation occurred in the old generation.
77 // This is benign here, as we keep alive all CLDs that were loaded during the
78 // CMS concurrent phase in the class loading, i.e. they will be iterated over
79 // and kept alive during remark.
80 // assert(java_lang_Class::is_primitive(obj), "Sanity check");
81 }
|