33 #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
34 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
35 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
36 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
37 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
38 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
39 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
40 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
41 #include "gc_implementation/shared/gcHeapSummary.hpp"
42 #include "gc_implementation/shared/gcTimer.hpp"
43 #include "gc_implementation/shared/gcTrace.hpp"
44 #include "gc_implementation/shared/gcTraceTime.hpp"
45 #include "gc_implementation/shared/isGCActiveMark.hpp"
46 #include "gc_implementation/shared/spaceDecorator.hpp"
47 #include "gc_interface/gcCause.hpp"
48 #include "memory/gcLocker.inline.hpp"
49 #include "memory/referencePolicy.hpp"
50 #include "memory/referenceProcessor.hpp"
51 #include "oops/methodData.hpp"
52 #include "oops/oop.inline.hpp"
53 #include "oops/oop.pcgc.inline.hpp"
54 #include "runtime/atomic.inline.hpp"
55 #include "runtime/fprofiler.hpp"
56 #include "runtime/safepoint.hpp"
57 #include "runtime/vmThread.hpp"
58 #include "services/management.hpp"
59 #include "services/memoryService.hpp"
60 #include "services/memTracker.hpp"
61 #include "utilities/events.hpp"
62 #include "utilities/stack.inline.hpp"
63
64 #include <math.h>
65
66 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
67
68 // All sizes are in HeapWords.
69 const size_t ParallelCompactData::Log2RegionSize = 16; // 64K words
70 const size_t ParallelCompactData::RegionSize = (size_t)1 << Log2RegionSize;
71 const size_t ParallelCompactData::RegionSizeBytes =
72 RegionSize << LogHeapWordSize;
73 const size_t ParallelCompactData::RegionSizeOffsetMask = RegionSize - 1;
2759 issued_a_warning = true;
2760 }
2761 }
2762
2763 for (cur_region = new_top_region; cur_region < old_top_region; ++cur_region) {
2764 const RegionData* const c = sd.region(cur_region);
2765 if (!c->available()) {
2766 warning("region " SIZE_FORMAT " not empty: "
2767 "destination_count=" SIZE_FORMAT,
2768 cur_region, c->destination_count());
2769 issued_a_warning = true;
2770 }
2771 }
2772
2773 if (issued_a_warning) {
2774 print_region_ranges();
2775 }
2776 }
2777 #endif // #ifdef ASSERT
2778
2779 // Update interior oops in the ranges of regions [beg_region, end_region).
2780 void
2781 PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
2782 SpaceId space_id,
2783 size_t beg_region,
2784 size_t end_region) {
2785 ParallelCompactData& sd = summary_data();
2786 ParMarkBitMap* const mbm = mark_bitmap();
2787
2788 HeapWord* beg_addr = sd.region_to_addr(beg_region);
2789 HeapWord* const end_addr = sd.region_to_addr(end_region);
2790 assert(beg_region <= end_region, "bad region range");
2791 assert(end_addr <= dense_prefix(space_id), "not in the dense prefix");
2792
2793 #ifdef ASSERT
2794 // Claim the regions to avoid triggering an assert when they are marked as
2795 // filled.
2796 for (size_t claim_region = beg_region; claim_region < end_region; ++claim_region) {
2797 assert(sd.region(claim_region)->claim_unsafe(), "claim() failed");
2798 }
2859 assert(id < last_space_id, "bad space id");
2860
2861 ParallelCompactData& sd = summary_data();
2862 const SpaceInfo* const space_info = _space_info + id;
2863 ObjectStartArray* const start_array = space_info->start_array();
2864
2865 const MutableSpace* const space = space_info->space();
2866 assert(space_info->dense_prefix() >= space->bottom(), "dense_prefix not set");
2867 HeapWord* const beg_addr = space_info->dense_prefix();
2868 HeapWord* const end_addr = sd.region_align_up(space_info->new_top());
2869
2870 const RegionData* const beg_region = sd.addr_to_region_ptr(beg_addr);
2871 const RegionData* const end_region = sd.addr_to_region_ptr(end_addr);
2872 const RegionData* cur_region;
2873 for (cur_region = beg_region; cur_region < end_region; ++cur_region) {
2874 HeapWord* const addr = cur_region->deferred_obj_addr();
2875 if (addr != NULL) {
2876 if (start_array != NULL) {
2877 start_array->allocate_block(addr);
2878 }
2879 oop(addr)->update_contents(cm);
2880 assert(oop(addr)->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(addr))));
2881 }
2882 }
2883 }
2884
2885 // Skip over count live words starting from beg, and return the address of the
2886 // next live word. Unless marked, the word corresponding to beg is assumed to
2887 // be dead. Callers must either ensure beg does not correspond to the middle of
2888 // an object, or account for those live words in some other way. Callers must
2889 // also ensure that there are enough live words in the range [beg, end) to skip.
2890 HeapWord*
2891 PSParallelCompact::skip_live_words(HeapWord* beg, HeapWord* end, size_t count)
2892 {
2893 assert(count > 0, "sanity");
2894
2895 ParMarkBitMap* m = mark_bitmap();
2896 idx_t bits_to_skip = m->words_to_bits(count);
2897 idx_t cur_beg = m->addr_to_bit(beg);
2898 const idx_t search_end = BitMap::word_align_up(m->addr_to_bit(end));
2899
3343
3344 _source = addr;
3345 assert(PSParallelCompact::summary_data().calc_new_pointer(source()) ==
3346 destination(), "wrong destination");
3347
3348 if (words > words_remaining()) {
3349 return ParMarkBitMap::would_overflow;
3350 }
3351
3352 // The start_array must be updated even if the object is not moving.
3353 if (_start_array != NULL) {
3354 _start_array->allocate_block(destination());
3355 }
3356
3357 if (destination() != source()) {
3358 DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3359 Copy::aligned_conjoint_words(source(), destination(), words);
3360 }
3361
3362 oop moved_oop = (oop) destination();
3363 moved_oop->update_contents(compaction_manager());
3364 assert(moved_oop->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(moved_oop)));
3365
3366 update_state(words);
3367 assert(destination() == (HeapWord*)moved_oop + moved_oop->size(), "sanity");
3368 return is_full() ? ParMarkBitMap::full : ParMarkBitMap::incomplete;
3369 }
3370
3371 UpdateOnlyClosure::UpdateOnlyClosure(ParMarkBitMap* mbm,
3372 ParCompactionManager* cm,
3373 PSParallelCompact::SpaceId space_id) :
3374 ParMarkBitMapClosure(mbm, cm),
3375 _space_id(space_id),
3376 _start_array(PSParallelCompact::start_array(space_id))
3377 {
3378 }
3379
3380 // Updates the references in the object to their new values.
3381 ParMarkBitMapClosure::IterationStatus
3382 UpdateOnlyClosure::do_addr(HeapWord* addr, size_t words) {
3383 do_addr(addr);
|
33 #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
34 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
35 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
36 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
37 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
38 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
39 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
40 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
41 #include "gc_implementation/shared/gcHeapSummary.hpp"
42 #include "gc_implementation/shared/gcTimer.hpp"
43 #include "gc_implementation/shared/gcTrace.hpp"
44 #include "gc_implementation/shared/gcTraceTime.hpp"
45 #include "gc_implementation/shared/isGCActiveMark.hpp"
46 #include "gc_implementation/shared/spaceDecorator.hpp"
47 #include "gc_interface/gcCause.hpp"
48 #include "memory/gcLocker.inline.hpp"
49 #include "memory/referencePolicy.hpp"
50 #include "memory/referenceProcessor.hpp"
51 #include "oops/methodData.hpp"
52 #include "oops/oop.inline.hpp"
53 #include "runtime/atomic.inline.hpp"
54 #include "runtime/fprofiler.hpp"
55 #include "runtime/safepoint.hpp"
56 #include "runtime/vmThread.hpp"
57 #include "services/management.hpp"
58 #include "services/memoryService.hpp"
59 #include "services/memTracker.hpp"
60 #include "utilities/events.hpp"
61 #include "utilities/stack.inline.hpp"
62
63 #include <math.h>
64
65 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
66
67 // All sizes are in HeapWords.
68 const size_t ParallelCompactData::Log2RegionSize = 16; // 64K words
69 const size_t ParallelCompactData::RegionSize = (size_t)1 << Log2RegionSize;
70 const size_t ParallelCompactData::RegionSizeBytes =
71 RegionSize << LogHeapWordSize;
72 const size_t ParallelCompactData::RegionSizeOffsetMask = RegionSize - 1;
2758 issued_a_warning = true;
2759 }
2760 }
2761
2762 for (cur_region = new_top_region; cur_region < old_top_region; ++cur_region) {
2763 const RegionData* const c = sd.region(cur_region);
2764 if (!c->available()) {
2765 warning("region " SIZE_FORMAT " not empty: "
2766 "destination_count=" SIZE_FORMAT,
2767 cur_region, c->destination_count());
2768 issued_a_warning = true;
2769 }
2770 }
2771
2772 if (issued_a_warning) {
2773 print_region_ranges();
2774 }
2775 }
2776 #endif // #ifdef ASSERT
2777
2778 inline void UpdateOnlyClosure::do_addr(HeapWord* addr) {
2779 _start_array->allocate_block(addr);
2780 compaction_manager()->update_contents(oop(addr));
2781 }
2782
2783 // Update interior oops in the ranges of regions [beg_region, end_region).
2784 void
2785 PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
2786 SpaceId space_id,
2787 size_t beg_region,
2788 size_t end_region) {
2789 ParallelCompactData& sd = summary_data();
2790 ParMarkBitMap* const mbm = mark_bitmap();
2791
2792 HeapWord* beg_addr = sd.region_to_addr(beg_region);
2793 HeapWord* const end_addr = sd.region_to_addr(end_region);
2794 assert(beg_region <= end_region, "bad region range");
2795 assert(end_addr <= dense_prefix(space_id), "not in the dense prefix");
2796
2797 #ifdef ASSERT
2798 // Claim the regions to avoid triggering an assert when they are marked as
2799 // filled.
2800 for (size_t claim_region = beg_region; claim_region < end_region; ++claim_region) {
2801 assert(sd.region(claim_region)->claim_unsafe(), "claim() failed");
2802 }
2863 assert(id < last_space_id, "bad space id");
2864
2865 ParallelCompactData& sd = summary_data();
2866 const SpaceInfo* const space_info = _space_info + id;
2867 ObjectStartArray* const start_array = space_info->start_array();
2868
2869 const MutableSpace* const space = space_info->space();
2870 assert(space_info->dense_prefix() >= space->bottom(), "dense_prefix not set");
2871 HeapWord* const beg_addr = space_info->dense_prefix();
2872 HeapWord* const end_addr = sd.region_align_up(space_info->new_top());
2873
2874 const RegionData* const beg_region = sd.addr_to_region_ptr(beg_addr);
2875 const RegionData* const end_region = sd.addr_to_region_ptr(end_addr);
2876 const RegionData* cur_region;
2877 for (cur_region = beg_region; cur_region < end_region; ++cur_region) {
2878 HeapWord* const addr = cur_region->deferred_obj_addr();
2879 if (addr != NULL) {
2880 if (start_array != NULL) {
2881 start_array->allocate_block(addr);
2882 }
2883 cm->update_contents(oop(addr));
2884 assert(oop(addr)->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(addr))));
2885 }
2886 }
2887 }
2888
2889 // Skip over count live words starting from beg, and return the address of the
2890 // next live word. Unless marked, the word corresponding to beg is assumed to
2891 // be dead. Callers must either ensure beg does not correspond to the middle of
2892 // an object, or account for those live words in some other way. Callers must
2893 // also ensure that there are enough live words in the range [beg, end) to skip.
2894 HeapWord*
2895 PSParallelCompact::skip_live_words(HeapWord* beg, HeapWord* end, size_t count)
2896 {
2897 assert(count > 0, "sanity");
2898
2899 ParMarkBitMap* m = mark_bitmap();
2900 idx_t bits_to_skip = m->words_to_bits(count);
2901 idx_t cur_beg = m->addr_to_bit(beg);
2902 const idx_t search_end = BitMap::word_align_up(m->addr_to_bit(end));
2903
3347
3348 _source = addr;
3349 assert(PSParallelCompact::summary_data().calc_new_pointer(source()) ==
3350 destination(), "wrong destination");
3351
3352 if (words > words_remaining()) {
3353 return ParMarkBitMap::would_overflow;
3354 }
3355
3356 // The start_array must be updated even if the object is not moving.
3357 if (_start_array != NULL) {
3358 _start_array->allocate_block(destination());
3359 }
3360
3361 if (destination() != source()) {
3362 DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3363 Copy::aligned_conjoint_words(source(), destination(), words);
3364 }
3365
3366 oop moved_oop = (oop) destination();
3367 compaction_manager()->update_contents(moved_oop);
3368 assert(moved_oop->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(moved_oop)));
3369
3370 update_state(words);
3371 assert(destination() == (HeapWord*)moved_oop + moved_oop->size(), "sanity");
3372 return is_full() ? ParMarkBitMap::full : ParMarkBitMap::incomplete;
3373 }
3374
3375 UpdateOnlyClosure::UpdateOnlyClosure(ParMarkBitMap* mbm,
3376 ParCompactionManager* cm,
3377 PSParallelCompact::SpaceId space_id) :
3378 ParMarkBitMapClosure(mbm, cm),
3379 _space_id(space_id),
3380 _start_array(PSParallelCompact::start_array(space_id))
3381 {
3382 }
3383
3384 // Updates the references in the object to their new values.
3385 ParMarkBitMapClosure::IterationStatus
3386 UpdateOnlyClosure::do_addr(HeapWord* addr, size_t words) {
3387 do_addr(addr);
|