580
581 DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
582 }
583
584 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
585 bool is_tlab,
586 bool* gc_overhead_limit_was_exceeded) {
587 GenCollectedHeap *gch = GenCollectedHeap::heap();
588
589 debug_only(gch->check_for_valid_allocation_state());
590 assert(gch->no_gc_in_progress(), "Allocation during gc not allowed");
591
592 // In general gc_overhead_limit_was_exceeded should be false so
593 // set it so here and reset it to true only if the gc time
594 // limit is being exceeded as checked below.
595 *gc_overhead_limit_was_exceeded = false;
596
597 HeapWord* result = NULL;
598
599 // Loop until the allocation is satisfied, or unsatisfied after GC.
600 for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) {
601 HandleMark hm; // Discard any handles allocated in each iteration.
602
603 // First allocation attempt is lock-free.
604 Generation *young = gch->get_gen(0);
605 assert(young->supports_inline_contig_alloc(),
606 "Otherwise, must do alloc within heap lock");
607 if (young->should_allocate(size, is_tlab)) {
608 result = young->par_allocate(size, is_tlab);
609 if (result != NULL) {
610 assert(gch->is_in_reserved(result), "result not in heap");
611 return result;
612 }
613 }
614 unsigned int gc_count_before; // Read inside the Heap_lock locked region.
615 {
616 MutexLocker ml(Heap_lock);
617 if (PrintGC && Verbose) {
618 gclog_or_tty->print_cr("TwoGenerationCollectorPolicy::mem_allocate_work:"
619 " attempting locked slow path allocation");
620 }
|
580
581 DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
582 }
583
584 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
585 bool is_tlab,
586 bool* gc_overhead_limit_was_exceeded) {
587 GenCollectedHeap *gch = GenCollectedHeap::heap();
588
589 debug_only(gch->check_for_valid_allocation_state());
590 assert(gch->no_gc_in_progress(), "Allocation during gc not allowed");
591
592 // In general gc_overhead_limit_was_exceeded should be false so
593 // set it so here and reset it to true only if the gc time
594 // limit is being exceeded as checked below.
595 *gc_overhead_limit_was_exceeded = false;
596
597 HeapWord* result = NULL;
598
599 // Loop until the allocation is satisfied, or unsatisfied after GC.
600 for (uint try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) {
601 HandleMark hm; // Discard any handles allocated in each iteration.
602
603 // First allocation attempt is lock-free.
604 Generation *young = gch->get_gen(0);
605 assert(young->supports_inline_contig_alloc(),
606 "Otherwise, must do alloc within heap lock");
607 if (young->should_allocate(size, is_tlab)) {
608 result = young->par_allocate(size, is_tlab);
609 if (result != NULL) {
610 assert(gch->is_in_reserved(result), "result not in heap");
611 return result;
612 }
613 }
614 unsigned int gc_count_before; // Read inside the Heap_lock locked region.
615 {
616 MutexLocker ml(Heap_lock);
617 if (PrintGC && Verbose) {
618 gclog_or_tty->print_cr("TwoGenerationCollectorPolicy::mem_allocate_work:"
619 " attempting locked slow path allocation");
620 }
|