hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp
author pliden
Mon, 13 Apr 2015 15:47:48 +0200
changeset 30173 13cf7580b000
parent 29798 451c73fdf690
permissions -rw-r--r--
8077413: Avoid use of Universe::heap() inside collectors Reviewed-by: stefank, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
     2
 * Copyright (c) 2001, 2015, 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
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "gc_implementation/shared/gcUtil.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "gc_implementation/shared/mutableNUMASpace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "gc_implementation/shared/spaceDecorator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "runtime/java.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
PSYoungGen::PSYoungGen(size_t        initial_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
                       size_t        min_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
                       size_t        max_size) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  _init_gen_size(initial_size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  _min_gen_size(min_size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _max_gen_size(max_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
{}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
void PSYoungGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  assert(_init_gen_size != 0, "Should have a finite size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  _virtual_space = new PSVirtualSpace(rs, alignment);
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    47
  if (!virtual_space()->expand_by(_init_gen_size)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    vm_exit_during_initialization("Could not reserve enough space for "
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                                  "object heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
void PSYoungGen::initialize(ReservedSpace rs, size_t alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  initialize_virtual_space(rs, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  initialize_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
void PSYoungGen::initialize_work() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    60
  _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    61
                        (HeapWord*)virtual_space()->high_boundary());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    62
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    63
  MemRegion cmr((HeapWord*)virtual_space()->low(),
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    64
                (HeapWord*)virtual_space()->high());
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
    65
  ParallelScavengeHeap::heap()->barrier_set()->resize_covered_region(cmr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    67
  if (ZapUnusedHeapArea) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    68
    // Mangle newly committed space immediately because it
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    69
    // can be done here more simply that after the new
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    70
    // spaces have been computed.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    71
    SpaceMangler::mangle_region(cmr);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
    72
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if (UseNUMA) {
1911
b7cfe7eb809c 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 977
diff changeset
    75
    _eden_space = new MutableNUMASpace(virtual_space()->alignment());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  } else {
1911
b7cfe7eb809c 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 977
diff changeset
    77
    _eden_space = new MutableSpace(virtual_space()->alignment());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  }
1911
b7cfe7eb809c 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 977
diff changeset
    79
  _from_space = new MutableSpace(virtual_space()->alignment());
b7cfe7eb809c 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 977
diff changeset
    80
  _to_space   = new MutableSpace(virtual_space()->alignment());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  if (_eden_space == NULL || _from_space == NULL || _to_space == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    vm_exit_during_initialization("Could not allocate a young gen space");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Allocate the mark sweep views of spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  _eden_mark_sweep =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      new PSMarkSweepDecorator(_eden_space, NULL, MarkSweepDeadRatio);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  _from_mark_sweep =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      new PSMarkSweepDecorator(_from_space, NULL, MarkSweepDeadRatio);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  _to_mark_sweep =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      new PSMarkSweepDecorator(_to_space, NULL, MarkSweepDeadRatio);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  if (_eden_mark_sweep == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      _from_mark_sweep == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      _to_mark_sweep == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    vm_exit_during_initialization("Could not complete allocation"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                                  " of the young generation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Generation Counters - generation 0, 3 subspaces
26324
6b9c12e15535 8028787: tmtools/jstat/gcoldcapacity/jstat_gcoldcapacity02 fails nsk.share.Failure: OGC < OGCMN in RT_Baseline
sjohanss
parents: 24424
diff changeset
   102
  _gen_counters = new PSGenerationCounters("new", 0, 3, _min_gen_size,
6b9c12e15535 8028787: tmtools/jstat/gcoldcapacity/jstat_gcoldcapacity02 fails nsk.share.Failure: OGC < OGCMN in RT_Baseline
sjohanss
parents: 24424
diff changeset
   103
                                           _max_gen_size, _virtual_space);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // Compute maximum space sizes for performance counters
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   106
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   107
  size_t alignment = heap->space_alignment();
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   108
  size_t size = virtual_space()->reserved_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  size_t max_survivor_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  size_t max_eden_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  if (UseAdaptiveSizePolicy) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    max_survivor_size = size / MinSurvivorRatio;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    // round the survivor space size down to the nearest alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    // and make sure its size is greater than 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    max_survivor_size = align_size_down(max_survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    max_survivor_size = MAX2(max_survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    // set the maximum size of eden to be the size of the young gen
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // less two times the minimum survivor size. The minimum survivor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    // size for UseAdaptiveSizePolicy is one alignment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    max_eden_size = size - 2 * alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    max_survivor_size = size / InitialSurvivorRatio;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    // round the survivor space size down to the nearest alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // and make sure its size is greater than 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    max_survivor_size = align_size_down(max_survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    max_survivor_size = MAX2(max_survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    // set the maximum size of eden to be the size of the young gen
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // less two times the survivor size when the generation is 100%
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // committed. The minimum survivor size for -UseAdaptiveSizePolicy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    // is dependent on the committed portion (current capacity) of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    // generation - the less space committed, the smaller the survivor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    // space, possibly as small as an alignment. However, we are interested
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    // in the case where the young generation is 100% committed, as this
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   140
    // is the point where eden reaches its maximum size. At this point,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    // the size of a survivor space is max_survivor_size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    max_eden_size = size - 2 * max_survivor_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  _eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
                                     _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  _from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                                     _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  _to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
                                   _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  compute_initial_space_boundaries();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
void PSYoungGen::compute_initial_space_boundaries() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   156
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // Compute sizes
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   159
  size_t alignment = heap->space_alignment();
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   160
  size_t size = virtual_space()->committed_size();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   161
  assert(size >= 3 * alignment, "Young space is not large enough for eden + 2 survivors");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  size_t survivor_size = size / InitialSurvivorRatio;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  survivor_size = align_size_down(survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // ... but never less than an alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  survivor_size = MAX2(survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Young generation is eden + 2 survivor spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  size_t eden_size = size - (2 * survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Now go ahead and set 'em.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  set_space_boundaries(eden_size, survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  space_invariants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    _eden_counters->update_capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    _from_counters->update_capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    _to_counters->update_capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
void PSYoungGen::set_space_boundaries(size_t eden_size, size_t survivor_size) {
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   183
  assert(eden_size < virtual_space()->committed_size(), "just checking");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  assert(eden_size > 0  && survivor_size > 0, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Initial layout is Eden, to, from. After swapping survivor spaces,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // that leaves us with Eden, from, to, which is step one in our two
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  // step resize-with-live-data procedure.
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   189
  char *eden_start = virtual_space()->low();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  char *to_start   = eden_start + eden_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  char *from_start = to_start   + survivor_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  char *from_end   = from_start + survivor_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   194
  assert(from_end == virtual_space()->high(), "just checking");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  assert(is_object_aligned((intptr_t)to_start),   "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  assert(is_object_aligned((intptr_t)from_start), "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  MemRegion eden_mr((HeapWord*)eden_start, (HeapWord*)to_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  MemRegion to_mr  ((HeapWord*)to_start, (HeapWord*)from_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  MemRegion from_mr((HeapWord*)from_start, (HeapWord*)from_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   203
  eden_space()->initialize(eden_mr, true, ZapUnusedHeapArea);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   204
    to_space()->initialize(to_mr  , true, ZapUnusedHeapArea);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   205
  from_space()->initialize(from_mr, true, ZapUnusedHeapArea);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
void PSYoungGen::space_invariants() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   210
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   211
  const size_t alignment = heap->space_alignment();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // Currently, our eden size cannot shrink to zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  guarantee(eden_space()->capacity_in_bytes() >= alignment, "eden too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  guarantee(from_space()->capacity_in_bytes() >= alignment, "from too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  guarantee(to_space()->capacity_in_bytes() >= alignment, "to too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // Relationship of spaces to each other
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  char* eden_start = (char*)eden_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  char* eden_end   = (char*)eden_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  char* from_start = (char*)from_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  char* from_end   = (char*)from_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  char* to_start   = (char*)to_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  char* to_end     = (char*)to_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   226
  guarantee(eden_start >= virtual_space()->low(), "eden bottom");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  guarantee(eden_start < eden_end, "eden space consistency");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  guarantee(from_start < from_end, "from space consistency");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  guarantee(to_start < to_end, "to space consistency");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Check whether from space is below to space
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  if (from_start < to_start) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    // Eden, from, to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    guarantee(eden_end <= from_start, "eden/from boundary");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    guarantee(from_end <= to_start,   "from/to boundary");
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   236
    guarantee(to_end <= virtual_space()->high(), "to end");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    // Eden, to, from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    guarantee(eden_end <= to_start, "eden/to boundary");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    guarantee(to_end <= from_start, "to/from boundary");
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   241
    guarantee(from_end <= virtual_space()->high(), "from end");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // More checks that the virtual space is consistent with the spaces
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   245
  assert(virtual_space()->committed_size() >=
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    (eden_space()->capacity_in_bytes() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
     to_space()->capacity_in_bytes() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
     from_space()->capacity_in_bytes()), "Committed size is inconsistent");
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   249
  assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    "Space invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  char* eden_top = (char*)eden_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  char* from_top = (char*)from_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  char* to_top = (char*)to_space()->top();
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   254
  assert(eden_top <= virtual_space()->high(), "eden top");
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   255
  assert(from_top <= virtual_space()->high(), "from top");
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   256
  assert(to_top <= virtual_space()->high(), "to top");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   258
  virtual_space()->verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
void PSYoungGen::resize(size_t eden_size, size_t survivor_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // Resize the generation if needed. If the generation resize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // reports false, do not attempt to resize the spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  if (resize_generation(eden_size, survivor_size)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    // Then we lay out the spaces inside the generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    resize_spaces(eden_size, survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    space_invariants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      gclog_or_tty->print_cr("Young generation size: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        _max_gen_size, min_gen_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   284
  const size_t alignment = virtual_space()->alignment();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   285
  size_t orig_size = virtual_space()->committed_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  bool size_changed = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // There used to be this guarantee there.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // guarantee ((eden_size + 2*survivor_size)  <= _max_gen_size, "incorrect input arguments");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // Code below forces this requirement.  In addition the desired eden
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   291
  // size and desired survivor sizes are desired goals and may
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // exceed the total generation size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // Adjust new generation size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  const size_t eden_plus_survivors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
          align_size_up(eden_size + 2 * survivor_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
                             min_gen_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  assert(desired_size <= max_size(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  if (desired_size > orig_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    // Grow the generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    size_t change = desired_size - orig_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    assert(change % alignment == 0, "just checking");
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   307
    HeapWord* prev_high = (HeapWord*) virtual_space()->high();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   308
    if (!virtual_space()->expand_by(change)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      return false; // Error if we fail to resize!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    }
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   311
    if (ZapUnusedHeapArea) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   312
      // Mangle newly committed space immediately because it
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   313
      // can be done here more simply that after the new
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   314
      // spaces have been computed.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   315
      HeapWord* new_high = (HeapWord*) virtual_space()->high();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   316
      MemRegion mangle_region(prev_high, new_high);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   317
      SpaceMangler::mangle_region(mangle_region);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   318
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    size_changed = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  } else if (desired_size < orig_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    size_t desired_change = orig_size - desired_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    assert(desired_change % alignment == 0, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    desired_change = limit_gen_shrink(desired_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    if (desired_change > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      virtual_space()->shrink_by(desired_change);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      reset_survivors_after_shrink();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      size_changed = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    if (Verbose && PrintGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      if (orig_size == gen_size_limit()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        gclog_or_tty->print_cr("PSYoung generation size at maximum: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
          SIZE_FORMAT "K", orig_size/K);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      } else if (orig_size == min_gen_size()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        gclog_or_tty->print_cr("PSYoung generation size at minium: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
          SIZE_FORMAT "K", orig_size/K);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  if (size_changed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    post_resize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    if (Verbose && PrintGC) {
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   348
      size_t current_size  = virtual_space()->committed_size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      gclog_or_tty->print_cr("PSYoung generation size changed: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
                             SIZE_FORMAT "K->" SIZE_FORMAT "K",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
                             orig_size/K, current_size/K);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   355
  guarantee(eden_plus_survivors <= virtual_space()->committed_size() ||
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   356
            virtual_space()->committed_size() == max_size(), "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   361
#ifndef PRODUCT
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   362
// In the numa case eden is not mangled so a survivor space
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   363
// moving into a region previously occupied by a survivor
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   364
// may find an unmangled region.  Also in the PS case eden
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   365
// to-space and from-space may not touch (i.e., there may be
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   366
// gaps between them due to movement while resizing the
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   367
// spaces).  Those gaps must be mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   368
void PSYoungGen::mangle_survivors(MutableSpace* s1,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   369
                                  MemRegion s1MR,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   370
                                  MutableSpace* s2,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   371
                                  MemRegion s2MR) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   372
  // Check eden and gap between eden and from-space, in deciding
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   373
  // what to mangle in from-space.  Check the gap between from-space
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   374
  // and to-space when deciding what to mangle.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   375
  //
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   376
  //      +--------+   +----+    +---+
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   377
  //      | eden   |   |s1  |    |s2 |
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   378
  //      +--------+   +----+    +---+
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   379
  //                 +-------+ +-----+
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   380
  //                 |s1MR   | |s2MR |
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   381
  //                 +-------+ +-----+
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   382
  // All of survivor-space is properly mangled so find the
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   383
  // upper bound on the mangling for any portion above current s1.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   384
  HeapWord* delta_end = MIN2(s1->bottom(), s1MR.end());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   385
  MemRegion delta1_left;
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   386
  if (s1MR.start() < delta_end) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   387
    delta1_left = MemRegion(s1MR.start(), delta_end);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   388
    s1->mangle_region(delta1_left);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   389
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   390
  // Find any portion to the right of the current s1.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   391
  HeapWord* delta_start = MAX2(s1->end(), s1MR.start());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   392
  MemRegion delta1_right;
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   393
  if (delta_start < s1MR.end()) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   394
    delta1_right = MemRegion(delta_start, s1MR.end());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   395
    s1->mangle_region(delta1_right);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   396
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   397
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   398
  // Similarly for the second survivor space except that
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   399
  // any of the new region that overlaps with the current
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   400
  // region of the first survivor space has already been
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   401
  // mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   402
  delta_end = MIN2(s2->bottom(), s2MR.end());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   403
  delta_start = MAX2(s2MR.start(), s1->end());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   404
  MemRegion delta2_left;
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   405
  if (s2MR.start() < delta_end) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   406
    delta2_left = MemRegion(s2MR.start(), delta_end);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   407
    s2->mangle_region(delta2_left);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   408
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   409
  delta_start = MAX2(s2->end(), s2MR.start());
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   410
  MemRegion delta2_right;
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   411
  if (delta_start < s2MR.end()) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   412
    s2->mangle_region(delta2_right);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   413
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   414
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   415
  if (TraceZapUnusedHeapArea) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   416
    // s1
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   417
    gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") "
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   418
      "New region: [" PTR_FORMAT ", " PTR_FORMAT ")",
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   419
      p2i(s1->bottom()), p2i(s1->end()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   420
      p2i(s1MR.start()), p2i(s1MR.end()));
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   421
    gclog_or_tty->print_cr("    Mangle before: [" PTR_FORMAT ", "
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   422
      PTR_FORMAT ")  Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")",
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   423
      p2i(delta1_left.start()), p2i(delta1_left.end()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   424
      p2i(delta1_right.start()), p2i(delta1_right.end()));
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   425
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   426
    // s2
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   427
    gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") "
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   428
      "New region: [" PTR_FORMAT ", " PTR_FORMAT ")",
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   429
      p2i(s2->bottom()), p2i(s2->end()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   430
      p2i(s2MR.start()), p2i(s2MR.end()));
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   431
    gclog_or_tty->print_cr("    Mangle before: [" PTR_FORMAT ", "
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   432
      PTR_FORMAT ")  Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")",
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   433
      p2i(delta2_left.start()), p2i(delta2_left.end()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   434
      p2i(delta2_right.start()), p2i(delta2_right.end()));
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   435
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   436
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   437
}
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   438
#endif // NOT PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
void PSYoungGen::resize_spaces(size_t requested_eden_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
                               size_t requested_survivor_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  assert(UseAdaptiveSizePolicy, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  assert(requested_eden_size > 0  && requested_survivor_size > 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
         "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // We require eden and to space to be empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
                  SIZE_FORMAT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
                  ", requested_survivor_size: " SIZE_FORMAT ")",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
                  requested_eden_size, requested_survivor_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    gclog_or_tty->print_cr("    eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
                  SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   458
                  p2i(eden_space()->bottom()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   459
                  p2i(eden_space()->end()),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
                  pointer_delta(eden_space()->end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
                                eden_space()->bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
                                sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    gclog_or_tty->print_cr("    from: [" PTR_FORMAT ".." PTR_FORMAT ") "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
                  SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   465
                  p2i(from_space()->bottom()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   466
                  p2i(from_space()->end()),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
                  pointer_delta(from_space()->end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
                                from_space()->bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
                                sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    gclog_or_tty->print_cr("      to: [" PTR_FORMAT ".." PTR_FORMAT ") "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
                  SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   472
                  p2i(to_space()->bottom()),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   473
                  p2i(to_space()->end()),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
                  pointer_delta(  to_space()->end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
                                  to_space()->bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
                                  sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  // There's nothing to do if the new sizes are the same as the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  if (requested_survivor_size == to_space()->capacity_in_bytes() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
      requested_survivor_size == from_space()->capacity_in_bytes() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
      requested_eden_size == eden_space()->capacity_in_bytes()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
      gclog_or_tty->print_cr("    capacities are the right sizes, returning");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  char* eden_start = (char*)eden_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  char* eden_end   = (char*)eden_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  char* from_start = (char*)from_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  char* from_end   = (char*)from_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  char* to_start   = (char*)to_space()->bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  char* to_end     = (char*)to_space()->end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   496
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   497
  const size_t alignment = heap->space_alignment();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  const bool maintain_minimum =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   501
  bool eden_from_to_order = from_start < to_start;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  // Check whether from space is below to space
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   503
  if (eden_from_to_order) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    // Eden, from, to
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   505
    eden_from_to_order = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      gclog_or_tty->print_cr("  Eden, from, to:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    // Set eden
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    // "requested_eden_size" is a goal for the size of eden
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    // and may not be attainable.  "eden_size" below is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    // calculated based on the location of from-space and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    // the goal for the size of eden.  from-space is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    // fixed in place because it contains live data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    // The calculation is done this way to avoid 32bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    // overflow (i.e., eden_start + requested_eden_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    // may too large for representation in 32bits).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    size_t eden_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    if (maintain_minimum) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      // Only make eden larger than the requested size if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      // the minimum size of the generation has to be maintained.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      // This could be done in general but policy at a higher
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      // level is determining a requested size for eden and that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      // should be honored unless there is a fundamental reason.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      eden_size = pointer_delta(from_start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
                                eden_start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
                                sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
      eden_size = MIN2(requested_eden_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
                       pointer_delta(from_start, eden_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    eden_end = eden_start + eden_size;
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 2105
diff changeset
   535
    assert(eden_end >= eden_start, "addition overflowed");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    // To may resize into from space as long as it is clear of live data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    // From space must remain page aligned, though, so we need to do some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    // extra calculations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    // First calculate an optimal to-space
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   542
    to_end   = (char*)virtual_space()->high();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
                                    sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    // Does the optimal to-space overlap from-space?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    if (to_start < (char*)from_space()->end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      // Calculate the minimum offset possible for from_end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
      size_t from_size = pointer_delta(from_space()->top(), from_start, sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
      // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
      if (from_size == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
        from_size = alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        from_size = align_size_up(from_size, alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
      from_end = from_start + from_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
      assert(from_end > from_start, "addition overflow or from_size problem");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
      guarantee(from_end <= (char*)from_space()->end(), "from_end moved to the right");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      // Now update to_start with the new from_end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
      to_start = MAX2(from_end, to_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    guarantee(to_start != to_end, "to space is zero sized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      gclog_or_tty->print_cr("    [eden_start .. eden_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   572
                    p2i(eden_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   573
                    p2i(eden_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
                    pointer_delta(eden_end, eden_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
      gclog_or_tty->print_cr("    [from_start .. from_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   577
                    p2i(from_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   578
                    p2i(from_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
                    pointer_delta(from_end, from_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      gclog_or_tty->print_cr("    [  to_start ..   to_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   582
                    p2i(to_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   583
                    p2i(to_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
                    pointer_delta(  to_end,   to_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    // Eden, to, from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
      gclog_or_tty->print_cr("  Eden, to, from:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    // To space gets priority over eden resizing. Note that we position
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    // to space as if we were able to resize from space, even though from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    // space is not modified.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    // Giving eden priority was tried and gave poorer performance.
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   596
    to_end   = (char*)pointer_delta(virtual_space()->high(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
                                    (char*)requested_survivor_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
                                    sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    to_end   = MIN2(to_end, from_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
                                    sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    // if the space sizes are to be increased by several times then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
    // 'to_start' will point beyond the young generation. In this case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
    // 'to_start' should be adjusted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    to_start = MAX2(to_start, eden_start + alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    // Compute how big eden can be, then adjust end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    // See  comments above on calculating eden_end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    size_t eden_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    if (maintain_minimum) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
      eden_size = pointer_delta(to_start, eden_start, sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
      eden_size = MIN2(requested_eden_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
                       pointer_delta(to_start, eden_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    eden_end = eden_start + eden_size;
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 2105
diff changeset
   617
    assert(eden_end >= eden_start, "addition overflowed");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    // Could choose to not let eden shrink
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    // to_start = MAX2(to_start, eden_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    // Don't let eden shrink down to 0 or less.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
    eden_end = MAX2(eden_end, eden_start + alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    to_start = MAX2(to_start, eden_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    if (PrintAdaptiveSizePolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      gclog_or_tty->print_cr("    [eden_start .. eden_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   629
                    p2i(eden_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   630
                    p2i(eden_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
                    pointer_delta(eden_end, eden_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
      gclog_or_tty->print_cr("    [  to_start ..   to_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   634
                    p2i(to_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   635
                    p2i(to_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
                    pointer_delta(  to_end,   to_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
      gclog_or_tty->print_cr("    [from_start .. from_end): "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
29798
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   639
                    p2i(from_start),
451c73fdf690 8076071: parallelScavenge: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 26324
diff changeset
   640
                    p2i(from_end),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
                    pointer_delta(from_end, from_start, sizeof(char)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  guarantee((HeapWord*)from_start <= from_space()->bottom(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
            "from start moved to the right");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  guarantee((HeapWord*)from_end >= from_space()->top(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
            "from end moved into live data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  assert(is_object_aligned((intptr_t)eden_start), "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  assert(is_object_aligned((intptr_t)from_start), "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  assert(is_object_aligned((intptr_t)to_start), "checking alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  MemRegion toMR  ((HeapWord*)to_start,   (HeapWord*)to_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  // Let's make sure the call to initialize doesn't reset "top"!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  HeapWord* old_from_top = from_space()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  // For PrintAdaptiveSizePolicy block  below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  size_t old_from = from_space()->capacity_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  size_t old_to   = to_space()->capacity_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   665
  if (ZapUnusedHeapArea) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   666
    // NUMA is a special case because a numa space is not mangled
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   667
    // in order to not prematurely bind its address to memory to
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   668
    // the wrong memory (i.e., don't want the GC thread to first
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   669
    // touch the memory).  The survivor spaces are not numa
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   670
    // spaces and are mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   671
    if (UseNUMA) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   672
      if (eden_from_to_order) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   673
        mangle_survivors(from_space(), fromMR, to_space(), toMR);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   674
      } else {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   675
        mangle_survivors(to_space(), toMR, from_space(), fromMR);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   676
      }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   677
    }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   678
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   679
    // If not mangling the spaces, do some checking to verify that
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   680
    // the spaces are already mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   681
    // The spaces should be correctly mangled at this point so
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   682
    // do some checking here. Note that they are not being mangled
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   683
    // in the calls to initialize().
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   684
    // Must check mangling before the spaces are reshaped.  Otherwise,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   685
    // the bottom or end of one space may have moved into an area
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   686
    // covered by another space and a failure of the check may
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   687
    // not correctly indicate which space is not properly mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   688
    HeapWord* limit = (HeapWord*) virtual_space()->high();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   689
    eden_space()->check_mangled_unused_area(limit);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   690
    from_space()->check_mangled_unused_area(limit);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   691
      to_space()->check_mangled_unused_area(limit);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   692
  }
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   693
  // When an existing space is being initialized, it is not
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   694
  // mangled because the space has been previously mangled.
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   695
  eden_space()->initialize(edenMR,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   696
                           SpaceDecorator::Clear,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   697
                           SpaceDecorator::DontMangle);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   698
    to_space()->initialize(toMR,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   699
                           SpaceDecorator::Clear,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   700
                           SpaceDecorator::DontMangle);
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   701
  from_space()->initialize(fromMR,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   702
                           SpaceDecorator::DontClear,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   703
                           SpaceDecorator::DontMangle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  assert(from_space()->top() == old_from_top, "from top changed!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  if (PrintAdaptiveSizePolicy) {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   708
    ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
                  "collection: %d "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
                  "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
                  "(" SIZE_FORMAT ", " SIZE_FORMAT ") ",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
                  heap->total_collections(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
                  old_from, old_to,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
                  from_space()->capacity_in_bytes(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
                  to_space()->capacity_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    gclog_or_tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
void PSYoungGen::swap_spaces() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  MutableSpace* s    = from_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  _from_space        = to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  _to_space          = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  // Now update the decorators.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  PSMarkSweepDecorator* md = from_mark_sweep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  _from_mark_sweep           = to_mark_sweep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  _to_mark_sweep             = md;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  assert(from_mark_sweep()->space() == from_space(), "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  assert(to_mark_sweep()->space() == to_space(), "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
size_t PSYoungGen::capacity_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  return eden_space()->capacity_in_bytes()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
       + from_space()->capacity_in_bytes();  // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
size_t PSYoungGen::used_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  return eden_space()->used_in_bytes()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
       + from_space()->used_in_bytes();      // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
size_t PSYoungGen::free_in_bytes() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  return eden_space()->free_in_bytes()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
       + from_space()->free_in_bytes();      // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
size_t PSYoungGen::capacity_in_words() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  return eden_space()->capacity_in_words()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
       + from_space()->capacity_in_words();  // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
size_t PSYoungGen::used_in_words() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  return eden_space()->used_in_words()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
       + from_space()->used_in_words();      // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
size_t PSYoungGen::free_in_words() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  return eden_space()->free_in_words()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
       + from_space()->free_in_words();      // to_space() is only used during scavenge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
void PSYoungGen::object_iterate(ObjectClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  eden_space()->object_iterate(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
  from_space()->object_iterate(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  to_space()->object_iterate(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
void PSYoungGen::precompact() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  eden_mark_sweep()->precompact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  from_mark_sweep()->precompact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  to_mark_sweep()->precompact();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
void PSYoungGen::adjust_pointers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  eden_mark_sweep()->adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  from_mark_sweep()->adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  to_mark_sweep()->adjust_pointers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
void PSYoungGen::compact() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  eden_mark_sweep()->compact(ZapUnusedHeapArea);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  from_mark_sweep()->compact(ZapUnusedHeapArea);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  // Mark sweep stores preserved markOops in to space, don't disturb!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  to_mark_sweep()->compact(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
void PSYoungGen::print() const { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
void PSYoungGen::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  st->print(" %-15s", "PSYoungGen");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  if (PrintGCDetails && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    st->print(" total " SIZE_FORMAT ", used " SIZE_FORMAT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
               capacity_in_bytes(), used_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
               capacity_in_bytes()/K, used_in_bytes()/K);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  }
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   804
  virtual_space()->print_space_boundaries_on(st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  st->print("  eden"); eden_space()->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  st->print("  from"); from_space()->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  st->print("  to  "); to_space()->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
15095
8ce5dcdbeb26 8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents: 12379
diff changeset
   810
// Note that a space is not printed before the [NAME:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
void PSYoungGen::print_used_change(size_t prev_used) const {
15095
8ce5dcdbeb26 8005672: Clean up some changes to GC logging with GCCause's
jmasa
parents: 12379
diff changeset
   812
  gclog_or_tty->print("[%s:", name());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  gclog_or_tty->print(" "  SIZE_FORMAT "K"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
                      "->" SIZE_FORMAT "K"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
                      "("  SIZE_FORMAT "K)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
                      prev_used / K, used_in_bytes() / K,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
                      capacity_in_bytes() / K);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  gclog_or_tty->print("]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
size_t PSYoungGen::available_for_expansion() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
size_t PSYoungGen::available_for_contraction() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
size_t PSYoungGen::available_to_min_gen() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  assert(virtual_space()->committed_size() >= min_gen_size(), "Invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  return virtual_space()->committed_size() - min_gen_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
// This method assumes that from-space has live data and that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
// any shrinkage of the young gen is limited by location of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
// from-space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
size_t PSYoungGen::available_to_live() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  size_t delta_in_survivor = 0;
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   841
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   842
  const size_t space_alignment = heap->space_alignment();
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents: 15095
diff changeset
   843
  const size_t gen_alignment = heap->generation_alignment();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  MutableSpace* space_shrinking = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  if (from_space()->end() > to_space()->end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    space_shrinking = from_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
    space_shrinking = to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  // Include any space that is committed but not included in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  // the survivor spaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  assert(((HeapWord*)virtual_space()->high()) >= space_shrinking->end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    "Survivor space beyond high end");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  size_t unused_committed = pointer_delta(virtual_space()->high(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    space_shrinking->end(), sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  if (space_shrinking->is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    // Don't let the space shrink to 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
    assert(space_shrinking->capacity_in_bytes() >= space_alignment,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
      "Space is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
    delta_in_survivor = space_shrinking->capacity_in_bytes() - space_alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
    delta_in_survivor = pointer_delta(space_shrinking->end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
                                      space_shrinking->top(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
                                      sizeof(char));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  size_t delta_in_bytes = unused_committed + delta_in_survivor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  return delta_in_bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
// Return the number of bytes available for resizing down the young
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
// generation.  This is the minimum of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
//      input "bytes"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
//      bytes to the minimum young gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
//      bytes to the size currently being used + some small extra
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
size_t PSYoungGen::limit_gen_shrink(size_t bytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  // Allow shrinkage into the current eden but keep eden large enough
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  // to maintain the minimum young gen size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  bytes = MIN3(bytes, available_to_min_gen(), available_to_live());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  return align_size_down(bytes, virtual_space()->alignment());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
void PSYoungGen::reset_after_change() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
void PSYoungGen::reset_survivors_after_shrink() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
                        (HeapWord*)virtual_space()->high_boundary());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  PSScavenge::reference_processor()->set_span(_reserved);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  MutableSpace* space_shrinking = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  if (from_space()->end() > to_space()->end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    space_shrinking = from_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
    space_shrinking = to_space();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  HeapWord* new_end = (HeapWord*)virtual_space()->high();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  assert(new_end >= space_shrinking->bottom(), "Shrink was too large");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  // Was there a shrink of the survivor space?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  if (new_end < space_shrinking->end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    MemRegion mr(space_shrinking->bottom(), new_end);
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   908
    space_shrinking->initialize(mr,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   909
                                SpaceDecorator::DontClear,
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   910
                                SpaceDecorator::Mangle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
// This method currently does not expect to expand into eden (i.e.,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
// the virtual space boundaries is expected to be consistent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
// with the eden boundaries..
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
void PSYoungGen::post_resize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  assert_locked_or_safepoint(Heap_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  assert((eden_space()->bottom() < to_space()->bottom()) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
         (eden_space()->bottom() < from_space()->bottom()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
         "Eden is assumed to be below the survivor spaces");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  MemRegion cmr((HeapWord*)virtual_space()->low(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
                (HeapWord*)virtual_space()->high());
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29798
diff changeset
   925
  ParallelScavengeHeap::heap()->barrier_set()->resize_covered_region(cmr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  space_invariants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
void PSYoungGen::update_counters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
    _eden_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
    _from_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    _to_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
    _gen_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9178
diff changeset
   940
void PSYoungGen::verify() {
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9178
diff changeset
   941
  eden_space()->verify();
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9178
diff changeset
   942
  from_space()->verify();
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 9178
diff changeset
   943
  to_space()->verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
}
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   945
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   946
#ifndef PRODUCT
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   947
void PSYoungGen::record_spaces_top() {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   948
  assert(ZapUnusedHeapArea, "Not mangling unused space");
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   949
  eden_space()->set_top_for_allocations();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   950
  from_space()->set_top_for_allocations();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   951
  to_space()->set_top_for_allocations();
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   952
}
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 186
diff changeset
   953
#endif