16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP 26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP 27 28 #include "gc/parallel/parallelScavengeHeap.hpp" 29 #include "gc/parallel/parMarkBitMap.inline.hpp" 30 #include "gc/parallel/psOldGen.hpp" 31 #include "gc/parallel/psPromotionLAB.inline.hpp" 32 #include "gc/parallel/psPromotionManager.hpp" 33 #include "gc/parallel/psScavenge.hpp" 34 #include "gc/shared/taskqueue.inline.hpp" 35 #include "logging/log.hpp" 36 #include "oops/oop.inline.hpp" 37 38 inline PSPromotionManager* PSPromotionManager::manager_array(uint index) { 39 assert(_manager_array != NULL, "access of NULL manager_array"); 40 assert(index <= ParallelGCThreads, "out of range manager_array access"); 41 return &_manager_array[index]; 42 } 43 44 template <class T> 45 inline void PSPromotionManager::push_depth(T* p) { 46 claimed_stack_depth()->push(p); 47 } 48 49 template <class T> 50 inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { 51 if (p != NULL) { // XXX: error if p != NULL here 52 oop o = oopDesc::load_decode_heap_oop_not_null(p); 53 if (o->is_forwarded()) { 54 o = o->forwardee(); 55 // Card mark 56 if (PSScavenge::is_obj_in_young(o)) { 57 PSScavenge::card_table()->inline_write_ref_field_gc(p, o); 58 } 59 oopDesc::encode_store_heap_oop_not_null(p, o); 60 } else { 61 push_depth(p); 62 } 63 } 64 } 65 66 template <class T> 67 inline void PSPromotionManager::claim_or_forward_depth(T* p) { 68 assert(should_scavenge(p, true), "revisiting object?"); 69 assert(ParallelScavengeHeap::heap()->is_in(p), "pointer outside heap"); 70 71 claim_or_forward_internal_depth(p); 72 } 73 74 inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj, 75 size_t obj_size, 76 uint age, bool tenured, 77 const PSPromotionLAB* lab) { 78 // Skip if memory allocation failed 79 if (new_obj != NULL) { 261 assert(o->is_forwarded(), "Sanity"); 262 new_obj = o->forwardee(); 263 } 264 265 // This code must come after the CAS test, or it will print incorrect 266 // information. 267 log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 268 should_scavenge(&new_obj) ? "copying" : "tenuring", 269 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); 270 271 return new_obj; 272 } 273 274 // Attempt to "claim" oop at p via CAS, push the new obj if successful 275 // This version tests the oop* to make sure it is within the heap before 276 // attempting marking. 277 template <class T, bool promote_immediately> 278 inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) { 279 assert(should_scavenge(p, true), "revisiting object?"); 280 281 oop o = oopDesc::load_decode_heap_oop_not_null(p); 282 oop new_obj = o->is_forwarded() 283 ? o->forwardee() 284 : copy_to_survivor_space<promote_immediately>(o); 285 286 // This code must come after the CAS test, or it will print incorrect 287 // information. 288 if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) { 289 log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 290 "forwarding", 291 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); 292 } 293 294 oopDesc::encode_store_heap_oop_not_null(p, new_obj); 295 296 // We cannot mark without test, as some code passes us pointers 297 // that are outside the heap. These pointers are either from roots 298 // or from metadata. 299 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && 300 ParallelScavengeHeap::heap()->is_in_reserved(p)) { 301 if (PSScavenge::is_obj_in_young(new_obj)) { 302 PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj); 303 } 304 } 305 } 306 307 inline void PSPromotionManager::process_popped_location_depth(StarTask p) { 308 if (is_oop_masked(p)) { 309 assert(PSChunkLargeArrays, "invariant"); 310 oop const old = unmask_chunked_array_oop(p); 311 process_array_chunk(old); 312 } else { 313 if (p.is_narrow()) { 314 assert(UseCompressedOops, "Error"); | 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP 26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP 27 28 #include "gc/parallel/parallelScavengeHeap.hpp" 29 #include "gc/parallel/parMarkBitMap.inline.hpp" 30 #include "gc/parallel/psOldGen.hpp" 31 #include "gc/parallel/psPromotionLAB.inline.hpp" 32 #include "gc/parallel/psPromotionManager.hpp" 33 #include "gc/parallel/psScavenge.hpp" 34 #include "gc/shared/taskqueue.inline.hpp" 35 #include "logging/log.hpp" 36 #include "oops/access.inline.hpp" 37 #include "oops/oop.inline.hpp" 38 39 inline PSPromotionManager* PSPromotionManager::manager_array(uint index) { 40 assert(_manager_array != NULL, "access of NULL manager_array"); 41 assert(index <= ParallelGCThreads, "out of range manager_array access"); 42 return &_manager_array[index]; 43 } 44 45 template <class T> 46 inline void PSPromotionManager::push_depth(T* p) { 47 claimed_stack_depth()->push(p); 48 } 49 50 template <class T> 51 inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { 52 if (p != NULL) { // XXX: error if p != NULL here 53 oop o = RawAccess<OOP_NOT_NULL>::oop_load(p); 54 if (o->is_forwarded()) { 55 o = o->forwardee(); 56 // Card mark 57 if (PSScavenge::is_obj_in_young(o)) { 58 PSScavenge::card_table()->inline_write_ref_field_gc(p, o); 59 } 60 RawAccess<OOP_NOT_NULL>::oop_store(p, o); 61 } else { 62 push_depth(p); 63 } 64 } 65 } 66 67 template <class T> 68 inline void PSPromotionManager::claim_or_forward_depth(T* p) { 69 assert(should_scavenge(p, true), "revisiting object?"); 70 assert(ParallelScavengeHeap::heap()->is_in(p), "pointer outside heap"); 71 72 claim_or_forward_internal_depth(p); 73 } 74 75 inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj, 76 size_t obj_size, 77 uint age, bool tenured, 78 const PSPromotionLAB* lab) { 79 // Skip if memory allocation failed 80 if (new_obj != NULL) { 262 assert(o->is_forwarded(), "Sanity"); 263 new_obj = o->forwardee(); 264 } 265 266 // This code must come after the CAS test, or it will print incorrect 267 // information. 268 log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 269 should_scavenge(&new_obj) ? "copying" : "tenuring", 270 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); 271 272 return new_obj; 273 } 274 275 // Attempt to "claim" oop at p via CAS, push the new obj if successful 276 // This version tests the oop* to make sure it is within the heap before 277 // attempting marking. 278 template <class T, bool promote_immediately> 279 inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) { 280 assert(should_scavenge(p, true), "revisiting object?"); 281 282 oop o = RawAccess<OOP_NOT_NULL>::oop_load(p); 283 oop new_obj = o->is_forwarded() 284 ? o->forwardee() 285 : copy_to_survivor_space<promote_immediately>(o); 286 287 // This code must come after the CAS test, or it will print incorrect 288 // information. 289 if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) { 290 log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 291 "forwarding", 292 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); 293 } 294 295 RawAccess<OOP_NOT_NULL>::oop_store(p, new_obj); 296 297 // We cannot mark without test, as some code passes us pointers 298 // that are outside the heap. These pointers are either from roots 299 // or from metadata. 300 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && 301 ParallelScavengeHeap::heap()->is_in_reserved(p)) { 302 if (PSScavenge::is_obj_in_young(new_obj)) { 303 PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj); 304 } 305 } 306 } 307 308 inline void PSPromotionManager::process_popped_location_depth(StarTask p) { 309 if (is_oop_masked(p)) { 310 assert(PSChunkLargeArrays, "invariant"); 311 oop const old = unmask_chunked_array_oop(p); 312 process_array_chunk(old); 313 } else { 314 if (p.is_narrow()) { 315 assert(UseCompressedOops, "Error"); |