src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-gc-g1-mmap Sdiff src/share/vm/gc_implementation/parallelScavenge

src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
  27 #include "gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp"
  28 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/os.hpp"
  31 #include "utilities/bitMap.inline.hpp"
  32 #include "services/memTracker.hpp"
  33 #ifdef TARGET_OS_FAMILY_linux
  34 # include "os_linux.inline.hpp"
  35 #endif
  36 #ifdef TARGET_OS_FAMILY_solaris
  37 # include "os_solaris.inline.hpp"
  38 #endif
  39 #ifdef TARGET_OS_FAMILY_windows
  40 # include "os_windows.inline.hpp"
  41 #endif
  42 #ifdef TARGET_OS_FAMILY_bsd
  43 # include "os_bsd.inline.hpp"
  44 #endif
  45 
  46 bool
  47 ParMarkBitMap::initialize(MemRegion covered_region)


  91 #ifdef ASSERT
  92 extern size_t mark_bitmap_count;
  93 extern size_t mark_bitmap_size;
  94 #endif  // #ifdef ASSERT
  95 
  96 bool
  97 ParMarkBitMap::mark_obj(HeapWord* addr, size_t size)
  98 {
  99   const idx_t beg_bit = addr_to_bit(addr);
 100   if (_beg_bits.par_set_bit(beg_bit)) {
 101     const idx_t end_bit = addr_to_bit(addr + size - 1);
 102     bool end_bit_ok = _end_bits.par_set_bit(end_bit);
 103     assert(end_bit_ok, "concurrency problem");
 104     DEBUG_ONLY(Atomic::inc_ptr(&mark_bitmap_count));
 105     DEBUG_ONLY(Atomic::add_ptr(size, &mark_bitmap_size));
 106     return true;
 107   }
 108   return false;
 109 }
 110 
 111 size_t
 112 ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const
 113 {
 114   assert(beg_addr <= end_addr, "bad range");
 115 
 116   idx_t live_bits = 0;
 117 
 118   // The bitmap routines require the right boundary to be word-aligned.
 119   const idx_t end_bit = addr_to_bit(end_addr);
 120   const idx_t range_end = BitMap::word_align_up(end_bit);
 121 
 122   idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
 123   while (beg_bit < end_bit) {
 124     idx_t tmp_end = find_obj_end(beg_bit, range_end);
 125     if (tmp_end < end_bit) {
 126       live_bits += tmp_end - beg_bit + 1;
 127       beg_bit = find_obj_beg(tmp_end + 1, range_end);
 128     } else {
 129       live_bits += end_bit - beg_bit;  // No + 1 here; end_bit is not counted.
 130       return bits_to_words(live_bits);
 131     }
 132   }
 133   return bits_to_words(live_bits);
 134 }
 135 
 136 size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const
 137 {
 138   assert(beg_addr <= (HeapWord*)end_obj, "bad range");
 139   assert(is_marked(end_obj), "end_obj must be live");
 140 
 141   idx_t live_bits = 0;
 142 
 143   // The bitmap routines require the right boundary to be word-aligned.
 144   const idx_t end_bit = addr_to_bit((HeapWord*)end_obj);
 145   const idx_t range_end = BitMap::word_align_up(end_bit);
 146 
 147   idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
 148   while (beg_bit < end_bit) {
 149     idx_t tmp_end = find_obj_end(beg_bit, range_end);
 150     assert(tmp_end < end_bit, "missing end bit");
 151     live_bits += tmp_end - beg_bit + 1;
 152     beg_bit = find_obj_beg(tmp_end + 1, range_end);
 153   }
 154   return bits_to_words(live_bits);
 155 }


 227     if (status != incomplete) {
 228       assert(status == would_overflow || status == full, "sanity");
 229       return status;
 230     }
 231 
 232     // Look for the start of the next object.
 233     const idx_t dead_space_beg = cur_end + 1;
 234     cur_beg = find_obj_beg(dead_space_beg, dead_search_end);
 235     if (cur_beg > dead_space_beg) {
 236       // Found dead space; compute the size and invoke the dead closure.
 237       const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
 238       const size_t size = obj_size(dead_space_beg, dead_space_end);
 239       dead_closure->do_addr(bit_to_addr(dead_space_beg), size);
 240     }
 241   }
 242 
 243   live_closure->set_source(bit_to_addr(range_end));
 244   return complete;
 245 }
 246 
 247 #ifndef PRODUCT
 248 void ParMarkBitMap::reset_counters()
 249 {
 250   _cas_tries = _cas_retries = _cas_by_another = 0;
 251 }
 252 #endif  // #ifndef PRODUCT
 253 
 254 #ifdef ASSERT
 255 void ParMarkBitMap::verify_clear() const
 256 {
 257   const idx_t* const beg = (const idx_t*)_virtual_space->committed_low_addr();
 258   const idx_t* const end = (const idx_t*)_virtual_space->committed_high_addr();
 259   for (const idx_t* p = beg; p < end; ++p) {
 260     assert(*p == 0, "bitmap not clear");
 261   }
 262 }
 263 #endif  // #ifdef ASSERT


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"

  27 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/os.hpp"
  30 #include "utilities/bitMap.inline.hpp"
  31 #include "services/memTracker.hpp"
  32 #ifdef TARGET_OS_FAMILY_linux
  33 # include "os_linux.inline.hpp"
  34 #endif
  35 #ifdef TARGET_OS_FAMILY_solaris
  36 # include "os_solaris.inline.hpp"
  37 #endif
  38 #ifdef TARGET_OS_FAMILY_windows
  39 # include "os_windows.inline.hpp"
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_bsd
  42 # include "os_bsd.inline.hpp"
  43 #endif
  44 
  45 bool
  46 ParMarkBitMap::initialize(MemRegion covered_region)


  90 #ifdef ASSERT
  91 extern size_t mark_bitmap_count;
  92 extern size_t mark_bitmap_size;
  93 #endif  // #ifdef ASSERT
  94 
  95 bool
  96 ParMarkBitMap::mark_obj(HeapWord* addr, size_t size)
  97 {
  98   const idx_t beg_bit = addr_to_bit(addr);
  99   if (_beg_bits.par_set_bit(beg_bit)) {
 100     const idx_t end_bit = addr_to_bit(addr + size - 1);
 101     bool end_bit_ok = _end_bits.par_set_bit(end_bit);
 102     assert(end_bit_ok, "concurrency problem");
 103     DEBUG_ONLY(Atomic::inc_ptr(&mark_bitmap_count));
 104     DEBUG_ONLY(Atomic::add_ptr(size, &mark_bitmap_size));
 105     return true;
 106   }
 107   return false;
 108 }
 109 

























 110 size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const
 111 {
 112   assert(beg_addr <= (HeapWord*)end_obj, "bad range");
 113   assert(is_marked(end_obj), "end_obj must be live");
 114 
 115   idx_t live_bits = 0;
 116 
 117   // The bitmap routines require the right boundary to be word-aligned.
 118   const idx_t end_bit = addr_to_bit((HeapWord*)end_obj);
 119   const idx_t range_end = BitMap::word_align_up(end_bit);
 120 
 121   idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
 122   while (beg_bit < end_bit) {
 123     idx_t tmp_end = find_obj_end(beg_bit, range_end);
 124     assert(tmp_end < end_bit, "missing end bit");
 125     live_bits += tmp_end - beg_bit + 1;
 126     beg_bit = find_obj_beg(tmp_end + 1, range_end);
 127   }
 128   return bits_to_words(live_bits);
 129 }


 201     if (status != incomplete) {
 202       assert(status == would_overflow || status == full, "sanity");
 203       return status;
 204     }
 205 
 206     // Look for the start of the next object.
 207     const idx_t dead_space_beg = cur_end + 1;
 208     cur_beg = find_obj_beg(dead_space_beg, dead_search_end);
 209     if (cur_beg > dead_space_beg) {
 210       // Found dead space; compute the size and invoke the dead closure.
 211       const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
 212       const size_t size = obj_size(dead_space_beg, dead_space_end);
 213       dead_closure->do_addr(bit_to_addr(dead_space_beg), size);
 214     }
 215   }
 216 
 217   live_closure->set_source(bit_to_addr(range_end));
 218   return complete;
 219 }
 220 







 221 #ifdef ASSERT
 222 void ParMarkBitMap::verify_clear() const
 223 {
 224   const idx_t* const beg = (const idx_t*)_virtual_space->committed_low_addr();
 225   const idx_t* const end = (const idx_t*)_virtual_space->committed_high_addr();
 226   for (const idx_t* p = beg; p < end; ++p) {
 227     assert(*p == 0, "bitmap not clear");
 228   }
 229 }
 230 #endif  // #ifdef ASSERT
src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File