140
141 size_t G1Allocator::unsafe_max_tlab_alloc() {
142 // Return the remaining space in the cur alloc region, but not less than
143 // the min TLAB size.
144
145 // Also, this value can be at most the humongous object threshold,
146 // since we can't allow tlabs to grow big enough to accommodate
147 // humongous objects.
148
149 HeapRegion* hr = mutator_alloc_region()->get();
150 size_t max_tlab = _g1h->max_tlab_size() * wordSize;
151 if (hr == NULL) {
152 return max_tlab;
153 } else {
154 return MIN2(MAX2(hr->free(), (size_t) MinTLABSize), max_tlab);
155 }
156 }
157
158 size_t G1Allocator::used_in_alloc_regions() {
159 assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf.");
160 size_t result = 0;
161
162 // Read only once in case it is set to NULL concurrently
163 HeapRegion* hr = mutator_alloc_region()->get();
164 if (hr != NULL) {
165 result += hr->used();
166 }
167 return result;
168 }
169
170
171 HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
172 size_t word_size) {
173 size_t temp = 0;
174 HeapWord* result = par_allocate_during_gc(dest, word_size, word_size, &temp);
175 assert(result == NULL || temp == word_size,
176 "Requested " SIZE_FORMAT " words, but got " SIZE_FORMAT " at " PTR_FORMAT,
177 word_size, temp, p2i(result));
178 return result;
179 }
180
181 HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
182 size_t min_word_size,
183 size_t desired_word_size,
184 size_t* actual_word_size) {
185 switch (dest.value()) {
186 case InCSetState::Young:
187 return survivor_attempt_allocation(min_word_size, desired_word_size, actual_word_size);
|
140
141 size_t G1Allocator::unsafe_max_tlab_alloc() {
142 // Return the remaining space in the cur alloc region, but not less than
143 // the min TLAB size.
144
145 // Also, this value can be at most the humongous object threshold,
146 // since we can't allow tlabs to grow big enough to accommodate
147 // humongous objects.
148
149 HeapRegion* hr = mutator_alloc_region()->get();
150 size_t max_tlab = _g1h->max_tlab_size() * wordSize;
151 if (hr == NULL) {
152 return max_tlab;
153 } else {
154 return MIN2(MAX2(hr->free(), (size_t) MinTLABSize), max_tlab);
155 }
156 }
157
158 size_t G1Allocator::used_in_alloc_regions() {
159 assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf.");
160 return mutator_alloc_region()->used_in_alloc_regions();
161 }
162
163
164 HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
165 size_t word_size) {
166 size_t temp = 0;
167 HeapWord* result = par_allocate_during_gc(dest, word_size, word_size, &temp);
168 assert(result == NULL || temp == word_size,
169 "Requested " SIZE_FORMAT " words, but got " SIZE_FORMAT " at " PTR_FORMAT,
170 word_size, temp, p2i(result));
171 return result;
172 }
173
174 HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
175 size_t min_word_size,
176 size_t desired_word_size,
177 size_t* actual_word_size) {
178 switch (dest.value()) {
179 case InCSetState::Young:
180 return survivor_attempt_allocation(min_word_size, desired_word_size, actual_word_size);
|