hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp
author jwilhelm
Thu, 23 Jan 2014 14:47:23 +0100
changeset 22551 9bf46d16dcc6
parent 22234 da823d78ad65
child 30264 142414794deb
permissions -rw-r--r--
8025856: Fix typos in the GC code Summary: Fix about 440 typos in comments in the VM code Reviewed-by: mgerdin, tschatzl, coleenp, kmo, jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 18443
diff changeset
     2
 * Copyright (c) 2001, 2013, 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: 5402
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
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: 5402
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "gc_implementation/parallelScavenge/psGenerationCounters.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "gc_implementation/shared/mutableSpace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "gc_implementation/shared/spaceCounters.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/safepoint.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class PSMarkSweepDecorator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12379
diff changeset
    37
class PSOldGen : public CHeapObj<mtGC> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  friend class PSPromotionManager; // Uses the cas_allocate methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  friend class ParallelScavengeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  friend class AdjoiningGenerations;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  MemRegion                _reserved;          // Used for simple containment tests
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  PSVirtualSpace*          _virtual_space;     // Controls mapping and unmapping of virtual mem
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  ObjectStartArray         _start_array;       // Keeps track of where objects start in a 512b block
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  MutableSpace*            _object_space;      // Where all the objects live
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  PSMarkSweepDecorator*    _object_mark_sweep; // The mark sweep view of _object_space
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  const char* const        _name;              // Name of this generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Performance Counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  PSGenerationCounters*    _gen_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  SpaceCounters*           _space_counters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Sizing information, in bytes, set in constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  const size_t _init_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  const size_t _min_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  const size_t _max_gen_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Used when initializing the _name field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static inline const char* select_name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
9997
b75b7939f448 6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents: 9178
diff changeset
    63
  HeapWord* allocate_noexpand(size_t word_size) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    // We assume the heap lock is held here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    assert_locked_or_safepoint(Heap_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    HeapWord* res = object_space()->allocate(word_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    if (res != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      _start_array.allocate_block(res);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Support for MT garbage collection. CAS allocation is lower overhead than grabbing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // and releasing the heap lock, which is held during gc's anyway. This method is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // safe for use at the same time as allocate_noexpand()!
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  HeapWord* cas_allocate_noexpand(size_t word_size) {
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 1217
diff changeset
    77
    assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    HeapWord* res = object_space()->cas_allocate(word_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    if (res != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      _start_array.allocate_block(res);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Support for MT garbage collection. See above comment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  HeapWord* cas_allocate(size_t word_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    HeapWord* res = cas_allocate_noexpand(word_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
9997
b75b7939f448 6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents: 9178
diff changeset
    91
  HeapWord* expand_and_allocate(size_t word_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  HeapWord* expand_and_cas_allocate(size_t word_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void expand(size_t bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool expand_by(size_t bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  bool expand_to_reserved();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void shrink(size_t bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void post_resize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Initialize the generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  PSOldGen(ReservedSpace rs, size_t alignment,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
           size_t initial_size, size_t min_size, size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
           const char* perf_data_name, int level);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  PSOldGen(size_t initial_size, size_t min_size, size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
           const char* perf_data_name, int level);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   110
  virtual void initialize(ReservedSpace rs, size_t alignment,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
                  const char* perf_data_name, int level);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  void initialize_virtual_space(ReservedSpace rs, size_t alignment);
18443
ca4b3427b7c7 8014851: UseAdaptiveGCBoundary is broken
jmasa
parents: 13728
diff changeset
   113
  virtual void initialize_work(const char* perf_data_name, int level);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   114
  virtual void initialize_performance_counters(const char* perf_data_name, int level);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  MemRegion reserved() const                { return _reserved; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  virtual size_t max_gen_size()             { return _max_gen_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  size_t min_gen_size()                     { return _min_gen_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Returns limit on the maximum size of the generation.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // is the same as _max_gen_size for PSOldGen but need not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // for a derived class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  virtual size_t gen_size_limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_in(const void* p) const           {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    return _virtual_space->contains((void *)p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  bool is_in_reserved(const void* p) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    return reserved().contains(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  MutableSpace*         object_space() const      { return _object_space; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  ObjectStartArray*     start_array()             { return &_start_array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  PSVirtualSpace*       virtual_space() const     { return _virtual_space;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Has the generation been successfully allocated?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  bool is_allocated();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // MarkSweep methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  virtual void precompact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void compact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Size info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  size_t capacity_in_bytes() const        { return object_space()->capacity_in_bytes(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  size_t used_in_bytes() const            { return object_space()->used_in_bytes(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  size_t free_in_bytes() const            { return object_space()->free_in_bytes(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  size_t capacity_in_words() const        { return object_space()->capacity_in_words(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  size_t used_in_words() const            { return object_space()->used_in_words(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  size_t free_in_words() const            { return object_space()->free_in_words(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Includes uncommitted memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  size_t contiguous_available() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  bool is_maximal_no_gc() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    return virtual_space()->uncommitted_size() == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // Calculating new sizes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  void resize(size_t desired_free_space);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Allocation. We report all successful allocations to the size policy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Note that the perm gen does not use this method, and should not!
9997
b75b7939f448 6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents: 9178
diff changeset
   167
  HeapWord* allocate(size_t word_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Iteration.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   170
  void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // Debugging - do not use for time critical operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual void print() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  void print_used_change(size_t prev_used) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9997
diff changeset
   178
  void verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  void verify_object_start_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // These should not used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  virtual void reset_after_change();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // These should not used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  virtual size_t available_for_expansion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  virtual size_t available_for_contraction();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  void space_invariants() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   190
  // Performance Counter support
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  void update_counters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Printing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  virtual const char* name() const { return _name; }
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   195
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   196
  // Debugging support
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   197
  // Save the tops of all spaces for later use during mangling.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 1
diff changeset
   198
  void record_spaces_top() PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   200
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   201
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP