Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 1391:79e419e5ea3b
6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize
Summary: Replaces the G1-specific parameter with the existing ones that are used by the other GCs (YoungPLABSize and OldPLABSize)
Reviewed-by: tonyp, johnc
author | apetrusenko |
---|---|
date | Fri, 16 Apr 2010 08:48:16 -0700 |
parents | 664ae0c5e0e5 |
children | 1316cec51b4d |
comparison
equal
deleted
inserted
replaced
1390:f9ec1e4bbb44 | 1391:79e419e5ea3b |
---|---|
230 | 230 |
231 // A list of the regions that have been set to be alloc regions in the | 231 // A list of the regions that have been set to be alloc regions in the |
232 // current collection. | 232 // current collection. |
233 HeapRegion* _gc_alloc_region_list; | 233 HeapRegion* _gc_alloc_region_list; |
234 | 234 |
235 // Determines PLAB size for a particular allocation purpose. | |
236 static size_t desired_plab_sz(GCAllocPurpose purpose); | |
237 | |
235 // When called by par thread, require par_alloc_during_gc_lock() to be held. | 238 // When called by par thread, require par_alloc_during_gc_lock() to be held. |
236 void push_gc_alloc_region(HeapRegion* hr); | 239 void push_gc_alloc_region(HeapRegion* hr); |
237 | 240 |
238 // This should only be called single-threaded. Undeclares all GC alloc | 241 // This should only be called single-threaded. Undeclares all GC alloc |
239 // regions. | 242 // regions. |
1365 // how many heap words does a single bitmap word corresponds to? | 1368 // how many heap words does a single bitmap word corresponds to? |
1366 static size_t bitmap_word_covers_words() { | 1369 static size_t bitmap_word_covers_words() { |
1367 return BitsPerWord << shifter(); | 1370 return BitsPerWord << shifter(); |
1368 } | 1371 } |
1369 | 1372 |
1370 static size_t gclab_word_size() { | 1373 size_t gclab_word_size() const { |
1371 return G1ParallelGCAllocBufferSize / HeapWordSize; | 1374 return _gclab_word_size; |
1372 } | 1375 } |
1373 | 1376 |
1374 static size_t bitmap_size_in_bits() { | 1377 // Calculates actual GCLab size in words |
1375 size_t bits_in_bitmap = gclab_word_size() >> shifter(); | 1378 size_t gclab_real_word_size() const { |
1379 return bitmap_size_in_bits(pointer_delta(_real_end_word, _start_word)) | |
1380 / BitsPerWord; | |
1381 } | |
1382 | |
1383 static size_t bitmap_size_in_bits(size_t gclab_word_size) { | |
1384 size_t bits_in_bitmap = gclab_word_size >> shifter(); | |
1376 // We are going to ensure that the beginning of a word in this | 1385 // We are going to ensure that the beginning of a word in this |
1377 // bitmap also corresponds to the beginning of a word in the | 1386 // bitmap also corresponds to the beginning of a word in the |
1378 // global marking bitmap. To handle the case where a GCLab | 1387 // global marking bitmap. To handle the case where a GCLab |
1379 // starts from the middle of the bitmap, we need to add enough | 1388 // starts from the middle of the bitmap, we need to add enough |
1380 // space (i.e. up to a bitmap word) to ensure that we have | 1389 // space (i.e. up to a bitmap word) to ensure that we have |
1381 // enough bits in the bitmap. | 1390 // enough bits in the bitmap. |
1382 return bits_in_bitmap + BitsPerWord - 1; | 1391 return bits_in_bitmap + BitsPerWord - 1; |
1383 } | 1392 } |
1384 public: | 1393 public: |
1385 GCLabBitMap(HeapWord* heap_start) | 1394 GCLabBitMap(HeapWord* heap_start, size_t gclab_word_size) |
1386 : BitMap(bitmap_size_in_bits()), | 1395 : BitMap(bitmap_size_in_bits(gclab_word_size)), |
1387 _cm(G1CollectedHeap::heap()->concurrent_mark()), | 1396 _cm(G1CollectedHeap::heap()->concurrent_mark()), |
1388 _shifter(shifter()), | 1397 _shifter(shifter()), |
1389 _bitmap_word_covers_words(bitmap_word_covers_words()), | 1398 _bitmap_word_covers_words(bitmap_word_covers_words()), |
1390 _heap_start(heap_start), | 1399 _heap_start(heap_start), |
1391 _gclab_word_size(gclab_word_size()), | 1400 _gclab_word_size(gclab_word_size), |
1392 _real_start_word(NULL), | 1401 _real_start_word(NULL), |
1393 _real_end_word(NULL), | 1402 _real_end_word(NULL), |
1394 _start_word(NULL) | 1403 _start_word(NULL) |
1395 { | 1404 { |
1396 guarantee( size_in_words() >= bitmap_size_in_words(), | 1405 guarantee( size_in_words() >= bitmap_size_in_words(), |
1481 assert(_real_start_word != NULL && _real_end_word != NULL, "invariant"); | 1490 assert(_real_start_word != NULL && _real_end_word != NULL, "invariant"); |
1482 | 1491 |
1483 mark_bitmap->mostly_disjoint_range_union(this, | 1492 mark_bitmap->mostly_disjoint_range_union(this, |
1484 0, // always start from the start of the bitmap | 1493 0, // always start from the start of the bitmap |
1485 _start_word, | 1494 _start_word, |
1486 size_in_words()); | 1495 gclab_real_word_size()); |
1487 _cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word)); | 1496 _cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word)); |
1488 | 1497 |
1489 #ifndef PRODUCT | 1498 #ifndef PRODUCT |
1490 if (use_local_bitmaps && verify_local_bitmaps) | 1499 if (use_local_bitmaps && verify_local_bitmaps) |
1491 verify(); | 1500 verify(); |
1493 } else { | 1502 } else { |
1494 assert(_real_start_word == NULL && _real_end_word == NULL, "invariant"); | 1503 assert(_real_start_word == NULL && _real_end_word == NULL, "invariant"); |
1495 } | 1504 } |
1496 } | 1505 } |
1497 | 1506 |
1498 static size_t bitmap_size_in_words() { | 1507 size_t bitmap_size_in_words() const { |
1499 return (bitmap_size_in_bits() + BitsPerWord - 1) / BitsPerWord; | 1508 return (bitmap_size_in_bits(gclab_word_size()) + BitsPerWord - 1) / BitsPerWord; |
1500 } | 1509 } |
1510 | |
1501 }; | 1511 }; |
1502 | 1512 |
1503 class G1ParGCAllocBuffer: public ParGCAllocBuffer { | 1513 class G1ParGCAllocBuffer: public ParGCAllocBuffer { |
1504 private: | 1514 private: |
1505 bool _retired; | 1515 bool _retired; |
1506 bool _during_marking; | 1516 bool _during_marking; |
1507 GCLabBitMap _bitmap; | 1517 GCLabBitMap _bitmap; |
1508 | 1518 |
1509 public: | 1519 public: |
1510 G1ParGCAllocBuffer() : | 1520 G1ParGCAllocBuffer(size_t gclab_word_size) : |
1511 ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize), | 1521 ParGCAllocBuffer(gclab_word_size), |
1512 _during_marking(G1CollectedHeap::heap()->mark_in_progress()), | 1522 _during_marking(G1CollectedHeap::heap()->mark_in_progress()), |
1513 _bitmap(G1CollectedHeap::heap()->reserved_region().start()), | 1523 _bitmap(G1CollectedHeap::heap()->reserved_region().start(), gclab_word_size), |
1514 _retired(false) | 1524 _retired(false) |
1515 { } | 1525 { } |
1516 | 1526 |
1517 inline bool mark(HeapWord* addr) { | 1527 inline bool mark(HeapWord* addr) { |
1518 guarantee(use_local_bitmaps, "invariant"); | 1528 guarantee(use_local_bitmaps, "invariant"); |
1547 G1RemSet* _g1_rem; | 1557 G1RemSet* _g1_rem; |
1548 | 1558 |
1549 typedef GrowableArray<StarTask> OverflowQueue; | 1559 typedef GrowableArray<StarTask> OverflowQueue; |
1550 OverflowQueue* _overflowed_refs; | 1560 OverflowQueue* _overflowed_refs; |
1551 | 1561 |
1552 G1ParGCAllocBuffer _alloc_buffers[GCAllocPurposeCount]; | 1562 G1ParGCAllocBuffer _surviving_alloc_buffer; |
1553 ageTable _age_table; | 1563 G1ParGCAllocBuffer _tenured_alloc_buffer; |
1564 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; | |
1565 ageTable _age_table; | |
1554 | 1566 |
1555 size_t _alloc_buffer_waste; | 1567 size_t _alloc_buffer_waste; |
1556 size_t _undo_waste; | 1568 size_t _undo_waste; |
1557 | 1569 |
1558 OopsInHeapRegionClosure* _evac_failure_cl; | 1570 OopsInHeapRegionClosure* _evac_failure_cl; |
1617 RefToScanQueue* refs() { return _refs; } | 1629 RefToScanQueue* refs() { return _refs; } |
1618 OverflowQueue* overflowed_refs() { return _overflowed_refs; } | 1630 OverflowQueue* overflowed_refs() { return _overflowed_refs; } |
1619 ageTable* age_table() { return &_age_table; } | 1631 ageTable* age_table() { return &_age_table; } |
1620 | 1632 |
1621 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { | 1633 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { |
1622 return &_alloc_buffers[purpose]; | 1634 return _alloc_buffers[purpose]; |
1623 } | 1635 } |
1624 | 1636 |
1625 size_t alloc_buffer_waste() { return _alloc_buffer_waste; } | 1637 size_t alloc_buffer_waste() { return _alloc_buffer_waste; } |
1626 size_t undo_waste() { return _undo_waste; } | 1638 size_t undo_waste() { return _undo_waste; } |
1627 | 1639 |
1682 } | 1694 } |
1683 | 1695 |
1684 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { | 1696 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { |
1685 | 1697 |
1686 HeapWord* obj = NULL; | 1698 HeapWord* obj = NULL; |
1687 if (word_sz * 100 < | 1699 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); |
1688 (size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) * | 1700 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { |
1689 ParallelGCBufferWastePct) { | |
1690 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); | 1701 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); |
1702 assert(gclab_word_size == alloc_buf->word_sz(), | |
1703 "dynamic resizing is not supported"); | |
1691 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); | 1704 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); |
1692 alloc_buf->retire(false, false); | 1705 alloc_buf->retire(false, false); |
1693 | 1706 |
1694 HeapWord* buf = | 1707 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); |
1695 _g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize); | |
1696 if (buf == NULL) return NULL; // Let caller handle allocation failure. | 1708 if (buf == NULL) return NULL; // Let caller handle allocation failure. |
1697 // Otherwise. | 1709 // Otherwise. |
1698 alloc_buf->set_buf(buf); | 1710 alloc_buf->set_buf(buf); |
1699 | 1711 |
1700 obj = alloc_buf->allocate(word_sz); | 1712 obj = alloc_buf->allocate(word_sz); |
1784 return _surviving_young_words; | 1796 return _surviving_young_words; |
1785 } | 1797 } |
1786 | 1798 |
1787 void retire_alloc_buffers() { | 1799 void retire_alloc_buffers() { |
1788 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | 1800 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { |
1789 size_t waste = _alloc_buffers[ap].words_remaining(); | 1801 size_t waste = _alloc_buffers[ap]->words_remaining(); |
1790 add_to_alloc_buffer_waste(waste); | 1802 add_to_alloc_buffer_waste(waste); |
1791 _alloc_buffers[ap].retire(true, false); | 1803 _alloc_buffers[ap]->retire(true, false); |
1792 } | 1804 } |
1793 } | 1805 } |
1794 | 1806 |
1795 private: | 1807 private: |
1796 template <class T> void deal_with_reference(T* ref_to_scan) { | 1808 template <class T> void deal_with_reference(T* ref_to_scan) { |