27 #include "classfile/systemDictionary.hpp"
28 #include "gc/shared/collectedHeap.inline.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "gc/shared/specialized_oop_closures.hpp"
31 #include "oops/instanceRefKlass.inline.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "utilities/macros.hpp"
34 #include "utilities/preserveException.hpp"
35
36 void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) {
37 // Clear the nonstatic oop-map entries corresponding to referent
38 // and nextPending field. They are treated specially by the
39 // garbage collector.
40 // The discovered field is used only by the garbage collector
41 // and is also treated specially.
42 InstanceKlass* ik = InstanceKlass::cast(k);
43
44 // Check that we have the right class
45 debug_only(static bool first_time = true);
46 assert(k == SystemDictionary::Reference_klass() && first_time,
47 "Invalid update of maps");
48 debug_only(first_time = false);
49 assert(ik->nonstatic_oop_map_count() == 1, "just checking");
50
51 OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
52
53 // Check that the current map is (2,4) - currently points at field with
54 // offset 2 (words) and has 4 map entries.
55 debug_only(int offset = java_lang_ref_Reference::referent_offset);
56 debug_only(unsigned int count = ((java_lang_ref_Reference::discovered_offset -
57 java_lang_ref_Reference::referent_offset)/heapOopSize) + 1);
58
59 if (UseSharedSpaces) {
60 assert(map->offset() == java_lang_ref_Reference::queue_offset &&
61 map->count() == 1, "just checking");
62 } else {
63 assert(map->offset() == offset && map->count() == count,
64 "just checking");
65
66 // Update map to (3,1) - point to offset of 3 (words) with 1 map entry.
67 map->set_offset(java_lang_ref_Reference::queue_offset);
68 map->set_count(1);
69 }
70 }
71
72
73 // Verification
74
75 void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
76 InstanceKlass::oop_verify_on(obj, st);
77 // Verify referent field
78 oop referent = java_lang_ref_Reference::referent(obj);
79 if (referent != NULL) {
80 guarantee(referent->is_oop(), "referent field heap failed");
81 }
82 // Verify next field
83 oop next = java_lang_ref_Reference::next(obj);
84 if (next != NULL) {
85 guarantee(next->is_oop(), "next field should be an oop");
86 guarantee(next->is_instance(), "next field should be an instance");
87 guarantee(InstanceKlass::cast(next->klass())->is_reference_instance_klass(), "next field verify failed");
88 }
89 }
|
27 #include "classfile/systemDictionary.hpp"
28 #include "gc/shared/collectedHeap.inline.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "gc/shared/specialized_oop_closures.hpp"
31 #include "oops/instanceRefKlass.inline.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "utilities/macros.hpp"
34 #include "utilities/preserveException.hpp"
35
36 void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) {
37 // Clear the nonstatic oop-map entries corresponding to referent
38 // and nextPending field. They are treated specially by the
39 // garbage collector.
40 // The discovered field is used only by the garbage collector
41 // and is also treated specially.
42 InstanceKlass* ik = InstanceKlass::cast(k);
43
44 // Check that we have the right class
45 debug_only(static bool first_time = true);
46 assert(k == SystemDictionary::Reference_klass() && first_time,
47 "Invalid update of Reference maps");
48 debug_only(first_time = false);
49 assert(ik->nonstatic_oop_map_count() == 1, "just checking");
50
51 OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
52
53 // Check that the current map is (2,4) - currently points at field with
54 // offset 2 (words) and has 4 map entries.
55 debug_only(int offset = java_lang_ref_Reference::referent_offset);
56 debug_only(unsigned int count = ((java_lang_ref_Reference::discovered_offset -
57 java_lang_ref_Reference::referent_offset)/heapOopSize) + 1);
58
59 if (UseSharedSpaces) {
60 assert(map->offset() == java_lang_ref_Reference::queue_offset &&
61 map->count() == 1, "just checking");
62 } else {
63 assert(map->offset() == offset && map->count() == count,
64 "just checking");
65
66 // Update map to (3,1) - point to offset of 3 (words) with 1 map entry.
67 map->set_offset(java_lang_ref_Reference::queue_offset);
68 map->set_count(1);
69 }
70 }
71
72 void InstanceRefKlass::update_nonstatic_ephemeron_oop_maps(Klass* k) {
73 // Clear the nonstatic oop-map entry corresponding to value field.
74 // It is treated specially by the garbage collector.
75 InstanceKlass* ik = InstanceKlass::cast(k);
76
77 // Check that we have the right class
78 debug_only(static bool first_time = true);
79 assert(k == SystemDictionary::Ephemeron_klass() && first_time,
80 "Invalid update of Ephemeron maps");
81 debug_only(first_time = false);
82 assert(ik->nonstatic_oop_map_count() == 2, "just checking");
83
84 // skip 1st map as it's the copy of the augmented Reference's map
85 OopMapBlock* map = ik->start_of_nonstatic_oop_maps() + 1;
86
87 debug_only(int offset = java_lang_ref_Ephemeron::value_offset);
88
89 if (UseSharedSpaces) {
90 assert(map->offset() == offset && map->count() == 0,
91 "just checking");
92 } else {
93 assert(map->offset() == offset && map->count() == 1,
94 "just checking");
95
96 // Update map to have 0 oops.
97 map->set_count(0);
98 }
99 }
100
101
102 // Verification
103
104 void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
105 InstanceKlass::oop_verify_on(obj, st);
106 // Verify referent field
107 oop referent = java_lang_ref_Reference::referent(obj);
108 if (referent != NULL) {
109 guarantee(referent->is_oop(), "referent field heap failed");
110 }
111 // Verify next field
112 oop next = java_lang_ref_Reference::next(obj);
113 if (next != NULL) {
114 guarantee(next->is_oop(), "next field should be an oop");
115 guarantee(next->is_instance(), "next field should be an instance");
116 guarantee(InstanceKlass::cast(next->klass())->is_reference_instance_klass(), "next field verify failed");
117 }
118 }
|