< prev index next >

src/share/vm/memory/sharedHeap.hpp

Print this page




  88 //  0 is a "special" value in set_n_threads() which translates to
  89 //  setting _n_threads to 1.
  90 //
  91 //  Some code uses _n_termination to decide if work should be done in
  92 //  parallel.  The notorious possibly_parallel_oops_do() in threads.cpp
  93 //  is an example of such code.  Look for variable "is_par" for other
  94 //  examples.
  95 //
  96 //  The active_workers is not reset to 0 after a parallel phase.  It's
  97 //  value may be used in later phases and in one instance at least
  98 //  (the parallel remark) it has to be used (the parallel remark depends
  99 //  on the partitioning done in the previous parallel scavenge).
 100 
 101 class SharedHeap : public CollectedHeap {
 102   friend class VMStructs;
 103 
 104   friend class VM_GC_Operation;
 105   friend class VM_CGC_Operation;
 106 
 107 protected:
 108   // There should be only a single instance of "SharedHeap" in a program.
 109   // This is enforced with the protected constructor below, which will also
 110   // set the static pointer "_sh" to that instance.
 111   static SharedHeap* _sh;
 112 
 113   // If we're doing parallel GC, use this gang of threads.
 114   FlexibleWorkGang* _workers;
 115 
 116   // Full initialization is done in a concrete subtype's "initialize"
 117   // function.
 118   SharedHeap();
 119 
 120   // Returns true if the calling thread holds the heap lock,
 121   // or the calling thread is a par gc thread and the heap_lock is held
 122   // by the vm thread doing a gc operation.
 123   bool heap_lock_held_for_gc();
 124   // True if the heap_lock is held by the a non-gc thread invoking a gc
 125   // operation.
 126   bool _thread_holds_heap_lock_for_gc;
 127 
 128 public:
 129   static SharedHeap* heap() { return _sh; }
 130 
 131   void set_barrier_set(BarrierSet* bs);
 132 
 133   // Does operations required after initialization has been done.
 134   virtual void post_initialize();
 135 
 136   // Initialization of ("weak") reference processing support
 137   virtual void ref_processing_init();
 138 
 139   // Iteration functions.
 140   void oop_iterate(ExtendedOopClosure* cl) = 0;
 141 
 142   // Iterate over all spaces in use in the heap, in an undefined order.
 143   virtual void space_iterate(SpaceClosure* cl) = 0;
 144 
 145   // A SharedHeap will contain some number of spaces.  This finds the
 146   // space whose reserved area contains the given address, or else returns
 147   // NULL.
 148   virtual Space* space_containing(const void* addr) const = 0;
 149 
 150   bool no_gc_in_progress() { return !is_gc_active(); }




  88 //  0 is a "special" value in set_n_threads() which translates to
  89 //  setting _n_threads to 1.
  90 //
  91 //  Some code uses _n_termination to decide if work should be done in
  92 //  parallel.  The notorious possibly_parallel_oops_do() in threads.cpp
  93 //  is an example of such code.  Look for variable "is_par" for other
  94 //  examples.
  95 //
  96 //  The active_workers is not reset to 0 after a parallel phase.  It's
  97 //  value may be used in later phases and in one instance at least
  98 //  (the parallel remark) it has to be used (the parallel remark depends
  99 //  on the partitioning done in the previous parallel scavenge).
 100 
 101 class SharedHeap : public CollectedHeap {
 102   friend class VMStructs;
 103 
 104   friend class VM_GC_Operation;
 105   friend class VM_CGC_Operation;
 106 
 107 protected:





 108   // If we're doing parallel GC, use this gang of threads.
 109   FlexibleWorkGang* _workers;
 110 
 111   // Full initialization is done in a concrete subtype's "initialize"
 112   // function.
 113   SharedHeap();
 114 








 115 public:


 116   void set_barrier_set(BarrierSet* bs);
 117 
 118   // Does operations required after initialization has been done.
 119   virtual void post_initialize();
 120 
 121   // Initialization of ("weak") reference processing support
 122   virtual void ref_processing_init();
 123 
 124   // Iteration functions.
 125   void oop_iterate(ExtendedOopClosure* cl) = 0;
 126 
 127   // Iterate over all spaces in use in the heap, in an undefined order.
 128   virtual void space_iterate(SpaceClosure* cl) = 0;
 129 
 130   // A SharedHeap will contain some number of spaces.  This finds the
 131   // space whose reserved area contains the given address, or else returns
 132   // NULL.
 133   virtual Space* space_containing(const void* addr) const = 0;
 134 
 135   bool no_gc_in_progress() { return !is_gc_active(); }


< prev index next >