comparison src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp @ 20273:9441d22e429a

8047820: G1 Block offset table does not need to support generic Space classes Reviewed-by: tschatzl, stefank
author mgerdin
date Wed, 25 Jun 2014 16:53:13 +0200
parents 78bbf4d43a14
children 1526a938e670
comparison
equal deleted inserted replaced
20272:e635a728f9da 20273:9441d22e429a
24 24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
27 27
28 #include "gc_implementation/g1/g1BlockOffsetTable.hpp" 28 #include "gc_implementation/g1/g1BlockOffsetTable.hpp"
29 #include "gc_implementation/g1/heapRegion.hpp"
29 #include "memory/space.hpp" 30 #include "memory/space.hpp"
30 31
31 inline HeapWord* G1BlockOffsetTable::block_start(const void* addr) { 32 inline HeapWord* G1BlockOffsetTable::block_start(const void* addr) {
32 if (addr >= _bottom && addr < _end) { 33 if (addr >= _bottom && addr < _end) {
33 return block_start_unsafe(addr); 34 return block_start_unsafe(addr);
67 PTR_FORMAT, 68 PTR_FORMAT,
68 p2i(result), p2i(_reserved.start()), p2i(_reserved.end()))); 69 p2i(result), p2i(_reserved.start()), p2i(_reserved.end())));
69 return result; 70 return result;
70 } 71 }
71 72
73 inline size_t
74 G1BlockOffsetArray::block_size(const HeapWord* p) const {
75 return gsp()->block_size(p);
76 }
77
72 inline HeapWord* 78 inline HeapWord*
73 G1BlockOffsetArray::block_at_or_preceding(const void* addr, 79 G1BlockOffsetArray::block_at_or_preceding(const void* addr,
74 bool has_max_index, 80 bool has_max_index,
75 size_t max_index) const { 81 size_t max_index) const {
76 assert(_array->offset_array(0) == 0, "objects can't cross covered areas"); 82 assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
86 while (offset >= N_words) { 92 while (offset >= N_words) {
87 // The excess of the offset from N_words indicates a power of Base 93 // The excess of the offset from N_words indicates a power of Base
88 // to go back by. 94 // to go back by.
89 size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset); 95 size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset);
90 q -= (N_words * n_cards_back); 96 q -= (N_words * n_cards_back);
91 assert(q >= _sp->bottom(), "Went below bottom!"); 97 assert(q >= gsp()->bottom(), "Went below bottom!");
92 index -= n_cards_back; 98 index -= n_cards_back;
93 offset = _array->offset_array(index); 99 offset = _array->offset_array(index);
94 } 100 }
95 assert(offset < N_words, "offset too large"); 101 assert(offset < N_words, "offset too large");
96 q -= offset; 102 q -= offset;
99 105
100 inline HeapWord* 106 inline HeapWord*
101 G1BlockOffsetArray:: 107 G1BlockOffsetArray::
102 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n, 108 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
103 const void* addr) const { 109 const void* addr) const {
104 if (csp() != NULL) { 110 if (addr >= gsp()->top()) return gsp()->top();
105 if (addr >= csp()->top()) return csp()->top(); 111 while (n <= addr) {
106 while (n <= addr) { 112 q = n;
107 q = n; 113 oop obj = oop(q);
108 oop obj = oop(q); 114 if (obj->klass_or_null() == NULL) return q;
109 if (obj->klass_or_null() == NULL) return q; 115 n += obj->size();
110 n += obj->size();
111 }
112 } else {
113 while (n <= addr) {
114 q = n;
115 oop obj = oop(q);
116 if (obj->klass_or_null() == NULL) return q;
117 n += _sp->block_size(q);
118 }
119 } 116 }
120 assert(q <= n, "wrong order for q and addr"); 117 assert(q <= n, "wrong order for q and addr");
121 assert(addr < n, "wrong order for addr and n"); 118 assert(addr < n, "wrong order for addr and n");
122 return q; 119 return q;
123 } 120 }
124 121
125 inline HeapWord* 122 inline HeapWord*
126 G1BlockOffsetArray::forward_to_block_containing_addr(HeapWord* q, 123 G1BlockOffsetArray::forward_to_block_containing_addr(HeapWord* q,
127 const void* addr) { 124 const void* addr) {
128 if (oop(q)->klass_or_null() == NULL) return q; 125 if (oop(q)->klass_or_null() == NULL) return q;
129 HeapWord* n = q + _sp->block_size(q); 126 HeapWord* n = q + block_size(q);
130 // In the normal case, where the query "addr" is a card boundary, and the 127 // In the normal case, where the query "addr" is a card boundary, and the
131 // offset table chunks are the same size as cards, the block starting at 128 // offset table chunks are the same size as cards, the block starting at
132 // "q" will contain addr, so the test below will fail, and we'll fall 129 // "q" will contain addr, so the test below will fail, and we'll fall
133 // through quickly. 130 // through quickly.
134 if (n <= addr) { 131 if (n <= addr) {