< prev index next >

src/share/vm/gc/shared/collectorPolicy.hpp

Print this page




  94 
  95   CollectorPolicy();
  96 
  97  public:
  98   virtual void initialize_all() {
  99     initialize_alignments();
 100     initialize_flags();
 101     initialize_size_info();
 102   }
 103 
 104   // Return maximum heap alignment that may be imposed by the policy.
 105   static size_t compute_heap_alignment();
 106 
 107   size_t space_alignment()        { return _space_alignment; }
 108   size_t heap_alignment()         { return _heap_alignment; }
 109 
 110   size_t initial_heap_byte_size() { return _initial_heap_byte_size; }
 111   size_t max_heap_byte_size()     { return _max_heap_byte_size; }
 112   size_t min_heap_byte_size()     { return _min_heap_byte_size; }
 113 
 114   enum Name {
 115     CollectorPolicyKind,
 116     GenCollectorPolicyKind,
 117     ConcurrentMarkSweepPolicyKind,
 118     G1CollectorPolicyKind
 119   };
 120 
 121   AdaptiveSizePolicy* size_policy() { return _size_policy; }
 122   bool should_clear_all_soft_refs() { return _should_clear_all_soft_refs; }
 123   void set_should_clear_all_soft_refs(bool v) { _should_clear_all_soft_refs = v; }
 124   // Returns the current value of _should_clear_all_soft_refs.
 125   // _should_clear_all_soft_refs is set to false as a side effect.
 126   bool use_should_clear_all_soft_refs(bool v);
 127   bool all_soft_refs_clear() { return _all_soft_refs_clear; }
 128   void set_all_soft_refs_clear(bool v) { _all_soft_refs_clear = v; }
 129 
 130   // Called by the GC after Soft Refs have been cleared to indicate
 131   // that the request in _should_clear_all_soft_refs has been fulfilled.
 132   void cleared_all_soft_refs();
 133 
 134   // Identification methods.
 135   virtual GenCollectorPolicy*           as_generation_policy()            { return NULL; }
 136   virtual MarkSweepPolicy*              as_mark_sweep_policy()            { return NULL; }
 137 #if INCLUDE_ALL_GCS
 138   virtual ConcurrentMarkSweepPolicy*    as_concurrent_mark_sweep_policy() { return NULL; }
 139   virtual G1CollectorPolicy*            as_g1_policy()                    { return NULL; }
 140 #endif // INCLUDE_ALL_GCS


 163                                       bool* gc_overhead_limit_was_exceeded) = 0;
 164 
 165   // This method controls how a collector handles one or more
 166   // of its generations being fully allocated.
 167   virtual HeapWord *satisfy_failed_allocation(size_t size, bool is_tlab) = 0;
 168   // This method controls how a collector handles a metadata allocation
 169   // failure.
 170   virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 171                                                        size_t size,
 172                                                        Metaspace::MetadataType mdtype);
 173 
 174   // Performance Counter support
 175   GCPolicyCounters* counters()     { return _gc_policy_counters; }
 176 
 177   // Create the jstat counters for the GC policy.  By default, policy's
 178   // don't have associated counters, and we complain if this is invoked.
 179   virtual void initialize_gc_policy_counters() {
 180     ShouldNotReachHere();
 181   }
 182 
 183   virtual CollectorPolicy::Name kind() {
 184     return CollectorPolicy::CollectorPolicyKind;
 185   }
 186 
 187   // Do any updates required to global flags that are due to heap initialization
 188   // changes
 189   virtual void post_heap_initialize() = 0;
 190 };
 191 
 192 class ClearedAllSoftRefs : public StackObj {
 193   bool _clear_all_soft_refs;
 194   CollectorPolicy* _collector_policy;
 195  public:
 196   ClearedAllSoftRefs(bool clear_all_soft_refs,
 197                      CollectorPolicy* collector_policy) :
 198     _clear_all_soft_refs(clear_all_soft_refs),
 199     _collector_policy(collector_policy) {}
 200 
 201   ~ClearedAllSoftRefs() {
 202     if (_clear_all_soft_refs) {
 203       _collector_policy->cleared_all_soft_refs();
 204     }
 205   }
 206 };


 278     initialize_generations();
 279   }
 280 
 281   size_t young_gen_size_lower_bound();
 282 
 283   size_t old_gen_size_lower_bound();
 284 
 285   HeapWord* mem_allocate_work(size_t size,
 286                               bool is_tlab,
 287                               bool* gc_overhead_limit_was_exceeded);
 288 
 289   HeapWord *satisfy_failed_allocation(size_t size, bool is_tlab);
 290 
 291   // Adaptive size policy
 292   virtual void initialize_size_policy(size_t init_eden_size,
 293                                       size_t init_promo_size,
 294                                       size_t init_survivor_size);
 295 
 296   virtual void post_heap_initialize() {
 297     assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info");
 298   }
 299 
 300   virtual CollectorPolicy::Name kind() {
 301     return CollectorPolicy::GenCollectorPolicyKind;
 302   }
 303 };
 304 
 305 class MarkSweepPolicy : public GenCollectorPolicy {
 306  protected:
 307   void initialize_alignments();
 308   void initialize_generations();
 309 
 310  public:
 311   MarkSweepPolicy() {}
 312 
 313   MarkSweepPolicy* as_mark_sweep_policy() { return this; }
 314 
 315   void initialize_gc_policy_counters();
 316 };
 317 
 318 #endif // SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP


  94 
  95   CollectorPolicy();
  96 
  97  public:
  98   virtual void initialize_all() {
  99     initialize_alignments();
 100     initialize_flags();
 101     initialize_size_info();
 102   }
 103 
 104   // Return maximum heap alignment that may be imposed by the policy.
 105   static size_t compute_heap_alignment();
 106 
 107   size_t space_alignment()        { return _space_alignment; }
 108   size_t heap_alignment()         { return _heap_alignment; }
 109 
 110   size_t initial_heap_byte_size() { return _initial_heap_byte_size; }
 111   size_t max_heap_byte_size()     { return _max_heap_byte_size; }
 112   size_t min_heap_byte_size()     { return _min_heap_byte_size; }
 113 







 114   AdaptiveSizePolicy* size_policy() { return _size_policy; }
 115   bool should_clear_all_soft_refs() { return _should_clear_all_soft_refs; }
 116   void set_should_clear_all_soft_refs(bool v) { _should_clear_all_soft_refs = v; }
 117   // Returns the current value of _should_clear_all_soft_refs.
 118   // _should_clear_all_soft_refs is set to false as a side effect.
 119   bool use_should_clear_all_soft_refs(bool v);
 120   bool all_soft_refs_clear() { return _all_soft_refs_clear; }
 121   void set_all_soft_refs_clear(bool v) { _all_soft_refs_clear = v; }
 122 
 123   // Called by the GC after Soft Refs have been cleared to indicate
 124   // that the request in _should_clear_all_soft_refs has been fulfilled.
 125   void cleared_all_soft_refs();
 126 
 127   // Identification methods.
 128   virtual GenCollectorPolicy*           as_generation_policy()            { return NULL; }
 129   virtual MarkSweepPolicy*              as_mark_sweep_policy()            { return NULL; }
 130 #if INCLUDE_ALL_GCS
 131   virtual ConcurrentMarkSweepPolicy*    as_concurrent_mark_sweep_policy() { return NULL; }
 132   virtual G1CollectorPolicy*            as_g1_policy()                    { return NULL; }
 133 #endif // INCLUDE_ALL_GCS


 156                                       bool* gc_overhead_limit_was_exceeded) = 0;
 157 
 158   // This method controls how a collector handles one or more
 159   // of its generations being fully allocated.
 160   virtual HeapWord *satisfy_failed_allocation(size_t size, bool is_tlab) = 0;
 161   // This method controls how a collector handles a metadata allocation
 162   // failure.
 163   virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 164                                                        size_t size,
 165                                                        Metaspace::MetadataType mdtype);
 166 
 167   // Performance Counter support
 168   GCPolicyCounters* counters()     { return _gc_policy_counters; }
 169 
 170   // Create the jstat counters for the GC policy.  By default, policy's
 171   // don't have associated counters, and we complain if this is invoked.
 172   virtual void initialize_gc_policy_counters() {
 173     ShouldNotReachHere();
 174   }
 175 




 176   // Do any updates required to global flags that are due to heap initialization
 177   // changes
 178   virtual void post_heap_initialize() = 0;
 179 };
 180 
 181 class ClearedAllSoftRefs : public StackObj {
 182   bool _clear_all_soft_refs;
 183   CollectorPolicy* _collector_policy;
 184  public:
 185   ClearedAllSoftRefs(bool clear_all_soft_refs,
 186                      CollectorPolicy* collector_policy) :
 187     _clear_all_soft_refs(clear_all_soft_refs),
 188     _collector_policy(collector_policy) {}
 189 
 190   ~ClearedAllSoftRefs() {
 191     if (_clear_all_soft_refs) {
 192       _collector_policy->cleared_all_soft_refs();
 193     }
 194   }
 195 };


 267     initialize_generations();
 268   }
 269 
 270   size_t young_gen_size_lower_bound();
 271 
 272   size_t old_gen_size_lower_bound();
 273 
 274   HeapWord* mem_allocate_work(size_t size,
 275                               bool is_tlab,
 276                               bool* gc_overhead_limit_was_exceeded);
 277 
 278   HeapWord *satisfy_failed_allocation(size_t size, bool is_tlab);
 279 
 280   // Adaptive size policy
 281   virtual void initialize_size_policy(size_t init_eden_size,
 282                                       size_t init_promo_size,
 283                                       size_t init_survivor_size);
 284 
 285   virtual void post_heap_initialize() {
 286     assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info");




 287   }
 288 };
 289 
 290 class MarkSweepPolicy : public GenCollectorPolicy {
 291  protected:
 292   void initialize_alignments();
 293   void initialize_generations();
 294 
 295  public:
 296   MarkSweepPolicy() {}
 297 
 298   MarkSweepPolicy* as_mark_sweep_policy() { return this; }
 299 
 300   void initialize_gc_policy_counters();
 301 };
 302 
 303 #endif // SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
< prev index next >