1 /*
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 *
215 return num_take_elems > 0; // was something transferred?
216 }
217
218 void ParScanThreadState::push_on_overflow_stack(oop p) {
219 assert(ParGCUseLocalOverflow, "Else should not call");
220 overflow_stack()->push(p);
221 assert(young_gen()->overflow_list() == NULL, "Error");
222 }
223
224 HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
225
226 // Otherwise, if the object is small enough, try to reallocate the
227 // buffer.
228 HeapWord* obj = NULL;
229 if (!_to_space_full) {
230 ParGCAllocBuffer* const plab = to_space_alloc_buffer();
231 Space* const sp = to_space();
232 if (word_sz * 100 <
233 ParallelGCBufferWastePct * plab->word_sz()) {
234 // Is small enough; abandon this buffer and start a new one.
235 plab->retire(false, false);
236 size_t buf_size = plab->word_sz();
237 HeapWord* buf_space = sp->par_allocate(buf_size);
238 if (buf_space == NULL) {
239 const size_t min_bytes =
240 ParGCAllocBuffer::min_size() << LogHeapWordSize;
241 size_t free_bytes = sp->free();
242 while(buf_space == NULL && free_bytes >= min_bytes) {
243 buf_size = free_bytes >> LogHeapWordSize;
244 assert(buf_size == (size_t)align_object_size(buf_size),
245 "Invariant");
246 buf_space = sp->par_allocate(buf_size);
247 free_bytes = sp->free();
248 }
249 }
250 if (buf_space != NULL) {
251 plab->set_word_size(buf_size);
252 plab->set_buf(buf_space);
253 record_survivor_plab(buf_space, buf_size);
254 obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
255 // Note that we cannot compare buf_size < word_sz below
446 pss.overflow_refills(), pss.overflow_refill_objs());
447 }
448 }
449 st->print("tot "); totals.print(st); st->cr();
450
451 DEBUG_ONLY(totals.verify());
452 }
453 #endif // TASKQUEUE_STATS
454
455 void ParScanThreadStateSet::flush()
456 {
457 // Work in this loop should be kept as lightweight as
458 // possible since this might otherwise become a bottleneck
459 // to scaling. Should we add heavy-weight work into this
460 // loop, consider parallelizing the loop into the worker threads.
461 for (int i = 0; i < length(); ++i) {
462 ParScanThreadState& par_scan_state = thread_state(i);
463
464 // Flush stats related to To-space PLAB activity and
465 // retire the last buffer.
466 par_scan_state.to_space_alloc_buffer()->
467 flush_stats_and_retire(_gen.plab_stats(),
468 true /* end_of_gc */,
469 false /* retain */);
470
471 // Every thread has its own age table. We need to merge
472 // them all into one.
473 ageTable *local_table = par_scan_state.age_table();
474 _gen.age_table()->merge(local_table);
475
476 // Inform old gen that we're done.
477 _next_gen.par_promote_alloc_done(i);
478 _next_gen.par_oop_since_save_marks_iterate_done(i);
479 }
480
481 if (UseConcMarkSweepGC) {
482 // We need to call this even when ResizeOldPLAB is disabled
483 // so as to avoid breaking some asserts. While we may be able
484 // to avoid this by reorganizing the code a bit, I am loathe
485 // to do that unless we find cases where ergo leads to bad
486 // performance.
487 CFLS_LAB::compute_desired_plab_size();
488 }
489 }
|
1 /*
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 *
215 return num_take_elems > 0; // was something transferred?
216 }
217
218 void ParScanThreadState::push_on_overflow_stack(oop p) {
219 assert(ParGCUseLocalOverflow, "Else should not call");
220 overflow_stack()->push(p);
221 assert(young_gen()->overflow_list() == NULL, "Error");
222 }
223
224 HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
225
226 // Otherwise, if the object is small enough, try to reallocate the
227 // buffer.
228 HeapWord* obj = NULL;
229 if (!_to_space_full) {
230 ParGCAllocBuffer* const plab = to_space_alloc_buffer();
231 Space* const sp = to_space();
232 if (word_sz * 100 <
233 ParallelGCBufferWastePct * plab->word_sz()) {
234 // Is small enough; abandon this buffer and start a new one.
235 plab->retire();
236 size_t buf_size = plab->word_sz();
237 HeapWord* buf_space = sp->par_allocate(buf_size);
238 if (buf_space == NULL) {
239 const size_t min_bytes =
240 ParGCAllocBuffer::min_size() << LogHeapWordSize;
241 size_t free_bytes = sp->free();
242 while(buf_space == NULL && free_bytes >= min_bytes) {
243 buf_size = free_bytes >> LogHeapWordSize;
244 assert(buf_size == (size_t)align_object_size(buf_size),
245 "Invariant");
246 buf_space = sp->par_allocate(buf_size);
247 free_bytes = sp->free();
248 }
249 }
250 if (buf_space != NULL) {
251 plab->set_word_size(buf_size);
252 plab->set_buf(buf_space);
253 record_survivor_plab(buf_space, buf_size);
254 obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
255 // Note that we cannot compare buf_size < word_sz below
446 pss.overflow_refills(), pss.overflow_refill_objs());
447 }
448 }
449 st->print("tot "); totals.print(st); st->cr();
450
451 DEBUG_ONLY(totals.verify());
452 }
453 #endif // TASKQUEUE_STATS
454
455 void ParScanThreadStateSet::flush()
456 {
457 // Work in this loop should be kept as lightweight as
458 // possible since this might otherwise become a bottleneck
459 // to scaling. Should we add heavy-weight work into this
460 // loop, consider parallelizing the loop into the worker threads.
461 for (int i = 0; i < length(); ++i) {
462 ParScanThreadState& par_scan_state = thread_state(i);
463
464 // Flush stats related to To-space PLAB activity and
465 // retire the last buffer.
466 par_scan_state.to_space_alloc_buffer()->flush_and_retire_stats(_gen.plab_stats());
467
468 // Every thread has its own age table. We need to merge
469 // them all into one.
470 ageTable *local_table = par_scan_state.age_table();
471 _gen.age_table()->merge(local_table);
472
473 // Inform old gen that we're done.
474 _next_gen.par_promote_alloc_done(i);
475 _next_gen.par_oop_since_save_marks_iterate_done(i);
476 }
477
478 if (UseConcMarkSweepGC) {
479 // We need to call this even when ResizeOldPLAB is disabled
480 // so as to avoid breaking some asserts. While we may be able
481 // to avoid this by reorganizing the code a bit, I am loathe
482 // to do that unless we find cases where ergo leads to bad
483 // performance.
484 CFLS_LAB::compute_desired_plab_size();
485 }
486 }
|