Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 6254:a2f7274eb6ef
7114678: G1: various small fixes, code cleanup, and refactoring
Summary: Various cleanups as a prelude to introducing iterators for HeapRegions.
Reviewed-by: johnc, brutisso
author | tonyp |
---|---|
date | Thu, 19 Jul 2012 15:15:54 -0700 |
parents | d2a62e0f25eb |
children | aaf61e68b255 |
comparison
equal
deleted
inserted
replaced
6253:db823a892a55 | 6254:a2f7274eb6ef |
---|---|
372 // allocating a number of dead regions. This way we can induce very | 372 // allocating a number of dead regions. This way we can induce very |
373 // frequent marking cycles and stress the cleanup / concurrent | 373 // frequent marking cycles and stress the cleanup / concurrent |
374 // cleanup code more (as all the regions that will be allocated by | 374 // cleanup code more (as all the regions that will be allocated by |
375 // this method will be found dead by the marking cycle). | 375 // this method will be found dead by the marking cycle). |
376 void allocate_dummy_regions() PRODUCT_RETURN; | 376 void allocate_dummy_regions() PRODUCT_RETURN; |
377 | |
378 // Clear RSets after a compaction. It also resets the GC time stamps. | |
379 void clear_rsets_post_compaction(); | |
380 | |
381 // If the HR printer is active, dump the state of the regions in the | |
382 // heap after a compaction. | |
383 void print_hrs_post_compaction(); | |
377 | 384 |
378 // These are macros so that, if the assert fires, we get the correct | 385 // These are macros so that, if the assert fires, we get the correct |
379 // line number, file, etc. | 386 // line number, file, etc. |
380 | 387 |
381 #define heap_locking_asserts_err_msg(_extra_message_) \ | 388 #define heap_locking_asserts_err_msg(_extra_message_) \ |
1059 // Clear the cached CSet starting regions and time stamps. | 1066 // Clear the cached CSet starting regions and time stamps. |
1060 // Their validity is dependent on the GC timestamp. | 1067 // Their validity is dependent on the GC timestamp. |
1061 clear_cset_start_regions(); | 1068 clear_cset_start_regions(); |
1062 } | 1069 } |
1063 | 1070 |
1071 void check_gc_time_stamps() PRODUCT_RETURN; | |
1072 | |
1064 void increment_gc_time_stamp() { | 1073 void increment_gc_time_stamp() { |
1065 ++_gc_time_stamp; | 1074 ++_gc_time_stamp; |
1066 OrderAccess::fence(); | 1075 OrderAccess::fence(); |
1067 } | 1076 } |
1077 | |
1078 // Reset the given region's GC timestamp. If it's starts humongous, | |
1079 // also reset the GC timestamp of its corresponding | |
1080 // continues humongous regions too. | |
1081 void reset_gc_time_stamps(HeapRegion* hr); | |
1068 | 1082 |
1069 void iterate_dirty_card_closure(CardTableEntryClosure* cl, | 1083 void iterate_dirty_card_closure(CardTableEntryClosure* cl, |
1070 DirtyCardQueue* into_cset_dcq, | 1084 DirtyCardQueue* into_cset_dcq, |
1071 bool concurrent, int worker_i); | 1085 bool concurrent, int worker_i); |
1072 | 1086 |
1299 virtual void space_iterate(SpaceClosure* cl); | 1313 virtual void space_iterate(SpaceClosure* cl); |
1300 | 1314 |
1301 // Iterate over heap regions, in address order, terminating the | 1315 // Iterate over heap regions, in address order, terminating the |
1302 // iteration early if the "doHeapRegion" method returns "true". | 1316 // iteration early if the "doHeapRegion" method returns "true". |
1303 void heap_region_iterate(HeapRegionClosure* blk) const; | 1317 void heap_region_iterate(HeapRegionClosure* blk) const; |
1304 | |
1305 // Iterate over heap regions starting with r (or the first region if "r" | |
1306 // is NULL), in address order, terminating early if the "doHeapRegion" | |
1307 // method returns "true". | |
1308 void heap_region_iterate_from(HeapRegion* r, HeapRegionClosure* blk) const; | |
1309 | 1318 |
1310 // Return the region with the given index. It assumes the index is valid. | 1319 // Return the region with the given index. It assumes the index is valid. |
1311 HeapRegion* region_at(uint index) const { return _hrs.at(index); } | 1320 HeapRegion* region_at(uint index) const { return _hrs.at(index); } |
1312 | 1321 |
1313 // Divide the heap region sequence into "chunks" of some size (the number | 1322 // Divide the heap region sequence into "chunks" of some size (the number |
1349 | 1358 |
1350 // Given the id of a worker, obtain or calculate a suitable | 1359 // Given the id of a worker, obtain or calculate a suitable |
1351 // starting region for iterating over the current collection set. | 1360 // starting region for iterating over the current collection set. |
1352 HeapRegion* start_cset_region_for_worker(int worker_i); | 1361 HeapRegion* start_cset_region_for_worker(int worker_i); |
1353 | 1362 |
1363 // This is a convenience method that is used by the | |
1364 // HeapRegionIterator classes to calculate the starting region for | |
1365 // each worker so that they do not all start from the same region. | |
1366 HeapRegion* start_region_for_worker(uint worker_i, uint no_of_par_workers); | |
1367 | |
1354 // Iterate over the regions (if any) in the current collection set. | 1368 // Iterate over the regions (if any) in the current collection set. |
1355 void collection_set_iterate(HeapRegionClosure* blk); | 1369 void collection_set_iterate(HeapRegionClosure* blk); |
1356 | 1370 |
1357 // As above but starting from region r | 1371 // As above but starting from region r |
1358 void collection_set_iterate_from(HeapRegion* r, HeapRegionClosure *blk); | 1372 void collection_set_iterate_from(HeapRegion* r, HeapRegionClosure *blk); |
1556 void doConcurrentMark(); | 1570 void doConcurrentMark(); |
1557 | 1571 |
1558 bool isMarkedPrev(oop obj) const; | 1572 bool isMarkedPrev(oop obj) const; |
1559 bool isMarkedNext(oop obj) const; | 1573 bool isMarkedNext(oop obj) const; |
1560 | 1574 |
1561 // vo == UsePrevMarking -> use "prev" marking information, | |
1562 // vo == UseNextMarking -> use "next" marking information, | |
1563 // vo == UseMarkWord -> use mark word from object header | |
1564 bool is_obj_dead_cond(const oop obj, | |
1565 const HeapRegion* hr, | |
1566 const VerifyOption vo) const { | |
1567 | |
1568 switch (vo) { | |
1569 case VerifyOption_G1UsePrevMarking: | |
1570 return is_obj_dead(obj, hr); | |
1571 case VerifyOption_G1UseNextMarking: | |
1572 return is_obj_ill(obj, hr); | |
1573 default: | |
1574 assert(vo == VerifyOption_G1UseMarkWord, "must be"); | |
1575 return !obj->is_gc_marked(); | |
1576 } | |
1577 } | |
1578 | |
1579 // Determine if an object is dead, given the object and also | 1575 // Determine if an object is dead, given the object and also |
1580 // the region to which the object belongs. An object is dead | 1576 // the region to which the object belongs. An object is dead |
1581 // iff a) it was not allocated since the last mark and b) it | 1577 // iff a) it was not allocated since the last mark and b) it |
1582 // is not marked. | 1578 // is not marked. |
1583 | 1579 |
1585 return | 1581 return |
1586 !hr->obj_allocated_since_prev_marking(obj) && | 1582 !hr->obj_allocated_since_prev_marking(obj) && |
1587 !isMarkedPrev(obj); | 1583 !isMarkedPrev(obj); |
1588 } | 1584 } |
1589 | 1585 |
1590 // This is used when copying an object to survivor space. | |
1591 // If the object is marked live, then we mark the copy live. | |
1592 // If the object is allocated since the start of this mark | |
1593 // cycle, then we mark the copy live. | |
1594 // If the object has been around since the previous mark | |
1595 // phase, and hasn't been marked yet during this phase, | |
1596 // then we don't mark it, we just wait for the | |
1597 // current marking cycle to get to it. | |
1598 | |
1599 // This function returns true when an object has been | 1586 // This function returns true when an object has been |
1600 // around since the previous marking and hasn't yet | 1587 // around since the previous marking and hasn't yet |
1601 // been marked during this marking. | 1588 // been marked during this marking. |
1602 | 1589 |
1603 bool is_obj_ill(const oop obj, const HeapRegion* hr) const { | 1590 bool is_obj_ill(const oop obj, const HeapRegion* hr) const { |
1610 // This will find the region to which the object belongs and | 1597 // This will find the region to which the object belongs and |
1611 // then call the region version of the same function. | 1598 // then call the region version of the same function. |
1612 | 1599 |
1613 // Added if it is in permanent gen it isn't dead. | 1600 // Added if it is in permanent gen it isn't dead. |
1614 // Added if it is NULL it isn't dead. | 1601 // Added if it is NULL it isn't dead. |
1615 | |
1616 // vo == UsePrevMarking -> use "prev" marking information, | |
1617 // vo == UseNextMarking -> use "next" marking information, | |
1618 // vo == UseMarkWord -> use mark word from object header | |
1619 bool is_obj_dead_cond(const oop obj, | |
1620 const VerifyOption vo) const { | |
1621 | |
1622 switch (vo) { | |
1623 case VerifyOption_G1UsePrevMarking: | |
1624 return is_obj_dead(obj); | |
1625 case VerifyOption_G1UseNextMarking: | |
1626 return is_obj_ill(obj); | |
1627 default: | |
1628 assert(vo == VerifyOption_G1UseMarkWord, "must be"); | |
1629 return !obj->is_gc_marked(); | |
1630 } | |
1631 } | |
1632 | 1602 |
1633 bool is_obj_dead(const oop obj) const { | 1603 bool is_obj_dead(const oop obj) const { |
1634 const HeapRegion* hr = heap_region_containing(obj); | 1604 const HeapRegion* hr = heap_region_containing(obj); |
1635 if (hr == NULL) { | 1605 if (hr == NULL) { |
1636 if (Universe::heap()->is_in_permanent(obj)) | 1606 if (Universe::heap()->is_in_permanent(obj)) |
1649 else if (obj == NULL) return false; | 1619 else if (obj == NULL) return false; |
1650 else return true; | 1620 else return true; |
1651 } | 1621 } |
1652 else return is_obj_ill(obj, hr); | 1622 else return is_obj_ill(obj, hr); |
1653 } | 1623 } |
1624 | |
1625 // The methods below are here for convenience and dispatch the | |
1626 // appropriate method depending on value of the given VerifyOption | |
1627 // parameter. The options for that parameter are: | |
1628 // | |
1629 // vo == UsePrevMarking -> use "prev" marking information, | |
1630 // vo == UseNextMarking -> use "next" marking information, | |
1631 // vo == UseMarkWord -> use mark word from object header | |
1632 | |
1633 bool is_obj_dead_cond(const oop obj, | |
1634 const HeapRegion* hr, | |
1635 const VerifyOption vo) const { | |
1636 switch (vo) { | |
1637 case VerifyOption_G1UsePrevMarking: return is_obj_dead(obj, hr); | |
1638 case VerifyOption_G1UseNextMarking: return is_obj_ill(obj, hr); | |
1639 case VerifyOption_G1UseMarkWord: return !obj->is_gc_marked(); | |
1640 default: ShouldNotReachHere(); | |
1641 } | |
1642 return false; // keep some compilers happy | |
1643 } | |
1644 | |
1645 bool is_obj_dead_cond(const oop obj, | |
1646 const VerifyOption vo) const { | |
1647 switch (vo) { | |
1648 case VerifyOption_G1UsePrevMarking: return is_obj_dead(obj); | |
1649 case VerifyOption_G1UseNextMarking: return is_obj_ill(obj); | |
1650 case VerifyOption_G1UseMarkWord: return !obj->is_gc_marked(); | |
1651 default: ShouldNotReachHere(); | |
1652 } | |
1653 return false; // keep some compilers happy | |
1654 } | |
1655 | |
1656 bool allocated_since_marking(oop obj, HeapRegion* hr, VerifyOption vo); | |
1657 HeapWord* top_at_mark_start(HeapRegion* hr, VerifyOption vo); | |
1658 bool is_marked(oop obj, VerifyOption vo); | |
1659 const char* top_at_mark_start_str(VerifyOption vo); | |
1654 | 1660 |
1655 // The following is just to alert the verification code | 1661 // The following is just to alert the verification code |
1656 // that a full collection has occurred and that the | 1662 // that a full collection has occurred and that the |
1657 // remembered sets are no longer up to date. | 1663 // remembered sets are no longer up to date. |
1658 bool _full_collection; | 1664 bool _full_collection; |