1008 static ParallelOldTracer* gc_tracer() { return &_gc_tracer; } 1009 1010 private: 1011 1012 static void initialize_space_info(); 1013 1014 // Return true if details about individual phases should be printed. 1015 static inline bool print_phases(); 1016 1017 // Clear the marking bitmap and summary data that cover the specified space. 1018 static void clear_data_covering_space(SpaceId id); 1019 1020 static void pre_compact(PreGCValues* pre_gc_values); 1021 static void post_compact(); 1022 1023 // Mark live objects 1024 static void marking_phase(ParCompactionManager* cm, 1025 bool maximum_heap_compaction, 1026 ParallelOldTracer *gc_tracer); 1027 1028 template <class T> 1029 static inline void follow_root(ParCompactionManager* cm, T* p); 1030 1031 // Compute the dense prefix for the designated space. This is an experimental 1032 // implementation currently not used in production. 1033 static HeapWord* compute_dense_prefix_via_density(const SpaceId id, 1034 bool maximum_compaction); 1035 1036 // Methods used to compute the dense prefix. 1037 1038 // Compute the value of the normal distribution at x = density. The mean and 1039 // standard deviation are values saved by initialize_dead_wood_limiter(). 1040 static inline double normal_distribution(double density); 1041 1042 // Initialize the static vars used by dead_wood_limiter(). 1043 static void initialize_dead_wood_limiter(); 1044 1045 // Return the percentage of space that can be treated as "dead wood" (i.e., 1046 // not reclaimed). 1047 static double dead_wood_limiter(double density, size_t min_percent); 1048 1049 // Find the first (left-most) region in the range [beg, end) that has at least 1050 // dead_words of dead space to the left. The argument beg must be the first 1319 // Verify that all the regions have been emptied. 1320 static void verify_complete(SpaceId space_id); 1321 #endif // #ifdef ASSERT 1322 }; 1323 1324 inline bool PSParallelCompact::mark_obj(oop obj) { 1325 const int obj_size = obj->size(); 1326 if (mark_bitmap()->mark_obj(obj, obj_size)) { 1327 _summary_data.add_obj(obj, obj_size); 1328 return true; 1329 } else { 1330 return false; 1331 } 1332 } 1333 1334 inline bool PSParallelCompact::is_marked(oop obj) { 1335 return mark_bitmap()->is_marked(obj); 1336 } 1337 1338 template <class T> 1339 inline void PSParallelCompact::follow_root(ParCompactionManager* cm, T* p) { 1340 assert(!Universe::heap()->is_in_reserved(p), 1341 "roots shouldn't be things within the heap"); 1342 1343 T heap_oop = oopDesc::load_heap_oop(p); 1344 if (!oopDesc::is_null(heap_oop)) { 1345 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1346 if (mark_bitmap()->is_unmarked(obj)) { 1347 if (mark_obj(obj)) { 1348 obj->follow_contents(cm); 1349 } 1350 } 1351 } 1352 cm->follow_marking_stacks(); 1353 } 1354 1355 template <class T> 1356 inline void PSParallelCompact::mark_and_push(ParCompactionManager* cm, T* p) { 1357 T heap_oop = oopDesc::load_heap_oop(p); 1358 if (!oopDesc::is_null(heap_oop)) { 1359 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1360 if (mark_bitmap()->is_unmarked(obj) && mark_obj(obj)) { 1361 cm->push(obj); 1362 } 1363 } 1364 } 1365 1366 template <class T> 1367 inline void PSParallelCompact::adjust_pointer(T* p) { 1368 T heap_oop = oopDesc::load_heap_oop(p); 1369 if (!oopDesc::is_null(heap_oop)) { 1370 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1371 oop new_obj = (oop)summary_data().calc_new_pointer(obj); 1372 assert(new_obj != NULL, // is forwarding ptr? 1373 "should be forwarded"); 1374 // Just always do the update unconditionally? 1375 if (new_obj != NULL) { 1506 decrement_words_remaining(words); 1507 _source += words; 1508 _destination += words; 1509 } 1510 1511 class UpdateOnlyClosure: public ParMarkBitMapClosure { 1512 private: 1513 const PSParallelCompact::SpaceId _space_id; 1514 ObjectStartArray* const _start_array; 1515 1516 public: 1517 UpdateOnlyClosure(ParMarkBitMap* mbm, 1518 ParCompactionManager* cm, 1519 PSParallelCompact::SpaceId space_id); 1520 1521 // Update the object. 1522 virtual IterationStatus do_addr(HeapWord* addr, size_t words); 1523 1524 inline void do_addr(HeapWord* addr); 1525 }; 1526 1527 inline void UpdateOnlyClosure::do_addr(HeapWord* addr) 1528 { 1529 _start_array->allocate_block(addr); 1530 oop(addr)->update_contents(compaction_manager()); 1531 } 1532 1533 class FillClosure: public ParMarkBitMapClosure 1534 { 1535 public: 1536 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) : 1537 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm), 1538 _start_array(PSParallelCompact::start_array(space_id)) 1539 { 1540 assert(space_id == PSParallelCompact::old_space_id, 1541 "cannot use FillClosure in the young gen"); 1542 } 1543 1544 virtual IterationStatus do_addr(HeapWord* addr, size_t size) { 1545 CollectedHeap::fill_with_objects(addr, size); 1546 HeapWord* const end = addr + size; 1547 do { 1548 _start_array->allocate_block(addr); 1549 addr += oop(addr)->size(); 1550 } while (addr < end); 1551 return ParMarkBitMap::incomplete; | 1008 static ParallelOldTracer* gc_tracer() { return &_gc_tracer; } 1009 1010 private: 1011 1012 static void initialize_space_info(); 1013 1014 // Return true if details about individual phases should be printed. 1015 static inline bool print_phases(); 1016 1017 // Clear the marking bitmap and summary data that cover the specified space. 1018 static void clear_data_covering_space(SpaceId id); 1019 1020 static void pre_compact(PreGCValues* pre_gc_values); 1021 static void post_compact(); 1022 1023 // Mark live objects 1024 static void marking_phase(ParCompactionManager* cm, 1025 bool maximum_heap_compaction, 1026 ParallelOldTracer *gc_tracer); 1027 1028 // Compute the dense prefix for the designated space. This is an experimental 1029 // implementation currently not used in production. 1030 static HeapWord* compute_dense_prefix_via_density(const SpaceId id, 1031 bool maximum_compaction); 1032 1033 // Methods used to compute the dense prefix. 1034 1035 // Compute the value of the normal distribution at x = density. The mean and 1036 // standard deviation are values saved by initialize_dead_wood_limiter(). 1037 static inline double normal_distribution(double density); 1038 1039 // Initialize the static vars used by dead_wood_limiter(). 1040 static void initialize_dead_wood_limiter(); 1041 1042 // Return the percentage of space that can be treated as "dead wood" (i.e., 1043 // not reclaimed). 1044 static double dead_wood_limiter(double density, size_t min_percent); 1045 1046 // Find the first (left-most) region in the range [beg, end) that has at least 1047 // dead_words of dead space to the left. The argument beg must be the first 1316 // Verify that all the regions have been emptied. 1317 static void verify_complete(SpaceId space_id); 1318 #endif // #ifdef ASSERT 1319 }; 1320 1321 inline bool PSParallelCompact::mark_obj(oop obj) { 1322 const int obj_size = obj->size(); 1323 if (mark_bitmap()->mark_obj(obj, obj_size)) { 1324 _summary_data.add_obj(obj, obj_size); 1325 return true; 1326 } else { 1327 return false; 1328 } 1329 } 1330 1331 inline bool PSParallelCompact::is_marked(oop obj) { 1332 return mark_bitmap()->is_marked(obj); 1333 } 1334 1335 template <class T> 1336 inline void PSParallelCompact::mark_and_push(ParCompactionManager* cm, T* p) { 1337 T heap_oop = oopDesc::load_heap_oop(p); 1338 if (!oopDesc::is_null(heap_oop)) { 1339 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1340 if (mark_bitmap()->is_unmarked(obj) && mark_obj(obj)) { 1341 cm->push(obj); 1342 } 1343 } 1344 } 1345 1346 template <class T> 1347 inline void PSParallelCompact::adjust_pointer(T* p) { 1348 T heap_oop = oopDesc::load_heap_oop(p); 1349 if (!oopDesc::is_null(heap_oop)) { 1350 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1351 oop new_obj = (oop)summary_data().calc_new_pointer(obj); 1352 assert(new_obj != NULL, // is forwarding ptr? 1353 "should be forwarded"); 1354 // Just always do the update unconditionally? 1355 if (new_obj != NULL) { 1486 decrement_words_remaining(words); 1487 _source += words; 1488 _destination += words; 1489 } 1490 1491 class UpdateOnlyClosure: public ParMarkBitMapClosure { 1492 private: 1493 const PSParallelCompact::SpaceId _space_id; 1494 ObjectStartArray* const _start_array; 1495 1496 public: 1497 UpdateOnlyClosure(ParMarkBitMap* mbm, 1498 ParCompactionManager* cm, 1499 PSParallelCompact::SpaceId space_id); 1500 1501 // Update the object. 1502 virtual IterationStatus do_addr(HeapWord* addr, size_t words); 1503 1504 inline void do_addr(HeapWord* addr); 1505 }; 1506 1507 class FillClosure: public ParMarkBitMapClosure 1508 { 1509 public: 1510 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) : 1511 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm), 1512 _start_array(PSParallelCompact::start_array(space_id)) 1513 { 1514 assert(space_id == PSParallelCompact::old_space_id, 1515 "cannot use FillClosure in the young gen"); 1516 } 1517 1518 virtual IterationStatus do_addr(HeapWord* addr, size_t size) { 1519 CollectedHeap::fill_with_objects(addr, size); 1520 HeapWord* const end = addr + size; 1521 do { 1522 _start_array->allocate_block(addr); 1523 addr += oop(addr)->size(); 1524 } while (addr < end); 1525 return ParMarkBitMap::incomplete; |