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),
47 _region_number(index),
48 _live_data(0),
49 reserved(MemRegion(start, regionSizeWords)),
50 _humongous_start(false),
51 _humongous_continuation(false),
52 _recycled(true),
53 _new_top(NULL),
54 _critical_pins(0) {
55
56 ContiguousSpace::initialize(reserved, true, false);
57 }
58
59 size_t ShenandoahHeapRegion::region_number() const {
60 return _region_number;
61 }
62
63 bool ShenandoahHeapRegion::rollback_allocation(uint size) {
64 set_top(top() - size);
65 return true;
66 }
67
68 void ShenandoahHeapRegion::clear_live_data() {
69 assert(Thread::current()->is_VM_thread(), "by VM thread");
70 _live_data = 0;
71 }
72
243 }
244
245 bool ShenandoahHeapRegion::is_humongous() const {
246 return _humongous_start || _humongous_continuation;
247 }
248
249 bool ShenandoahHeapRegion::is_humongous_start() const {
250 return _humongous_start;
251 }
252
253 bool ShenandoahHeapRegion::is_humongous_continuation() const {
254 return _humongous_continuation;
255 }
256
257 void ShenandoahHeapRegion::recycle() {
258 ContiguousSpace::initialize(reserved, true, false);
259 clear_live_data();
260 _humongous_start = false;
261 _humongous_continuation = false;
262 _recycled = true;
263 set_in_collection_set(false);
264 // Reset C-TAMS pointer to ensure size-based iteration, everything
265 // in that regions is going to be new objects.
266 _heap->set_complete_top_at_mark_start(bottom(), bottom());
267 // We can only safely reset the C-TAMS pointer if the bitmap is clear for that region.
268 assert(_heap->is_complete_bitmap_clear_range(bottom(), end()), "must be clear");
269 _heap->connection_matrix()->clear_region(region_number());
270 }
271
272 HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
273 assert(MemRegion(bottom(), end()).contains(p),
274 "p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
275 p2i(p), p2i(bottom()), p2i(end()));
276 if (p >= top()) {
277 return top();
278 } else {
279 HeapWord* last = bottom() + BrooksPointer::word_size();
280 HeapWord* cur = last;
281 while (cur <= p) {
282 last = cur;
|
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),
47 _region_number(index),
48 _live_data(0),
49 reserved(MemRegion(start, regionSizeWords)),
50 _humongous_start(false),
51 _humongous_continuation(false),
52 _recycled(true),
53 _root(false),
54 _new_top(NULL),
55 _critical_pins(0) {
56
57 ContiguousSpace::initialize(reserved, true, false);
58 }
59
60 size_t ShenandoahHeapRegion::region_number() const {
61 return _region_number;
62 }
63
64 bool ShenandoahHeapRegion::rollback_allocation(uint size) {
65 set_top(top() - size);
66 return true;
67 }
68
69 void ShenandoahHeapRegion::clear_live_data() {
70 assert(Thread::current()->is_VM_thread(), "by VM thread");
71 _live_data = 0;
72 }
73
244 }
245
246 bool ShenandoahHeapRegion::is_humongous() const {
247 return _humongous_start || _humongous_continuation;
248 }
249
250 bool ShenandoahHeapRegion::is_humongous_start() const {
251 return _humongous_start;
252 }
253
254 bool ShenandoahHeapRegion::is_humongous_continuation() const {
255 return _humongous_continuation;
256 }
257
258 void ShenandoahHeapRegion::recycle() {
259 ContiguousSpace::initialize(reserved, true, false);
260 clear_live_data();
261 _humongous_start = false;
262 _humongous_continuation = false;
263 _recycled = true;
264 _root = false;
265 set_in_collection_set(false);
266 // Reset C-TAMS pointer to ensure size-based iteration, everything
267 // in that regions is going to be new objects.
268 _heap->set_complete_top_at_mark_start(bottom(), bottom());
269 // We can only safely reset the C-TAMS pointer if the bitmap is clear for that region.
270 assert(_heap->is_complete_bitmap_clear_range(bottom(), end()), "must be clear");
271 _heap->connection_matrix()->clear_region(region_number());
272 }
273
274 HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const {
275 assert(MemRegion(bottom(), end()).contains(p),
276 "p ("PTR_FORMAT") not in space ["PTR_FORMAT", "PTR_FORMAT")",
277 p2i(p), p2i(bottom()), p2i(end()));
278 if (p >= top()) {
279 return top();
280 } else {
281 HeapWord* last = bottom() + BrooksPointer::word_size();
282 HeapWord* cur = last;
283 while (cur <= p) {
284 last = cur;
|