Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp @ 20337:1f1d373cd044
8038423: G1: Decommit memory within heap
Summary: Allow G1 to decommit memory of arbitrary regions within the heap and their associated auxiliary data structures card table, BOT, hot card cache, and mark bitmaps.
Reviewed-by: mgerdin, brutisso, jwilhelm
author | tschatzl |
---|---|
date | Thu, 21 Aug 2014 11:47:10 +0200 |
parents | 2c6ef90f030a |
children | 0fcaab91d485 |
comparison
equal
deleted
inserted
replaced
20336:6701abbc4441 | 20337:1f1d373cd044 |
---|---|
43 if (addr >= _bottom && addr < _end) { | 43 if (addr >= _bottom && addr < _end) { |
44 return block_start_unsafe_const(addr); | 44 return block_start_unsafe_const(addr); |
45 } else { | 45 } else { |
46 return NULL; | 46 return NULL; |
47 } | 47 } |
48 } | |
49 | |
50 #define check_index(index, msg) \ | |
51 assert((index) < (_reserved.word_size() >> LogN_words), \ | |
52 err_msg("%s - index: "SIZE_FORMAT", _vs.committed_size: "SIZE_FORMAT, \ | |
53 msg, (index), (_reserved.word_size() >> LogN_words))); \ | |
54 assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)), \ | |
55 err_msg("Index "SIZE_FORMAT" corresponding to "PTR_FORMAT \ | |
56 " (%u) is not in committed area.", \ | |
57 (index), \ | |
58 p2i(address_for_index_raw(index)), \ | |
59 G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index)))); | |
60 | |
61 u_char G1BlockOffsetSharedArray::offset_array(size_t index) const { | |
62 check_index(index, "index out of range"); | |
63 return _offset_array[index]; | |
64 } | |
65 | |
66 void G1BlockOffsetSharedArray::set_offset_array(size_t index, u_char offset) { | |
67 check_index(index, "index out of range"); | |
68 set_offset_array_raw(index, offset); | |
69 } | |
70 | |
71 void G1BlockOffsetSharedArray::set_offset_array(size_t index, HeapWord* high, HeapWord* low) { | |
72 check_index(index, "index out of range"); | |
73 assert(high >= low, "addresses out of order"); | |
74 size_t offset = pointer_delta(high, low); | |
75 check_offset(offset, "offset too large"); | |
76 set_offset_array(index, (u_char)offset); | |
77 } | |
78 | |
79 void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_char offset) { | |
80 check_index(right, "right index out of range"); | |
81 assert(left <= right, "indexes out of order"); | |
82 size_t num_cards = right - left + 1; | |
83 if (UseMemSetInBOT) { | |
84 memset(&_offset_array[left], offset, num_cards); | |
85 } else { | |
86 size_t i = left; | |
87 const size_t end = i + num_cards; | |
88 for (; i < end; i++) { | |
89 _offset_array[i] = offset; | |
90 } | |
91 } | |
92 } | |
93 | |
94 void G1BlockOffsetSharedArray::check_offset_array(size_t index, HeapWord* high, HeapWord* low) const { | |
95 check_index(index, "index out of range"); | |
96 assert(high >= low, "addresses out of order"); | |
97 check_offset(pointer_delta(high, low), "offset too large"); | |
98 assert(_offset_array[index] == pointer_delta(high, low), "Wrong offset"); | |
99 } | |
100 | |
101 // Variant of index_for that does not check the index for validity. | |
102 inline size_t G1BlockOffsetSharedArray::index_for_raw(const void* p) const { | |
103 return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN; | |
48 } | 104 } |
49 | 105 |
50 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const { | 106 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const { |
51 char* pc = (char*)p; | 107 char* pc = (char*)p; |
52 assert(pc >= (char*)_reserved.start() && | 108 assert(pc >= (char*)_reserved.start() && |
53 pc < (char*)_reserved.end(), | 109 pc < (char*)_reserved.end(), |
54 err_msg("p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")", | 110 err_msg("p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")", |
55 p2i(p), p2i(_reserved.start()), p2i(_reserved.end()))); | 111 p2i(p), p2i(_reserved.start()), p2i(_reserved.end()))); |
56 size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char)); | 112 size_t result = index_for_raw(p); |
57 size_t result = delta >> LogN; | |
58 check_index(result, "bad index from address"); | 113 check_index(result, "bad index from address"); |
59 return result; | 114 return result; |
60 } | 115 } |
61 | 116 |
62 inline HeapWord* | 117 inline HeapWord* |
63 G1BlockOffsetSharedArray::address_for_index(size_t index) const { | 118 G1BlockOffsetSharedArray::address_for_index(size_t index) const { |
64 check_index(index, "index out of range"); | 119 check_index(index, "index out of range"); |
65 HeapWord* result = _reserved.start() + (index << LogN_words); | 120 HeapWord* result = address_for_index_raw(index); |
66 assert(result >= _reserved.start() && result < _reserved.end(), | 121 assert(result >= _reserved.start() && result < _reserved.end(), |
67 err_msg("bad address from index result " PTR_FORMAT | 122 err_msg("bad address from index result " PTR_FORMAT |
68 " _reserved.start() " PTR_FORMAT " _reserved.end() " | 123 " _reserved.start() " PTR_FORMAT " _reserved.end() " |
69 PTR_FORMAT, | 124 PTR_FORMAT, |
70 p2i(result), p2i(_reserved.start()), p2i(_reserved.end()))); | 125 p2i(result), p2i(_reserved.start()), p2i(_reserved.end()))); |
71 return result; | 126 return result; |
72 } | 127 } |
128 | |
129 #undef check_index | |
73 | 130 |
74 inline size_t | 131 inline size_t |
75 G1BlockOffsetArray::block_size(const HeapWord* p) const { | 132 G1BlockOffsetArray::block_size(const HeapWord* p) const { |
76 return gsp()->block_size(p); | 133 return gsp()->block_size(p); |
77 } | 134 } |