459 460 oop CollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) { 461 ObjArrayAllocator allocator(klass, size, length, do_zero, THREAD); 462 return allocator.allocate(); 463 } 464 465 oop CollectedHeap::class_allocate(Klass* klass, int size, TRAPS) { 466 ClassAllocator allocator(klass, size, THREAD); 467 return allocator.allocate(); 468 } 469 470 void CollectedHeap::ensure_parsability(bool retire_tlabs) { 471 // The second disjunct in the assertion below makes a concession 472 // for the start-up verification done while the VM is being 473 // created. Callers be careful that you know that mutators 474 // aren't going to interfere -- for instance, this is permissible 475 // if we are still single-threaded and have either not yet 476 // started allocating (nothing much to verify) or we have 477 // started allocating but are now a full-fledged JavaThread 478 // (and have thus made our TLAB's) available for filling. 479 assert(SafepointSynchronize::is_at_safepoint() || 480 !is_init_completed(), 481 "Should only be called at a safepoint or at start-up" 482 " otherwise concurrent mutator activity may make heap " 483 " unparsable again"); 484 const bool use_tlab = UseTLAB; 485 // The main thread starts allocating via a TLAB even before it 486 // has added itself to the threads list at vm boot-up. 487 JavaThreadIteratorWithHandle jtiwh; 488 assert(!use_tlab || jtiwh.length() > 0, 489 "Attempt to fill tlabs before main thread has been added" 490 " to threads list is doomed to failure!"); 491 BarrierSet *bs = BarrierSet::barrier_set(); 492 for (; JavaThread *thread = jtiwh.next(); ) { 493 if (use_tlab) thread->tlab().make_parsable(retire_tlabs); 494 bs->make_parsable(thread); 495 } 496 } 497 498 void CollectedHeap::accumulate_statistics_all_tlabs() { 499 if (UseTLAB) { 500 assert(SafepointSynchronize::is_at_safepoint() || 501 !is_init_completed(), 502 "should only accumulate statistics on tlabs at safepoint"); 503 504 ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); 505 } 506 } 507 508 void CollectedHeap::resize_all_tlabs() { 509 if (UseTLAB) { 510 assert(SafepointSynchronize::is_at_safepoint() || 511 !is_init_completed(), 512 "should only resize tlabs at safepoint"); 513 514 ThreadLocalAllocBuffer::resize_all_tlabs(); 515 } 516 } 517 518 void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) { 519 assert(timer != NULL, "timer is null"); 520 if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) { 521 GCTraceTime(Info, gc) tm(before ? "Heap Dump (before full gc)" : "Heap Dump (after full gc)", timer); 522 HeapDumper::dump_heap(); 523 } 524 | 459 460 oop CollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) { 461 ObjArrayAllocator allocator(klass, size, length, do_zero, THREAD); 462 return allocator.allocate(); 463 } 464 465 oop CollectedHeap::class_allocate(Klass* klass, int size, TRAPS) { 466 ClassAllocator allocator(klass, size, THREAD); 467 return allocator.allocate(); 468 } 469 470 void CollectedHeap::ensure_parsability(bool retire_tlabs) { 471 // The second disjunct in the assertion below makes a concession 472 // for the start-up verification done while the VM is being 473 // created. Callers be careful that you know that mutators 474 // aren't going to interfere -- for instance, this is permissible 475 // if we are still single-threaded and have either not yet 476 // started allocating (nothing much to verify) or we have 477 // started allocating but are now a full-fledged JavaThread 478 // (and have thus made our TLAB's) available for filling. 479 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), 480 "Should only be called at a safepoint or at start-up" 481 " otherwise concurrent mutator activity may make heap " 482 " unparsable again"); 483 484 if (UseTLAB && retire_tlabs) { 485 // Accumulate statistics before retiring 486 ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); 487 } 488 489 // The main thread starts allocating via a TLAB even before it 490 // has added itself to the threads list at vm boot-up. 491 JavaThreadIteratorWithHandle jtiwh; 492 assert(jtiwh.length() > 0, 493 "Attempt to fill tlabs before main thread has been added" 494 " to threads list is doomed to failure!"); 495 BarrierSet *bs = BarrierSet::barrier_set(); 496 for (; JavaThread *thread = jtiwh.next(); ) { 497 if (UseTLAB) { 498 thread->tlab().make_parsable(retire_tlabs); 499 } 500 bs->make_parsable(thread); 501 } 502 } 503 504 void CollectedHeap::resize_all_tlabs() { 505 if (UseTLAB) { 506 assert(SafepointSynchronize::is_at_safepoint() || 507 !is_init_completed(), 508 "should only resize tlabs at safepoint"); 509 510 ThreadLocalAllocBuffer::resize_all_tlabs(); 511 } 512 } 513 514 void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) { 515 assert(timer != NULL, "timer is null"); 516 if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) { 517 GCTraceTime(Info, gc) tm(before ? "Heap Dump (before full gc)" : "Heap Dump (after full gc)", timer); 518 HeapDumper::dump_heap(); 519 } 520 |