17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
27 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
28 #include "gc_implementation/parNew/parNewGeneration.hpp"
29 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
30 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
31 #include "gc_implementation/shared/ageTable.hpp"
32 #include "gc_implementation/shared/copyFailedInfo.hpp"
33 #include "gc_implementation/shared/gcHeapSummary.hpp"
34 #include "gc_implementation/shared/gcTimer.hpp"
35 #include "gc_implementation/shared/gcTrace.hpp"
36 #include "gc_implementation/shared/gcTraceTime.hpp"
37 #include "gc_implementation/shared/plab.inline.hpp"
38 #include "gc_implementation/shared/spaceDecorator.hpp"
39 #include "memory/defNewGeneration.inline.hpp"
40 #include "memory/genCollectedHeap.hpp"
41 #include "memory/genOopClosures.inline.hpp"
42 #include "memory/generation.hpp"
43 #include "memory/referencePolicy.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/strongRootsScope.hpp"
46 #include "memory/space.hpp"
47 #include "oops/objArrayOop.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "runtime/atomic.inline.hpp"
50 #include "runtime/handles.hpp"
51 #include "runtime/handles.inline.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/thread.inline.hpp"
54 #include "utilities/copy.hpp"
55 #include "utilities/globalDefinitions.hpp"
56 #include "utilities/stack.inline.hpp"
57 #include "utilities/workgroup.hpp"
209 }
210 bool ok = queue->push(obj_to_push);
211 assert(ok, "Should have succeeded");
212 }
213 assert(young_gen()->overflow_list() == NULL, "Error");
214 return num_take_elems > 0; // was something transferred?
215 }
216
217 void ParScanThreadState::push_on_overflow_stack(oop p) {
218 assert(ParGCUseLocalOverflow, "Else should not call");
219 overflow_stack()->push(p);
220 assert(young_gen()->overflow_list() == NULL, "Error");
221 }
222
223 HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
224
225 // Otherwise, if the object is small enough, try to reallocate the
226 // buffer.
227 HeapWord* obj = NULL;
228 if (!_to_space_full) {
229 PLAB* const plab = to_space_alloc_buffer();
230 Space* const sp = to_space();
231 if (word_sz * 100 <
232 ParallelGCBufferWastePct * plab->word_sz()) {
233 // Is small enough; abandon this buffer and start a new one.
234 plab->retire();
235 size_t buf_size = plab->word_sz();
236 HeapWord* buf_space = sp->par_allocate(buf_size);
237 if (buf_space == NULL) {
238 const size_t min_bytes =
239 PLAB::min_size() << LogHeapWordSize;
240 size_t free_bytes = sp->free();
241 while(buf_space == NULL && free_bytes >= min_bytes) {
242 buf_size = free_bytes >> LogHeapWordSize;
243 assert(buf_size == (size_t)align_object_size(buf_size),
244 "Invariant");
245 buf_space = sp->par_allocate(buf_size);
246 free_bytes = sp->free();
247 }
248 }
249 if (buf_space != NULL) {
250 plab->set_word_size(buf_size);
251 plab->set_buf(buf_space);
252 record_survivor_plab(buf_space, buf_size);
253 obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
254 // Note that we cannot compare buf_size < word_sz below
255 // because of AlignmentReserve (see PLAB::allocate()).
256 assert(obj != NULL || plab->words_remaining() < word_sz,
257 "Else should have been able to allocate");
258 // It's conceivable that we may be able to use the
259 // buffer we just grabbed for subsequent small requests
260 // even if not for this one.
261 } else {
262 // We're used up.
263 _to_space_full = true;
264 }
265
266 } else {
267 // Too large; allocate the object individually.
268 obj = sp->par_allocate(word_sz);
269 }
270 }
271 return obj;
272 }
273
274
275 void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj,
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
27 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
28 #include "gc_implementation/parNew/parNewGeneration.hpp"
29 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
30 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
31 #include "gc_implementation/shared/ageTable.hpp"
32 #include "gc_implementation/shared/copyFailedInfo.hpp"
33 #include "gc_implementation/shared/gcHeapSummary.hpp"
34 #include "gc_implementation/shared/gcTimer.hpp"
35 #include "gc_implementation/shared/gcTrace.hpp"
36 #include "gc_implementation/shared/gcTraceTime.hpp"
37 #include "gc_implementation/shared/parGCAllocBuffer.inline.hpp"
38 #include "gc_implementation/shared/spaceDecorator.hpp"
39 #include "memory/defNewGeneration.inline.hpp"
40 #include "memory/genCollectedHeap.hpp"
41 #include "memory/genOopClosures.inline.hpp"
42 #include "memory/generation.hpp"
43 #include "memory/referencePolicy.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "memory/strongRootsScope.hpp"
46 #include "memory/space.hpp"
47 #include "oops/objArrayOop.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "runtime/atomic.inline.hpp"
50 #include "runtime/handles.hpp"
51 #include "runtime/handles.inline.hpp"
52 #include "runtime/java.hpp"
53 #include "runtime/thread.inline.hpp"
54 #include "utilities/copy.hpp"
55 #include "utilities/globalDefinitions.hpp"
56 #include "utilities/stack.inline.hpp"
57 #include "utilities/workgroup.hpp"
209 }
210 bool ok = queue->push(obj_to_push);
211 assert(ok, "Should have succeeded");
212 }
213 assert(young_gen()->overflow_list() == NULL, "Error");
214 return num_take_elems > 0; // was something transferred?
215 }
216
217 void ParScanThreadState::push_on_overflow_stack(oop p) {
218 assert(ParGCUseLocalOverflow, "Else should not call");
219 overflow_stack()->push(p);
220 assert(young_gen()->overflow_list() == NULL, "Error");
221 }
222
223 HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
224
225 // Otherwise, if the object is small enough, try to reallocate the
226 // buffer.
227 HeapWord* obj = NULL;
228 if (!_to_space_full) {
229 ParGCAllocBuffer* const plab = to_space_alloc_buffer();
230 Space* const sp = to_space();
231 if (word_sz * 100 <
232 ParallelGCBufferWastePct * plab->word_sz()) {
233 // Is small enough; abandon this buffer and start a new one.
234 plab->retire();
235 size_t buf_size = plab->word_sz();
236 HeapWord* buf_space = sp->par_allocate(buf_size);
237 if (buf_space == NULL) {
238 const size_t min_bytes =
239 ParGCAllocBuffer::min_size() << LogHeapWordSize;
240 size_t free_bytes = sp->free();
241 while(buf_space == NULL && free_bytes >= min_bytes) {
242 buf_size = free_bytes >> LogHeapWordSize;
243 assert(buf_size == (size_t)align_object_size(buf_size),
244 "Invariant");
245 buf_space = sp->par_allocate(buf_size);
246 free_bytes = sp->free();
247 }
248 }
249 if (buf_space != NULL) {
250 plab->set_word_size(buf_size);
251 plab->set_buf(buf_space);
252 record_survivor_plab(buf_space, buf_size);
253 obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
254 // Note that we cannot compare buf_size < word_sz below
255 // because of AlignmentReserve (see ParGCAllocBuffer::allocate()).
256 assert(obj != NULL || plab->words_remaining() < word_sz,
257 "Else should have been able to allocate");
258 // It's conceivable that we may be able to use the
259 // buffer we just grabbed for subsequent small requests
260 // even if not for this one.
261 } else {
262 // We're used up.
263 _to_space_full = true;
264 }
265
266 } else {
267 // Too large; allocate the object individually.
268 obj = sp->par_allocate(word_sz);
269 }
270 }
271 return obj;
272 }
273
274
275 void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj,
|