Mercurial > hg > jdk9-shenandoah > hotspot
changeset 9433:40b528fa3e2a
Keep track of compaction-top region correctly. Collect free regions and live data correctly in separate pass after compaction.
author | rkennke |
---|---|
date | Tue, 28 Jul 2015 16:10:57 +0200 |
parents | ba60b7af3eb4 |
children | 9ec23e56f818 |
files | src/share/vm/gc/shared/space.cpp src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp src/share/vm/gc_implementation/shenandoah/shenandoahHeap.hpp src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.cpp src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.hpp src/share/vm/gc_implementation/shenandoah/shenandoahMarkCompact.cpp |
diffstat | 6 files changed, 59 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/gc/shared/space.cpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc/shared/space.cpp Tue Jul 28 16:10:57 2015 +0200 @@ -385,6 +385,10 @@ assert(cp->space != NULL, "generation must have a first compaction space"); } compact_top = cp->space->bottom(); + if (UseShenandoahGC) { + // TODO: Make better. + compact_top += 1; + } cp->space->set_compaction_top(compact_top); cp->threshold = cp->space->initialize_threshold(); compaction_max_size = pointer_delta(cp->space->end(), compact_top);
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp Tue Jul 28 16:10:57 2015 +0200 @@ -2827,3 +2827,13 @@ ShenandoahJNICritical* ShenandoahHeap::jni_critical() { return _jni_critical; } + +ShenandoahHeapRegion* ShenandoahHeap::next_compaction_region(const ShenandoahHeapRegion* r) { + HeapWord* next_addr = r->bottom() + ShenandoahHeapRegion::RegionSizeBytes / HeapWordSize; + ShenandoahHeapRegion* next = heap_region_containing(next_addr); + if (next->is_humongous()) { + return next_compaction_region(next); + } else { + return next; + } +}
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.hpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.hpp Tue Jul 28 16:10:57 2015 +0200 @@ -360,6 +360,8 @@ size_t num_regions(); size_t max_regions(); + ShenandoahHeapRegion* next_compaction_region(const ShenandoahHeapRegion* r); + void recycle_dirty_regions(); void register_region_with_in_cset_fast_test(ShenandoahHeapRegion* r) {
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.cpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.cpp Tue Jul 28 16:10:57 2015 +0200 @@ -315,3 +315,7 @@ tty->print_cr("Maximum number of regions: "SIZE_FORMAT, max_heap_size / RegionSizeBytes); } } + +CompactibleSpace* ShenandoahHeapRegion::next_compaction_space() const { + return ShenandoahHeap::heap()->next_compaction_region(this); +}
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.hpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegion.hpp Tue Jul 28 16:10:57 2015 +0200 @@ -85,6 +85,8 @@ void save_mark_word(oop obj) {saved_mark_word = obj->mark();} markOop mark_word() {return saved_mark_word;} + virtual CompactibleSpace* next_compaction_space() const; + private: void do_reset();
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahMarkCompact.cpp Tue Jul 28 16:09:55 2015 +0200 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahMarkCompact.cpp Tue Jul 28 16:10:57 2015 +0200 @@ -221,13 +221,13 @@ public: ShenandoahPrepareForCompaction() : _heap(ShenandoahHeap::heap()) { + _cp.space = _heap->heap_regions()[0]; _cp.threshold = _heap->start_of_heap(); } bool doHeapRegion(ShenandoahHeapRegion* r) { // We need to save the contents if (!r->is_humongous()) { - _cp.space = r; r->prepare_for_compaction(&_cp); } else { if (r->is_humongous_start()) { @@ -253,7 +253,7 @@ // We must adjust the pointers on the single H object. oop obj = oop(r->bottom() + BrooksPointer::BROOKS_POINTER_OBJ_SIZE); // point all the oops to the new location - obj->ms_adjust_pointers(); + MarkSweep::adjust_pointers(obj); } } else { r->adjust_pointers(); @@ -301,14 +301,13 @@ }; class CompactObjectsClosure : public ShenandoahHeapRegionClosure { - size_t _live; - ShenandoahHeap* _heap; + +private: bool _dead_humongous; + public: - CompactObjectsClosure() : _live(0), _heap(ShenandoahHeap::heap()), - _dead_humongous(false) { - _heap->clear_free_regions(); + CompactObjectsClosure() : _dead_humongous(false) { } bool doHeapRegion(ShenandoahHeapRegion* r) { @@ -332,10 +331,35 @@ } else { _dead_humongous = false; r->compact(); + } + + return false; + } + +}; + +class ShenandoahPostCompactClosure : public ShenandoahHeapRegionClosure { + size_t _live; + ShenandoahHeap* _heap; +public: + + ShenandoahPostCompactClosure() : _live(0), _heap(ShenandoahHeap::heap()) { + _heap->clear_free_regions(); + } + + bool doHeapRegion(ShenandoahHeapRegion* r) { + if (r->is_humongous()) { + if (r->is_humongous_start()) { + oop obj = oop(r->bottom() + BrooksPointer::BROOKS_POINTER_OBJ_SIZE); + size_t size = obj->size() + BrooksPointer::BROOKS_POINTER_OBJ_SIZE; + _live += size * HeapWordSize; + } + + } else { // The brooks pointer calculation adaptation // leaves us one past where we want to be. - r->set_top(r->compaction_top() - BrooksPointer::BROOKS_POINTER_OBJ_SIZE); - size_t live = r->top() - r->bottom(); + r->set_top(r->top() - BrooksPointer::BROOKS_POINTER_OBJ_SIZE); + size_t live = r->used(); if (live == 0) _heap->add_free_region(r); r->setLiveData(live); _live += live; @@ -356,5 +380,8 @@ ShenandoahCleanupObjectClosure cleanup; heap->object_iterate(&cleanup); - heap->set_used(coc.getLive()); + ShenandoahPostCompactClosure post_compact; + heap->heap_region_iterate(&post_compact); + + heap->set_used(post_compact.getLive()); }