49 #include "utilities/globalDefinitions.hpp"
50
51 inline ShenandoahHeap* ShenandoahHeap::heap() {
52 return named_heap<ShenandoahHeap>(CollectedHeap::Shenandoah);
53 }
54
55 inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() {
56 size_t new_index = Atomic::add(&_index, (size_t) 1);
57 // get_region() provides the bounds-check and returns NULL on OOB.
58 return _heap->get_region(new_index - 1);
59 }
60
61 inline bool ShenandoahHeap::has_forwarded_objects() const {
62 return _gc_state.is_set(HAS_FORWARDED);
63 }
64
65 inline WorkGang* ShenandoahHeap::workers() const {
66 return _workers;
67 }
68
69 inline WorkGang* ShenandoahHeap::get_safepoint_workers() {
70 return _safepoint_workers;
71 }
72
73 inline size_t ShenandoahHeap::heap_region_index_containing(const void* addr) const {
74 uintptr_t region_start = ((uintptr_t) addr);
75 uintptr_t index = (region_start - (uintptr_t) base()) >> ShenandoahHeapRegion::region_size_bytes_shift();
76 assert(index < num_regions(), "Region index is in bounds: " PTR_FORMAT, p2i(addr));
77 return index;
78 }
79
80 inline ShenandoahHeapRegion* const ShenandoahHeap::heap_region_containing(const void* addr) const {
81 size_t index = heap_region_index_containing(addr);
82 ShenandoahHeapRegion* const result = get_region(index);
83 assert(addr >= result->bottom() && addr < result->end(), "Heap region contains the address: " PTR_FORMAT, p2i(addr));
84 return result;
85 }
86
87 inline void ShenandoahHeap::enter_evacuation(Thread* t) {
88 _oom_evac_handler.enter_evacuation(t);
89 }
|
49 #include "utilities/globalDefinitions.hpp"
50
51 inline ShenandoahHeap* ShenandoahHeap::heap() {
52 return named_heap<ShenandoahHeap>(CollectedHeap::Shenandoah);
53 }
54
55 inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() {
56 size_t new_index = Atomic::add(&_index, (size_t) 1);
57 // get_region() provides the bounds-check and returns NULL on OOB.
58 return _heap->get_region(new_index - 1);
59 }
60
61 inline bool ShenandoahHeap::has_forwarded_objects() const {
62 return _gc_state.is_set(HAS_FORWARDED);
63 }
64
65 inline WorkGang* ShenandoahHeap::workers() const {
66 return _workers;
67 }
68
69 inline WorkGang* ShenandoahHeap::safepoint_workers() {
70 return _safepoint_workers;
71 }
72
73 inline size_t ShenandoahHeap::heap_region_index_containing(const void* addr) const {
74 uintptr_t region_start = ((uintptr_t) addr);
75 uintptr_t index = (region_start - (uintptr_t) base()) >> ShenandoahHeapRegion::region_size_bytes_shift();
76 assert(index < num_regions(), "Region index is in bounds: " PTR_FORMAT, p2i(addr));
77 return index;
78 }
79
80 inline ShenandoahHeapRegion* const ShenandoahHeap::heap_region_containing(const void* addr) const {
81 size_t index = heap_region_index_containing(addr);
82 ShenandoahHeapRegion* const result = get_region(index);
83 assert(addr >= result->bottom() && addr < result->end(), "Heap region contains the address: " PTR_FORMAT, p2i(addr));
84 return result;
85 }
86
87 inline void ShenandoahHeap::enter_evacuation(Thread* t) {
88 _oom_evac_handler.enter_evacuation(t);
89 }
|