< prev index next >
src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp
Print this page
rev 12551 : Refactor/consolidate/cleanup
*** 34,57 ****
Monitor ShenandoahHeapRegion::_mem_protect_lock(Mutex::special, "ShenandoahMemProtect_lock", true, Monitor::_safepoint_check_never);
size_t ShenandoahHeapRegion::RegionSizeShift = 0;
size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
! jint ShenandoahHeapRegion::initialize_heap_region(HeapWord* start,
size_t regionSizeWords, size_t index) {
!
reserved = MemRegion(start, regionSizeWords);
ContiguousSpace::initialize(reserved, true, false);
_live_data = 0;
- _is_in_collection_set = false;
_region_number = index;
#ifdef ASSERT
_mem_protection_level = 1; // Off, level 1.
#endif
- _top_at_mark_start = bottom();
- _top_at_prev_mark_start = bottom();
- _top_prev_mark_bitmap = bottom();
return JNI_OK;
}
size_t ShenandoahHeapRegion::region_number() const {
return _region_number;
--- 34,53 ----
Monitor ShenandoahHeapRegion::_mem_protect_lock(Mutex::special, "ShenandoahMemProtect_lock", true, Monitor::_safepoint_check_never);
size_t ShenandoahHeapRegion::RegionSizeShift = 0;
size_t ShenandoahHeapRegion::RegionSizeBytes = 0;
! jint ShenandoahHeapRegion::initialize_heap_region(ShenandoahHeap* heap, HeapWord* start,
size_t regionSizeWords, size_t index) {
! _heap = heap;
reserved = MemRegion(start, regionSizeWords);
ContiguousSpace::initialize(reserved, true, false);
_live_data = 0;
_region_number = index;
#ifdef ASSERT
_mem_protection_level = 1; // Off, level 1.
#endif
return JNI_OK;
}
size_t ShenandoahHeapRegion::region_number() const {
return _region_number;
*** 82,93 ****
get_live_data(), used());
size_t result = used() - get_live_data();
return result;
}
! bool ShenandoahHeapRegion::is_in_collection_set() const {
! return _is_in_collection_set;
}
#include <sys/mman.h>
#ifdef ASSERT
--- 78,107 ----
get_live_data(), used());
size_t result = used() - get_live_data();
return result;
}
! bool ShenandoahHeapRegion::in_collection_set() const {
! return _heap->region_in_collection_set(_region_number);
! }
!
! void ShenandoahHeapRegion::set_in_collection_set(bool b) {
! assert(! (is_humongous() && b), "never ever enter a humongous region into the collection set");
!
! _heap->set_region_in_collection_set(_region_number, b);
!
! #ifdef ASSERT
! if (ShenandoahVerifyWritesToFromSpace || ShenandoahVerifyReadsToFromSpace) {
! if (b) {
! memProtectionOn();
! assert(_mem_protection_level == 0, "need to be protected here");
! } else {
! assert(_mem_protection_level == 0, "need to be protected here");
! memProtectionOff();
! }
! }
! #endif
}
#include <sys/mman.h>
#ifdef ASSERT
*** 123,164 ****
}
}
#endif
- void ShenandoahHeapRegion::set_is_in_collection_set(bool b) {
- assert(! (is_humongous() && b), "never ever enter a humongous region into the collection set");
-
- _is_in_collection_set = b;
-
- if (b) {
- // tty->print_cr("registering region in fast-cset");
- // print();
- ShenandoahHeap::heap()->register_region_with_in_cset_fast_test(this);
- }
-
- #ifdef ASSERT
- if (ShenandoahVerifyWritesToFromSpace || ShenandoahVerifyReadsToFromSpace) {
- if (b) {
- memProtectionOn();
- assert(_mem_protection_level == 0, "need to be protected here");
- } else {
- assert(_mem_protection_level == 0, "need to be protected here");
- memProtectionOff();
- }
- }
- #endif
- }
-
- ByteSize ShenandoahHeapRegion::is_in_collection_set_offset() {
- return byte_offset_of(ShenandoahHeapRegion, _is_in_collection_set);
- }
-
void ShenandoahHeapRegion::print_on(outputStream* st) const {
st->print("ShenandoahHeapRegion: "PTR_FORMAT"/"SIZE_FORMAT, p2i(this), _region_number);
! if (is_in_collection_set())
st->print("C");
if (is_humongous_start()) {
st->print("H");
}
if (is_humongous_continuation()) {
--- 137,150 ----
}
}
#endif
void ShenandoahHeapRegion::print_on(outputStream* st) const {
st->print("ShenandoahHeapRegion: "PTR_FORMAT"/"SIZE_FORMAT, p2i(this), _region_number);
! if (in_collection_set())
st->print("C");
if (is_humongous_start()) {
st->print("H");
}
if (is_humongous_continuation()) {
*** 170,206 ****
st->print_cr("live = "SIZE_FORMAT" garbage = "SIZE_FORMAT" bottom = "PTR_FORMAT" end = "PTR_FORMAT" top = "PTR_FORMAT,
get_live_data(), garbage(), p2i(bottom()), p2i(end()), p2i(top()));
}
- class SkipUnreachableObjectToOopClosure: public ObjectClosure {
- ExtendedOopClosure* _cl;
- bool _skip_unreachable_objects;
- ShenandoahHeap* _heap;
-
- public:
- SkipUnreachableObjectToOopClosure(ExtendedOopClosure* cl, bool skip_unreachable_objects) :
- _cl(cl), _skip_unreachable_objects(skip_unreachable_objects), _heap(ShenandoahHeap::heap()) {}
-
- void do_object(oop obj) {
-
- if ((! _skip_unreachable_objects) || _heap->is_marked_current(obj)) {
- #ifdef ASSERT
- if (_skip_unreachable_objects) {
- assert(_heap->is_marked_current(obj), "obj must be live");
- }
- #endif
- obj->oop_iterate(_cl);
- }
-
- }
- };
-
void ShenandoahHeapRegion::object_iterate_interruptible(ObjectClosure* blk, bool allow_cancel) {
HeapWord* p = bottom() + BrooksPointer::word_size();
! ShenandoahHeap* heap = ShenandoahHeap::heap();
! while (p < top() && !(allow_cancel && heap->cancelled_concgc())) {
blk->do_object(oop(p));
#ifdef ASSERT
if (ShenandoahVerifyReadsToFromSpace) {
memProtectionOff();
p += oop(p)->size() + BrooksPointer::word_size();
--- 156,168 ----
st->print_cr("live = "SIZE_FORMAT" garbage = "SIZE_FORMAT" bottom = "PTR_FORMAT" end = "PTR_FORMAT" top = "PTR_FORMAT,
get_live_data(), garbage(), p2i(bottom()), p2i(end()), p2i(top()));
}
void ShenandoahHeapRegion::object_iterate_interruptible(ObjectClosure* blk, bool allow_cancel) {
HeapWord* p = bottom() + BrooksPointer::word_size();
! while (p < top() && !(allow_cancel && _heap->cancelled_concgc())) {
blk->do_object(oop(p));
#ifdef ASSERT
if (ShenandoahVerifyReadsToFromSpace) {
memProtectionOff();
p += oop(p)->size() + BrooksPointer::word_size();
*** 226,240 ****
}
}
return NULL; // all done
}
- void ShenandoahHeapRegion::oop_iterate_skip_unreachable(ExtendedOopClosure* cl, bool skip_unreachable_objects) {
- SkipUnreachableObjectToOopClosure cl2(cl, skip_unreachable_objects);
- object_iterate_interruptible(&cl2, false);
- }
-
void ShenandoahHeapRegion::fill_region() {
ShenandoahHeap* sh = (ShenandoahHeap*) Universe::heap();
if (free() > (BrooksPointer::word_size() + CollectedHeap::min_fill_size())) {
HeapWord* filler = allocate(BrooksPointer::word_size());
--- 188,197 ----
*** 262,289 ****
bool ShenandoahHeapRegion::is_humongous_continuation() const {
return _humongous_continuation;
}
! void ShenandoahHeapRegion::do_reset() {
ContiguousSpace::initialize(reserved, true, false);
clear_live_data();
_humongous_start = false;
_humongous_continuation = false;
! // _top_at_mark_start = bottom();
! _top_at_prev_mark_start = bottom();
! }
!
! void ShenandoahHeapRegion::recycle() {
! do_reset();
! set_is_in_collection_set(false);
! }
!
! void ShenandoahHeapRegion::reset() {
! assert(_mem_protection_level == 1, "needs to be unprotected here");
! do_reset();
! _is_in_collection_set = false;
}
HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
assert(MemRegion(bottom(), end()).contains(p),
"p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
--- 219,234 ----
bool ShenandoahHeapRegion::is_humongous_continuation() const {
return _humongous_continuation;
}
! void ShenandoahHeapRegion::recycle() {
ContiguousSpace::initialize(reserved, true, false);
clear_live_data();
_humongous_start = false;
_humongous_continuation = false;
! set_in_collection_set(false);
}
HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
assert(MemRegion(bottom(), end()).contains(p),
"p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
*** 362,372 ****
log_info(gc, init)("Initial number of regions: "SIZE_FORMAT, initial_heap_size / RegionSizeBytes);
log_info(gc, init)("Maximum number of regions: "SIZE_FORMAT, max_heap_size / RegionSizeBytes);
}
CompactibleSpace* ShenandoahHeapRegion::next_compaction_space() const {
! return ShenandoahHeap::heap()->next_compaction_region(this);
}
void ShenandoahHeapRegion::prepare_for_compaction(CompactPoint* cp) {
scan_and_forward(this, cp);
}
--- 307,317 ----
log_info(gc, init)("Initial number of regions: "SIZE_FORMAT, initial_heap_size / RegionSizeBytes);
log_info(gc, init)("Maximum number of regions: "SIZE_FORMAT, max_heap_size / RegionSizeBytes);
}
CompactibleSpace* ShenandoahHeapRegion::next_compaction_space() const {
! return _heap->next_compaction_region(this);
}
void ShenandoahHeapRegion::prepare_for_compaction(CompactPoint* cp) {
scan_and_forward(this, cp);
}
*** 383,433 ****
void ShenandoahHeapRegion::compact() {
assert(!is_humongous(), "Shouldn't be compacting humongous regions");
scan_and_compact(this);
}
- void ShenandoahHeapRegion::init_top_at_mark_start() {
- _top_at_mark_start = top();
- ShenandoahHeap::heap()->set_top_at_mark_start(bottom(), top());
- }
-
- void ShenandoahHeapRegion::set_top_at_mark_start(HeapWord* top) {
- _top_at_mark_start = top;
- ShenandoahHeap::heap()->set_top_at_mark_start(bottom(), top);
- }
-
- void ShenandoahHeapRegion::reset_top_at_prev_mark_start() {
- _top_at_prev_mark_start = bottom();
- }
-
- HeapWord* ShenandoahHeapRegion::top_at_mark_start() {
- return _top_at_mark_start;
- }
-
- HeapWord* ShenandoahHeapRegion::top_at_prev_mark_start() {
- return _top_at_prev_mark_start;
- }
-
- HeapWord* ShenandoahHeapRegion::top_prev_mark_bitmap() {
- return _top_prev_mark_bitmap;
- }
-
- bool ShenandoahHeapRegion::allocated_after_prev_mark_start(HeapWord* addr) const {
- return addr >= _top_at_prev_mark_start;
- }
-
- void ShenandoahHeapRegion::swap_top_at_mark_start() {
- HeapWord* tmp = _top_at_prev_mark_start;
- _top_at_prev_mark_start = _top_at_mark_start;
- _top_at_mark_start = tmp;
- ShenandoahHeap::heap()->set_top_at_mark_start(bottom(), tmp);
- }
-
- void ShenandoahHeapRegion::set_top_prev_mark_bitmap(HeapWord* top) {
- _top_prev_mark_bitmap = top;
- }
-
void ShenandoahHeapRegion::pin() {
assert(! SafepointSynchronize::is_at_safepoint(), "only outside safepoints");
assert(_critical_pins >= 0, "sanity");
Atomic::inc(&_critical_pins);
}
--- 328,337 ----
< prev index next >