826 JavaThread* jthr = JavaThread::current();
827 if (!jthr->in_critical()) {
828 // Wait for JNI critical section to be exited
829 GCLocker::stall_until_clear();
830 // The GC invoked by the last thread leaving the critical
831 // section will be a young collection and a full collection
832 // is (currently) needed for unloading classes so continue
833 // to the next iteration to get a full GC.
834 continue;
835 } else {
836 if (CheckJNICalls) {
837 fatal("Possible deadlock due to allocating while"
838 " in jni critical section");
839 }
840 return NULL;
841 }
842 }
843
844 { // Need lock to get self consistent gc_count's
845 MutexLocker ml(Heap_lock);
846 gc_count = Universe::heap()->total_collections();
847 full_gc_count = Universe::heap()->total_full_collections();
848 }
849
850 // Generate a VM operation
851 VM_CollectForMetadataAllocation op(loader_data,
852 word_size,
853 mdtype,
854 gc_count,
855 full_gc_count,
856 GCCause::_metadata_GC_threshold);
857 VMThread::execute(&op);
858
859 // If GC was locked out, try again. Check before checking success because the
860 // prologue could have succeeded and the GC still have been locked out.
861 if (op.gc_locked()) {
862 continue;
863 }
864
865 if (op.prologue_succeeded()) {
866 return op.result();
867 }
|
826 JavaThread* jthr = JavaThread::current();
827 if (!jthr->in_critical()) {
828 // Wait for JNI critical section to be exited
829 GCLocker::stall_until_clear();
830 // The GC invoked by the last thread leaving the critical
831 // section will be a young collection and a full collection
832 // is (currently) needed for unloading classes so continue
833 // to the next iteration to get a full GC.
834 continue;
835 } else {
836 if (CheckJNICalls) {
837 fatal("Possible deadlock due to allocating while"
838 " in jni critical section");
839 }
840 return NULL;
841 }
842 }
843
844 { // Need lock to get self consistent gc_count's
845 MutexLocker ml(Heap_lock);
846 gc_count = GC::gc()->heap()->total_collections();
847 full_gc_count = GC::gc()->heap()->total_full_collections();
848 }
849
850 // Generate a VM operation
851 VM_CollectForMetadataAllocation op(loader_data,
852 word_size,
853 mdtype,
854 gc_count,
855 full_gc_count,
856 GCCause::_metadata_GC_threshold);
857 VMThread::execute(&op);
858
859 // If GC was locked out, try again. Check before checking success because the
860 // prologue could have succeeded and the GC still have been locked out.
861 if (op.gc_locked()) {
862 continue;
863 }
864
865 if (op.prologue_succeeded()) {
866 return op.result();
867 }
|