< prev index next >

src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp

Print this page
rev 50092 : [mq]: allocations-rt.patch


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "gc/parallel/adjoiningGenerations.hpp"
  28 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
  29 #include "gc/parallel/gcTaskManager.hpp"
  30 #include "gc/parallel/generationSizer.hpp"
  31 #include "gc/parallel/objectStartArray.inline.hpp"
  32 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  33 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  34 #include "gc/parallel/psMarkSweep.hpp"
  35 #include "gc/parallel/psMemoryPool.hpp"
  36 #include "gc/parallel/psParallelCompact.inline.hpp"
  37 #include "gc/parallel/psPromotionManager.hpp"
  38 #include "gc/parallel/psScavenge.hpp"
  39 #include "gc/parallel/vmPSOperations.hpp"

  40 #include "gc/shared/gcHeapSummary.hpp"
  41 #include "gc/shared/gcLocker.hpp"
  42 #include "gc/shared/gcWhen.hpp"
  43 #include "logging/log.hpp"
  44 #include "oops/oop.inline.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/java.hpp"
  47 #include "runtime/vmThread.hpp"
  48 #include "services/memoryManager.hpp"
  49 #include "services/memTracker.hpp"
  50 #include "utilities/vmError.hpp"
  51 
  52 PSYoungGen*  ParallelScavengeHeap::_young_gen = NULL;
  53 PSOldGen*    ParallelScavengeHeap::_old_gen = NULL;
  54 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
  55 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
  56 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
  57 
  58 jint ParallelScavengeHeap::initialize() {
  59   const size_t heap_size = _collector_policy->max_heap_byte_size();


 213 // attempting garbage collection. It is okay to grab locks and
 214 // expand the heap, if that can be done without coming to a safepoint.
 215 // It is likely that the basic allocation policy will not be very
 216 // aggressive.
 217 //
 218 // The failed allocation policy is invoked from the VM thread after
 219 // the basic allocation policy is unable to satisfy a mem_allocate
 220 // request. This policy needs to cover the entire range of collection,
 221 // heap expansion, and out-of-memory conditions. It should make every
 222 // attempt to allocate the requested memory.
 223 
 224 // Basic allocation policy. Should never be called at a safepoint, or
 225 // from the VM thread.
 226 //
 227 // This method must handle cases where many mem_allocate requests fail
 228 // simultaneously. When that happens, only one VM operation will succeed,
 229 // and the rest will not be executed. For that reason, this method loops
 230 // during failed allocation attempts. If the java heap becomes exhausted,
 231 // we rely on the size_policy object to force a bail out.
 232 HeapWord* ParallelScavengeHeap::mem_allocate(
 233                                      size_t size,
 234                                      bool* gc_overhead_limit_was_exceeded) {
 235   assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
 236   assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
 237   assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
 238 





 239   // In general gc_overhead_limit_was_exceeded should be false so
 240   // set it so here and reset it to true only if the gc time
 241   // limit is being exceeded as checked below.
 242   *gc_overhead_limit_was_exceeded = false;
 243 
 244   HeapWord* result = young_gen()->allocate(size);
 245 
 246   uint loop_count = 0;
 247   uint gc_count = 0;
 248   uint gclocker_stalled_count = 0;
 249 
 250   while (result == NULL) {
 251     // We don't want to have multiple collections for a single filled generation.
 252     // To prevent this, each thread tracks the total_collections() value, and if
 253     // the count has changed, does not do a new collection.
 254     //
 255     // The collection count must be read only while holding the heap lock. VM
 256     // operations also hold the heap lock during collections. There is a lock
 257     // contention case where thread A blocks waiting on the Heap_lock, while
 258     // thread B is holding it doing a collection. When thread A gets the lock,
 259     // the collection count has already changed. To prevent duplicate collections,
 260     // The policy MUST attempt allocations during the same period it reads the
 261     // total_collections() value!
 262     {
 263       MutexLocker ml(Heap_lock);
 264       gc_count = total_collections();




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "gc/parallel/adjoiningGenerations.hpp"
  28 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
  29 #include "gc/parallel/gcTaskManager.hpp"
  30 #include "gc/parallel/generationSizer.hpp"
  31 #include "gc/parallel/objectStartArray.inline.hpp"
  32 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  33 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  34 #include "gc/parallel/psMarkSweep.hpp"
  35 #include "gc/parallel/psMemoryPool.hpp"
  36 #include "gc/parallel/psParallelCompact.inline.hpp"
  37 #include "gc/parallel/psPromotionManager.hpp"
  38 #include "gc/parallel/psScavenge.hpp"
  39 #include "gc/parallel/vmPSOperations.hpp"
  40 #include "gc/shared/collectedHeap.inline.hpp"
  41 #include "gc/shared/gcHeapSummary.hpp"
  42 #include "gc/shared/gcLocker.hpp"
  43 #include "gc/shared/gcWhen.hpp"
  44 #include "logging/log.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/vmThread.hpp"
  49 #include "services/memoryManager.hpp"
  50 #include "services/memTracker.hpp"
  51 #include "utilities/vmError.hpp"
  52 
  53 PSYoungGen*  ParallelScavengeHeap::_young_gen = NULL;
  54 PSOldGen*    ParallelScavengeHeap::_old_gen = NULL;
  55 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
  56 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
  57 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
  58 
  59 jint ParallelScavengeHeap::initialize() {
  60   const size_t heap_size = _collector_policy->max_heap_byte_size();


 214 // attempting garbage collection. It is okay to grab locks and
 215 // expand the heap, if that can be done without coming to a safepoint.
 216 // It is likely that the basic allocation policy will not be very
 217 // aggressive.
 218 //
 219 // The failed allocation policy is invoked from the VM thread after
 220 // the basic allocation policy is unable to satisfy a mem_allocate
 221 // request. This policy needs to cover the entire range of collection,
 222 // heap expansion, and out-of-memory conditions. It should make every
 223 // attempt to allocate the requested memory.
 224 
 225 // Basic allocation policy. Should never be called at a safepoint, or
 226 // from the VM thread.
 227 //
 228 // This method must handle cases where many mem_allocate requests fail
 229 // simultaneously. When that happens, only one VM operation will succeed,
 230 // and the rest will not be executed. For that reason, this method loops
 231 // during failed allocation attempts. If the java heap becomes exhausted,
 232 // we rely on the size_policy object to force a bail out.
 233 HeapWord* ParallelScavengeHeap::mem_allocate(
 234                                      size_t size, Klass* klass, Thread* thread,
 235                                      bool* gc_overhead_limit_was_exceeded) {
 236   assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
 237   assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
 238   assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
 239 
 240   HeapWord* result = allocate_from_tlab(klass, thread, size);
 241   if (result != NULL) {
 242     return result;
 243   }
 244 
 245   // In general gc_overhead_limit_was_exceeded should be false so
 246   // set it so here and reset it to true only if the gc time
 247   // limit is being exceeded as checked below.
 248   *gc_overhead_limit_was_exceeded = false;
 249 
 250   result = young_gen()->allocate(size);
 251 
 252   uint loop_count = 0;
 253   uint gc_count = 0;
 254   uint gclocker_stalled_count = 0;
 255 
 256   while (result == NULL) {
 257     // We don't want to have multiple collections for a single filled generation.
 258     // To prevent this, each thread tracks the total_collections() value, and if
 259     // the count has changed, does not do a new collection.
 260     //
 261     // The collection count must be read only while holding the heap lock. VM
 262     // operations also hold the heap lock during collections. There is a lock
 263     // contention case where thread A blocks waiting on the Heap_lock, while
 264     // thread B is holding it doing a collection. When thread A gets the lock,
 265     // the collection count has already changed. To prevent duplicate collections,
 266     // The policy MUST attempt allocations during the same period it reads the
 267     // total_collections() value!
 268     {
 269       MutexLocker ml(Heap_lock);
 270       gc_count = total_collections();


< prev index next >