index

src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp

Print this page
rev 7474 : imported patch cleanup


 243 // simultaneously. When that happens, only one VM operation will succeed,
 244 // and the rest will not be executed. For that reason, this method loops
 245 // during failed allocation attempts. If the java heap becomes exhausted,
 246 // we rely on the size_policy object to force a bail out.
 247 HeapWord* ParallelScavengeHeap::mem_allocate(
 248                                      size_t size,
 249                                      bool* gc_overhead_limit_was_exceeded) {
 250   assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
 251   assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
 252   assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
 253 
 254   // In general gc_overhead_limit_was_exceeded should be false so
 255   // set it so here and reset it to true only if the gc time
 256   // limit is being exceeded as checked below.
 257   *gc_overhead_limit_was_exceeded = false;
 258 
 259   HeapWord* result = young_gen()->allocate(size);
 260 
 261   uint loop_count = 0;
 262   uint gc_count = 0;
 263   int gclocker_stalled_count = 0;
 264 
 265   while (result == NULL) {
 266     // We don't want to have multiple collections for a single filled generation.
 267     // To prevent this, each thread tracks the total_collections() value, and if
 268     // the count has changed, does not do a new collection.
 269     //
 270     // The collection count must be read only while holding the heap lock. VM
 271     // operations also hold the heap lock during collections. There is a lock
 272     // contention case where thread A blocks waiting on the Heap_lock, while
 273     // thread B is holding it doing a collection. When thread A gets the lock,
 274     // the collection count has already changed. To prevent duplicate collections,
 275     // The policy MUST attempt allocations during the same period it reads the
 276     // total_collections() value!
 277     {
 278       MutexLocker ml(Heap_lock);
 279       gc_count = Universe::heap()->total_collections();
 280 
 281       result = young_gen()->allocate(size);
 282       if (result != NULL) {
 283         return result;




 243 // simultaneously. When that happens, only one VM operation will succeed,
 244 // and the rest will not be executed. For that reason, this method loops
 245 // during failed allocation attempts. If the java heap becomes exhausted,
 246 // we rely on the size_policy object to force a bail out.
 247 HeapWord* ParallelScavengeHeap::mem_allocate(
 248                                      size_t size,
 249                                      bool* gc_overhead_limit_was_exceeded) {
 250   assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
 251   assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
 252   assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
 253 
 254   // In general gc_overhead_limit_was_exceeded should be false so
 255   // set it so here and reset it to true only if the gc time
 256   // limit is being exceeded as checked below.
 257   *gc_overhead_limit_was_exceeded = false;
 258 
 259   HeapWord* result = young_gen()->allocate(size);
 260 
 261   uint loop_count = 0;
 262   uint gc_count = 0;
 263   uint gclocker_stalled_count = 0;
 264 
 265   while (result == NULL) {
 266     // We don't want to have multiple collections for a single filled generation.
 267     // To prevent this, each thread tracks the total_collections() value, and if
 268     // the count has changed, does not do a new collection.
 269     //
 270     // The collection count must be read only while holding the heap lock. VM
 271     // operations also hold the heap lock during collections. There is a lock
 272     // contention case where thread A blocks waiting on the Heap_lock, while
 273     // thread B is holding it doing a collection. When thread A gets the lock,
 274     // the collection count has already changed. To prevent duplicate collections,
 275     // The policy MUST attempt allocations during the same period it reads the
 276     // total_collections() value!
 277     {
 278       MutexLocker ml(Heap_lock);
 279       gc_count = Universe::heap()->total_collections();
 280 
 281       result = young_gen()->allocate(size);
 282       if (result != NULL) {
 283         return result;


index