src/share/vm/gc_implementation/g1/g1Allocator.cpp

changeset 7651
c132be0fb74d
parent 7647
80ac3ee51955
equal deleted inserted replaced
7650:dfa21a177d66 7651:c132be0fb74d
111 } 111 }
112 112
113 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : 113 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
114 ParGCAllocBuffer(gclab_word_size), _retired(true) { } 114 ParGCAllocBuffer(gclab_word_size), _retired(true) { }
115 115
116 HeapWord* G1ParGCAllocator::allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) { 116 HeapWord* G1ParGCAllocator::allocate_direct_or_new_plab(InCSetState dest,
117 HeapWord* obj = NULL; 117 size_t word_sz,
118 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); 118 AllocationContext_t context) {
119 size_t gclab_word_size = _g1h->desired_plab_sz(dest);
119 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { 120 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
120 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose, context); 121 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context);
121 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); 122 add_to_alloc_buffer_waste(alloc_buf->words_remaining());
122 alloc_buf->retire(false /* end_of_gc */, false /* retain */); 123 alloc_buf->retire(false /* end_of_gc */, false /* retain */);
123 124
124 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size, context); 125 HeapWord* buf = _g1h->par_allocate_during_gc(dest, gclab_word_size, context);
125 if (buf == NULL) { 126 if (buf == NULL) {
126 return NULL; // Let caller handle allocation failure. 127 return NULL; // Let caller handle allocation failure.
127 } 128 }
128 // Otherwise. 129 // Otherwise.
129 alloc_buf->set_word_size(gclab_word_size); 130 alloc_buf->set_word_size(gclab_word_size);
130 alloc_buf->set_buf(buf); 131 alloc_buf->set_buf(buf);
131 132
132 obj = alloc_buf->allocate(word_sz); 133 HeapWord* const obj = alloc_buf->allocate(word_sz);
133 assert(obj != NULL, "buffer was definitely big enough..."); 134 assert(obj != NULL, "buffer was definitely big enough...");
135 return obj;
134 } else { 136 } else {
135 obj = _g1h->par_allocate_during_gc(purpose, word_sz, context); 137 return _g1h->par_allocate_during_gc(dest, word_sz, context);
136 } 138 }
137 return obj;
138 } 139 }
139 140
140 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) : 141 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) :
141 G1ParGCAllocator(g1h), 142 G1ParGCAllocator(g1h),
142 _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), 143 _surviving_alloc_buffer(g1h->desired_plab_sz(InCSetState::Young)),
143 _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)) { 144 _tenured_alloc_buffer(g1h->desired_plab_sz(InCSetState::Old)) {
144 145 for (uint state = 0; state < InCSetState::Num; state++) {
145 _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer; 146 _alloc_buffers[state] = NULL;
146 _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; 147 }
147 148 _alloc_buffers[InCSetState::Young] = &_surviving_alloc_buffer;
149 _alloc_buffers[InCSetState::Old] = &_tenured_alloc_buffer;
148 } 150 }
149 151
150 void G1DefaultParGCAllocator::retire_alloc_buffers() { 152 void G1DefaultParGCAllocator::retire_alloc_buffers() {
151 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { 153 for (uint state = 0; state < InCSetState::Num; state++) {
152 size_t waste = _alloc_buffers[ap]->words_remaining(); 154 G1ParGCAllocBuffer* const buf = _alloc_buffers[state];
153 add_to_alloc_buffer_waste(waste); 155 if (buf != NULL) {
154 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), 156 add_to_alloc_buffer_waste(buf->words_remaining());
155 true /* end_of_gc */, 157 buf->flush_stats_and_retire(_g1h->alloc_buffer_stats(state),
156 false /* retain */); 158 true /* end_of_gc */,
159 false /* retain */);
160 }
157 } 161 }
158 } 162 }

mercurial