hotspot/src/share/vm/memory/tenuredGeneration.cpp
author brutisso
Wed, 10 Dec 2014 11:31:43 +0100
changeset 28032 195f814dfa62
parent 27904 d606512952cc
child 28033 ab63acbd99ec
permissions -rw-r--r--
8066781: Minor cleanups to TenuredGeneration Reviewed-by: kbarrett, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 16681
diff changeset
     2
 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
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: 2105
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: 6985
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    26
#include "gc_implementation/shared/collectorCounters.hpp"
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
    27
#include "gc_implementation/shared/gcTimer.hpp"
13466
9fdf353d5f4c 6818524: G1: use ergonomic resizing of PLABs
johnc
parents: 13195
diff changeset
    28
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    29
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    30
#include "memory/blockOffsetTable.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    31
#include "memory/generationSpec.hpp"
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
    32
#include "memory/genMarkSweep.hpp"
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
    33
#include "memory/genOopClosures.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    34
#include "memory/space.hpp"
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
    35
#include "memory/tenuredGeneration.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    36
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    37
#include "runtime/java.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15091
diff changeset
    38
#include "utilities/macros.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
TenuredGeneration::TenuredGeneration(ReservedSpace rs,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                                     size_t initial_byte_size, int level,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
                                     GenRemSet* remset) :
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
    43
  CardGeneration(rs, initial_byte_size, level, remset)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  HeapWord* bottom = (HeapWord*) _virtual_space.low();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  HeapWord* end    = (HeapWord*) _virtual_space.high();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  _the_space  = new TenuredSpace(_bts, MemRegion(bottom, end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  _the_space->reset_saved_mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  _shrink_factor = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  _capacity_at_prologue = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  _gc_stats = new GCStats();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // initialize performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  const char* gen_name = "old";
26324
6b9c12e15535 8028787: tmtools/jstat/gcoldcapacity/jstat_gcoldcapacity02 fails nsk.share.Failure: OGC < OGCMN in RT_Baseline
sjohanss
parents: 22551
diff changeset
    57
  GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Generation Counters -- generation 1, 1 subspace
26324
6b9c12e15535 8028787: tmtools/jstat/gcoldcapacity/jstat_gcoldcapacity02 fails nsk.share.Failure: OGC < OGCMN in RT_Baseline
sjohanss
parents: 22551
diff changeset
    60
  _gen_counters = new GenerationCounters(gen_name, 1, 1,
6b9c12e15535 8028787: tmtools/jstat/gcoldcapacity/jstat_gcoldcapacity02 fails nsk.share.Failure: OGC < OGCMN in RT_Baseline
sjohanss
parents: 22551
diff changeset
    61
      gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _gc_counters = new CollectorCounters("MSC", 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  _space_counters = new CSpaceCounters(gen_name, 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
                                       _virtual_space.reserved_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
                                       _the_space, _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
void TenuredGeneration::gc_prologue(bool full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  _capacity_at_prologue = capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  _used_at_prologue = used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
bool TenuredGeneration::should_collect(bool  full,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                                       size_t size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
                                       bool   is_tlab) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // This should be one big conditional or (||), but I want to be able to tell
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // why it returns what it returns (without re-evaluating the conditionals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // in case they aren't idempotent), so I'm doing it this way.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // DeMorgan says it's okay.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool result = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  if (!result && full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    if (PrintGC && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      gclog_or_tty->print_cr("TenuredGeneration::should_collect: because"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
                    " full");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  if (!result && should_allocate(size, is_tlab)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    if (PrintGC && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      gclog_or_tty->print_cr("TenuredGeneration::should_collect: because"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                    " should_allocate(" SIZE_FORMAT ")",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                    size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // If we don't have very much free space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // XXX: 10000 should be a percentage of the capacity!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  if (!result && free() < 10000) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    if (PrintGC && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      gclog_or_tty->print_cr("TenuredGeneration::should_collect: because"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                    " free(): " SIZE_FORMAT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                    free());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   108
  // If we had to expand to accommodate promotions from younger generations
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  if (!result && _capacity_at_prologue < capacity()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    if (PrintGC && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      gclog_or_tty->print_cr("TenuredGeneration::should_collect: because"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
                    "_capacity_at_prologue: " SIZE_FORMAT " < capacity(): " SIZE_FORMAT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
                    _capacity_at_prologue, capacity());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   120
void TenuredGeneration::compute_new_size() {
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   121
  assert_locked_or_safepoint(Heap_lock);
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   122
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   123
  // Compute some numbers about the state of the heap.
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   124
  const size_t used_after_gc = used();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   125
  const size_t capacity_after_gc = capacity();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   126
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   127
  CardGeneration::compute_new_size();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   128
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   129
  assert(used() == used_after_gc && used_after_gc <= capacity(),
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   130
         err_msg("used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   131
         " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()));
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   132
}
27898
813ad96387b3 8065972: Remove support for ParNew+SerialOld and DefNew+CMS
brutisso
parents: 26324
diff changeset
   133
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
void TenuredGeneration::update_gc_stats(int current_level,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
                                        bool full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // If the next lower level(s) has been collected, gather any statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // that are of interest at this point.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  if (!full && (current_level + 1) == level()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    // Calculate size of data promoted from the younger generations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    // before doing the collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    size_t used_before_gc = used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    // If the younger gen collections were skipped, then the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    // number of promoted bytes will be 0 and adding it to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    // average will incorrectly lessen the average.  It is, however,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    // also possible that no promotion was needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    if (used_before_gc >= _used_at_prologue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      size_t promoted_in_bytes = used_before_gc - _used_at_prologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      gc_stats()->avg_promoted()->sample(promoted_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
void TenuredGeneration::update_counters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    _space_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    _gen_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
6985
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   161
bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   162
  size_t available = max_contiguous_available();
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   163
  size_t av_promo  = (size_t)gc_stats()->avg_promoted()->padded_average();
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   164
  bool   res = (available >= av_promo) || (available >= max_promotion_in_bytes);
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   165
  if (PrintGC && Verbose) {
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   166
    gclog_or_tty->print_cr(
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   167
      "Tenured: promo attempt is%s safe: available("SIZE_FORMAT") %s av_promo("SIZE_FORMAT"),"
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   168
      "max_promo("SIZE_FORMAT")",
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   169
      res? "":" not", available, res? ">=":"<",
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   170
      av_promo, max_promotion_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  }
6985
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   172
  return res;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   174
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   175
void TenuredGeneration::collect(bool   full,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   176
                                bool   clear_all_soft_refs,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   177
                                size_t size,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   178
                                bool   is_tlab) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   179
  GenCollectedHeap* gch = GenCollectedHeap::heap();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   180
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   181
  SpecializationStats::clear();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   182
  // Temporarily expand the span of our ref processor, so
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   183
  // refs discovery is over the entire heap, not just this generation
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   184
  ReferenceProcessorSpanMutator
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   185
    x(ref_processor(), gch->reserved_region());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   186
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   187
  STWGCTimer* gc_timer = GenMarkSweep::gc_timer();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   188
  gc_timer->register_gc_start();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   189
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   190
  SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   191
  gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   192
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   193
  GenMarkSweep::invoke_at_safepoint(_level, ref_processor(), clear_all_soft_refs);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   194
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   195
  gc_timer->register_gc_end();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   196
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   197
  gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   198
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   199
  SpecializationStats::print();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   200
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   201
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   202
HeapWord*
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   203
TenuredGeneration::expand_and_allocate(size_t word_size,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   204
                                       bool is_tlab,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   205
                                       bool parallel) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   206
  assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   207
  if (parallel) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   208
    MutexLocker x(ParGCRareEvent_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   209
    HeapWord* result = NULL;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   210
    size_t byte_size = word_size * HeapWordSize;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   211
    while (true) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   212
      expand(byte_size, _min_heap_delta_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   213
      if (GCExpandToAllocateDelayMillis > 0) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   214
        os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   215
      }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   216
      result = _the_space->par_allocate(word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   217
      if ( result != NULL) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   218
        return result;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   219
      } else {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   220
        // If there's not enough expansion space available, give up.
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   221
        if (_virtual_space.uncommitted_size() < byte_size) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   222
          return NULL;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   223
        }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   224
        // else try again
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   225
      }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   226
    }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   227
  } else {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   228
    expand(word_size*HeapWordSize, _min_heap_delta_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   229
    return _the_space->allocate(word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   230
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   231
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   232
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   233
bool TenuredGeneration::expand(size_t bytes, size_t expand_bytes) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   234
  GCMutexLocker x(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   235
  return CardGeneration::expand(bytes, expand_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   236
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   237
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   238
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   239
void TenuredGeneration::shrink(size_t bytes) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   240
  assert_locked_or_safepoint(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   241
  size_t size = ReservedSpace::page_align_size_down(bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   242
  if (size > 0) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   243
    shrink_by(size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   244
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   245
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   246
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   247
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   248
size_t TenuredGeneration::capacity() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   249
  return _the_space->capacity();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   250
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   251
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   252
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   253
size_t TenuredGeneration::used() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   254
  return _the_space->used();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   255
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   256
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   257
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   258
size_t TenuredGeneration::free() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   259
  return _the_space->free();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   260
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   261
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   262
MemRegion TenuredGeneration::used_region() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   263
  return the_space()->used_region();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   264
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   265
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   266
size_t TenuredGeneration::unsafe_max_alloc_nogc() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   267
  return _the_space->free();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   268
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   269
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   270
size_t TenuredGeneration::contiguous_available() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   271
  return _the_space->free() + _virtual_space.uncommitted_size();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   272
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   273
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   274
bool TenuredGeneration::grow_by(size_t bytes) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   275
  assert_locked_or_safepoint(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   276
  bool result = _virtual_space.expand_by(bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   277
  if (result) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   278
    size_t new_word_size =
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   279
       heap_word_size(_virtual_space.committed_size());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   280
    MemRegion mr(_the_space->bottom(), new_word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   281
    // Expand card table
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   282
    Universe::heap()->barrier_set()->resize_covered_region(mr);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   283
    // Expand shared block offset array
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   284
    _bts->resize(new_word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   285
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   286
    // Fix for bug #4668531
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   287
    if (ZapUnusedHeapArea) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   288
      MemRegion mangle_region(_the_space->end(),
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   289
      (HeapWord*)_virtual_space.high());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   290
      SpaceMangler::mangle_region(mangle_region);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   291
    }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   292
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   293
    // Expand space -- also expands space's BOT
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   294
    // (which uses (part of) shared array above)
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   295
    _the_space->set_end((HeapWord*)_virtual_space.high());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   296
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   297
    // update the space and generation capacity counters
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   298
    update_counters();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   299
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   300
    if (Verbose && PrintGC) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   301
      size_t new_mem_size = _virtual_space.committed_size();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   302
      size_t old_mem_size = new_mem_size - bytes;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   303
      gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by "
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   304
                      SIZE_FORMAT "K to " SIZE_FORMAT "K",
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   305
                      name(), old_mem_size/K, bytes/K, new_mem_size/K);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   306
    }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   307
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   308
  return result;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   309
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   310
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   311
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   312
bool TenuredGeneration::grow_to_reserved() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   313
  assert_locked_or_safepoint(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   314
  bool success = true;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   315
  const size_t remaining_bytes = _virtual_space.uncommitted_size();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   316
  if (remaining_bytes > 0) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   317
    success = grow_by(remaining_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   318
    DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   319
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   320
  return success;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   321
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   322
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   323
void TenuredGeneration::shrink_by(size_t bytes) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   324
  assert_locked_or_safepoint(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   325
  // Shrink committed space
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   326
  _virtual_space.shrink_by(bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   327
  // Shrink space; this also shrinks the space's BOT
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   328
  _the_space->set_end((HeapWord*) _virtual_space.high());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   329
  size_t new_word_size = heap_word_size(_the_space->capacity());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   330
  // Shrink the shared block offset array
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   331
  _bts->resize(new_word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   332
  MemRegion mr(_the_space->bottom(), new_word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   333
  // Shrink the card table
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   334
  Universe::heap()->barrier_set()->resize_covered_region(mr);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   335
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   336
  if (Verbose && PrintGC) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   337
    size_t new_mem_size = _virtual_space.committed_size();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   338
    size_t old_mem_size = new_mem_size + bytes;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   339
    gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   340
                  name(), old_mem_size/K, new_mem_size/K);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   341
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   342
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   343
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   344
// Currently nothing to do.
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   345
void TenuredGeneration::prepare_for_verify() {}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   346
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   347
void TenuredGeneration::object_iterate(ObjectClosure* blk) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   348
  _the_space->object_iterate(blk);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   349
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   350
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   351
void TenuredGeneration::space_iterate(SpaceClosure* blk,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   352
                                                 bool usedOnly) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   353
  blk->do_space(_the_space);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   354
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   355
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   356
void TenuredGeneration::younger_refs_iterate(OopsInGenClosure* blk) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   357
  blk->set_generation(this);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   358
  younger_refs_in_space_iterate(_the_space, blk);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   359
  blk->reset_generation();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   360
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   361
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   362
void TenuredGeneration::save_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   363
  _the_space->set_saved_mark();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   364
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   365
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   366
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   367
void TenuredGeneration::reset_saved_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   368
  _the_space->reset_saved_mark();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   369
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   370
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   371
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   372
bool TenuredGeneration::no_allocs_since_save_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   373
  return _the_space->saved_mark_at_top();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   374
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   375
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   376
#define TenuredGen_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix)     \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   377
                                                                                \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   378
void TenuredGeneration::                                                        \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   379
oop_since_save_marks_iterate##nv_suffix(OopClosureType* blk) {                  \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   380
  blk->set_generation(this);                                                    \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   381
  _the_space->oop_since_save_marks_iterate##nv_suffix(blk);                     \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   382
  blk->reset_generation();                                                      \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   383
  save_marks();                                                                 \
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   384
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   385
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   386
ALL_SINCE_SAVE_MARKS_CLOSURES(TenuredGen_SINCE_SAVE_MARKS_ITERATE_DEFN)
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   387
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   388
#undef TenuredGen_SINCE_SAVE_MARKS_ITERATE_DEFN
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   389
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   390
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   391
void TenuredGeneration::gc_epilogue(bool full) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   392
  // update the generation and space performance counters
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   393
  update_counters();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   394
  if (ZapUnusedHeapArea) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   395
    the_space()->check_mangled_unused_area_complete();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   396
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   397
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   398
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   399
void TenuredGeneration::record_spaces_top() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   400
  assert(ZapUnusedHeapArea, "Not mangling unused space");
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   401
  the_space()->set_top_for_allocations();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   402
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   403
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   404
void TenuredGeneration::verify() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   405
  the_space()->verify();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   406
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   407
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   408
void TenuredGeneration::print_on(outputStream* st)  const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   409
  Generation::print_on(st);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   410
  st->print("   the");
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   411
  the_space()->print_on(st);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   412
}