src/hotspot/share/gc/parallel/psYoungGen.hpp
author stefank
Sat, 26 May 2018 06:59:49 +0200
changeset 50752 9d62da00bf15
parent 49982 9042ffe5b7fe
child 53244 9807daeb47c4
permissions -rw-r--r--
8204540: Automatic oop closure devirtualization Reviewed-by: kbarrett, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
41283
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 30764
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSYOUNGGEN_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSYOUNGGEN_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    28
#include "gc/parallel/mutableSpace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    29
#include "gc/parallel/objectStartArray.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    30
#include "gc/parallel/psGenerationCounters.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    31
#include "gc/parallel/psVirtualspace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
    32
#include "gc/parallel/spaceCounters.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class PSMarkSweepDecorator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12379
diff changeset
    36
class PSYoungGen : public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  friend class ParallelScavengeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  friend class AdjoiningGenerations;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  MemRegion       _reserved;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  PSVirtualSpace* _virtual_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  MutableSpace* _eden_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  MutableSpace* _from_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  MutableSpace* _to_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // MarkSweep Decorators
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  PSMarkSweepDecorator* _eden_mark_sweep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  PSMarkSweepDecorator* _from_mark_sweep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  PSMarkSweepDecorator* _to_mark_sweep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Sizing information, in bytes, set in constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  const size_t _init_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  const size_t _min_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  const size_t _max_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  PSGenerationCounters*     _gen_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  SpaceCounters*            _eden_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  SpaceCounters*            _from_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  SpaceCounters*            _to_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Initialize the space boundaries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void compute_initial_space_boundaries();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Space boundary helper
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  void set_space_boundaries(size_t eden_size, size_t survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  virtual bool resize_generation(size_t eden_size, size_t survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  virtual void resize_spaces(size_t eden_size, size_t survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // Adjust the spaces to be consistent with the virtual space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void post_resize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Return number of bytes that the generation can change.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // These should not be used by PSYoungGen
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  virtual size_t available_for_expansion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  virtual size_t available_for_contraction();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Given a desired shrinkage in the size of the young generation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // return the actual size available for shrinkage.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  virtual size_t limit_gen_shrink(size_t desired_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // returns the number of bytes available from the current size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // down to the minimum generation size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  size_t available_to_min_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // Return the number of bytes available for shrinkage considering
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // the location the live data in the generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  virtual size_t available_to_live();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Initialize the generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  PSYoungGen(size_t        initial_byte_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
             size_t        minimum_byte_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
             size_t        maximum_byte_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void initialize_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  virtual void initialize(ReservedSpace rs, size_t alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  virtual void initialize_virtual_space(ReservedSpace rs, size_t alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  MemRegion reserved() const            { return _reserved; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  bool is_in(const void* p) const   {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      return _virtual_space->contains((void *)p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  bool is_in_reserved(const void* p) const   {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      return reserved().contains((void *)p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  MutableSpace*   eden_space() const    { return _eden_space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  MutableSpace*   from_space() const    { return _from_space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  MutableSpace*   to_space() const      { return _to_space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  PSVirtualSpace* virtual_space() const { return _virtual_space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // For Adaptive size policy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  size_t min_gen_size() { return _min_gen_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // MarkSweep support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  PSMarkSweepDecorator* eden_mark_sweep() const    { return _eden_mark_sweep; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  PSMarkSweepDecorator* from_mark_sweep() const    { return _from_mark_sweep; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  PSMarkSweepDecorator* to_mark_sweep() const      { return _to_mark_sweep;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 47216
diff changeset
   126
#if INCLUDE_SERIALGC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void precompact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  void adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void compact();
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 47216
diff changeset
   130
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 13728
diff changeset
   132
  // Called during/after GC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void swap_spaces();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Resize generation using suggested free space size and survivor size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // NOTE:  "eden_size" and "survivor_size" are suggestions only. Current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  //        heap layout (particularly, live objects in from space) might
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  //        not allow us to use these values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void resize(size_t eden_size, size_t survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Size info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  size_t capacity_in_bytes() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  size_t used_in_bytes() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  size_t free_in_bytes() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  size_t capacity_in_words() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  size_t used_in_words() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  size_t free_in_words() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // The max this generation can grow to
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 13728
diff changeset
   151
  size_t max_size() const { return _reserved.byte_size(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // The max this generation can grow to if the boundary between
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // the generations are allowed to move.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  size_t gen_size_limit() const { return _max_gen_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  bool is_maximal_no_gc() const {
22555
ea32f6c51d08 8028391: Make the Min/MaxHeapFreeRatio flags manageable
jwilhelm
parents: 13728
diff changeset
   158
    return true;  // Never expands except at a GC
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // Allocation
9997
b75b7939f448 6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents: 9178
diff changeset
   162
  HeapWord* allocate(size_t word_size) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    HeapWord* result = eden_space()->cas_allocate(word_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
41283
2615c024f3eb 8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents: 30764
diff changeset
   167
  HeapWord* volatile* top_addr() const   { return eden_space()->top_addr(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  HeapWord** end_addr() const   { return eden_space()->end_addr(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // Iteration.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   171
  void oop_iterate(OopIterateClosure* cl);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  void object_iterate(ObjectClosure* cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual void reset_after_change();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void reset_survivors_after_shrink();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Performance Counter support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void update_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // Debugging - do not use for time critical operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  void print() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  void print_used_change(size_t prev_used) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  virtual const char* name() const { return "PSYoungGen"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9997
diff changeset
   186
  void verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  // Space boundary invariant checker
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  void space_invariants() PRODUCT_RETURN;
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   190
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   191
  // Helper for mangling survivor spaces.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   192
  void mangle_survivors(MutableSpace* s1,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   193
                        MemRegion s1MR,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   194
                        MutableSpace* s2,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   195
                        MemRegion s2MR) PRODUCT_RETURN;
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   196
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   197
  void record_spaces_top() PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   199
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22555
diff changeset
   200
#endif // SHARE_VM_GC_PARALLEL_PSYOUNGGEN_HPP