--- old/src/share/vm/gc/parallel/objectStartArray.cpp 2016-01-13 23:35:10.813640000 +0100 +++ new/src/share/vm/gc/parallel/objectStartArray.cpp 2016-01-13 23:35:10.655630000 +0100 @@ -123,6 +123,27 @@ memset(_blocks_region.start(), clean_block, _blocks_region.byte_size()); } +// Optimized for finding the first object that crosses into +// a given block. The blocks contain the offset of the last +// object in that block. Scroll backwards by one, and the first +// object hit should be at the beginning of the block +HeapWord* ObjectStartArray::object_start(HeapWord* addr) const { + assert_covered_region_contains(addr); + jbyte* block = block_for_addr(addr); + HeapWord* scroll_forward = offset_addr_for_block(block--); + while (scroll_forward > addr) { + scroll_forward = offset_addr_for_block(block--); + } + + HeapWord* next = scroll_forward; + while (next <= addr) { + scroll_forward = next; + next += oop(next)->size(); + } + assert(scroll_forward <= addr, "wrong order for current and arg"); + assert(addr <= next, "wrong order for arg and next"); + return scroll_forward; +} bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr, HeapWord* end_addr) const {