33 #include "oops/oop.inline.hpp" |
33 #include "oops/oop.inline.hpp" |
34 #include "oops/verifyOopClosure.hpp" |
34 #include "oops/verifyOopClosure.hpp" |
35 #include "runtime/handles.inline.hpp" |
35 #include "runtime/handles.inline.hpp" |
36 #include "runtime/thread.inline.hpp" |
36 #include "runtime/thread.inline.hpp" |
37 #include "utilities/copy.hpp" |
37 #include "utilities/copy.hpp" |
38 |
38 #include "utilities/macros.hpp" |
39 bool always_do_update_barrier = false; |
|
40 |
39 |
41 void oopDesc::print_on(outputStream* st) const { |
40 void oopDesc::print_on(outputStream* st) const { |
42 klass()->oop_print_on(oop(this), st); |
41 klass()->oop_print_on(oop(this), st); |
43 } |
42 } |
44 |
43 |
103 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) { |
102 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) { |
104 if (!Universe::heap()->is_oop(obj)) { |
103 if (!Universe::heap()->is_oop(obj)) { |
105 return false; |
104 return false; |
106 } |
105 } |
107 |
106 |
108 // Header verification: the mark is typically non-NULL. If we're |
107 // Header verification: the mark is typically non-zero. If we're |
109 // at a safepoint, it must not be null. |
108 // at a safepoint, it must not be zero. |
110 // Outside of a safepoint, the header could be changing (for example, |
109 // Outside of a safepoint, the header could be changing (for example, |
111 // another thread could be inflating a lock on this object). |
110 // another thread could be inflating a lock on this object). |
112 if (ignore_mark_word) { |
111 if (ignore_mark_word) { |
113 return true; |
112 return true; |
114 } |
113 } |
115 if (obj->mark_raw() != NULL) { |
114 if (obj->mark_raw().value() != 0) { |
116 return true; |
115 return true; |
117 } |
116 } |
118 return !SafepointSynchronize::is_at_safepoint(); |
117 return !SafepointSynchronize::is_at_safepoint(); |
119 } |
118 } |
120 |
119 |
121 // used only for asserts and guarantees |
120 // used only for asserts and guarantees |
122 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) { |
121 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) { |
123 return obj == NULL ? true : is_oop(obj, ignore_mark_word); |
122 return obj == NULL ? true : is_oop(obj, ignore_mark_word); |
124 } |
123 } |
125 |
|
126 #ifndef PRODUCT |
|
127 #if INCLUDE_CDS_JAVA_HEAP |
|
128 bool oopDesc::is_archived_object(oop p) { |
|
129 return HeapShared::is_archived_object(p); |
|
130 } |
|
131 #endif |
|
132 #endif // PRODUCT |
|
133 |
124 |
134 VerifyOopClosure VerifyOopClosure::verify_oop; |
125 VerifyOopClosure VerifyOopClosure::verify_oop; |
135 |
126 |
136 template <class T> void VerifyOopClosure::do_oop_work(T* p) { |
127 template <class T> void VerifyOopClosure::do_oop_work(T* p) { |
137 oop obj = RawAccess<>::oop_load(p); |
128 oop obj = RawAccess<>::oop_load(p); |
171 } else { |
162 } else { |
172 return *(void**)addr; |
163 return *(void**)addr; |
173 } |
164 } |
174 } |
165 } |
175 |
166 |
176 bool oopDesc::is_valid(oop obj) { |
|
177 if (!is_object_aligned(obj)) return false; |
|
178 if ((size_t)(oopDesc*)obj < os::min_page_size()) return false; |
|
179 |
|
180 // We need at least the mark and the klass word in the committed region. |
|
181 if (!os::is_readable_range(obj, (oopDesc*)obj + 1)) return false; |
|
182 if (!Universe::heap()->is_in(obj)) return false; |
|
183 |
|
184 Klass* k = (Klass*)load_klass_raw(obj); |
|
185 return Klass::is_valid(k); |
|
186 } |
|
187 |
|
188 oop oopDesc::oop_or_null(address addr) { |
|
189 if (is_valid(oop(addr))) { |
|
190 // We were just given an oop directly. |
|
191 return oop(addr); |
|
192 } |
|
193 |
|
194 // Try to find addr using block_start. |
|
195 HeapWord* p = Universe::heap()->block_start(addr); |
|
196 if (p != NULL && Universe::heap()->block_is_obj(p)) { |
|
197 if (!is_valid(oop(p))) return NULL; |
|
198 return oop(p); |
|
199 } |
|
200 |
|
201 // If we can't find it it just may mean that heap wasn't parsable. |
|
202 return NULL; |
|
203 } |
|
204 |
|
205 oop oopDesc::obj_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); } |
167 oop oopDesc::obj_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); } |
206 |
168 |
207 void oopDesc::obj_field_put_raw(int offset, oop value) { RawAccess<>::oop_store_at(as_oop(), offset, value); } |
169 void oopDesc::obj_field_put_raw(int offset, oop value) { RawAccess<>::oop_store_at(as_oop(), offset, value); } |
208 void oopDesc::release_obj_field_put(int offset, oop value) { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); } |
170 void oopDesc::release_obj_field_put(int offset, oop value) { HeapAccess<MO_RELEASE>::oop_store_at(as_oop(), offset, value); } |
209 void oopDesc::obj_field_put_volatile(int offset, oop value) { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); } |
171 void oopDesc::obj_field_put_volatile(int offset, oop value) { HeapAccess<MO_SEQ_CST>::oop_store_at(as_oop(), offset, value); } |
242 jfloat oopDesc::float_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); } |
204 jfloat oopDesc::float_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); } |
243 void oopDesc::release_float_field_put(int offset, jfloat value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); } |
205 void oopDesc::release_float_field_put(int offset, jfloat value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); } |
244 |
206 |
245 jdouble oopDesc::double_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); } |
207 jdouble oopDesc::double_field_acquire(int offset) const { return HeapAccess<MO_ACQUIRE>::load_at(as_oop(), offset); } |
246 void oopDesc::release_double_field_put(int offset, jdouble value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); } |
208 void oopDesc::release_double_field_put(int offset, jdouble value) { HeapAccess<MO_RELEASE>::store_at(as_oop(), offset, value); } |
|
209 |
|
210 #ifdef ASSERT |
|
211 void oopDesc::verify_forwardee(oop forwardee) { |
|
212 #if INCLUDE_CDS_JAVA_HEAP |
|
213 assert(!HeapShared::is_archived_object(forwardee) && !HeapShared::is_archived_object(this), |
|
214 "forwarding archive object"); |
|
215 #endif |
|
216 } |
|
217 #endif |