changeset 4682:4868caa99ecf

8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp Reviewed-by: stefank, tschatzl
author brutisso
date Mon, 13 May 2013 14:09:05 +0200
parents 7a95933197d0
children 0a2986f36965
files src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
diffstat 4 files changed, 12 insertions(+), 138 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Mon May 13 09:45:33 2013 +0200
+++ b/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Mon May 13 14:09:05 2013 +0200
@@ -24,7 +24,6 @@
 
 #include "precompiled.hpp"
 #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
-#include "gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp"
 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/os.hpp"
@@ -108,31 +107,6 @@
   return false;
 }
 
-size_t
-ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const
-{
-  assert(beg_addr <= end_addr, "bad range");
-
-  idx_t live_bits = 0;
-
-  // The bitmap routines require the right boundary to be word-aligned.
-  const idx_t end_bit = addr_to_bit(end_addr);
-  const idx_t range_end = BitMap::word_align_up(end_bit);
-
-  idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
-  while (beg_bit < end_bit) {
-    idx_t tmp_end = find_obj_end(beg_bit, range_end);
-    if (tmp_end < end_bit) {
-      live_bits += tmp_end - beg_bit + 1;
-      beg_bit = find_obj_beg(tmp_end + 1, range_end);
-    } else {
-      live_bits += end_bit - beg_bit;  // No + 1 here; end_bit is not counted.
-      return bits_to_words(live_bits);
-    }
-  }
-  return bits_to_words(live_bits);
-}
-
 size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const
 {
   assert(beg_addr <= (HeapWord*)end_obj, "bad range");
@@ -244,13 +218,6 @@
   return complete;
 }
 
-#ifndef PRODUCT
-void ParMarkBitMap::reset_counters()
-{
-  _cas_tries = _cas_retries = _cas_by_another = 0;
-}
-#endif  // #ifndef PRODUCT
-
 #ifdef ASSERT
 void ParMarkBitMap::verify_clear() const
 {
--- a/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Mon May 13 09:45:33 2013 +0200
+++ b/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp	Mon May 13 14:09:05 2013 +0200
@@ -26,11 +26,11 @@
 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP
 
 #include "memory/memRegion.hpp"
-#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
-#include "utilities/bitMap.inline.hpp"
+#include "oops/oop.hpp"
+#include "utilities/bitMap.hpp"
 
-class oopDesc;
 class ParMarkBitMapClosure;
+class PSVirtualSpace;
 
 class ParMarkBitMap: public CHeapObj<mtGC>
 {
@@ -41,13 +41,11 @@
   enum IterationStatus { incomplete, complete, full, would_overflow };
 
   inline ParMarkBitMap();
-  inline ParMarkBitMap(MemRegion covered_region);
   bool initialize(MemRegion covered_region);
 
   // Atomically mark an object as live.
   bool mark_obj(HeapWord* addr, size_t size);
   inline bool mark_obj(oop obj, int size);
-  inline bool mark_obj(oop obj);
 
   // Return whether the specified begin or end bit is set.
   inline bool is_obj_beg(idx_t bit) const;
@@ -77,11 +75,6 @@
   // Return the size in words of the object (a search is done for the end bit).
   inline size_t obj_size(idx_t beg_bit)  const;
   inline size_t obj_size(HeapWord* addr) const;
-  inline size_t obj_size(oop obj)        const;
-
-  // Synonyms for the above.
-  size_t obj_size_in_words(oop obj) const { return obj_size((HeapWord*)obj); }
-  size_t obj_size_in_words(HeapWord* addr) const { return obj_size(addr); }
 
   // Apply live_closure to each live object that lies completely within the
   // range [live_range_beg, live_range_end).  This is used to iterate over the
@@ -124,15 +117,12 @@
                                  HeapWord* range_end,
                                  HeapWord* dead_range_end) const;
 
-  // Return the number of live words in the range [beg_addr, end_addr) due to
+  // Return the number of live words in the range [beg_addr, end_obj) due to
   // objects that start in the range.  If a live object extends onto the range,
   // the caller must detect and account for any live words due to that object.
   // If a live object extends beyond the end of the range, only the words within
-  // the range are included in the result.
-  size_t live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const;
-
-  // Same as the above, except the end of the range must be a live object, which
-  // is the case when updating pointers.  This allows a branch to be removed
+  // the range are included in the result. The end of the range must be a live object,
+  // which is the case when updating pointers.  This allows a branch to be removed
   // from inside the loop.
   size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const;
 
@@ -156,22 +146,11 @@
   // Clear a range of bits or the entire bitmap (both begin and end bits are
   // cleared).
   inline void clear_range(idx_t beg, idx_t end);
-  inline void clear() { clear_range(0, size()); }
 
   // Return the number of bits required to represent the specified number of
   // HeapWords, or the specified region.
   static inline idx_t bits_required(size_t words);
   static inline idx_t bits_required(MemRegion covered_region);
-  static inline idx_t words_required(MemRegion covered_region);
-
-#ifndef PRODUCT
-  // CAS statistics.
-  size_t cas_tries() { return _cas_tries; }
-  size_t cas_retries() { return _cas_retries; }
-  size_t cas_by_another() { return _cas_by_another; }
-
-  void reset_counters();
-#endif  // #ifndef PRODUCT
 
   void print_on_error(outputStream* st) const {
     st->print_cr("Marking Bits: (ParMarkBitMap*) " PTR_FORMAT, this);
@@ -197,28 +176,11 @@
   BitMap          _beg_bits;
   BitMap          _end_bits;
   PSVirtualSpace* _virtual_space;
-
-#ifndef PRODUCT
-  size_t _cas_tries;
-  size_t _cas_retries;
-  size_t _cas_by_another;
-#endif  // #ifndef PRODUCT
 };
 
 inline ParMarkBitMap::ParMarkBitMap():
-  _beg_bits(),
-  _end_bits()
-{
-  _region_start = 0;
-  _virtual_space = 0;
-}
-
-inline ParMarkBitMap::ParMarkBitMap(MemRegion covered_region):
-  _beg_bits(),
-  _end_bits()
-{
-  initialize(covered_region);
-}
+  _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL)
+{ }
 
 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
 {
@@ -240,12 +202,6 @@
   return bits_required(covered_region.word_size());
 }
 
-inline ParMarkBitMap::idx_t
-ParMarkBitMap::words_required(MemRegion covered_region)
-{
-  return bits_required(covered_region) / BitsPerWord;
-}
-
 inline HeapWord*
 ParMarkBitMap::region_start() const
 {
@@ -350,11 +306,6 @@
   return obj_size(addr_to_bit(addr));
 }
 
-inline size_t ParMarkBitMap::obj_size(oop obj) const
-{
-  return obj_size((HeapWord*)obj);
-}
-
 inline ParMarkBitMap::IterationStatus
 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
                        HeapWord* range_beg,
@@ -435,8 +386,10 @@
 
 inline void ParMarkBitMap::verify_addr(HeapWord* addr) const {
   // Allow one past the last valid address; useful for loop bounds.
-  assert(addr >= region_start(), "addr too small");
-  assert(addr <= region_start() + region_size(), "addr too big");
+  assert(addr >= region_start(),
+      err_msg("addr too small, addr: " PTR_FORMAT " region start: " PTR_FORMAT, addr, region_start()));
+  assert(addr <= region_end(),
+      err_msg("addr too big, addr: " PTR_FORMAT " region end: " PTR_FORMAT, addr, region_end()));
 }
 #endif  // #ifdef ASSERT
 
--- a/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp	Mon May 13 09:45:33 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_INLINE_HPP
-#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_INLINE_HPP
-
-#include "oops/oop.hpp"
-
-inline bool
-ParMarkBitMap::mark_obj(oop obj)
-{
- return mark_obj(obj, obj->size());
-}
-
-#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_INLINE_HPP
--- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon May 13 09:45:33 2013 +0200
+++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon May 13 14:09:05 2013 +0200
@@ -948,7 +948,6 @@
 
   pre_gc_values->fill(heap);
 
-  NOT_PRODUCT(_mark_bitmap.reset_counters());
   DEBUG_ONLY(add_obj_count = add_obj_size = 0;)
   DEBUG_ONLY(mark_bitmap_count = mark_bitmap_size = 0;)
 
@@ -2042,15 +2041,6 @@
     marking_start.update();
     marking_phase(vmthread_cm, maximum_heap_compaction);
 
-#ifndef PRODUCT
-    if (TraceParallelOldGCMarkingPhase) {
-      gclog_or_tty->print_cr("marking_phase: cas_tries %d  cas_retries %d "
-        "cas_by_another %d",
-        mark_bitmap()->cas_tries(), mark_bitmap()->cas_retries(),
-        mark_bitmap()->cas_by_another());
-    }
-#endif  // #ifndef PRODUCT
-
     bool max_on_system_gc = UseMaximumCompactionOnSystemGC
       && gc_cause == GCCause::_java_lang_system_gc;
     summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc);