src/share/vm/memory/collectorPolicy.hpp

changeset 6085
8f07aa079343
parent 6084
46d7652b223c
child 6091
236cecd9ec97
     1.1 --- a/src/share/vm/memory/collectorPolicy.hpp	Mon Oct 21 18:56:20 2013 +0200
     1.2 +++ b/src/share/vm/memory/collectorPolicy.hpp	Fri Nov 01 17:09:38 2013 +0100
     1.3 @@ -61,17 +61,23 @@
     1.4   protected:
     1.5    GCPolicyCounters* _gc_policy_counters;
     1.6  
     1.7 -  // Requires that the concrete subclass sets the alignment constraints
     1.8 -  // before calling.
     1.9 +  virtual void initialize_alignments() = 0;
    1.10    virtual void initialize_flags();
    1.11    virtual void initialize_size_info();
    1.12  
    1.13 +  DEBUG_ONLY(virtual void assert_flags();)
    1.14 +  DEBUG_ONLY(virtual void assert_size_info();)
    1.15 +
    1.16    size_t _initial_heap_byte_size;
    1.17    size_t _max_heap_byte_size;
    1.18    size_t _min_heap_byte_size;
    1.19  
    1.20 -  size_t _min_alignment;
    1.21 -  size_t _max_alignment;
    1.22 +  size_t _space_alignment;
    1.23 +  size_t _heap_alignment;
    1.24 +
    1.25 +  // Needed to keep information if MaxHeapSize was set on the command line
    1.26 +  // when the flag value is aligned etc by ergonomics
    1.27 +  bool _max_heap_size_cmdline;
    1.28  
    1.29    // The sizing of the heap are controlled by a sizing policy.
    1.30    AdaptiveSizePolicy* _size_policy;
    1.31 @@ -87,23 +93,20 @@
    1.32    // mem_allocate() where it returns op.result()
    1.33    bool _all_soft_refs_clear;
    1.34  
    1.35 -  CollectorPolicy() :
    1.36 -    _min_alignment(1),
    1.37 -    _max_alignment(1),
    1.38 -    _initial_heap_byte_size(0),
    1.39 -    _max_heap_byte_size(0),
    1.40 -    _min_heap_byte_size(0),
    1.41 -    _size_policy(NULL),
    1.42 -    _should_clear_all_soft_refs(false),
    1.43 -    _all_soft_refs_clear(false)
    1.44 -  {}
    1.45 +  CollectorPolicy();
    1.46  
    1.47   public:
    1.48 +  virtual void initialize_all() {
    1.49 +    initialize_alignments();
    1.50 +    initialize_flags();
    1.51 +    initialize_size_info();
    1.52 +  }
    1.53 +
    1.54    // Return maximum heap alignment that may be imposed by the policy
    1.55 -  static size_t compute_max_alignment();
    1.56 +  static size_t compute_heap_alignment();
    1.57  
    1.58 -  size_t min_alignment()          { return _min_alignment; }
    1.59 -  size_t max_alignment()          { return _max_alignment; }
    1.60 +  size_t space_alignment()        { return _space_alignment; }
    1.61 +  size_t heap_alignment()         { return _heap_alignment; }
    1.62  
    1.63    size_t initial_heap_byte_size() { return _initial_heap_byte_size; }
    1.64    size_t max_heap_byte_size()     { return _max_heap_byte_size; }
    1.65 @@ -195,6 +198,9 @@
    1.66      return false;
    1.67    }
    1.68  
    1.69 +  // Do any updates required to global flags that are due to heap initialization
    1.70 +  // changes
    1.71 +  virtual void post_heap_initialize() = 0;
    1.72  };
    1.73  
    1.74  class ClearedAllSoftRefs : public StackObj {
    1.75 @@ -219,6 +225,10 @@
    1.76    size_t _initial_gen0_size;
    1.77    size_t _max_gen0_size;
    1.78  
    1.79 +  // _gen_alignment and _space_alignment will have the same value most of the
    1.80 +  // time. When using large pages they can differ.
    1.81 +  size_t _gen_alignment;
    1.82 +
    1.83    GenerationSpec **_generations;
    1.84  
    1.85    // Return true if an allocation should be attempted in the older
    1.86 @@ -229,23 +239,31 @@
    1.87    void initialize_flags();
    1.88    void initialize_size_info();
    1.89  
    1.90 +  DEBUG_ONLY(void assert_flags();)
    1.91 +  DEBUG_ONLY(void assert_size_info();)
    1.92 +
    1.93    // Try to allocate space by expanding the heap.
    1.94    virtual HeapWord* expand_heap_and_allocate(size_t size, bool is_tlab);
    1.95  
    1.96 - // Scale the base_size by NewRation according to
    1.97 +  // Compute max heap alignment
    1.98 +  size_t compute_max_alignment();
    1.99 +
   1.100 + // Scale the base_size by NewRatio according to
   1.101   //     result = base_size / (NewRatio + 1)
   1.102   // and align by min_alignment()
   1.103   size_t scale_by_NewRatio_aligned(size_t base_size);
   1.104  
   1.105 - // Bound the value by the given maximum minus the
   1.106 - // min_alignment.
   1.107 + // Bound the value by the given maximum minus the min_alignment
   1.108   size_t bound_minus_alignment(size_t desired_size, size_t maximum_size);
   1.109  
   1.110   public:
   1.111 +  GenCollectorPolicy();
   1.112 +
   1.113    // Accessors
   1.114    size_t min_gen0_size()     { return _min_gen0_size; }
   1.115    size_t initial_gen0_size() { return _initial_gen0_size; }
   1.116    size_t max_gen0_size()     { return _max_gen0_size; }
   1.117 +  size_t gen_alignment()     { return _gen_alignment; }
   1.118  
   1.119    virtual int number_of_generations() = 0;
   1.120  
   1.121 @@ -256,14 +274,15 @@
   1.122  
   1.123    virtual GenCollectorPolicy* as_generation_policy() { return this; }
   1.124  
   1.125 -  virtual void initialize_generations() = 0;
   1.126 +  virtual void initialize_generations() { };
   1.127  
   1.128    virtual void initialize_all() {
   1.129 -    initialize_flags();
   1.130 -    initialize_size_info();
   1.131 +    CollectorPolicy::initialize_all();
   1.132      initialize_generations();
   1.133    }
   1.134  
   1.135 +  size_t young_gen_size_lower_bound();
   1.136 +
   1.137    HeapWord* mem_allocate_work(size_t size,
   1.138                                bool is_tlab,
   1.139                                bool* gc_overhead_limit_was_exceeded);
   1.140 @@ -275,10 +294,8 @@
   1.141                                        size_t init_promo_size,
   1.142                                        size_t init_survivor_size);
   1.143  
   1.144 -  // The alignment used for eden and survivors within the young gen
   1.145 -  // and for boundary between young gen and old gen.
   1.146 -  static size_t intra_heap_alignment() {
   1.147 -    return 64 * K * HeapWordSize;
   1.148 +  virtual void post_heap_initialize() {
   1.149 +    assert(_max_gen0_size == MaxNewSize, "Should be taken care of by initialize_size_info");
   1.150    }
   1.151  };
   1.152  
   1.153 @@ -296,9 +313,14 @@
   1.154  
   1.155    void initialize_flags();
   1.156    void initialize_size_info();
   1.157 -  void initialize_generations()                { ShouldNotReachHere(); }
   1.158 +
   1.159 +  DEBUG_ONLY(void assert_flags();)
   1.160 +  DEBUG_ONLY(void assert_size_info();)
   1.161  
   1.162   public:
   1.163 +  TwoGenerationCollectorPolicy() : GenCollectorPolicy(), _min_gen1_size(0),
   1.164 +    _initial_gen1_size(0), _max_gen1_size(0) {}
   1.165 +
   1.166    // Accessors
   1.167    size_t min_gen1_size()     { return _min_gen1_size; }
   1.168    size_t initial_gen1_size() { return _initial_gen1_size; }
   1.169 @@ -321,10 +343,11 @@
   1.170  
   1.171  class MarkSweepPolicy : public TwoGenerationCollectorPolicy {
   1.172   protected:
   1.173 +  void initialize_alignments();
   1.174    void initialize_generations();
   1.175  
   1.176   public:
   1.177 -  MarkSweepPolicy();
   1.178 +  MarkSweepPolicy() {}
   1.179  
   1.180    MarkSweepPolicy* as_mark_sweep_policy() { return this; }
   1.181  

mercurial