Mercurial > hg > truffle
comparison src/share/vm/memory/collectorPolicy.cpp @ 8853:2e093b564241
7014552: gc/lock/jni/jnilockXXX works too slow on 1-processor machine
Summary: Keep a counter of how many times we were stalled by the GC locker, add a diagnostic flag which sets the limit.
Reviewed-by: brutisso, ehelin, johnc
author | mgerdin |
---|---|
date | Thu, 28 Mar 2013 10:27:28 +0100 |
parents | 82657b6a8cc0 |
children | 6f817ce50129 |
comparison
equal
deleted
inserted
replaced
8827:42e370795a39 | 8853:2e093b564241 |
---|---|
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"); |