src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp
Print this page
rev 4123 : 7163191: G1: introduce a "heap spanning table" abstraction
Summary: Add a heap spanning table and employ it for the heap region sequence table.
Reviewed-by:
@@ -26,41 +26,29 @@
#define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP
#include "gc_implementation/g1/heapRegion.hpp"
#include "gc_implementation/g1/heapRegionSeq.hpp"
-inline uintx HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const {
- assert(_heap_bottom <= addr && addr < _heap_end,
- err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
- addr, _heap_bottom, _heap_end));
- uintx index = (uintx) addr >> _region_shift;
- return index;
-}
-
-inline HeapRegion* HeapRegionSeq::addr_to_region_unsafe(HeapWord* addr) const {
- assert(_heap_bottom <= addr && addr < _heap_end,
- err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
- addr, _heap_bottom, _heap_end));
- uintx index_biased = addr_to_index_biased(addr);
- HeapRegion* hr = _regions_biased[index_biased];
- assert(hr != NULL, "invariant");
+inline HeapRegion* HeapRegionSeq::at(uint index) const {
+ HeapRegion* hr = get(_regions, index);
+ assert(hr != NULL, "sanity");
+ assert(hr->hrs_index() == index, "sanity");
return hr;
}
-inline HeapRegion* HeapRegionSeq::addr_to_region(HeapWord* addr) const {
- if (addr != NULL && addr < _heap_end) {
- assert(addr >= _heap_bottom,
- err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, _heap_bottom));
- return addr_to_region_unsafe(addr);
+inline HeapRegion* HeapRegionSeq::at(HeapWord* addr) const {
+ HeapRegion* hr = get(_regions_biased, addr);
+ if (in_g1_heap(addr)) {
+ assert(hr != NULL, "if the address is valid, hr should not be NULL");
+ } else {
+ assert(hr == NULL, "if the address is not valid, hr should be NULL");
}
- return NULL;
+ return hr;
}
-inline HeapRegion* HeapRegionSeq::at(uint index) const {
- assert(index < length(), "pre-condition");
- HeapRegion* hr = _regions[index];
- assert(hr != NULL, "sanity");
- assert(hr->hrs_index() == index, "sanity");
+inline HeapRegion* HeapRegionSeq::at_unsafe(HeapWord* addr) const {
+ HeapRegion* hr = get_unsafe(_regions_biased, addr);
+ assert(hr != NULL, "invariant");
return hr;
}
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP