--- old/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2012-09-21 16:29:11.824563931 -0700 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2012-09-21 16:29:11.477898272 -0700 @@ -1192,25 +1192,7 @@ BitMap* _region_bm; BitMap* _card_bm; - void set_card_bitmap_range(BitMap::idx_t start_idx, BitMap::idx_t last_idx) { - assert(start_idx <= last_idx, "sanity"); - - // Set the inclusive bit range [start_idx, last_idx]. - // For small ranges (up to 8 cards) use a simple loop; otherwise - // use par_at_put_range. - if ((last_idx - start_idx) < 8) { - for (BitMap::idx_t i = start_idx; i <= last_idx; i += 1) { - _card_bm->par_set_bit(i); - } - } else { - assert(last_idx < _card_bm->size(), "sanity"); - // Note BitMap::par_at_put_range() is exclusive. - BitMap::idx_t max_idx = MAX2(last_idx+1, _card_bm->size()); - _card_bm->par_at_put_range(start_idx, max_idx, true); - } - } - - // It takes a region that's not empty (i.e., it has at least one + // Takes a region that's not empty (i.e., it has at least one // live object in it and sets its corresponding bit on the region // bitmap to 1. If the region is "starts humongous" it will also set // to 1 the bits on the region bitmap that correspond to its @@ -1283,7 +1265,7 @@ BitMap::idx_t last_idx = _cm->card_bitmap_index_for(obj_last); // Set the bits in the card BM for this object (inclusive). - set_card_bitmap_range(start_idx, last_idx); + _cm->set_card_bitmap_range(_card_bm, start_idx, last_idx, true /* is_par */); // Add the size of this object to the number of marked bytes. marked_bytes += (size_t)obj_sz * HeapWordSize; @@ -1298,7 +1280,7 @@ BitMap::idx_t start_idx = _cm->card_bitmap_index_for(nextTop); BitMap::idx_t last_idx = _cm->card_bitmap_index_for(top - 1); - set_card_bitmap_range(start_idx, last_idx); + _cm->set_card_bitmap_range(_card_bm, start_idx, last_idx, true /* is_par */); // This definitely means the region has live objects. set_bit_for_region(hr); @@ -1552,13 +1534,14 @@ // Now set the bits for [ntams, top] BitMap::idx_t start_idx = _cm->card_bitmap_index_for(ntams); - // set_card_bitmap_range() expects the last_idx to be with - // the range of the bit map (see assertion in set_card_bitmap_range()), - // so limit it to that range with this application of MIN2. + // The utility routine set_card_bitmap_range() expects last_idx + // to be within the range of the bit map (see assertion in + // set_card_bitmap_range()), so limit last_idx to that range + // with this application of MIN2. BitMap::idx_t last_idx = MIN2(_cm->card_bitmap_index_for(top), _card_bm->size()-1); if (start_idx < _card_bm->size()) { - set_card_bitmap_range(start_idx, last_idx); + _cm->set_card_bitmap_range(_card_bm, start_idx, last_idx, true /* is_par */); } else { // To reach here start_idx must be beyond the end of // the bit map and last_idx must have been limited by --- old/src/share/vm/gc_implementation/g1/concurrentMark.hpp 2012-09-21 16:29:14.967022701 -0700 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.hpp 2012-09-21 16:29:14.590317381 -0700 @@ -808,6 +808,13 @@ // Counting data structure accessors + // Utility routine to set an inclusive range of cards on the given + // card liveness bitmap + inline void set_card_bitmap_range(BitMap* card_bm, + BitMap::idx_t start_idx, + BitMap::idx_t last_idx, + bool is_par); + // Returns the card number of the bottom of the G1 heap. // Used in biasing indices into accounting card bitmaps. intptr_t heap_bottom_card_num() const { --- old/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp 2012-09-21 16:29:16.407801875 -0700 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp 2012-09-21 16:29:16.195984171 -0700 @@ -28,6 +28,40 @@ #include "gc_implementation/g1/concurrentMark.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" +// Utility routine to set an inclusive range of cards on the given +// card liveness bitmap +inline void ConcurrentMark::set_card_bitmap_range(BitMap* card_bm, + BitMap::idx_t start_idx, + BitMap::idx_t last_idx, + bool is_par) { + // Set the inclusive bit range [start_idx, last_idx]. + + assert(start_idx <= last_idx, "sanity"); + assert(last_idx < card_bm->size(), "sanity"); + BitMap::idx_t end_idx = MIN2(last_idx+1, card_bm->size()); + + // For small ranges use a simple loop; otherwise use set_range or + // use par_at_put_range (if parallel). The range is made up of the + // cards that are spanned by an object/mem region so 8 cards will + // allow up to object sizes up to 4K to be handled using the loop. + if ((end_idx - start_idx) <= 8) { + for (BitMap::idx_t i = start_idx; i < end_idx; i += 1) { + if (is_par) { + card_bm->par_set_bit(i); + } else { + card_bm->set_bit(i); + } + } + } else { + // Note BitMap::par_at_put_range() and BitMap::set_range() are exclusive. + if (is_par) { + card_bm->par_at_put_range(start_idx, end_idx, true); + } else { + card_bm->set_range(start_idx, end_idx); + } + } +} + // Returns the index in the liveness accounting card bitmap // for the given address inline BitMap::idx_t ConcurrentMark::card_bitmap_index_for(HeapWord* addr) { @@ -63,22 +97,10 @@ BitMap::idx_t start_idx = card_bitmap_index_for(start); BitMap::idx_t last_idx = card_bitmap_index_for(last); - // The card bitmap is task/worker specific => no need to use 'par' routines. + // The card bitmap is task/worker specific => no need to use + // the 'par' BitMap routines. // Set bits in the inclusive bit range [start_idx, last_idx]. - // - // For small ranges use a simple loop; otherwise use set_range - // The range are the cards that are spanned by the object/region - // so 8 cards will allow objects/regions up to 4K to be handled - // using the loop. - if ((last_idx - start_idx) <= 8) { - for (BitMap::idx_t i = start_idx; i <= last_idx; i += 1) { - task_card_bm->set_bit(i); - } - } else { - assert(last_idx < task_card_bm->size(), "sanity"); - // Note: BitMap::set_range() is exclusive. - task_card_bm->set_range(start_idx, last_idx+1); - } + set_card_bitmap_range(task_card_bm, start_idx, last_idx, false /* is_par */); } // Counts the given memory region in the task/worker counting