src/share/vm/gc_implementation/parNew/parNewGeneration.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6719
8e20ef014b08
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
aoqi@0 27 #include "gc_implementation/parNew/parNewGeneration.hpp"
aoqi@0 28 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
aoqi@0 29 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
aoqi@0 30 #include "gc_implementation/shared/ageTable.hpp"
aoqi@0 31 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
aoqi@0 32 #include "gc_implementation/shared/gcHeapSummary.hpp"
aoqi@0 33 #include "gc_implementation/shared/gcTimer.hpp"
aoqi@0 34 #include "gc_implementation/shared/gcTrace.hpp"
aoqi@0 35 #include "gc_implementation/shared/gcTraceTime.hpp"
aoqi@0 36 #include "gc_implementation/shared/copyFailedInfo.hpp"
aoqi@0 37 #include "gc_implementation/shared/spaceDecorator.hpp"
aoqi@0 38 #include "memory/defNewGeneration.inline.hpp"
aoqi@0 39 #include "memory/genCollectedHeap.hpp"
aoqi@0 40 #include "memory/genOopClosures.inline.hpp"
aoqi@0 41 #include "memory/generation.hpp"
aoqi@0 42 #include "memory/generation.inline.hpp"
aoqi@0 43 #include "memory/referencePolicy.hpp"
aoqi@0 44 #include "memory/resourceArea.hpp"
aoqi@0 45 #include "memory/sharedHeap.hpp"
aoqi@0 46 #include "memory/space.hpp"
aoqi@0 47 #include "oops/objArrayOop.hpp"
aoqi@0 48 #include "oops/oop.inline.hpp"
aoqi@0 49 #include "oops/oop.pcgc.inline.hpp"
aoqi@0 50 #include "runtime/handles.hpp"
aoqi@0 51 #include "runtime/handles.inline.hpp"
aoqi@0 52 #include "runtime/java.hpp"
aoqi@0 53 #include "runtime/thread.hpp"
aoqi@0 54 #include "utilities/copy.hpp"
aoqi@0 55 #include "utilities/globalDefinitions.hpp"
aoqi@0 56 #include "utilities/workgroup.hpp"
aoqi@0 57
aoqi@0 58 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
aoqi@0 59
aoqi@0 60 #ifdef _MSC_VER
aoqi@0 61 #pragma warning( push )
aoqi@0 62 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
aoqi@0 63 #endif
aoqi@0 64 ParScanThreadState::ParScanThreadState(Space* to_space_,
aoqi@0 65 ParNewGeneration* gen_,
aoqi@0 66 Generation* old_gen_,
aoqi@0 67 int thread_num_,
aoqi@0 68 ObjToScanQueueSet* work_queue_set_,
aoqi@0 69 Stack<oop, mtGC>* overflow_stacks_,
aoqi@0 70 size_t desired_plab_sz_,
aoqi@0 71 ParallelTaskTerminator& term_) :
aoqi@0 72 _to_space(to_space_), _old_gen(old_gen_), _young_gen(gen_), _thread_num(thread_num_),
aoqi@0 73 _work_queue(work_queue_set_->queue(thread_num_)), _to_space_full(false),
aoqi@0 74 _overflow_stack(overflow_stacks_ ? overflow_stacks_ + thread_num_ : NULL),
aoqi@0 75 _ageTable(false), // false ==> not the global age table, no perf data.
aoqi@0 76 _to_space_alloc_buffer(desired_plab_sz_),
aoqi@0 77 _to_space_closure(gen_, this), _old_gen_closure(gen_, this),
aoqi@0 78 _to_space_root_closure(gen_, this), _old_gen_root_closure(gen_, this),
aoqi@0 79 _older_gen_closure(gen_, this),
aoqi@0 80 _evacuate_followers(this, &_to_space_closure, &_old_gen_closure,
aoqi@0 81 &_to_space_root_closure, gen_, &_old_gen_root_closure,
aoqi@0 82 work_queue_set_, &term_),
aoqi@0 83 _is_alive_closure(gen_), _scan_weak_ref_closure(gen_, this),
aoqi@0 84 _keep_alive_closure(&_scan_weak_ref_closure),
aoqi@0 85 _strong_roots_time(0.0), _term_time(0.0)
aoqi@0 86 {
aoqi@0 87 #if TASKQUEUE_STATS
aoqi@0 88 _term_attempts = 0;
aoqi@0 89 _overflow_refills = 0;
aoqi@0 90 _overflow_refill_objs = 0;
aoqi@0 91 #endif // TASKQUEUE_STATS
aoqi@0 92
aoqi@0 93 _survivor_chunk_array =
aoqi@0 94 (ChunkArray*) old_gen()->get_data_recorder(thread_num());
aoqi@0 95 _hash_seed = 17; // Might want to take time-based random value.
aoqi@0 96 _start = os::elapsedTime();
aoqi@0 97 _old_gen_closure.set_generation(old_gen_);
aoqi@0 98 _old_gen_root_closure.set_generation(old_gen_);
aoqi@0 99 }
aoqi@0 100 #ifdef _MSC_VER
aoqi@0 101 #pragma warning( pop )
aoqi@0 102 #endif
aoqi@0 103
aoqi@0 104 void ParScanThreadState::record_survivor_plab(HeapWord* plab_start,
aoqi@0 105 size_t plab_word_size) {
aoqi@0 106 ChunkArray* sca = survivor_chunk_array();
aoqi@0 107 if (sca != NULL) {
aoqi@0 108 // A non-null SCA implies that we want the PLAB data recorded.
aoqi@0 109 sca->record_sample(plab_start, plab_word_size);
aoqi@0 110 }
aoqi@0 111 }
aoqi@0 112
aoqi@0 113 bool ParScanThreadState::should_be_partially_scanned(oop new_obj, oop old_obj) const {
aoqi@0 114 return new_obj->is_objArray() &&
aoqi@0 115 arrayOop(new_obj)->length() > ParGCArrayScanChunk &&
aoqi@0 116 new_obj != old_obj;
aoqi@0 117 }
aoqi@0 118
aoqi@0 119 void ParScanThreadState::scan_partial_array_and_push_remainder(oop old) {
aoqi@0 120 assert(old->is_objArray(), "must be obj array");
aoqi@0 121 assert(old->is_forwarded(), "must be forwarded");
aoqi@0 122 assert(Universe::heap()->is_in_reserved(old), "must be in heap.");
aoqi@0 123 assert(!old_gen()->is_in(old), "must be in young generation.");
aoqi@0 124
aoqi@0 125 objArrayOop obj = objArrayOop(old->forwardee());
aoqi@0 126 // Process ParGCArrayScanChunk elements now
aoqi@0 127 // and push the remainder back onto queue
aoqi@0 128 int start = arrayOop(old)->length();
aoqi@0 129 int end = obj->length();
aoqi@0 130 int remainder = end - start;
aoqi@0 131 assert(start <= end, "just checking");
aoqi@0 132 if (remainder > 2 * ParGCArrayScanChunk) {
aoqi@0 133 // Test above combines last partial chunk with a full chunk
aoqi@0 134 end = start + ParGCArrayScanChunk;
aoqi@0 135 arrayOop(old)->set_length(end);
aoqi@0 136 // Push remainder.
aoqi@0 137 bool ok = work_queue()->push(old);
aoqi@0 138 assert(ok, "just popped, push must be okay");
aoqi@0 139 } else {
aoqi@0 140 // Restore length so that it can be used if there
aoqi@0 141 // is a promotion failure and forwarding pointers
aoqi@0 142 // must be removed.
aoqi@0 143 arrayOop(old)->set_length(end);
aoqi@0 144 }
aoqi@0 145
aoqi@0 146 // process our set of indices (include header in first chunk)
aoqi@0 147 // should make sure end is even (aligned to HeapWord in case of compressed oops)
aoqi@0 148 if ((HeapWord *)obj < young_old_boundary()) {
aoqi@0 149 // object is in to_space
aoqi@0 150 obj->oop_iterate_range(&_to_space_closure, start, end);
aoqi@0 151 } else {
aoqi@0 152 // object is in old generation
aoqi@0 153 obj->oop_iterate_range(&_old_gen_closure, start, end);
aoqi@0 154 }
aoqi@0 155 }
aoqi@0 156
aoqi@0 157
aoqi@0 158 void ParScanThreadState::trim_queues(int max_size) {
aoqi@0 159 ObjToScanQueue* queue = work_queue();
aoqi@0 160 do {
aoqi@0 161 while (queue->size() > (juint)max_size) {
aoqi@0 162 oop obj_to_scan;
aoqi@0 163 if (queue->pop_local(obj_to_scan)) {
aoqi@0 164 if ((HeapWord *)obj_to_scan < young_old_boundary()) {
aoqi@0 165 if (obj_to_scan->is_objArray() &&
aoqi@0 166 obj_to_scan->is_forwarded() &&
aoqi@0 167 obj_to_scan->forwardee() != obj_to_scan) {
aoqi@0 168 scan_partial_array_and_push_remainder(obj_to_scan);
aoqi@0 169 } else {
aoqi@0 170 // object is in to_space
aoqi@0 171 obj_to_scan->oop_iterate(&_to_space_closure);
aoqi@0 172 }
aoqi@0 173 } else {
aoqi@0 174 // object is in old generation
aoqi@0 175 obj_to_scan->oop_iterate(&_old_gen_closure);
aoqi@0 176 }
aoqi@0 177 }
aoqi@0 178 }
aoqi@0 179 // For the case of compressed oops, we have a private, non-shared
aoqi@0 180 // overflow stack, so we eagerly drain it so as to more evenly
aoqi@0 181 // distribute load early. Note: this may be good to do in
aoqi@0 182 // general rather than delay for the final stealing phase.
aoqi@0 183 // If applicable, we'll transfer a set of objects over to our
aoqi@0 184 // work queue, allowing them to be stolen and draining our
aoqi@0 185 // private overflow stack.
aoqi@0 186 } while (ParGCTrimOverflow && young_gen()->take_from_overflow_list(this));
aoqi@0 187 }
aoqi@0 188
aoqi@0 189 bool ParScanThreadState::take_from_overflow_stack() {
aoqi@0 190 assert(ParGCUseLocalOverflow, "Else should not call");
aoqi@0 191 assert(young_gen()->overflow_list() == NULL, "Error");
aoqi@0 192 ObjToScanQueue* queue = work_queue();
aoqi@0 193 Stack<oop, mtGC>* const of_stack = overflow_stack();
aoqi@0 194 const size_t num_overflow_elems = of_stack->size();
aoqi@0 195 const size_t space_available = queue->max_elems() - queue->size();
aoqi@0 196 const size_t num_take_elems = MIN3(space_available / 4,
aoqi@0 197 ParGCDesiredObjsFromOverflowList,
aoqi@0 198 num_overflow_elems);
aoqi@0 199 // Transfer the most recent num_take_elems from the overflow
aoqi@0 200 // stack to our work queue.
aoqi@0 201 for (size_t i = 0; i != num_take_elems; i++) {
aoqi@0 202 oop cur = of_stack->pop();
aoqi@0 203 oop obj_to_push = cur->forwardee();
aoqi@0 204 assert(Universe::heap()->is_in_reserved(cur), "Should be in heap");
aoqi@0 205 assert(!old_gen()->is_in_reserved(cur), "Should be in young gen");
aoqi@0 206 assert(Universe::heap()->is_in_reserved(obj_to_push), "Should be in heap");
aoqi@0 207 if (should_be_partially_scanned(obj_to_push, cur)) {
aoqi@0 208 assert(arrayOop(cur)->length() == 0, "entire array remaining to be scanned");
aoqi@0 209 obj_to_push = cur;
aoqi@0 210 }
aoqi@0 211 bool ok = queue->push(obj_to_push);
aoqi@0 212 assert(ok, "Should have succeeded");
aoqi@0 213 }
aoqi@0 214 assert(young_gen()->overflow_list() == NULL, "Error");
aoqi@0 215 return num_take_elems > 0; // was something transferred?
aoqi@0 216 }
aoqi@0 217
aoqi@0 218 void ParScanThreadState::push_on_overflow_stack(oop p) {
aoqi@0 219 assert(ParGCUseLocalOverflow, "Else should not call");
aoqi@0 220 overflow_stack()->push(p);
aoqi@0 221 assert(young_gen()->overflow_list() == NULL, "Error");
aoqi@0 222 }
aoqi@0 223
aoqi@0 224 HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) {
aoqi@0 225
aoqi@0 226 // Otherwise, if the object is small enough, try to reallocate the
aoqi@0 227 // buffer.
aoqi@0 228 HeapWord* obj = NULL;
aoqi@0 229 if (!_to_space_full) {
aoqi@0 230 ParGCAllocBuffer* const plab = to_space_alloc_buffer();
aoqi@0 231 Space* const sp = to_space();
aoqi@0 232 if (word_sz * 100 <
aoqi@0 233 ParallelGCBufferWastePct * plab->word_sz()) {
aoqi@0 234 // Is small enough; abandon this buffer and start a new one.
aoqi@0 235 plab->retire(false, false);
aoqi@0 236 size_t buf_size = plab->word_sz();
aoqi@0 237 HeapWord* buf_space = sp->par_allocate(buf_size);
aoqi@0 238 if (buf_space == NULL) {
aoqi@0 239 const size_t min_bytes =
aoqi@0 240 ParGCAllocBuffer::min_size() << LogHeapWordSize;
aoqi@0 241 size_t free_bytes = sp->free();
aoqi@0 242 while(buf_space == NULL && free_bytes >= min_bytes) {
aoqi@0 243 buf_size = free_bytes >> LogHeapWordSize;
aoqi@0 244 assert(buf_size == (size_t)align_object_size(buf_size),
aoqi@0 245 "Invariant");
aoqi@0 246 buf_space = sp->par_allocate(buf_size);
aoqi@0 247 free_bytes = sp->free();
aoqi@0 248 }
aoqi@0 249 }
aoqi@0 250 if (buf_space != NULL) {
aoqi@0 251 plab->set_word_size(buf_size);
aoqi@0 252 plab->set_buf(buf_space);
aoqi@0 253 record_survivor_plab(buf_space, buf_size);
aoqi@0 254 obj = plab->allocate(word_sz);
aoqi@0 255 // Note that we cannot compare buf_size < word_sz below
aoqi@0 256 // because of AlignmentReserve (see ParGCAllocBuffer::allocate()).
aoqi@0 257 assert(obj != NULL || plab->words_remaining() < word_sz,
aoqi@0 258 "Else should have been able to allocate");
aoqi@0 259 // It's conceivable that we may be able to use the
aoqi@0 260 // buffer we just grabbed for subsequent small requests
aoqi@0 261 // even if not for this one.
aoqi@0 262 } else {
aoqi@0 263 // We're used up.
aoqi@0 264 _to_space_full = true;
aoqi@0 265 }
aoqi@0 266
aoqi@0 267 } else {
aoqi@0 268 // Too large; allocate the object individually.
aoqi@0 269 obj = sp->par_allocate(word_sz);
aoqi@0 270 }
aoqi@0 271 }
aoqi@0 272 return obj;
aoqi@0 273 }
aoqi@0 274
aoqi@0 275
aoqi@0 276 void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj,
aoqi@0 277 size_t word_sz) {
aoqi@0 278 // Is the alloc in the current alloc buffer?
aoqi@0 279 if (to_space_alloc_buffer()->contains(obj)) {
aoqi@0 280 assert(to_space_alloc_buffer()->contains(obj + word_sz - 1),
aoqi@0 281 "Should contain whole object.");
aoqi@0 282 to_space_alloc_buffer()->undo_allocation(obj, word_sz);
aoqi@0 283 } else {
aoqi@0 284 CollectedHeap::fill_with_object(obj, word_sz);
aoqi@0 285 }
aoqi@0 286 }
aoqi@0 287
aoqi@0 288 void ParScanThreadState::print_promotion_failure_size() {
aoqi@0 289 if (_promotion_failed_info.has_failed() && PrintPromotionFailure) {
aoqi@0 290 gclog_or_tty->print(" (%d: promotion failure size = " SIZE_FORMAT ") ",
aoqi@0 291 _thread_num, _promotion_failed_info.first_size());
aoqi@0 292 }
aoqi@0 293 }
aoqi@0 294
aoqi@0 295 class ParScanThreadStateSet: private ResourceArray {
aoqi@0 296 public:
aoqi@0 297 // Initializes states for the specified number of threads;
aoqi@0 298 ParScanThreadStateSet(int num_threads,
aoqi@0 299 Space& to_space,
aoqi@0 300 ParNewGeneration& gen,
aoqi@0 301 Generation& old_gen,
aoqi@0 302 ObjToScanQueueSet& queue_set,
aoqi@0 303 Stack<oop, mtGC>* overflow_stacks_,
aoqi@0 304 size_t desired_plab_sz,
aoqi@0 305 ParallelTaskTerminator& term);
aoqi@0 306
aoqi@0 307 ~ParScanThreadStateSet() { TASKQUEUE_STATS_ONLY(reset_stats()); }
aoqi@0 308
aoqi@0 309 inline ParScanThreadState& thread_state(int i);
aoqi@0 310
aoqi@0 311 void trace_promotion_failed(YoungGCTracer& gc_tracer);
aoqi@0 312 void reset(int active_workers, bool promotion_failed);
aoqi@0 313 void flush();
aoqi@0 314
aoqi@0 315 #if TASKQUEUE_STATS
aoqi@0 316 static void
aoqi@0 317 print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
aoqi@0 318 void print_termination_stats(outputStream* const st = gclog_or_tty);
aoqi@0 319 static void
aoqi@0 320 print_taskqueue_stats_hdr(outputStream* const st = gclog_or_tty);
aoqi@0 321 void print_taskqueue_stats(outputStream* const st = gclog_or_tty);
aoqi@0 322 void reset_stats();
aoqi@0 323 #endif // TASKQUEUE_STATS
aoqi@0 324
aoqi@0 325 private:
aoqi@0 326 ParallelTaskTerminator& _term;
aoqi@0 327 ParNewGeneration& _gen;
aoqi@0 328 Generation& _next_gen;
aoqi@0 329 public:
aoqi@0 330 bool is_valid(int id) const { return id < length(); }
aoqi@0 331 ParallelTaskTerminator* terminator() { return &_term; }
aoqi@0 332 };
aoqi@0 333
aoqi@0 334
aoqi@0 335 ParScanThreadStateSet::ParScanThreadStateSet(
aoqi@0 336 int num_threads, Space& to_space, ParNewGeneration& gen,
aoqi@0 337 Generation& old_gen, ObjToScanQueueSet& queue_set,
aoqi@0 338 Stack<oop, mtGC>* overflow_stacks,
aoqi@0 339 size_t desired_plab_sz, ParallelTaskTerminator& term)
aoqi@0 340 : ResourceArray(sizeof(ParScanThreadState), num_threads),
aoqi@0 341 _gen(gen), _next_gen(old_gen), _term(term)
aoqi@0 342 {
aoqi@0 343 assert(num_threads > 0, "sanity check!");
aoqi@0 344 assert(ParGCUseLocalOverflow == (overflow_stacks != NULL),
aoqi@0 345 "overflow_stack allocation mismatch");
aoqi@0 346 // Initialize states.
aoqi@0 347 for (int i = 0; i < num_threads; ++i) {
aoqi@0 348 new ((ParScanThreadState*)_data + i)
aoqi@0 349 ParScanThreadState(&to_space, &gen, &old_gen, i, &queue_set,
aoqi@0 350 overflow_stacks, desired_plab_sz, term);
aoqi@0 351 }
aoqi@0 352 }
aoqi@0 353
aoqi@0 354 inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i)
aoqi@0 355 {
aoqi@0 356 assert(i >= 0 && i < length(), "sanity check!");
aoqi@0 357 return ((ParScanThreadState*)_data)[i];
aoqi@0 358 }
aoqi@0 359
aoqi@0 360 void ParScanThreadStateSet::trace_promotion_failed(YoungGCTracer& gc_tracer) {
aoqi@0 361 for (int i = 0; i < length(); ++i) {
aoqi@0 362 if (thread_state(i).promotion_failed()) {
aoqi@0 363 gc_tracer.report_promotion_failed(thread_state(i).promotion_failed_info());
aoqi@0 364 thread_state(i).promotion_failed_info().reset();
aoqi@0 365 }
aoqi@0 366 }
aoqi@0 367 }
aoqi@0 368
aoqi@0 369 void ParScanThreadStateSet::reset(int active_threads, bool promotion_failed)
aoqi@0 370 {
aoqi@0 371 _term.reset_for_reuse(active_threads);
aoqi@0 372 if (promotion_failed) {
aoqi@0 373 for (int i = 0; i < length(); ++i) {
aoqi@0 374 thread_state(i).print_promotion_failure_size();
aoqi@0 375 }
aoqi@0 376 }
aoqi@0 377 }
aoqi@0 378
aoqi@0 379 #if TASKQUEUE_STATS
aoqi@0 380 void
aoqi@0 381 ParScanThreadState::reset_stats()
aoqi@0 382 {
aoqi@0 383 taskqueue_stats().reset();
aoqi@0 384 _term_attempts = 0;
aoqi@0 385 _overflow_refills = 0;
aoqi@0 386 _overflow_refill_objs = 0;
aoqi@0 387 }
aoqi@0 388
aoqi@0 389 void ParScanThreadStateSet::reset_stats()
aoqi@0 390 {
aoqi@0 391 for (int i = 0; i < length(); ++i) {
aoqi@0 392 thread_state(i).reset_stats();
aoqi@0 393 }
aoqi@0 394 }
aoqi@0 395
aoqi@0 396 void
aoqi@0 397 ParScanThreadStateSet::print_termination_stats_hdr(outputStream* const st)
aoqi@0 398 {
aoqi@0 399 st->print_raw_cr("GC Termination Stats");
aoqi@0 400 st->print_raw_cr(" elapsed --strong roots-- "
aoqi@0 401 "-------termination-------");
aoqi@0 402 st->print_raw_cr("thr ms ms % "
aoqi@0 403 " ms % attempts");
aoqi@0 404 st->print_raw_cr("--- --------- --------- ------ "
aoqi@0 405 "--------- ------ --------");
aoqi@0 406 }
aoqi@0 407
aoqi@0 408 void ParScanThreadStateSet::print_termination_stats(outputStream* const st)
aoqi@0 409 {
aoqi@0 410 print_termination_stats_hdr(st);
aoqi@0 411
aoqi@0 412 for (int i = 0; i < length(); ++i) {
aoqi@0 413 const ParScanThreadState & pss = thread_state(i);
aoqi@0 414 const double elapsed_ms = pss.elapsed_time() * 1000.0;
aoqi@0 415 const double s_roots_ms = pss.strong_roots_time() * 1000.0;
aoqi@0 416 const double term_ms = pss.term_time() * 1000.0;
aoqi@0 417 st->print_cr("%3d %9.2f %9.2f %6.2f "
aoqi@0 418 "%9.2f %6.2f " SIZE_FORMAT_W(8),
aoqi@0 419 i, elapsed_ms, s_roots_ms, s_roots_ms * 100 / elapsed_ms,
aoqi@0 420 term_ms, term_ms * 100 / elapsed_ms, pss.term_attempts());
aoqi@0 421 }
aoqi@0 422 }
aoqi@0 423
aoqi@0 424 // Print stats related to work queue activity.
aoqi@0 425 void ParScanThreadStateSet::print_taskqueue_stats_hdr(outputStream* const st)
aoqi@0 426 {
aoqi@0 427 st->print_raw_cr("GC Task Stats");
aoqi@0 428 st->print_raw("thr "); TaskQueueStats::print_header(1, st); st->cr();
aoqi@0 429 st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr();
aoqi@0 430 }
aoqi@0 431
aoqi@0 432 void ParScanThreadStateSet::print_taskqueue_stats(outputStream* const st)
aoqi@0 433 {
aoqi@0 434 print_taskqueue_stats_hdr(st);
aoqi@0 435
aoqi@0 436 TaskQueueStats totals;
aoqi@0 437 for (int i = 0; i < length(); ++i) {
aoqi@0 438 const ParScanThreadState & pss = thread_state(i);
aoqi@0 439 const TaskQueueStats & stats = pss.taskqueue_stats();
aoqi@0 440 st->print("%3d ", i); stats.print(st); st->cr();
aoqi@0 441 totals += stats;
aoqi@0 442
aoqi@0 443 if (pss.overflow_refills() > 0) {
aoqi@0 444 st->print_cr(" " SIZE_FORMAT_W(10) " overflow refills "
aoqi@0 445 SIZE_FORMAT_W(10) " overflow objects",
aoqi@0 446 pss.overflow_refills(), pss.overflow_refill_objs());
aoqi@0 447 }
aoqi@0 448 }
aoqi@0 449 st->print("tot "); totals.print(st); st->cr();
aoqi@0 450
aoqi@0 451 DEBUG_ONLY(totals.verify());
aoqi@0 452 }
aoqi@0 453 #endif // TASKQUEUE_STATS
aoqi@0 454
aoqi@0 455 void ParScanThreadStateSet::flush()
aoqi@0 456 {
aoqi@0 457 // Work in this loop should be kept as lightweight as
aoqi@0 458 // possible since this might otherwise become a bottleneck
aoqi@0 459 // to scaling. Should we add heavy-weight work into this
aoqi@0 460 // loop, consider parallelizing the loop into the worker threads.
aoqi@0 461 for (int i = 0; i < length(); ++i) {
aoqi@0 462 ParScanThreadState& par_scan_state = thread_state(i);
aoqi@0 463
aoqi@0 464 // Flush stats related to To-space PLAB activity and
aoqi@0 465 // retire the last buffer.
aoqi@0 466 par_scan_state.to_space_alloc_buffer()->
aoqi@0 467 flush_stats_and_retire(_gen.plab_stats(),
aoqi@0 468 true /* end_of_gc */,
aoqi@0 469 false /* retain */);
aoqi@0 470
aoqi@0 471 // Every thread has its own age table. We need to merge
aoqi@0 472 // them all into one.
aoqi@0 473 ageTable *local_table = par_scan_state.age_table();
aoqi@0 474 _gen.age_table()->merge(local_table);
aoqi@0 475
aoqi@0 476 // Inform old gen that we're done.
aoqi@0 477 _next_gen.par_promote_alloc_done(i);
aoqi@0 478 _next_gen.par_oop_since_save_marks_iterate_done(i);
aoqi@0 479 }
aoqi@0 480
aoqi@0 481 if (UseConcMarkSweepGC && ParallelGCThreads > 0) {
aoqi@0 482 // We need to call this even when ResizeOldPLAB is disabled
aoqi@0 483 // so as to avoid breaking some asserts. While we may be able
aoqi@0 484 // to avoid this by reorganizing the code a bit, I am loathe
aoqi@0 485 // to do that unless we find cases where ergo leads to bad
aoqi@0 486 // performance.
aoqi@0 487 CFLS_LAB::compute_desired_plab_size();
aoqi@0 488 }
aoqi@0 489 }
aoqi@0 490
aoqi@0 491 ParScanClosure::ParScanClosure(ParNewGeneration* g,
aoqi@0 492 ParScanThreadState* par_scan_state) :
aoqi@0 493 OopsInKlassOrGenClosure(g), _par_scan_state(par_scan_state), _g(g)
aoqi@0 494 {
aoqi@0 495 assert(_g->level() == 0, "Optimized for youngest generation");
aoqi@0 496 _boundary = _g->reserved().end();
aoqi@0 497 }
aoqi@0 498
aoqi@0 499 void ParScanWithBarrierClosure::do_oop(oop* p) { ParScanClosure::do_oop_work(p, true, false); }
aoqi@0 500 void ParScanWithBarrierClosure::do_oop(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
aoqi@0 501
aoqi@0 502 void ParScanWithoutBarrierClosure::do_oop(oop* p) { ParScanClosure::do_oop_work(p, false, false); }
aoqi@0 503 void ParScanWithoutBarrierClosure::do_oop(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }
aoqi@0 504
aoqi@0 505 void ParRootScanWithBarrierTwoGensClosure::do_oop(oop* p) { ParScanClosure::do_oop_work(p, true, true); }
aoqi@0 506 void ParRootScanWithBarrierTwoGensClosure::do_oop(narrowOop* p) { ParScanClosure::do_oop_work(p, true, true); }
aoqi@0 507
aoqi@0 508 void ParRootScanWithoutBarrierClosure::do_oop(oop* p) { ParScanClosure::do_oop_work(p, false, true); }
aoqi@0 509 void ParRootScanWithoutBarrierClosure::do_oop(narrowOop* p) { ParScanClosure::do_oop_work(p, false, true); }
aoqi@0 510
aoqi@0 511 ParScanWeakRefClosure::ParScanWeakRefClosure(ParNewGeneration* g,
aoqi@0 512 ParScanThreadState* par_scan_state)
aoqi@0 513 : ScanWeakRefClosure(g), _par_scan_state(par_scan_state)
aoqi@0 514 {}
aoqi@0 515
aoqi@0 516 void ParScanWeakRefClosure::do_oop(oop* p) { ParScanWeakRefClosure::do_oop_work(p); }
aoqi@0 517 void ParScanWeakRefClosure::do_oop(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
aoqi@0 518
aoqi@0 519 #ifdef WIN32
aoqi@0 520 #pragma warning(disable: 4786) /* identifier was truncated to '255' characters in the browser information */
aoqi@0 521 #endif
aoqi@0 522
aoqi@0 523 ParEvacuateFollowersClosure::ParEvacuateFollowersClosure(
aoqi@0 524 ParScanThreadState* par_scan_state_,
aoqi@0 525 ParScanWithoutBarrierClosure* to_space_closure_,
aoqi@0 526 ParScanWithBarrierClosure* old_gen_closure_,
aoqi@0 527 ParRootScanWithoutBarrierClosure* to_space_root_closure_,
aoqi@0 528 ParNewGeneration* par_gen_,
aoqi@0 529 ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure_,
aoqi@0 530 ObjToScanQueueSet* task_queues_,
aoqi@0 531 ParallelTaskTerminator* terminator_) :
aoqi@0 532
aoqi@0 533 _par_scan_state(par_scan_state_),
aoqi@0 534 _to_space_closure(to_space_closure_),
aoqi@0 535 _old_gen_closure(old_gen_closure_),
aoqi@0 536 _to_space_root_closure(to_space_root_closure_),
aoqi@0 537 _old_gen_root_closure(old_gen_root_closure_),
aoqi@0 538 _par_gen(par_gen_),
aoqi@0 539 _task_queues(task_queues_),
aoqi@0 540 _terminator(terminator_)
aoqi@0 541 {}
aoqi@0 542
aoqi@0 543 void ParEvacuateFollowersClosure::do_void() {
aoqi@0 544 ObjToScanQueue* work_q = par_scan_state()->work_queue();
aoqi@0 545
aoqi@0 546 while (true) {
aoqi@0 547
aoqi@0 548 // Scan to-space and old-gen objs until we run out of both.
aoqi@0 549 oop obj_to_scan;
aoqi@0 550 par_scan_state()->trim_queues(0);
aoqi@0 551
aoqi@0 552 // We have no local work, attempt to steal from other threads.
aoqi@0 553
aoqi@0 554 // attempt to steal work from promoted.
aoqi@0 555 if (task_queues()->steal(par_scan_state()->thread_num(),
aoqi@0 556 par_scan_state()->hash_seed(),
aoqi@0 557 obj_to_scan)) {
aoqi@0 558 bool res = work_q->push(obj_to_scan);
aoqi@0 559 assert(res, "Empty queue should have room for a push.");
aoqi@0 560
aoqi@0 561 // if successful, goto Start.
aoqi@0 562 continue;
aoqi@0 563
aoqi@0 564 // try global overflow list.
aoqi@0 565 } else if (par_gen()->take_from_overflow_list(par_scan_state())) {
aoqi@0 566 continue;
aoqi@0 567 }
aoqi@0 568
aoqi@0 569 // Otherwise, offer termination.
aoqi@0 570 par_scan_state()->start_term_time();
aoqi@0 571 if (terminator()->offer_termination()) break;
aoqi@0 572 par_scan_state()->end_term_time();
aoqi@0 573 }
aoqi@0 574 assert(par_gen()->_overflow_list == NULL && par_gen()->_num_par_pushes == 0,
aoqi@0 575 "Broken overflow list?");
aoqi@0 576 // Finish the last termination pause.
aoqi@0 577 par_scan_state()->end_term_time();
aoqi@0 578 }
aoqi@0 579
aoqi@0 580 ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* next_gen,
aoqi@0 581 HeapWord* young_old_boundary, ParScanThreadStateSet* state_set) :
aoqi@0 582 AbstractGangTask("ParNewGeneration collection"),
aoqi@0 583 _gen(gen), _next_gen(next_gen),
aoqi@0 584 _young_old_boundary(young_old_boundary),
aoqi@0 585 _state_set(state_set)
aoqi@0 586 {}
aoqi@0 587
aoqi@0 588 // Reset the terminator for the given number of
aoqi@0 589 // active threads.
aoqi@0 590 void ParNewGenTask::set_for_termination(int active_workers) {
aoqi@0 591 _state_set->reset(active_workers, _gen->promotion_failed());
aoqi@0 592 // Should the heap be passed in? There's only 1 for now so
aoqi@0 593 // grab it instead.
aoqi@0 594 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 595 gch->set_n_termination(active_workers);
aoqi@0 596 }
aoqi@0 597
aoqi@0 598 void ParNewGenTask::work(uint worker_id) {
aoqi@0 599 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 600 // Since this is being done in a separate thread, need new resource
aoqi@0 601 // and handle marks.
aoqi@0 602 ResourceMark rm;
aoqi@0 603 HandleMark hm;
aoqi@0 604 // We would need multiple old-gen queues otherwise.
aoqi@0 605 assert(gch->n_gens() == 2, "Par young collection currently only works with one older gen.");
aoqi@0 606
aoqi@0 607 Generation* old_gen = gch->next_gen(_gen);
aoqi@0 608
aoqi@0 609 ParScanThreadState& par_scan_state = _state_set->thread_state(worker_id);
aoqi@0 610 assert(_state_set->is_valid(worker_id), "Should not have been called");
aoqi@0 611
aoqi@0 612 par_scan_state.set_young_old_boundary(_young_old_boundary);
aoqi@0 613
aoqi@0 614 KlassScanClosure klass_scan_closure(&par_scan_state.to_space_root_closure(),
aoqi@0 615 gch->rem_set()->klass_rem_set());
aoqi@0 616
aoqi@0 617 int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache;
aoqi@0 618
aoqi@0 619 par_scan_state.start_strong_roots();
aoqi@0 620 gch->gen_process_strong_roots(_gen->level(),
aoqi@0 621 true, // Process younger gens, if any,
aoqi@0 622 // as strong roots.
aoqi@0 623 false, // no scope; this is parallel code
aoqi@0 624 true, // is scavenging
aoqi@0 625 SharedHeap::ScanningOption(so),
aoqi@0 626 &par_scan_state.to_space_root_closure(),
aoqi@0 627 true, // walk *all* scavengable nmethods
aoqi@0 628 &par_scan_state.older_gen_closure(),
aoqi@0 629 &klass_scan_closure);
aoqi@0 630 par_scan_state.end_strong_roots();
aoqi@0 631
aoqi@0 632 // "evacuate followers".
aoqi@0 633 par_scan_state.evacuate_followers_closure().do_void();
aoqi@0 634 }
aoqi@0 635
aoqi@0 636 #ifdef _MSC_VER
aoqi@0 637 #pragma warning( push )
aoqi@0 638 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
aoqi@0 639 #endif
aoqi@0 640 ParNewGeneration::
aoqi@0 641 ParNewGeneration(ReservedSpace rs, size_t initial_byte_size, int level)
aoqi@0 642 : DefNewGeneration(rs, initial_byte_size, level, "PCopy"),
aoqi@0 643 _overflow_list(NULL),
aoqi@0 644 _is_alive_closure(this),
aoqi@0 645 _plab_stats(YoungPLABSize, PLABWeight)
aoqi@0 646 {
aoqi@0 647 NOT_PRODUCT(_overflow_counter = ParGCWorkQueueOverflowInterval;)
aoqi@0 648 NOT_PRODUCT(_num_par_pushes = 0;)
aoqi@0 649 _task_queues = new ObjToScanQueueSet(ParallelGCThreads);
aoqi@0 650 guarantee(_task_queues != NULL, "task_queues allocation failure.");
aoqi@0 651
aoqi@0 652 for (uint i1 = 0; i1 < ParallelGCThreads; i1++) {
aoqi@0 653 ObjToScanQueue *q = new ObjToScanQueue();
aoqi@0 654 guarantee(q != NULL, "work_queue Allocation failure.");
aoqi@0 655 _task_queues->register_queue(i1, q);
aoqi@0 656 }
aoqi@0 657
aoqi@0 658 for (uint i2 = 0; i2 < ParallelGCThreads; i2++)
aoqi@0 659 _task_queues->queue(i2)->initialize();
aoqi@0 660
aoqi@0 661 _overflow_stacks = NULL;
aoqi@0 662 if (ParGCUseLocalOverflow) {
aoqi@0 663
aoqi@0 664 // typedef to workaround NEW_C_HEAP_ARRAY macro, which can not deal
aoqi@0 665 // with ','
aoqi@0 666 typedef Stack<oop, mtGC> GCOopStack;
aoqi@0 667
aoqi@0 668 _overflow_stacks = NEW_C_HEAP_ARRAY(GCOopStack, ParallelGCThreads, mtGC);
aoqi@0 669 for (size_t i = 0; i < ParallelGCThreads; ++i) {
aoqi@0 670 new (_overflow_stacks + i) Stack<oop, mtGC>();
aoqi@0 671 }
aoqi@0 672 }
aoqi@0 673
aoqi@0 674 if (UsePerfData) {
aoqi@0 675 EXCEPTION_MARK;
aoqi@0 676 ResourceMark rm;
aoqi@0 677
aoqi@0 678 const char* cname =
aoqi@0 679 PerfDataManager::counter_name(_gen_counters->name_space(), "threads");
aoqi@0 680 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
aoqi@0 681 ParallelGCThreads, CHECK);
aoqi@0 682 }
aoqi@0 683 }
aoqi@0 684 #ifdef _MSC_VER
aoqi@0 685 #pragma warning( pop )
aoqi@0 686 #endif
aoqi@0 687
aoqi@0 688 // ParNewGeneration::
aoqi@0 689 ParKeepAliveClosure::ParKeepAliveClosure(ParScanWeakRefClosure* cl) :
aoqi@0 690 DefNewGeneration::KeepAliveClosure(cl), _par_cl(cl) {}
aoqi@0 691
aoqi@0 692 template <class T>
aoqi@0 693 void /*ParNewGeneration::*/ParKeepAliveClosure::do_oop_work(T* p) {
aoqi@0 694 #ifdef ASSERT
aoqi@0 695 {
aoqi@0 696 assert(!oopDesc::is_null(*p), "expected non-null ref");
aoqi@0 697 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
aoqi@0 698 // We never expect to see a null reference being processed
aoqi@0 699 // as a weak reference.
aoqi@0 700 assert(obj->is_oop(), "expected an oop while scanning weak refs");
aoqi@0 701 }
aoqi@0 702 #endif // ASSERT
aoqi@0 703
aoqi@0 704 _par_cl->do_oop_nv(p);
aoqi@0 705
aoqi@0 706 if (Universe::heap()->is_in_reserved(p)) {
aoqi@0 707 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
aoqi@0 708 _rs->write_ref_field_gc_par(p, obj);
aoqi@0 709 }
aoqi@0 710 }
aoqi@0 711
aoqi@0 712 void /*ParNewGeneration::*/ParKeepAliveClosure::do_oop(oop* p) { ParKeepAliveClosure::do_oop_work(p); }
aoqi@0 713 void /*ParNewGeneration::*/ParKeepAliveClosure::do_oop(narrowOop* p) { ParKeepAliveClosure::do_oop_work(p); }
aoqi@0 714
aoqi@0 715 // ParNewGeneration::
aoqi@0 716 KeepAliveClosure::KeepAliveClosure(ScanWeakRefClosure* cl) :
aoqi@0 717 DefNewGeneration::KeepAliveClosure(cl) {}
aoqi@0 718
aoqi@0 719 template <class T>
aoqi@0 720 void /*ParNewGeneration::*/KeepAliveClosure::do_oop_work(T* p) {
aoqi@0 721 #ifdef ASSERT
aoqi@0 722 {
aoqi@0 723 assert(!oopDesc::is_null(*p), "expected non-null ref");
aoqi@0 724 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
aoqi@0 725 // We never expect to see a null reference being processed
aoqi@0 726 // as a weak reference.
aoqi@0 727 assert(obj->is_oop(), "expected an oop while scanning weak refs");
aoqi@0 728 }
aoqi@0 729 #endif // ASSERT
aoqi@0 730
aoqi@0 731 _cl->do_oop_nv(p);
aoqi@0 732
aoqi@0 733 if (Universe::heap()->is_in_reserved(p)) {
aoqi@0 734 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
aoqi@0 735 _rs->write_ref_field_gc_par(p, obj);
aoqi@0 736 }
aoqi@0 737 }
aoqi@0 738
aoqi@0 739 void /*ParNewGeneration::*/KeepAliveClosure::do_oop(oop* p) { KeepAliveClosure::do_oop_work(p); }
aoqi@0 740 void /*ParNewGeneration::*/KeepAliveClosure::do_oop(narrowOop* p) { KeepAliveClosure::do_oop_work(p); }
aoqi@0 741
aoqi@0 742 template <class T> void ScanClosureWithParBarrier::do_oop_work(T* p) {
aoqi@0 743 T heap_oop = oopDesc::load_heap_oop(p);
aoqi@0 744 if (!oopDesc::is_null(heap_oop)) {
aoqi@0 745 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
aoqi@0 746 if ((HeapWord*)obj < _boundary) {
aoqi@0 747 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
aoqi@0 748 oop new_obj = obj->is_forwarded()
aoqi@0 749 ? obj->forwardee()
aoqi@0 750 : _g->DefNewGeneration::copy_to_survivor_space(obj);
aoqi@0 751 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
aoqi@0 752 }
aoqi@0 753 if (_gc_barrier) {
aoqi@0 754 // If p points to a younger generation, mark the card.
aoqi@0 755 if ((HeapWord*)obj < _gen_boundary) {
aoqi@0 756 _rs->write_ref_field_gc_par(p, obj);
aoqi@0 757 }
aoqi@0 758 }
aoqi@0 759 }
aoqi@0 760 }
aoqi@0 761
aoqi@0 762 void ScanClosureWithParBarrier::do_oop(oop* p) { ScanClosureWithParBarrier::do_oop_work(p); }
aoqi@0 763 void ScanClosureWithParBarrier::do_oop(narrowOop* p) { ScanClosureWithParBarrier::do_oop_work(p); }
aoqi@0 764
aoqi@0 765 class ParNewRefProcTaskProxy: public AbstractGangTask {
aoqi@0 766 typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
aoqi@0 767 public:
aoqi@0 768 ParNewRefProcTaskProxy(ProcessTask& task, ParNewGeneration& gen,
aoqi@0 769 Generation& next_gen,
aoqi@0 770 HeapWord* young_old_boundary,
aoqi@0 771 ParScanThreadStateSet& state_set);
aoqi@0 772
aoqi@0 773 private:
aoqi@0 774 virtual void work(uint worker_id);
aoqi@0 775 virtual void set_for_termination(int active_workers) {
aoqi@0 776 _state_set.terminator()->reset_for_reuse(active_workers);
aoqi@0 777 }
aoqi@0 778 private:
aoqi@0 779 ParNewGeneration& _gen;
aoqi@0 780 ProcessTask& _task;
aoqi@0 781 Generation& _next_gen;
aoqi@0 782 HeapWord* _young_old_boundary;
aoqi@0 783 ParScanThreadStateSet& _state_set;
aoqi@0 784 };
aoqi@0 785
aoqi@0 786 ParNewRefProcTaskProxy::ParNewRefProcTaskProxy(
aoqi@0 787 ProcessTask& task, ParNewGeneration& gen,
aoqi@0 788 Generation& next_gen,
aoqi@0 789 HeapWord* young_old_boundary,
aoqi@0 790 ParScanThreadStateSet& state_set)
aoqi@0 791 : AbstractGangTask("ParNewGeneration parallel reference processing"),
aoqi@0 792 _gen(gen),
aoqi@0 793 _task(task),
aoqi@0 794 _next_gen(next_gen),
aoqi@0 795 _young_old_boundary(young_old_boundary),
aoqi@0 796 _state_set(state_set)
aoqi@0 797 {
aoqi@0 798 }
aoqi@0 799
aoqi@0 800 void ParNewRefProcTaskProxy::work(uint worker_id)
aoqi@0 801 {
aoqi@0 802 ResourceMark rm;
aoqi@0 803 HandleMark hm;
aoqi@0 804 ParScanThreadState& par_scan_state = _state_set.thread_state(worker_id);
aoqi@0 805 par_scan_state.set_young_old_boundary(_young_old_boundary);
aoqi@0 806 _task.work(worker_id, par_scan_state.is_alive_closure(),
aoqi@0 807 par_scan_state.keep_alive_closure(),
aoqi@0 808 par_scan_state.evacuate_followers_closure());
aoqi@0 809 }
aoqi@0 810
aoqi@0 811 class ParNewRefEnqueueTaskProxy: public AbstractGangTask {
aoqi@0 812 typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
aoqi@0 813 EnqueueTask& _task;
aoqi@0 814
aoqi@0 815 public:
aoqi@0 816 ParNewRefEnqueueTaskProxy(EnqueueTask& task)
aoqi@0 817 : AbstractGangTask("ParNewGeneration parallel reference enqueue"),
aoqi@0 818 _task(task)
aoqi@0 819 { }
aoqi@0 820
aoqi@0 821 virtual void work(uint worker_id)
aoqi@0 822 {
aoqi@0 823 _task.work(worker_id);
aoqi@0 824 }
aoqi@0 825 };
aoqi@0 826
aoqi@0 827
aoqi@0 828 void ParNewRefProcTaskExecutor::execute(ProcessTask& task)
aoqi@0 829 {
aoqi@0 830 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 831 assert(gch->kind() == CollectedHeap::GenCollectedHeap,
aoqi@0 832 "not a generational heap");
aoqi@0 833 FlexibleWorkGang* workers = gch->workers();
aoqi@0 834 assert(workers != NULL, "Need parallel worker threads.");
aoqi@0 835 _state_set.reset(workers->active_workers(), _generation.promotion_failed());
aoqi@0 836 ParNewRefProcTaskProxy rp_task(task, _generation, *_generation.next_gen(),
aoqi@0 837 _generation.reserved().end(), _state_set);
aoqi@0 838 workers->run_task(&rp_task);
aoqi@0 839 _state_set.reset(0 /* bad value in debug if not reset */,
aoqi@0 840 _generation.promotion_failed());
aoqi@0 841 }
aoqi@0 842
aoqi@0 843 void ParNewRefProcTaskExecutor::execute(EnqueueTask& task)
aoqi@0 844 {
aoqi@0 845 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 846 FlexibleWorkGang* workers = gch->workers();
aoqi@0 847 assert(workers != NULL, "Need parallel worker threads.");
aoqi@0 848 ParNewRefEnqueueTaskProxy enq_task(task);
aoqi@0 849 workers->run_task(&enq_task);
aoqi@0 850 }
aoqi@0 851
aoqi@0 852 void ParNewRefProcTaskExecutor::set_single_threaded_mode()
aoqi@0 853 {
aoqi@0 854 _state_set.flush();
aoqi@0 855 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 856 gch->set_par_threads(0); // 0 ==> non-parallel.
aoqi@0 857 gch->save_marks();
aoqi@0 858 }
aoqi@0 859
aoqi@0 860 ScanClosureWithParBarrier::
aoqi@0 861 ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier) :
aoqi@0 862 ScanClosure(g, gc_barrier) {}
aoqi@0 863
aoqi@0 864 EvacuateFollowersClosureGeneral::
aoqi@0 865 EvacuateFollowersClosureGeneral(GenCollectedHeap* gch, int level,
aoqi@0 866 OopsInGenClosure* cur,
aoqi@0 867 OopsInGenClosure* older) :
aoqi@0 868 _gch(gch), _level(level),
aoqi@0 869 _scan_cur_or_nonheap(cur), _scan_older(older)
aoqi@0 870 {}
aoqi@0 871
aoqi@0 872 void EvacuateFollowersClosureGeneral::do_void() {
aoqi@0 873 do {
aoqi@0 874 // Beware: this call will lead to closure applications via virtual
aoqi@0 875 // calls.
aoqi@0 876 _gch->oop_since_save_marks_iterate(_level,
aoqi@0 877 _scan_cur_or_nonheap,
aoqi@0 878 _scan_older);
aoqi@0 879 } while (!_gch->no_allocs_since_save_marks(_level));
aoqi@0 880 }
aoqi@0 881
aoqi@0 882
aoqi@0 883 // A Generation that does parallel young-gen collection.
aoqi@0 884
aoqi@0 885 bool ParNewGeneration::_avoid_promotion_undo = false;
aoqi@0 886
aoqi@0 887 void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) {
aoqi@0 888 assert(_promo_failure_scan_stack.is_empty(), "post condition");
aoqi@0 889 _promo_failure_scan_stack.clear(true); // Clear cached segments.
aoqi@0 890
aoqi@0 891 remove_forwarding_pointers();
aoqi@0 892 if (PrintGCDetails) {
aoqi@0 893 gclog_or_tty->print(" (promotion failed)");
aoqi@0 894 }
aoqi@0 895 // All the spaces are in play for mark-sweep.
aoqi@0 896 swap_spaces(); // Make life simpler for CMS || rescan; see 6483690.
aoqi@0 897 from()->set_next_compaction_space(to());
aoqi@0 898 gch->set_incremental_collection_failed();
aoqi@0 899 // Inform the next generation that a promotion failure occurred.
aoqi@0 900 _next_gen->promotion_failure_occurred();
aoqi@0 901
aoqi@0 902 // Trace promotion failure in the parallel GC threads
aoqi@0 903 thread_state_set.trace_promotion_failed(gc_tracer);
aoqi@0 904 // Single threaded code may have reported promotion failure to the global state
aoqi@0 905 if (_promotion_failed_info.has_failed()) {
aoqi@0 906 gc_tracer.report_promotion_failed(_promotion_failed_info);
aoqi@0 907 }
aoqi@0 908 // Reset the PromotionFailureALot counters.
aoqi@0 909 NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
aoqi@0 910 }
aoqi@0 911
aoqi@0 912 void ParNewGeneration::collect(bool full,
aoqi@0 913 bool clear_all_soft_refs,
aoqi@0 914 size_t size,
aoqi@0 915 bool is_tlab) {
aoqi@0 916 assert(full || size > 0, "otherwise we don't want to collect");
aoqi@0 917
aoqi@0 918 GenCollectedHeap* gch = GenCollectedHeap::heap();
aoqi@0 919
aoqi@0 920 _gc_timer->register_gc_start();
aoqi@0 921
aoqi@0 922 assert(gch->kind() == CollectedHeap::GenCollectedHeap,
aoqi@0 923 "not a CMS generational heap");
aoqi@0 924 AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy();
aoqi@0 925 FlexibleWorkGang* workers = gch->workers();
aoqi@0 926 assert(workers != NULL, "Need workgang for parallel work");
aoqi@0 927 int active_workers =
aoqi@0 928 AdaptiveSizePolicy::calc_active_workers(workers->total_workers(),
aoqi@0 929 workers->active_workers(),
aoqi@0 930 Threads::number_of_non_daemon_threads());
aoqi@0 931 workers->set_active_workers(active_workers);
aoqi@0 932 assert(gch->n_gens() == 2,
aoqi@0 933 "Par collection currently only works with single older gen.");
aoqi@0 934 _next_gen = gch->next_gen(this);
aoqi@0 935 // Do we have to avoid promotion_undo?
aoqi@0 936 if (gch->collector_policy()->is_concurrent_mark_sweep_policy()) {
aoqi@0 937 set_avoid_promotion_undo(true);
aoqi@0 938 }
aoqi@0 939
aoqi@0 940 // If the next generation is too full to accommodate worst-case promotion
aoqi@0 941 // from this generation, pass on collection; let the next generation
aoqi@0 942 // do it.
aoqi@0 943 if (!collection_attempt_is_safe()) {
aoqi@0 944 gch->set_incremental_collection_failed(); // slight lie, in that we did not even attempt one
aoqi@0 945 return;
aoqi@0 946 }
aoqi@0 947 assert(to()->is_empty(), "Else not collection_attempt_is_safe");
aoqi@0 948
aoqi@0 949 ParNewTracer gc_tracer;
aoqi@0 950 gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
aoqi@0 951 gch->trace_heap_before_gc(&gc_tracer);
aoqi@0 952
aoqi@0 953 init_assuming_no_promotion_failure();
aoqi@0 954
aoqi@0 955 if (UseAdaptiveSizePolicy) {
aoqi@0 956 set_survivor_overflow(false);
aoqi@0 957 size_policy->minor_collection_begin();
aoqi@0 958 }
aoqi@0 959
aoqi@0 960 GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL);
aoqi@0 961 // Capture heap used before collection (for printing).
aoqi@0 962 size_t gch_prev_used = gch->used();
aoqi@0 963
aoqi@0 964 SpecializationStats::clear();
aoqi@0 965
aoqi@0 966 age_table()->clear();
aoqi@0 967 to()->clear(SpaceDecorator::Mangle);
aoqi@0 968
aoqi@0 969 gch->save_marks();
aoqi@0 970 assert(workers != NULL, "Need parallel worker threads.");
aoqi@0 971 int n_workers = active_workers;
aoqi@0 972
aoqi@0 973 // Set the correct parallelism (number of queues) in the reference processor
aoqi@0 974 ref_processor()->set_active_mt_degree(n_workers);
aoqi@0 975
aoqi@0 976 // Always set the terminator for the active number of workers
aoqi@0 977 // because only those workers go through the termination protocol.
aoqi@0 978 ParallelTaskTerminator _term(n_workers, task_queues());
aoqi@0 979 ParScanThreadStateSet thread_state_set(workers->active_workers(),
aoqi@0 980 *to(), *this, *_next_gen, *task_queues(),
aoqi@0 981 _overflow_stacks, desired_plab_sz(), _term);
aoqi@0 982
aoqi@0 983 ParNewGenTask tsk(this, _next_gen, reserved().end(), &thread_state_set);
aoqi@0 984 gch->set_par_threads(n_workers);
aoqi@0 985 gch->rem_set()->prepare_for_younger_refs_iterate(true);
aoqi@0 986 // It turns out that even when we're using 1 thread, doing the work in a
aoqi@0 987 // separate thread causes wide variance in run times. We can't help this
aoqi@0 988 // in the multi-threaded case, but we special-case n=1 here to get
aoqi@0 989 // repeatable measurements of the 1-thread overhead of the parallel code.
aoqi@0 990 if (n_workers > 1) {
aoqi@0 991 GenCollectedHeap::StrongRootsScope srs(gch);
aoqi@0 992 workers->run_task(&tsk);
aoqi@0 993 } else {
aoqi@0 994 GenCollectedHeap::StrongRootsScope srs(gch);
aoqi@0 995 tsk.work(0);
aoqi@0 996 }
aoqi@0 997 thread_state_set.reset(0 /* Bad value in debug if not reset */,
aoqi@0 998 promotion_failed());
aoqi@0 999
aoqi@0 1000 // Process (weak) reference objects found during scavenge.
aoqi@0 1001 ReferenceProcessor* rp = ref_processor();
aoqi@0 1002 IsAliveClosure is_alive(this);
aoqi@0 1003 ScanWeakRefClosure scan_weak_ref(this);
aoqi@0 1004 KeepAliveClosure keep_alive(&scan_weak_ref);
aoqi@0 1005 ScanClosure scan_without_gc_barrier(this, false);
aoqi@0 1006 ScanClosureWithParBarrier scan_with_gc_barrier(this, true);
aoqi@0 1007 set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
aoqi@0 1008 EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
aoqi@0 1009 &scan_without_gc_barrier, &scan_with_gc_barrier);
aoqi@0 1010 rp->setup_policy(clear_all_soft_refs);
aoqi@0 1011 // Can the mt_degree be set later (at run_task() time would be best)?
aoqi@0 1012 rp->set_active_mt_degree(active_workers);
aoqi@0 1013 ReferenceProcessorStats stats;
aoqi@0 1014 if (rp->processing_is_mt()) {
aoqi@0 1015 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
aoqi@0 1016 stats = rp->process_discovered_references(&is_alive, &keep_alive,
aoqi@0 1017 &evacuate_followers, &task_executor,
aoqi@0 1018 _gc_timer);
aoqi@0 1019 } else {
aoqi@0 1020 thread_state_set.flush();
aoqi@0 1021 gch->set_par_threads(0); // 0 ==> non-parallel.
aoqi@0 1022 gch->save_marks();
aoqi@0 1023 stats = rp->process_discovered_references(&is_alive, &keep_alive,
aoqi@0 1024 &evacuate_followers, NULL,
aoqi@0 1025 _gc_timer);
aoqi@0 1026 }
aoqi@0 1027 gc_tracer.report_gc_reference_stats(stats);
aoqi@0 1028 if (!promotion_failed()) {
aoqi@0 1029 // Swap the survivor spaces.
aoqi@0 1030 eden()->clear(SpaceDecorator::Mangle);
aoqi@0 1031 from()->clear(SpaceDecorator::Mangle);
aoqi@0 1032 if (ZapUnusedHeapArea) {
aoqi@0 1033 // This is now done here because of the piece-meal mangling which
aoqi@0 1034 // can check for valid mangling at intermediate points in the
aoqi@0 1035 // collection(s). When a minor collection fails to collect
aoqi@0 1036 // sufficient space resizing of the young generation can occur
aoqi@0 1037 // an redistribute the spaces in the young generation. Mangle
aoqi@0 1038 // here so that unzapped regions don't get distributed to
aoqi@0 1039 // other spaces.
aoqi@0 1040 to()->mangle_unused_area();
aoqi@0 1041 }
aoqi@0 1042 swap_spaces();
aoqi@0 1043
aoqi@0 1044 // A successful scavenge should restart the GC time limit count which is
aoqi@0 1045 // for full GC's.
aoqi@0 1046 size_policy->reset_gc_overhead_limit_count();
aoqi@0 1047
aoqi@0 1048 assert(to()->is_empty(), "to space should be empty now");
aoqi@0 1049
aoqi@0 1050 adjust_desired_tenuring_threshold();
aoqi@0 1051 } else {
aoqi@0 1052 handle_promotion_failed(gch, thread_state_set, gc_tracer);
aoqi@0 1053 }
aoqi@0 1054 // set new iteration safe limit for the survivor spaces
aoqi@0 1055 from()->set_concurrent_iteration_safe_limit(from()->top());
aoqi@0 1056 to()->set_concurrent_iteration_safe_limit(to()->top());
aoqi@0 1057
aoqi@0 1058 if (ResizePLAB) {
aoqi@0 1059 plab_stats()->adjust_desired_plab_sz(n_workers);
aoqi@0 1060 }
aoqi@0 1061
aoqi@0 1062 if (PrintGC && !PrintGCDetails) {
aoqi@0 1063 gch->print_heap_change(gch_prev_used);
aoqi@0 1064 }
aoqi@0 1065
aoqi@0 1066 if (PrintGCDetails && ParallelGCVerbose) {
aoqi@0 1067 TASKQUEUE_STATS_ONLY(thread_state_set.print_termination_stats());
aoqi@0 1068 TASKQUEUE_STATS_ONLY(thread_state_set.print_taskqueue_stats());
aoqi@0 1069 }
aoqi@0 1070
aoqi@0 1071 if (UseAdaptiveSizePolicy) {
aoqi@0 1072 size_policy->minor_collection_end(gch->gc_cause());
aoqi@0 1073 size_policy->avg_survived()->sample(from()->used());
aoqi@0 1074 }
aoqi@0 1075
aoqi@0 1076 // We need to use a monotonically non-deccreasing time in ms
aoqi@0 1077 // or we will see time-warp warnings and os::javaTimeMillis()
aoqi@0 1078 // does not guarantee monotonicity.
aoqi@0 1079 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
aoqi@0 1080 update_time_of_last_gc(now);
aoqi@0 1081
aoqi@0 1082 SpecializationStats::print();
aoqi@0 1083
aoqi@0 1084 rp->set_enqueuing_is_done(true);
aoqi@0 1085 if (rp->processing_is_mt()) {
aoqi@0 1086 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
aoqi@0 1087 rp->enqueue_discovered_references(&task_executor);
aoqi@0 1088 } else {
aoqi@0 1089 rp->enqueue_discovered_references(NULL);
aoqi@0 1090 }
aoqi@0 1091 rp->verify_no_references_recorded();
aoqi@0 1092
aoqi@0 1093 gch->trace_heap_after_gc(&gc_tracer);
aoqi@0 1094 gc_tracer.report_tenuring_threshold(tenuring_threshold());
aoqi@0 1095
aoqi@0 1096 _gc_timer->register_gc_end();
aoqi@0 1097
aoqi@0 1098 gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
aoqi@0 1099 }
aoqi@0 1100
aoqi@0 1101 static int sum;
aoqi@0 1102 void ParNewGeneration::waste_some_time() {
aoqi@0 1103 for (int i = 0; i < 100; i++) {
aoqi@0 1104 sum += i;
aoqi@0 1105 }
aoqi@0 1106 }
aoqi@0 1107
aoqi@0 1108 static const oop ClaimedForwardPtr = cast_to_oop<intptr_t>(0x4);
aoqi@0 1109
aoqi@0 1110 // Because of concurrency, there are times where an object for which
aoqi@0 1111 // "is_forwarded()" is true contains an "interim" forwarding pointer
aoqi@0 1112 // value. Such a value will soon be overwritten with a real value.
aoqi@0 1113 // This method requires "obj" to have a forwarding pointer, and waits, if
aoqi@0 1114 // necessary for a real one to be inserted, and returns it.
aoqi@0 1115
aoqi@0 1116 oop ParNewGeneration::real_forwardee(oop obj) {
aoqi@0 1117 oop forward_ptr = obj->forwardee();
aoqi@0 1118 if (forward_ptr != ClaimedForwardPtr) {
aoqi@0 1119 return forward_ptr;
aoqi@0 1120 } else {
aoqi@0 1121 return real_forwardee_slow(obj);
aoqi@0 1122 }
aoqi@0 1123 }
aoqi@0 1124
aoqi@0 1125 oop ParNewGeneration::real_forwardee_slow(oop obj) {
aoqi@0 1126 // Spin-read if it is claimed but not yet written by another thread.
aoqi@0 1127 oop forward_ptr = obj->forwardee();
aoqi@0 1128 while (forward_ptr == ClaimedForwardPtr) {
aoqi@0 1129 waste_some_time();
aoqi@0 1130 assert(obj->is_forwarded(), "precondition");
aoqi@0 1131 forward_ptr = obj->forwardee();
aoqi@0 1132 }
aoqi@0 1133 return forward_ptr;
aoqi@0 1134 }
aoqi@0 1135
aoqi@0 1136 #ifdef ASSERT
aoqi@0 1137 bool ParNewGeneration::is_legal_forward_ptr(oop p) {
aoqi@0 1138 return
aoqi@0 1139 (_avoid_promotion_undo && p == ClaimedForwardPtr)
aoqi@0 1140 || Universe::heap()->is_in_reserved(p);
aoqi@0 1141 }
aoqi@0 1142 #endif
aoqi@0 1143
aoqi@0 1144 void ParNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) {
aoqi@0 1145 if (m->must_be_preserved_for_promotion_failure(obj)) {
aoqi@0 1146 // We should really have separate per-worker stacks, rather
aoqi@0 1147 // than use locking of a common pair of stacks.
aoqi@0 1148 MutexLocker ml(ParGCRareEvent_lock);
aoqi@0 1149 preserve_mark(obj, m);
aoqi@0 1150 }
aoqi@0 1151 }
aoqi@0 1152
aoqi@0 1153 // Multiple GC threads may try to promote an object. If the object
aoqi@0 1154 // is successfully promoted, a forwarding pointer will be installed in
aoqi@0 1155 // the object in the young generation. This method claims the right
aoqi@0 1156 // to install the forwarding pointer before it copies the object,
aoqi@0 1157 // thus avoiding the need to undo the copy as in
aoqi@0 1158 // copy_to_survivor_space_avoiding_with_undo.
aoqi@0 1159
aoqi@0 1160 oop ParNewGeneration::copy_to_survivor_space_avoiding_promotion_undo(
aoqi@0 1161 ParScanThreadState* par_scan_state, oop old, size_t sz, markOop m) {
aoqi@0 1162 // In the sequential version, this assert also says that the object is
aoqi@0 1163 // not forwarded. That might not be the case here. It is the case that
aoqi@0 1164 // the caller observed it to be not forwarded at some time in the past.
aoqi@0 1165 assert(is_in_reserved(old), "shouldn't be scavenging this oop");
aoqi@0 1166
aoqi@0 1167 // The sequential code read "old->age()" below. That doesn't work here,
aoqi@0 1168 // since the age is in the mark word, and that might be overwritten with
aoqi@0 1169 // a forwarding pointer by a parallel thread. So we must save the mark
aoqi@0 1170 // word in a local and then analyze it.
aoqi@0 1171 oopDesc dummyOld;
aoqi@0 1172 dummyOld.set_mark(m);
aoqi@0 1173 assert(!dummyOld.is_forwarded(),
aoqi@0 1174 "should not be called with forwarding pointer mark word.");
aoqi@0 1175
aoqi@0 1176 oop new_obj = NULL;
aoqi@0 1177 oop forward_ptr;
aoqi@0 1178
aoqi@0 1179 // Try allocating obj in to-space (unless too old)
aoqi@0 1180 if (dummyOld.age() < tenuring_threshold()) {
aoqi@0 1181 new_obj = (oop)par_scan_state->alloc_in_to_space(sz);
aoqi@0 1182 if (new_obj == NULL) {
aoqi@0 1183 set_survivor_overflow(true);
aoqi@0 1184 }
aoqi@0 1185 }
aoqi@0 1186
aoqi@0 1187 if (new_obj == NULL) {
aoqi@0 1188 // Either to-space is full or we decided to promote
aoqi@0 1189 // try allocating obj tenured
aoqi@0 1190
aoqi@0 1191 // Attempt to install a null forwarding pointer (atomically),
aoqi@0 1192 // to claim the right to install the real forwarding pointer.
aoqi@0 1193 forward_ptr = old->forward_to_atomic(ClaimedForwardPtr);
aoqi@0 1194 if (forward_ptr != NULL) {
aoqi@0 1195 // someone else beat us to it.
aoqi@0 1196 return real_forwardee(old);
aoqi@0 1197 }
aoqi@0 1198
aoqi@0 1199 new_obj = _next_gen->par_promote(par_scan_state->thread_num(),
aoqi@0 1200 old, m, sz);
aoqi@0 1201
aoqi@0 1202 if (new_obj == NULL) {
aoqi@0 1203 // promotion failed, forward to self
aoqi@0 1204 _promotion_failed = true;
aoqi@0 1205 new_obj = old;
aoqi@0 1206
aoqi@0 1207 preserve_mark_if_necessary(old, m);
aoqi@0 1208 par_scan_state->register_promotion_failure(sz);
aoqi@0 1209 }
aoqi@0 1210
aoqi@0 1211 old->forward_to(new_obj);
aoqi@0 1212 forward_ptr = NULL;
aoqi@0 1213 } else {
aoqi@0 1214 // Is in to-space; do copying ourselves.
aoqi@0 1215 Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz);
aoqi@0 1216 forward_ptr = old->forward_to_atomic(new_obj);
aoqi@0 1217 // Restore the mark word copied above.
aoqi@0 1218 new_obj->set_mark(m);
aoqi@0 1219 // Increment age if obj still in new generation
aoqi@0 1220 new_obj->incr_age();
aoqi@0 1221 par_scan_state->age_table()->add(new_obj, sz);
aoqi@0 1222 }
aoqi@0 1223 assert(new_obj != NULL, "just checking");
aoqi@0 1224
aoqi@0 1225 #ifndef PRODUCT
aoqi@0 1226 // This code must come after the CAS test, or it will print incorrect
aoqi@0 1227 // information.
aoqi@0 1228 if (TraceScavenge) {
aoqi@0 1229 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
aoqi@0 1230 is_in_reserved(new_obj) ? "copying" : "tenuring",
aoqi@0 1231 new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size());
aoqi@0 1232 }
aoqi@0 1233 #endif
aoqi@0 1234
aoqi@0 1235 if (forward_ptr == NULL) {
aoqi@0 1236 oop obj_to_push = new_obj;
aoqi@0 1237 if (par_scan_state->should_be_partially_scanned(obj_to_push, old)) {
aoqi@0 1238 // Length field used as index of next element to be scanned.
aoqi@0 1239 // Real length can be obtained from real_forwardee()
aoqi@0 1240 arrayOop(old)->set_length(0);
aoqi@0 1241 obj_to_push = old;
aoqi@0 1242 assert(obj_to_push->is_forwarded() && obj_to_push->forwardee() != obj_to_push,
aoqi@0 1243 "push forwarded object");
aoqi@0 1244 }
aoqi@0 1245 // Push it on one of the queues of to-be-scanned objects.
aoqi@0 1246 bool simulate_overflow = false;
aoqi@0 1247 NOT_PRODUCT(
aoqi@0 1248 if (ParGCWorkQueueOverflowALot && should_simulate_overflow()) {
aoqi@0 1249 // simulate a stack overflow
aoqi@0 1250 simulate_overflow = true;
aoqi@0 1251 }
aoqi@0 1252 )
aoqi@0 1253 if (simulate_overflow || !par_scan_state->work_queue()->push(obj_to_push)) {
aoqi@0 1254 // Add stats for overflow pushes.
aoqi@0 1255 if (Verbose && PrintGCDetails) {
aoqi@0 1256 gclog_or_tty->print("queue overflow!\n");
aoqi@0 1257 }
aoqi@0 1258 push_on_overflow_list(old, par_scan_state);
aoqi@0 1259 TASKQUEUE_STATS_ONLY(par_scan_state->taskqueue_stats().record_overflow(0));
aoqi@0 1260 }
aoqi@0 1261
aoqi@0 1262 return new_obj;
aoqi@0 1263 }
aoqi@0 1264
aoqi@0 1265 // Oops. Someone beat us to it. Undo the allocation. Where did we
aoqi@0 1266 // allocate it?
aoqi@0 1267 if (is_in_reserved(new_obj)) {
aoqi@0 1268 // Must be in to_space.
aoqi@0 1269 assert(to()->is_in_reserved(new_obj), "Checking");
aoqi@0 1270 if (forward_ptr == ClaimedForwardPtr) {
aoqi@0 1271 // Wait to get the real forwarding pointer value.
aoqi@0 1272 forward_ptr = real_forwardee(old);
aoqi@0 1273 }
aoqi@0 1274 par_scan_state->undo_alloc_in_to_space((HeapWord*)new_obj, sz);
aoqi@0 1275 }
aoqi@0 1276
aoqi@0 1277 return forward_ptr;
aoqi@0 1278 }
aoqi@0 1279
aoqi@0 1280
aoqi@0 1281 // Multiple GC threads may try to promote the same object. If two
aoqi@0 1282 // or more GC threads copy the object, only one wins the race to install
aoqi@0 1283 // the forwarding pointer. The other threads have to undo their copy.
aoqi@0 1284
aoqi@0 1285 oop ParNewGeneration::copy_to_survivor_space_with_undo(
aoqi@0 1286 ParScanThreadState* par_scan_state, oop old, size_t sz, markOop m) {
aoqi@0 1287
aoqi@0 1288 // In the sequential version, this assert also says that the object is
aoqi@0 1289 // not forwarded. That might not be the case here. It is the case that
aoqi@0 1290 // the caller observed it to be not forwarded at some time in the past.
aoqi@0 1291 assert(is_in_reserved(old), "shouldn't be scavenging this oop");
aoqi@0 1292
aoqi@0 1293 // The sequential code read "old->age()" below. That doesn't work here,
aoqi@0 1294 // since the age is in the mark word, and that might be overwritten with
aoqi@0 1295 // a forwarding pointer by a parallel thread. So we must save the mark
aoqi@0 1296 // word here, install it in a local oopDesc, and then analyze it.
aoqi@0 1297 oopDesc dummyOld;
aoqi@0 1298 dummyOld.set_mark(m);
aoqi@0 1299 assert(!dummyOld.is_forwarded(),
aoqi@0 1300 "should not be called with forwarding pointer mark word.");
aoqi@0 1301
aoqi@0 1302 bool failed_to_promote = false;
aoqi@0 1303 oop new_obj = NULL;
aoqi@0 1304 oop forward_ptr;
aoqi@0 1305
aoqi@0 1306 // Try allocating obj in to-space (unless too old)
aoqi@0 1307 if (dummyOld.age() < tenuring_threshold()) {
aoqi@0 1308 new_obj = (oop)par_scan_state->alloc_in_to_space(sz);
aoqi@0 1309 if (new_obj == NULL) {
aoqi@0 1310 set_survivor_overflow(true);
aoqi@0 1311 }
aoqi@0 1312 }
aoqi@0 1313
aoqi@0 1314 if (new_obj == NULL) {
aoqi@0 1315 // Either to-space is full or we decided to promote
aoqi@0 1316 // try allocating obj tenured
aoqi@0 1317 new_obj = _next_gen->par_promote(par_scan_state->thread_num(),
aoqi@0 1318 old, m, sz);
aoqi@0 1319
aoqi@0 1320 if (new_obj == NULL) {
aoqi@0 1321 // promotion failed, forward to self
aoqi@0 1322 forward_ptr = old->forward_to_atomic(old);
aoqi@0 1323 new_obj = old;
aoqi@0 1324
aoqi@0 1325 if (forward_ptr != NULL) {
aoqi@0 1326 return forward_ptr; // someone else succeeded
aoqi@0 1327 }
aoqi@0 1328
aoqi@0 1329 _promotion_failed = true;
aoqi@0 1330 failed_to_promote = true;
aoqi@0 1331
aoqi@0 1332 preserve_mark_if_necessary(old, m);
aoqi@0 1333 par_scan_state->register_promotion_failure(sz);
aoqi@0 1334 }
aoqi@0 1335 } else {
aoqi@0 1336 // Is in to-space; do copying ourselves.
aoqi@0 1337 Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz);
aoqi@0 1338 // Restore the mark word copied above.
aoqi@0 1339 new_obj->set_mark(m);
aoqi@0 1340 // Increment age if new_obj still in new generation
aoqi@0 1341 new_obj->incr_age();
aoqi@0 1342 par_scan_state->age_table()->add(new_obj, sz);
aoqi@0 1343 }
aoqi@0 1344 assert(new_obj != NULL, "just checking");
aoqi@0 1345
aoqi@0 1346 #ifndef PRODUCT
aoqi@0 1347 // This code must come after the CAS test, or it will print incorrect
aoqi@0 1348 // information.
aoqi@0 1349 if (TraceScavenge) {
aoqi@0 1350 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
aoqi@0 1351 is_in_reserved(new_obj) ? "copying" : "tenuring",
aoqi@0 1352 new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size());
aoqi@0 1353 }
aoqi@0 1354 #endif
aoqi@0 1355
aoqi@0 1356 // Now attempt to install the forwarding pointer (atomically).
aoqi@0 1357 // We have to copy the mark word before overwriting with forwarding
aoqi@0 1358 // ptr, so we can restore it below in the copy.
aoqi@0 1359 if (!failed_to_promote) {
aoqi@0 1360 forward_ptr = old->forward_to_atomic(new_obj);
aoqi@0 1361 }
aoqi@0 1362
aoqi@0 1363 if (forward_ptr == NULL) {
aoqi@0 1364 oop obj_to_push = new_obj;
aoqi@0 1365 if (par_scan_state->should_be_partially_scanned(obj_to_push, old)) {
aoqi@0 1366 // Length field used as index of next element to be scanned.
aoqi@0 1367 // Real length can be obtained from real_forwardee()
aoqi@0 1368 arrayOop(old)->set_length(0);
aoqi@0 1369 obj_to_push = old;
aoqi@0 1370 assert(obj_to_push->is_forwarded() && obj_to_push->forwardee() != obj_to_push,
aoqi@0 1371 "push forwarded object");
aoqi@0 1372 }
aoqi@0 1373 // Push it on one of the queues of to-be-scanned objects.
aoqi@0 1374 bool simulate_overflow = false;
aoqi@0 1375 NOT_PRODUCT(
aoqi@0 1376 if (ParGCWorkQueueOverflowALot && should_simulate_overflow()) {
aoqi@0 1377 // simulate a stack overflow
aoqi@0 1378 simulate_overflow = true;
aoqi@0 1379 }
aoqi@0 1380 )
aoqi@0 1381 if (simulate_overflow || !par_scan_state->work_queue()->push(obj_to_push)) {
aoqi@0 1382 // Add stats for overflow pushes.
aoqi@0 1383 push_on_overflow_list(old, par_scan_state);
aoqi@0 1384 TASKQUEUE_STATS_ONLY(par_scan_state->taskqueue_stats().record_overflow(0));
aoqi@0 1385 }
aoqi@0 1386
aoqi@0 1387 return new_obj;
aoqi@0 1388 }
aoqi@0 1389
aoqi@0 1390 // Oops. Someone beat us to it. Undo the allocation. Where did we
aoqi@0 1391 // allocate it?
aoqi@0 1392 if (is_in_reserved(new_obj)) {
aoqi@0 1393 // Must be in to_space.
aoqi@0 1394 assert(to()->is_in_reserved(new_obj), "Checking");
aoqi@0 1395 par_scan_state->undo_alloc_in_to_space((HeapWord*)new_obj, sz);
aoqi@0 1396 } else {
aoqi@0 1397 assert(!_avoid_promotion_undo, "Should not be here if avoiding.");
aoqi@0 1398 _next_gen->par_promote_alloc_undo(par_scan_state->thread_num(),
aoqi@0 1399 (HeapWord*)new_obj, sz);
aoqi@0 1400 }
aoqi@0 1401
aoqi@0 1402 return forward_ptr;
aoqi@0 1403 }
aoqi@0 1404
aoqi@0 1405 #ifndef PRODUCT
aoqi@0 1406 // It's OK to call this multi-threaded; the worst thing
aoqi@0 1407 // that can happen is that we'll get a bunch of closely
aoqi@0 1408 // spaced simulated oveflows, but that's OK, in fact
aoqi@0 1409 // probably good as it would exercise the overflow code
aoqi@0 1410 // under contention.
aoqi@0 1411 bool ParNewGeneration::should_simulate_overflow() {
aoqi@0 1412 if (_overflow_counter-- <= 0) { // just being defensive
aoqi@0 1413 _overflow_counter = ParGCWorkQueueOverflowInterval;
aoqi@0 1414 return true;
aoqi@0 1415 } else {
aoqi@0 1416 return false;
aoqi@0 1417 }
aoqi@0 1418 }
aoqi@0 1419 #endif
aoqi@0 1420
aoqi@0 1421 // In case we are using compressed oops, we need to be careful.
aoqi@0 1422 // If the object being pushed is an object array, then its length
aoqi@0 1423 // field keeps track of the "grey boundary" at which the next
aoqi@0 1424 // incremental scan will be done (see ParGCArrayScanChunk).
aoqi@0 1425 // When using compressed oops, this length field is kept in the
aoqi@0 1426 // lower 32 bits of the erstwhile klass word and cannot be used
aoqi@0 1427 // for the overflow chaining pointer (OCP below). As such the OCP
aoqi@0 1428 // would itself need to be compressed into the top 32-bits in this
aoqi@0 1429 // case. Unfortunately, see below, in the event that we have a
aoqi@0 1430 // promotion failure, the node to be pushed on the list can be
aoqi@0 1431 // outside of the Java heap, so the heap-based pointer compression
aoqi@0 1432 // would not work (we would have potential aliasing between C-heap
aoqi@0 1433 // and Java-heap pointers). For this reason, when using compressed
aoqi@0 1434 // oops, we simply use a worker-thread-local, non-shared overflow
aoqi@0 1435 // list in the form of a growable array, with a slightly different
aoqi@0 1436 // overflow stack draining strategy. If/when we start using fat
aoqi@0 1437 // stacks here, we can go back to using (fat) pointer chains
aoqi@0 1438 // (although some performance comparisons would be useful since
aoqi@0 1439 // single global lists have their own performance disadvantages
aoqi@0 1440 // as we were made painfully aware not long ago, see 6786503).
aoqi@0 1441 #define BUSY (cast_to_oop<intptr_t>(0x1aff1aff))
aoqi@0 1442 void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) {
aoqi@0 1443 assert(is_in_reserved(from_space_obj), "Should be from this generation");
aoqi@0 1444 if (ParGCUseLocalOverflow) {
aoqi@0 1445 // In the case of compressed oops, we use a private, not-shared
aoqi@0 1446 // overflow stack.
aoqi@0 1447 par_scan_state->push_on_overflow_stack(from_space_obj);
aoqi@0 1448 } else {
aoqi@0 1449 assert(!UseCompressedOops, "Error");
aoqi@0 1450 // if the object has been forwarded to itself, then we cannot
aoqi@0 1451 // use the klass pointer for the linked list. Instead we have
aoqi@0 1452 // to allocate an oopDesc in the C-Heap and use that for the linked list.
aoqi@0 1453 // XXX This is horribly inefficient when a promotion failure occurs
aoqi@0 1454 // and should be fixed. XXX FIX ME !!!
aoqi@0 1455 #ifndef PRODUCT
aoqi@0 1456 Atomic::inc_ptr(&_num_par_pushes);
aoqi@0 1457 assert(_num_par_pushes > 0, "Tautology");
aoqi@0 1458 #endif
aoqi@0 1459 if (from_space_obj->forwardee() == from_space_obj) {
aoqi@0 1460 oopDesc* listhead = NEW_C_HEAP_ARRAY(oopDesc, 1, mtGC);
aoqi@0 1461 listhead->forward_to(from_space_obj);
aoqi@0 1462 from_space_obj = listhead;
aoqi@0 1463 }
aoqi@0 1464 oop observed_overflow_list = _overflow_list;
aoqi@0 1465 oop cur_overflow_list;
aoqi@0 1466 do {
aoqi@0 1467 cur_overflow_list = observed_overflow_list;
aoqi@0 1468 if (cur_overflow_list != BUSY) {
aoqi@0 1469 from_space_obj->set_klass_to_list_ptr(cur_overflow_list);
aoqi@0 1470 } else {
aoqi@0 1471 from_space_obj->set_klass_to_list_ptr(NULL);
aoqi@0 1472 }
aoqi@0 1473 observed_overflow_list =
aoqi@0 1474 (oop)Atomic::cmpxchg_ptr(from_space_obj, &_overflow_list, cur_overflow_list);
aoqi@0 1475 } while (cur_overflow_list != observed_overflow_list);
aoqi@0 1476 }
aoqi@0 1477 }
aoqi@0 1478
aoqi@0 1479 bool ParNewGeneration::take_from_overflow_list(ParScanThreadState* par_scan_state) {
aoqi@0 1480 bool res;
aoqi@0 1481
aoqi@0 1482 if (ParGCUseLocalOverflow) {
aoqi@0 1483 res = par_scan_state->take_from_overflow_stack();
aoqi@0 1484 } else {
aoqi@0 1485 assert(!UseCompressedOops, "Error");
aoqi@0 1486 res = take_from_overflow_list_work(par_scan_state);
aoqi@0 1487 }
aoqi@0 1488 return res;
aoqi@0 1489 }
aoqi@0 1490
aoqi@0 1491
aoqi@0 1492 // *NOTE*: The overflow list manipulation code here and
aoqi@0 1493 // in CMSCollector:: are very similar in shape,
aoqi@0 1494 // except that in the CMS case we thread the objects
aoqi@0 1495 // directly into the list via their mark word, and do
aoqi@0 1496 // not need to deal with special cases below related
aoqi@0 1497 // to chunking of object arrays and promotion failure
aoqi@0 1498 // handling.
aoqi@0 1499 // CR 6797058 has been filed to attempt consolidation of
aoqi@0 1500 // the common code.
aoqi@0 1501 // Because of the common code, if you make any changes in
aoqi@0 1502 // the code below, please check the CMS version to see if
aoqi@0 1503 // similar changes might be needed.
aoqi@0 1504 // See CMSCollector::par_take_from_overflow_list() for
aoqi@0 1505 // more extensive documentation comments.
aoqi@0 1506 bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan_state) {
aoqi@0 1507 ObjToScanQueue* work_q = par_scan_state->work_queue();
aoqi@0 1508 // How many to take?
aoqi@0 1509 size_t objsFromOverflow = MIN2((size_t)(work_q->max_elems() - work_q->size())/4,
aoqi@0 1510 (size_t)ParGCDesiredObjsFromOverflowList);
aoqi@0 1511
aoqi@0 1512 assert(!UseCompressedOops, "Error");
aoqi@0 1513 assert(par_scan_state->overflow_stack() == NULL, "Error");
aoqi@0 1514 if (_overflow_list == NULL) return false;
aoqi@0 1515
aoqi@0 1516 // Otherwise, there was something there; try claiming the list.
aoqi@0 1517 oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
aoqi@0 1518 // Trim off a prefix of at most objsFromOverflow items
aoqi@0 1519 Thread* tid = Thread::current();
aoqi@0 1520 size_t spin_count = (size_t)ParallelGCThreads;
aoqi@0 1521 size_t sleep_time_millis = MAX2((size_t)1, objsFromOverflow/100);
aoqi@0 1522 for (size_t spin = 0; prefix == BUSY && spin < spin_count; spin++) {
aoqi@0 1523 // someone grabbed it before we did ...
aoqi@0 1524 // ... we spin for a short while...
aoqi@0 1525 os::sleep(tid, sleep_time_millis, false);
aoqi@0 1526 if (_overflow_list == NULL) {
aoqi@0 1527 // nothing left to take
aoqi@0 1528 return false;
aoqi@0 1529 } else if (_overflow_list != BUSY) {
aoqi@0 1530 // try and grab the prefix
aoqi@0 1531 prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));
aoqi@0 1532 }
aoqi@0 1533 }
aoqi@0 1534 if (prefix == NULL || prefix == BUSY) {
aoqi@0 1535 // Nothing to take or waited long enough
aoqi@0 1536 if (prefix == NULL) {
aoqi@0 1537 // Write back the NULL in case we overwrote it with BUSY above
aoqi@0 1538 // and it is still the same value.
aoqi@0 1539 (void) Atomic::cmpxchg_ptr(NULL, &_overflow_list, BUSY);
aoqi@0 1540 }
aoqi@0 1541 return false;
aoqi@0 1542 }
aoqi@0 1543 assert(prefix != NULL && prefix != BUSY, "Error");
aoqi@0 1544 size_t i = 1;
aoqi@0 1545 oop cur = prefix;
aoqi@0 1546 while (i < objsFromOverflow && cur->klass_or_null() != NULL) {
aoqi@0 1547 i++; cur = cur->list_ptr_from_klass();
aoqi@0 1548 }
aoqi@0 1549
aoqi@0 1550 // Reattach remaining (suffix) to overflow list
aoqi@0 1551 if (cur->klass_or_null() == NULL) {
aoqi@0 1552 // Write back the NULL in lieu of the BUSY we wrote
aoqi@0 1553 // above and it is still the same value.
aoqi@0 1554 if (_overflow_list == BUSY) {
aoqi@0 1555 (void) Atomic::cmpxchg_ptr(NULL, &_overflow_list, BUSY);
aoqi@0 1556 }
aoqi@0 1557 } else {
aoqi@0 1558 assert(cur->klass_or_null() != (Klass*)(address)BUSY, "Error");
aoqi@0 1559 oop suffix = cur->list_ptr_from_klass(); // suffix will be put back on global list
aoqi@0 1560 cur->set_klass_to_list_ptr(NULL); // break off suffix
aoqi@0 1561 // It's possible that the list is still in the empty(busy) state
aoqi@0 1562 // we left it in a short while ago; in that case we may be
aoqi@0 1563 // able to place back the suffix.
aoqi@0 1564 oop observed_overflow_list = _overflow_list;
aoqi@0 1565 oop cur_overflow_list = observed_overflow_list;
aoqi@0 1566 bool attached = false;
aoqi@0 1567 while (observed_overflow_list == BUSY || observed_overflow_list == NULL) {
aoqi@0 1568 observed_overflow_list =
aoqi@0 1569 (oop) Atomic::cmpxchg_ptr(suffix, &_overflow_list, cur_overflow_list);
aoqi@0 1570 if (cur_overflow_list == observed_overflow_list) {
aoqi@0 1571 attached = true;
aoqi@0 1572 break;
aoqi@0 1573 } else cur_overflow_list = observed_overflow_list;
aoqi@0 1574 }
aoqi@0 1575 if (!attached) {
aoqi@0 1576 // Too bad, someone else got in in between; we'll need to do a splice.
aoqi@0 1577 // Find the last item of suffix list
aoqi@0 1578 oop last = suffix;
aoqi@0 1579 while (last->klass_or_null() != NULL) {
aoqi@0 1580 last = last->list_ptr_from_klass();
aoqi@0 1581 }
aoqi@0 1582 // Atomically prepend suffix to current overflow list
aoqi@0 1583 observed_overflow_list = _overflow_list;
aoqi@0 1584 do {
aoqi@0 1585 cur_overflow_list = observed_overflow_list;
aoqi@0 1586 if (cur_overflow_list != BUSY) {
aoqi@0 1587 // Do the splice ...
aoqi@0 1588 last->set_klass_to_list_ptr(cur_overflow_list);
aoqi@0 1589 } else { // cur_overflow_list == BUSY
aoqi@0 1590 last->set_klass_to_list_ptr(NULL);
aoqi@0 1591 }
aoqi@0 1592 observed_overflow_list =
aoqi@0 1593 (oop)Atomic::cmpxchg_ptr(suffix, &_overflow_list, cur_overflow_list);
aoqi@0 1594 } while (cur_overflow_list != observed_overflow_list);
aoqi@0 1595 }
aoqi@0 1596 }
aoqi@0 1597
aoqi@0 1598 // Push objects on prefix list onto this thread's work queue
aoqi@0 1599 assert(prefix != NULL && prefix != BUSY, "program logic");
aoqi@0 1600 cur = prefix;
aoqi@0 1601 ssize_t n = 0;
aoqi@0 1602 while (cur != NULL) {
aoqi@0 1603 oop obj_to_push = cur->forwardee();
aoqi@0 1604 oop next = cur->list_ptr_from_klass();
aoqi@0 1605 cur->set_klass(obj_to_push->klass());
aoqi@0 1606 // This may be an array object that is self-forwarded. In that case, the list pointer
aoqi@0 1607 // space, cur, is not in the Java heap, but rather in the C-heap and should be freed.
aoqi@0 1608 if (!is_in_reserved(cur)) {
aoqi@0 1609 // This can become a scaling bottleneck when there is work queue overflow coincident
aoqi@0 1610 // with promotion failure.
aoqi@0 1611 oopDesc* f = cur;
aoqi@0 1612 FREE_C_HEAP_ARRAY(oopDesc, f, mtGC);
aoqi@0 1613 } else if (par_scan_state->should_be_partially_scanned(obj_to_push, cur)) {
aoqi@0 1614 assert(arrayOop(cur)->length() == 0, "entire array remaining to be scanned");
aoqi@0 1615 obj_to_push = cur;
aoqi@0 1616 }
aoqi@0 1617 bool ok = work_q->push(obj_to_push);
aoqi@0 1618 assert(ok, "Should have succeeded");
aoqi@0 1619 cur = next;
aoqi@0 1620 n++;
aoqi@0 1621 }
aoqi@0 1622 TASKQUEUE_STATS_ONLY(par_scan_state->note_overflow_refill(n));
aoqi@0 1623 #ifndef PRODUCT
aoqi@0 1624 assert(_num_par_pushes >= n, "Too many pops?");
aoqi@0 1625 Atomic::add_ptr(-(intptr_t)n, &_num_par_pushes);
aoqi@0 1626 #endif
aoqi@0 1627 return true;
aoqi@0 1628 }
aoqi@0 1629 #undef BUSY
aoqi@0 1630
aoqi@0 1631 void ParNewGeneration::ref_processor_init() {
aoqi@0 1632 if (_ref_processor == NULL) {
aoqi@0 1633 // Allocate and initialize a reference processor
aoqi@0 1634 _ref_processor =
aoqi@0 1635 new ReferenceProcessor(_reserved, // span
aoqi@0 1636 ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
aoqi@0 1637 (int) ParallelGCThreads, // mt processing degree
aoqi@0 1638 refs_discovery_is_mt(), // mt discovery
aoqi@0 1639 (int) ParallelGCThreads, // mt discovery degree
aoqi@0 1640 refs_discovery_is_atomic(), // atomic_discovery
aoqi@0 1641 NULL); // is_alive_non_header
aoqi@0 1642 }
aoqi@0 1643 }
aoqi@0 1644
aoqi@0 1645 const char* ParNewGeneration::name() const {
aoqi@0 1646 return "par new generation";
aoqi@0 1647 }

mercurial