Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.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 | 3c226052f7dc |
children | 7b835924c31c |
comparison
equal
deleted
inserted
replaced
8827:42e370795a39 | 8853:2e093b564241 |
---|---|
324 | 324 |
325 HeapWord* result = young_gen()->allocate(size); | 325 HeapWord* result = young_gen()->allocate(size); |
326 | 326 |
327 uint loop_count = 0; | 327 uint loop_count = 0; |
328 uint gc_count = 0; | 328 uint gc_count = 0; |
329 int gclocker_stalled_count = 0; | |
329 | 330 |
330 while (result == NULL) { | 331 while (result == NULL) { |
331 // We don't want to have multiple collections for a single filled generation. | 332 // We don't want to have multiple collections for a single filled generation. |
332 // To prevent this, each thread tracks the total_collections() value, and if | 333 // To prevent this, each thread tracks the total_collections() value, and if |
333 // the count has changed, does not do a new collection. | 334 // the count has changed, does not do a new collection. |
352 result = mem_allocate_old_gen(size); | 353 result = mem_allocate_old_gen(size); |
353 if (result != NULL) { | 354 if (result != NULL) { |
354 return result; | 355 return result; |
355 } | 356 } |
356 | 357 |
358 if (gclocker_stalled_count > GCLockerRetryAllocationCount) { | |
359 return NULL; | |
360 } | |
361 | |
357 // Failed to allocate without a gc. | 362 // Failed to allocate without a gc. |
358 if (GC_locker::is_active_and_needs_gc()) { | 363 if (GC_locker::is_active_and_needs_gc()) { |
359 // If this thread is not in a jni critical section, we stall | 364 // If this thread is not in a jni critical section, we stall |
360 // the requestor until the critical section has cleared and | 365 // the requestor until the critical section has cleared and |
361 // GC allowed. When the critical section clears, a GC is | 366 // GC allowed. When the critical section clears, a GC is |
364 // rather than causing more, now probably unnecessary, GC attempts. | 369 // rather than causing more, now probably unnecessary, GC attempts. |
365 JavaThread* jthr = JavaThread::current(); | 370 JavaThread* jthr = JavaThread::current(); |
366 if (!jthr->in_critical()) { | 371 if (!jthr->in_critical()) { |
367 MutexUnlocker mul(Heap_lock); | 372 MutexUnlocker mul(Heap_lock); |
368 GC_locker::stall_until_clear(); | 373 GC_locker::stall_until_clear(); |
374 gclocker_stalled_count += 1; | |
369 continue; | 375 continue; |
370 } else { | 376 } else { |
371 if (CheckJNICalls) { | 377 if (CheckJNICalls) { |
372 fatal("Possible deadlock due to allocating while" | 378 fatal("Possible deadlock due to allocating while" |
373 " in jni critical section"); | 379 " in jni critical section"); |