652 // initiated by the last thread exiting the critical section; so
653 // we retry the allocation sequence from the beginning of the loop,
654 // rather than causing more, now probably unnecessary, GC attempts.
655 JavaThread* jthr = JavaThread::current();
656 if (!jthr->in_critical()) {
657 MutexUnlocker mul(Heap_lock);
658 // Wait for JNI critical section to be exited
659 GC_locker::stall_until_clear();
660 gclocker_stalled_count += 1;
661 continue;
662 } else {
663 if (CheckJNICalls) {
664 fatal("Possible deadlock due to allocating while"
665 " in jni critical section");
666 }
667 return NULL;
668 }
669 }
670
671 // Read the gc count while the heap lock is held.
672 gc_count_before = Universe::heap()->total_collections();
673 }
674
675 VM_GenCollectForAllocation op(size, is_tlab, gc_count_before);
676 VMThread::execute(&op);
677 if (op.prologue_succeeded()) {
678 result = op.result();
679 if (op.gc_locked()) {
680 assert(result == NULL, "must be NULL if gc_locked() is true");
681 continue; // Retry and/or stall as necessary.
682 }
683
684 // Allocation has failed and a collection
685 // has been done. If the gc time limit was exceeded the
686 // this time, return NULL so that an out-of-memory
687 // will be thrown. Clear gc_overhead_limit_exceeded
688 // so that the overhead exceeded does not persist.
689
690 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
691 const bool softrefs_clear = all_soft_refs_clear();
692
|
652 // initiated by the last thread exiting the critical section; so
653 // we retry the allocation sequence from the beginning of the loop,
654 // rather than causing more, now probably unnecessary, GC attempts.
655 JavaThread* jthr = JavaThread::current();
656 if (!jthr->in_critical()) {
657 MutexUnlocker mul(Heap_lock);
658 // Wait for JNI critical section to be exited
659 GC_locker::stall_until_clear();
660 gclocker_stalled_count += 1;
661 continue;
662 } else {
663 if (CheckJNICalls) {
664 fatal("Possible deadlock due to allocating while"
665 " in jni critical section");
666 }
667 return NULL;
668 }
669 }
670
671 // Read the gc count while the heap lock is held.
672 gc_count_before = gch->total_collections();
673 }
674
675 VM_GenCollectForAllocation op(size, is_tlab, gc_count_before);
676 VMThread::execute(&op);
677 if (op.prologue_succeeded()) {
678 result = op.result();
679 if (op.gc_locked()) {
680 assert(result == NULL, "must be NULL if gc_locked() is true");
681 continue; // Retry and/or stall as necessary.
682 }
683
684 // Allocation has failed and a collection
685 // has been done. If the gc time limit was exceeded the
686 // this time, return NULL so that an out-of-memory
687 // will be thrown. Clear gc_overhead_limit_exceeded
688 // so that the overhead exceeded does not persist.
689
690 const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
691 const bool softrefs_clear = all_soft_refs_clear();
692
|