comparison src/share/vm/memory/collectorPolicy.cpp @ 8883:b9a918201d47

Merge with hsx25
author Gilles Duboscq <duboscq@ssw.jku.at>
date Sat, 06 Apr 2013 20:04:06 +0200
parents 2e093b564241
children 6f817ce50129
comparison
equal deleted inserted replaced
8660:d47b52b0ff68 8883:b9a918201d47
530 530
531 HeapWord* result = NULL; 531 HeapWord* result = NULL;
532 532
533 // Loop until the allocation is satisified, 533 // Loop until the allocation is satisified,
534 // or unsatisfied after GC. 534 // or unsatisfied after GC.
535 for (int try_count = 1; /* return or throw */; try_count += 1) { 535 for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) {
536 HandleMark hm; // discard any handles allocated in each iteration 536 HandleMark hm; // discard any handles allocated in each iteration
537 537
538 // First allocation attempt is lock-free. 538 // First allocation attempt is lock-free.
539 Generation *gen0 = gch->get_gen(0); 539 Generation *gen0 = gch->get_gen(0);
540 assert(gen0->supports_inline_contig_alloc(), 540 assert(gen0->supports_inline_contig_alloc(),
574 if (result != NULL) { 574 if (result != NULL) {
575 return result; 575 return result;
576 } 576 }
577 } 577 }
578 578
579 if (gclocker_stalled_count > GCLockerRetryAllocationCount) {
580 return NULL; // we didn't get to do a GC and we didn't get any memory
581 }
582
579 // If this thread is not in a jni critical section, we stall 583 // If this thread is not in a jni critical section, we stall
580 // the requestor until the critical section has cleared and 584 // the requestor until the critical section has cleared and
581 // GC allowed. When the critical section clears, a GC is 585 // GC allowed. When the critical section clears, a GC is
582 // initiated by the last thread exiting the critical section; so 586 // initiated by the last thread exiting the critical section; so
583 // we retry the allocation sequence from the beginning of the loop, 587 // we retry the allocation sequence from the beginning of the loop,
585 JavaThread* jthr = JavaThread::current(); 589 JavaThread* jthr = JavaThread::current();
586 if (!jthr->in_critical()) { 590 if (!jthr->in_critical()) {
587 MutexUnlocker mul(Heap_lock); 591 MutexUnlocker mul(Heap_lock);
588 // Wait for JNI critical section to be exited 592 // Wait for JNI critical section to be exited
589 GC_locker::stall_until_clear(); 593 GC_locker::stall_until_clear();
594 gclocker_stalled_count += 1;
590 continue; 595 continue;
591 } else { 596 } else {
592 if (CheckJNICalls) { 597 if (CheckJNICalls) {
593 fatal("Possible deadlock due to allocating while" 598 fatal("Possible deadlock due to allocating while"
594 " in jni critical section"); 599 " in jni critical section");
618 // will be thrown. Clear gc_overhead_limit_exceeded 623 // will be thrown. Clear gc_overhead_limit_exceeded
619 // so that the overhead exceeded does not persist. 624 // so that the overhead exceeded does not persist.
620 625
621 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded(); 626 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
622 const bool softrefs_clear = all_soft_refs_clear(); 627 const bool softrefs_clear = all_soft_refs_clear();
623 assert(!limit_exceeded || softrefs_clear, "Should have been cleared"); 628
624 if (limit_exceeded && softrefs_clear) { 629 if (limit_exceeded && softrefs_clear) {
625 *gc_overhead_limit_was_exceeded = true; 630 *gc_overhead_limit_was_exceeded = true;
626 size_policy()->set_gc_overhead_limit_exceeded(false); 631 size_policy()->set_gc_overhead_limit_exceeded(false);
627 if (op.result() != NULL) { 632 if (op.result() != NULL) {
628 CollectedHeap::fill_with_object(op.result(), size); 633 CollectedHeap::fill_with_object(op.result(), size);