106 }
107
108 if (requested_blocks_size_in_bytes < current_blocks_size_in_bytes) {
109 // Shrink
110 size_t shrink_by = current_blocks_size_in_bytes - requested_blocks_size_in_bytes;
111 _virtual_space.shrink_by(shrink_by);
112 }
113
114 _blocks_region.set_word_size(requested_blocks_size_in_bytes / sizeof(HeapWord));
115
116 assert(requested_blocks_size_in_bytes % sizeof(HeapWord) == 0, "Block table not expanded in word sized increment");
117 assert(requested_blocks_size_in_bytes == _blocks_region.byte_size(), "Sanity");
118 assert(block_for_addr(low_bound) == &_raw_base[0], "Checking start of map");
119 assert(block_for_addr(high_bound-1) <= &_raw_base[_blocks_region.byte_size()-1], "Checking end of map");
120 }
121
122 void ObjectStartArray::reset() {
123 memset(_blocks_region.start(), clean_block, _blocks_region.byte_size());
124 }
125
126
127 bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr,
128 HeapWord* end_addr) const {
129 assert(start_addr <= end_addr,
130 "Range is wrong. start_addr (" PTR_FORMAT ") is after end_addr (" PTR_FORMAT ")",
131 p2i(start_addr), p2i(end_addr));
132 if (start_addr > end_addr) {
133 return false;
134 }
135
136 jbyte* start_block = block_for_addr(start_addr);
137 jbyte* end_block = block_for_addr(end_addr);
138
139 for (jbyte* block = start_block; block <= end_block; block++) {
140 if (*block != clean_block) {
141 return true;
142 }
143 }
144
145 return false;
|
106 }
107
108 if (requested_blocks_size_in_bytes < current_blocks_size_in_bytes) {
109 // Shrink
110 size_t shrink_by = current_blocks_size_in_bytes - requested_blocks_size_in_bytes;
111 _virtual_space.shrink_by(shrink_by);
112 }
113
114 _blocks_region.set_word_size(requested_blocks_size_in_bytes / sizeof(HeapWord));
115
116 assert(requested_blocks_size_in_bytes % sizeof(HeapWord) == 0, "Block table not expanded in word sized increment");
117 assert(requested_blocks_size_in_bytes == _blocks_region.byte_size(), "Sanity");
118 assert(block_for_addr(low_bound) == &_raw_base[0], "Checking start of map");
119 assert(block_for_addr(high_bound-1) <= &_raw_base[_blocks_region.byte_size()-1], "Checking end of map");
120 }
121
122 void ObjectStartArray::reset() {
123 memset(_blocks_region.start(), clean_block, _blocks_region.byte_size());
124 }
125
126 // Optimized for finding the first object that crosses into
127 // a given block. The blocks contain the offset of the last
128 // object in that block. Scroll backwards by one, and the first
129 // object hit should be at the beginning of the block
130 HeapWord* ObjectStartArray::object_start(HeapWord* addr) const {
131 assert_covered_region_contains(addr);
132 jbyte* block = block_for_addr(addr);
133 HeapWord* scroll_forward = offset_addr_for_block(block--);
134 while (scroll_forward > addr) {
135 scroll_forward = offset_addr_for_block(block--);
136 }
137
138 HeapWord* next = scroll_forward;
139 while (next <= addr) {
140 scroll_forward = next;
141 next += oop(next)->size();
142 }
143 assert(scroll_forward <= addr, "wrong order for current and arg");
144 assert(addr <= next, "wrong order for arg and next");
145 return scroll_forward;
146 }
147
148 bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr,
149 HeapWord* end_addr) const {
150 assert(start_addr <= end_addr,
151 "Range is wrong. start_addr (" PTR_FORMAT ") is after end_addr (" PTR_FORMAT ")",
152 p2i(start_addr), p2i(end_addr));
153 if (start_addr > end_addr) {
154 return false;
155 }
156
157 jbyte* start_block = block_for_addr(start_addr);
158 jbyte* end_block = block_for_addr(end_addr);
159
160 for (jbyte* block = start_block; block <= end_block; block++) {
161 if (*block != clean_block) {
162 return true;
163 }
164 }
165
166 return false;
|