45 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
45 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
46 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
46 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
47 #include "oops/oop.pcgc.inline.hpp" |
47 #include "oops/oop.pcgc.inline.hpp" |
48 #endif |
48 #endif |
49 |
49 |
50 int instanceMirrorKlass::_offset_of_static_fields = 0; |
50 int InstanceMirrorKlass::_offset_of_static_fields = 0; |
51 |
51 |
52 #ifdef ASSERT |
52 #ifdef ASSERT |
53 template <class T> void assert_is_in(T *p) { |
53 template <class T> void assert_is_in(T *p) { |
54 T heap_oop = oopDesc::load_heap_oop(p); |
54 T heap_oop = oopDesc::load_heap_oop(p); |
55 if (!oopDesc::is_null(heap_oop)) { |
55 if (!oopDesc::is_null(heap_oop)) { |
167 MarkSweep::mark_and_push(p), \ |
167 MarkSweep::mark_and_push(p), \ |
168 assert_is_in_closed_subset) |
168 assert_is_in_closed_subset) |
169 } |
169 } |
170 |
170 |
171 #ifndef SERIALGC |
171 #ifndef SERIALGC |
172 void instanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm, |
172 void InstanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm, |
173 oop obj) { |
173 oop obj) { |
174 InstanceKlass::oop_follow_contents(cm, obj); |
174 InstanceKlass::oop_follow_contents(cm, obj); |
175 |
175 |
176 // Follow the klass field in the mirror. |
176 // Follow the klass field in the mirror. |
177 Klass* klass = java_lang_Class::as_Klass(obj); |
177 Klass* klass = java_lang_Class::as_Klass(obj); |
189 PSParallelCompact::mark_and_push(cm, p), \ |
189 PSParallelCompact::mark_and_push(cm, p), \ |
190 assert_is_in) |
190 assert_is_in) |
191 } |
191 } |
192 #endif // SERIALGC |
192 #endif // SERIALGC |
193 |
193 |
194 int instanceMirrorKlass::oop_adjust_pointers(oop obj) { |
194 int InstanceMirrorKlass::oop_adjust_pointers(oop obj) { |
195 int size = oop_size(obj); |
195 int size = oop_size(obj); |
196 InstanceKlass::oop_adjust_pointers(obj); |
196 InstanceKlass::oop_adjust_pointers(obj); |
197 |
197 |
198 // Follow the klass field in the mirror. |
198 // Follow the klass field in the mirror. |
199 Klass* klass = java_lang_Class::as_Klass(obj); |
199 Klass* klass = java_lang_Class::as_Klass(obj); |
233 /* Make sure the non-virtual and the virtual versions match. */ \ |
233 /* Make sure the non-virtual and the virtual versions match. */ \ |
234 assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ |
234 assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ |
235 "Inconsistency in do_metadata"); \ |
235 "Inconsistency in do_metadata"); \ |
236 if (closure->do_metadata##nv_suffix()) |
236 if (closure->do_metadata##nv_suffix()) |
237 |
237 |
238 // Macro to define instanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for |
238 // Macro to define InstanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for |
239 // all closures. Macros calling macros above for each oop size. |
239 // all closures. Macros calling macros above for each oop size. |
240 |
240 |
241 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
241 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
242 \ |
242 \ |
243 int instanceMirrorKlass:: \ |
243 int InstanceMirrorKlass:: \ |
244 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
244 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
245 /* Get size before changing pointers */ \ |
245 /* Get size before changing pointers */ \ |
246 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
246 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
247 \ |
247 \ |
248 InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ |
248 InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ |
263 } |
263 } |
264 |
264 |
265 #ifndef SERIALGC |
265 #ifndef SERIALGC |
266 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
266 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
267 \ |
267 \ |
268 int instanceMirrorKlass:: \ |
268 int InstanceMirrorKlass:: \ |
269 oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
269 oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
270 /* Get size before changing pointers */ \ |
270 /* Get size before changing pointers */ \ |
271 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
271 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
272 \ |
272 \ |
273 InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ |
273 InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ |
281 #endif // !SERIALGC |
281 #endif // !SERIALGC |
282 |
282 |
283 |
283 |
284 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
284 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
285 \ |
285 \ |
286 int instanceMirrorKlass:: \ |
286 int InstanceMirrorKlass:: \ |
287 oop_oop_iterate##nv_suffix##_m(oop obj, \ |
287 oop_oop_iterate##nv_suffix##_m(oop obj, \ |
288 OopClosureType* closure, \ |
288 OopClosureType* closure, \ |
289 MemRegion mr) { \ |
289 MemRegion mr) { \ |
290 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
290 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
291 \ |
291 \ |
316 #endif // SERIALGC |
316 #endif // SERIALGC |
317 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
317 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
318 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
318 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
319 |
319 |
320 #ifndef SERIALGC |
320 #ifndef SERIALGC |
321 void instanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
321 void InstanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
322 // Note that we don't have to follow the mirror -> klass pointer, since all |
322 // Note that we don't have to follow the mirror -> klass pointer, since all |
323 // klasses that are dirty will be scavenged when we iterate over the |
323 // klasses that are dirty will be scavenged when we iterate over the |
324 // ClassLoaderData objects. |
324 // ClassLoaderData objects. |
325 |
325 |
326 InstanceKlass::oop_push_contents(pm, obj); |
326 InstanceKlass::oop_push_contents(pm, obj); |
330 pm->claim_or_forward_depth(p); \ |
330 pm->claim_or_forward_depth(p); \ |
331 }, \ |
331 }, \ |
332 assert_nothing ) |
332 assert_nothing ) |
333 } |
333 } |
334 |
334 |
335 int instanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
335 int InstanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
336 int size = oop_size(obj); |
336 int size = oop_size(obj); |
337 InstanceKlass::oop_update_pointers(cm, obj); |
337 InstanceKlass::oop_update_pointers(cm, obj); |
338 |
338 |
339 // Follow the klass field in the mirror. |
339 // Follow the klass field in the mirror. |
340 Klass* klass = java_lang_Class::as_Klass(obj); |
340 Klass* klass = java_lang_Class::as_Klass(obj); |
353 assert_nothing) |
353 assert_nothing) |
354 return size; |
354 return size; |
355 } |
355 } |
356 #endif // SERIALGC |
356 #endif // SERIALGC |
357 |
357 |
358 int instanceMirrorKlass::instance_size(KlassHandle k) { |
358 int InstanceMirrorKlass::instance_size(KlassHandle k) { |
359 if (k() != NULL && k->oop_is_instance()) { |
359 if (k() != NULL && k->oop_is_instance()) { |
360 return align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size()); |
360 return align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size()); |
361 } |
361 } |
362 return size_helper(); |
362 return size_helper(); |
363 } |
363 } |
364 |
364 |
365 instanceOop instanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) { |
365 instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) { |
366 // Query before forming handle. |
366 // Query before forming handle. |
367 int size = instance_size(k); |
367 int size = instance_size(k); |
368 KlassHandle h_k(THREAD, this); |
368 KlassHandle h_k(THREAD, this); |
369 instanceOop i = (instanceOop) CollectedHeap::Class_obj_allocate(h_k, size, k, CHECK_NULL); |
369 instanceOop i = (instanceOop) CollectedHeap::Class_obj_allocate(h_k, size, k, CHECK_NULL); |
370 return i; |
370 return i; |
371 } |
371 } |
372 |
372 |
373 int instanceMirrorKlass::oop_size(oop obj) const { |
373 int InstanceMirrorKlass::oop_size(oop obj) const { |
374 return java_lang_Class::oop_size(obj); |
374 return java_lang_Class::oop_size(obj); |
375 } |
375 } |
376 |
376 |
377 int instanceMirrorKlass::compute_static_oop_field_count(oop obj) { |
377 int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) { |
378 Klass* k = java_lang_Class::as_Klass(obj); |
378 Klass* k = java_lang_Class::as_Klass(obj); |
379 if (k != NULL && k->oop_is_instance()) { |
379 if (k != NULL && k->oop_is_instance()) { |
380 return InstanceKlass::cast(k)->static_oop_field_count(); |
380 return InstanceKlass::cast(k)->static_oop_field_count(); |
381 } |
381 } |
382 return 0; |
382 return 0; |