hotspot/src/share/vm/memory/sharedHeap.cpp
changeset 30147 af9a41999c6e
parent 29804 dcb9861190d2
child 30152 5fe1c8494b49
equal deleted inserted replaced
29809:c59a5f161524 30147:af9a41999c6e
    33 #include "runtime/fprofiler.hpp"
    33 #include "runtime/fprofiler.hpp"
    34 #include "runtime/java.hpp"
    34 #include "runtime/java.hpp"
    35 #include "utilities/copy.hpp"
    35 #include "utilities/copy.hpp"
    36 #include "utilities/workgroup.hpp"
    36 #include "utilities/workgroup.hpp"
    37 
    37 
    38 SharedHeap* SharedHeap::_sh;
       
    39 
       
    40 SharedHeap::SharedHeap() :
    38 SharedHeap::SharedHeap() :
    41   CollectedHeap(),
    39   CollectedHeap(),
    42   _workers(NULL)
    40   _workers(NULL)
    43 {
    41 {
    44   _sh = this;  // ch is static, should be set only once.
       
    45   if (UseConcMarkSweepGC || UseG1GC) {
    42   if (UseConcMarkSweepGC || UseG1GC) {
    46     _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,
    43     _workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,
    47                             /* are_GC_task_threads */true,
    44                             /* are_GC_task_threads */true,
    48                             /* are_ConcurrentGC_threads */false);
    45                             /* are_ConcurrentGC_threads */false);
    49     if (_workers == NULL) {
    46     if (_workers == NULL) {
    50       vm_exit_during_initialization("Failed necessary allocation.");
    47       vm_exit_during_initialization("Failed necessary allocation.");
    51     } else {
    48     } else {
    52       _workers->initialize_workers();
    49       _workers->initialize_workers();
    53     }
    50     }
    54   }
    51   }
    55 }
       
    56 
       
    57 bool SharedHeap::heap_lock_held_for_gc() {
       
    58   Thread* t = Thread::current();
       
    59   return    Heap_lock->owned_by_self()
       
    60          || (   (t->is_GC_task_thread() ||  t->is_VM_thread())
       
    61              && _thread_holds_heap_lock_for_gc);
       
    62 }
    52 }
    63 
    53 
    64 void SharedHeap::set_par_threads(uint t) {
    54 void SharedHeap::set_par_threads(uint t) {
    65   assert(t == 0 || !UseSerialGC, "Cannot have parallel threads");
    55   assert(t == 0 || !UseSerialGC, "Cannot have parallel threads");
    66   _n_par_threads = t;
    56   _n_par_threads = t;