47 |
47 |
48 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const { |
48 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const { |
49 char* pc = (char*)p; |
49 char* pc = (char*)p; |
50 assert(pc >= (char*)_reserved.start() && |
50 assert(pc >= (char*)_reserved.start() && |
51 pc < (char*)_reserved.end(), |
51 pc < (char*)_reserved.end(), |
52 "p not in range."); |
52 err_msg("p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")", |
|
53 p, (char*)_reserved.start(), (char*)_reserved.end())); |
53 size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char)); |
54 size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char)); |
54 size_t result = delta >> LogN; |
55 size_t result = delta >> LogN; |
55 assert(result < _vs.committed_size(), "bad index from address"); |
56 check_index(result, "bad index from address"); |
56 return result; |
57 return result; |
57 } |
58 } |
58 |
59 |
59 inline HeapWord* |
60 inline HeapWord* |
60 G1BlockOffsetSharedArray::address_for_index(size_t index) const { |
61 G1BlockOffsetSharedArray::address_for_index(size_t index) const { |
61 assert(index < _vs.committed_size(), "bad index"); |
62 check_index(index, "index out of range"); |
62 HeapWord* result = _reserved.start() + (index << LogN_words); |
63 HeapWord* result = _reserved.start() + (index << LogN_words); |
63 assert(result >= _reserved.start() && result < _reserved.end(), |
64 assert(result >= _reserved.start() && result < _reserved.end(), |
64 err_msg("bad address from index result " PTR_FORMAT |
65 err_msg("bad address from index result " PTR_FORMAT |
65 " _reserved.start() " PTR_FORMAT " _reserved.end() " |
66 " _reserved.start() " PTR_FORMAT " _reserved.end() " |
66 PTR_FORMAT, |
67 PTR_FORMAT, |