< prev index next >

src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp

Print this page
rev 13055 : Implement barriers for maintaining connection matrix.


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

  26 #include "gc/shenandoah/shenandoahHeap.hpp"
  27 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  28 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  29 #include "gc/shared/space.inline.hpp"
  30 #include "memory/universe.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/mutexLocker.hpp"
  33 #include "runtime/os.hpp"
  34 #include "runtime/safepoint.hpp"
  35 
  36 Monitor ShenandoahHeapRegion::_mem_protect_lock(Mutex::special, "ShenandoahMemProtect_lock", true, Monitor::_safepoint_check_never);
  37 size_t ShenandoahHeapRegion::RegionSizeShift = 0;
  38 size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
  39 
  40 ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start,
  41                                            size_t regionSizeWords, size_t index) :
  42 #ifdef ASSERT
  43   _mem_protection_level(0),
  44 #endif
  45   _heap(heap),


 237 bool ShenandoahHeapRegion::is_humongous_start() const {
 238   return _humongous_start;
 239 }
 240 
 241 bool ShenandoahHeapRegion::is_humongous_continuation() const {
 242   return _humongous_continuation;
 243 }
 244 
 245 void ShenandoahHeapRegion::recycle() {
 246   ContiguousSpace::initialize(reserved, true, false);
 247   clear_live_data();
 248   _humongous_start = false;
 249   _humongous_continuation = false;
 250   _recycled = true;
 251   set_in_collection_set(false);
 252   // Reset C-TAMS pointer to ensure size-based iteration, everything
 253   // in that regions is going to be new objects.
 254   _heap->set_complete_top_at_mark_start(bottom(), bottom());
 255   // We can only safely reset the C-TAMS pointer if the bitmap is clear for that region.
 256   assert(_heap->is_complete_bitmap_clear_range(bottom(), end()), "must be clear");

 257 }
 258 
 259 HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
 260   assert(MemRegion(bottom(), end()).contains(p),
 261          "p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
 262          p2i(p), p2i(bottom()), p2i(end()));
 263   if (p >= top()) {
 264     return top();
 265   } else {
 266     HeapWord* last = bottom() + BrooksPointer::word_size();
 267     HeapWord* cur = last;
 268     while (cur <= p) {
 269       last = cur;
 270       cur += oop(cur)->size() + BrooksPointer::word_size();
 271     }
 272     assert(oop(last)->is_oop(),
 273            PTR_FORMAT" should be an object start", p2i(last));
 274     return last;
 275   }
 276 }




   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "memory/allocation.hpp"
  25 #include "gc/shenandoah/brooksPointer.hpp"
  26 #include "gc/shenandoah/shenandoahConnectionMatrix.hpp"
  27 #include "gc/shenandoah/shenandoahHeap.hpp"
  28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  29 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  30 #include "gc/shared/space.inline.hpp"
  31 #include "memory/universe.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "runtime/mutexLocker.hpp"
  34 #include "runtime/os.hpp"
  35 #include "runtime/safepoint.hpp"
  36 
  37 Monitor ShenandoahHeapRegion::_mem_protect_lock(Mutex::special, "ShenandoahMemProtect_lock", true, Monitor::_safepoint_check_never);
  38 size_t ShenandoahHeapRegion::RegionSizeShift = 0;
  39 size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
  40 
  41 ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start,
  42                                            size_t regionSizeWords, size_t index) :
  43 #ifdef ASSERT
  44   _mem_protection_level(0),
  45 #endif
  46   _heap(heap),


 238 bool ShenandoahHeapRegion::is_humongous_start() const {
 239   return _humongous_start;
 240 }
 241 
 242 bool ShenandoahHeapRegion::is_humongous_continuation() const {
 243   return _humongous_continuation;
 244 }
 245 
 246 void ShenandoahHeapRegion::recycle() {
 247   ContiguousSpace::initialize(reserved, true, false);
 248   clear_live_data();
 249   _humongous_start = false;
 250   _humongous_continuation = false;
 251   _recycled = true;
 252   set_in_collection_set(false);
 253   // Reset C-TAMS pointer to ensure size-based iteration, everything
 254   // in that regions is going to be new objects.
 255   _heap->set_complete_top_at_mark_start(bottom(), bottom());
 256   // We can only safely reset the C-TAMS pointer if the bitmap is clear for that region.
 257   assert(_heap->is_complete_bitmap_clear_range(bottom(), end()), "must be clear");
 258   _heap->connection_matrix()->clear_region(region_number());
 259 }
 260 
 261 HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
 262   assert(MemRegion(bottom(), end()).contains(p),
 263          "p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
 264          p2i(p), p2i(bottom()), p2i(end()));
 265   if (p >= top()) {
 266     return top();
 267   } else {
 268     HeapWord* last = bottom() + BrooksPointer::word_size();
 269     HeapWord* cur = last;
 270     while (cur <= p) {
 271       last = cur;
 272       cur += oop(cur)->size() + BrooksPointer::word_size();
 273     }
 274     assert(oop(last)->is_oop(),
 275            PTR_FORMAT" should be an object start", p2i(last));
 276     return last;
 277   }
 278 }


< prev index next >