src/hotspot/share/gc/serial/tenuredGeneration.cpp
author stefank
Mon, 07 May 2018 14:42:08 +0200
changeset 50034 01a88f825a84
parent 49982 9042ffe5b7fe
child 53726 5ef581e59d91
permissions -rw-r--r--
8202641: Replace OOP_SINCE_SAVE_MARKS with templates Reviewed-by: eosterlund, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
28938
11510c618fc7 8072056: Remove unnecessary header file #include
tschatzl
parents: 28220
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: 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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    26
#include "gc/serial/genMarkSweep.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    27
#include "gc/serial/tenuredGeneration.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    28
#include "gc/shared/blockOffsetTable.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    29
#include "gc/shared/cardGeneration.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    30
#include "gc/shared/collectorCounters.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    31
#include "gc/shared/gcTimer.hpp"
46564
0ec329b23bbf 8182696: Remove gcTrace.hpp include from referenceProcessor.hpp
stefank
parents: 35939
diff changeset
    32
#include "gc/shared/gcTrace.hpp"
49734
f946776e9354 8201244: Clean out unnecessary includes of heap headers
stefank
parents: 47216
diff changeset
    33
#include "gc/shared/genCollectedHeap.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    34
#include "gc/shared/genOopClosures.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    35
#include "gc/shared/generationSpec.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    36
#include "gc/shared/space.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    37
#include "logging/log.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    38
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    39
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6985
diff changeset
    40
#include "runtime/java.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15091
diff changeset
    41
#include "utilities/macros.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49734
diff changeset
    42
#if INCLUDE_CMSGC
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    43
#include "gc/cms/parOopClosures.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29687
diff changeset
    44
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
TenuredGeneration::TenuredGeneration(ReservedSpace rs,
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
    47
                                     size_t initial_byte_size,
33212
906b3d079b13 8139434: Unify GenRemSet and CardTableRS
david
parents: 33105
diff changeset
    48
                                     CardTableRS* remset) :
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
    49
  CardGeneration(rs, initial_byte_size, remset)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  HeapWord* bottom = (HeapWord*) _virtual_space.low();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  HeapWord* end    = (HeapWord*) _virtual_space.high();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  _the_space  = new TenuredSpace(_bts, MemRegion(bottom, end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _the_space->reset_saved_mark();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  _shrink_factor = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  _capacity_at_prologue = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  _gc_stats = new GCStats();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // initialize performance counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  const char* gen_name = "old";
32735
c6063d028c3c 8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents: 32623
diff changeset
    63
  GenCollectorPolicy* gcp = GenCollectedHeap::heap()->gen_policy();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // 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
    65
  _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
    66
      gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  _gc_counters = new CollectorCounters("MSC", 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  _space_counters = new CSpaceCounters(gen_name, 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
                                       _virtual_space.reserved_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
                                       _the_space, _gen_counters);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
void TenuredGeneration::gc_prologue(bool full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  _capacity_at_prologue = capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  _used_at_prologue = used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
bool TenuredGeneration::should_collect(bool  full,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
                                       size_t size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
                                       bool   is_tlab) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // This should be one big conditional or (||), but I want to be able to tell
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // why it returns what it returns (without re-evaluating the conditionals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // in case they aren't idempotent), so I'm doing it this way.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // DeMorgan says it's okay.
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    87
  if (full) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    88
    log_trace(gc)("TenuredGeneration::should_collect: because full");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    89
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    91
  if (should_allocate(size, is_tlab)) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    92
    log_trace(gc)("TenuredGeneration::should_collect: because should_allocate(" SIZE_FORMAT ")", size);
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    93
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // If we don't have very much free space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // XXX: 10000 should be a percentage of the capacity!!!
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    97
  if (free() < 10000) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    98
    log_trace(gc)("TenuredGeneration::should_collect: because free(): " SIZE_FORMAT, free());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
    99
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31592
diff changeset
   101
  // If we had to expand to accommodate promotions from the young generation
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   102
  if (_capacity_at_prologue < capacity()) {
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   103
    log_trace(gc)("TenuredGeneration::should_collect: because_capacity_at_prologue: " SIZE_FORMAT " < capacity(): " SIZE_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   104
        _capacity_at_prologue, capacity());
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   105
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   107
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   108
  return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   111
void TenuredGeneration::compute_new_size() {
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   112
  assert_locked_or_safepoint(Heap_lock);
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   113
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   114
  // 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
   115
  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
   116
  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
   117
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   118
  CardGeneration::compute_new_size();
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   119
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   120
  assert(used() == used_after_gc && used_after_gc <= capacity(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32735
diff changeset
   121
         "used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32735
diff changeset
   122
         " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity());
16681
d64161ca3e3c 8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents: 15482
diff changeset
   123
}
27898
813ad96387b3 8065972: Remove support for ParNew+SerialOld and DefNew+CMS
brutisso
parents: 26324
diff changeset
   124
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
   125
void TenuredGeneration::update_gc_stats(Generation* current_generation,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
                                        bool full) {
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
   127
  // If the young generation has been collected, gather any statistics
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // that are of interest at this point.
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
   129
  bool current_is_young = GenCollectedHeap::heap()->is_young_gen(current_generation);
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
   130
  if (!full && current_is_young) {
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31592
diff changeset
   131
    // Calculate size of data promoted from the young generation
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    // before doing the collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    size_t used_before_gc = used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31592
diff changeset
   135
    // If the young gen collection was skipped, then the
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    // number of promoted bytes will be 0 and adding it to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    // average will incorrectly lessen the average.  It is, however,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    // also possible that no promotion was needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    if (used_before_gc >= _used_at_prologue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      size_t promoted_in_bytes = used_before_gc - _used_at_prologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      gc_stats()->avg_promoted()->sample(promoted_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
void TenuredGeneration::update_counters() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    _space_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    _gen_counters->update_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
6985
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   153
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
   154
  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
   155
  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
   156
  bool   res = (available >= av_promo) || (available >= max_promotion_in_bytes);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   157
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   158
  log_trace(gc)("Tenured: promo attempt is%s safe: available(" SIZE_FORMAT ") %s av_promo(" SIZE_FORMAT "), max_promo(" SIZE_FORMAT ")",
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   159
    res? "":" not", available, res? ">=":"<", av_promo, max_promotion_in_bytes);
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33212
diff changeset
   160
6985
e9364ec299ac 6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents: 5547
diff changeset
   161
  return res;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
}
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   163
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   164
void TenuredGeneration::collect(bool   full,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   165
                                bool   clear_all_soft_refs,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   166
                                size_t size,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   167
                                bool   is_tlab) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   168
  GenCollectedHeap* gch = GenCollectedHeap::heap();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   169
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   170
  // Temporarily expand the span of our ref processor, so
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   171
  // refs discovery is over the entire heap, not just this generation
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   172
  ReferenceProcessorSpanMutator
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   173
    x(ref_processor(), gch->reserved_region());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   174
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   175
  STWGCTimer* gc_timer = GenMarkSweep::gc_timer();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   176
  gc_timer->register_gc_start();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   177
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   178
  SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   179
  gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   180
35939
05df7e64ecfc 8149035: Make the full_gc_dump() calls be recorded as part of the GC
brutisso
parents: 35061
diff changeset
   181
  gch->pre_full_gc_dump(gc_timer);
05df7e64ecfc 8149035: Make the full_gc_dump() calls be recorded as part of the GC
brutisso
parents: 35061
diff changeset
   182
31358
693058672cc6 8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents: 30764
diff changeset
   183
  GenMarkSweep::invoke_at_safepoint(ref_processor(), clear_all_soft_refs);
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   184
35939
05df7e64ecfc 8149035: Make the full_gc_dump() calls be recorded as part of the GC
brutisso
parents: 35061
diff changeset
   185
  gch->post_full_gc_dump(gc_timer);
05df7e64ecfc 8149035: Make the full_gc_dump() calls be recorded as part of the GC
brutisso
parents: 35061
diff changeset
   186
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   187
  gc_timer->register_gc_end();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   188
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   189
  gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions());
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   190
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   191
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   192
HeapWord*
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   193
TenuredGeneration::expand_and_allocate(size_t word_size,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   194
                                       bool is_tlab,
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   195
                                       bool parallel) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   196
  assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   197
  if (parallel) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   198
    MutexLocker x(ParGCRareEvent_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   199
    HeapWord* result = NULL;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   200
    size_t byte_size = word_size * HeapWordSize;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   201
    while (true) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   202
      expand(byte_size, _min_heap_delta_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   203
      if (GCExpandToAllocateDelayMillis > 0) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   204
        os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   205
      }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   206
      result = _the_space->par_allocate(word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   207
      if ( result != NULL) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   208
        return result;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   209
      } else {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   210
        // If there's not enough expansion space available, give up.
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   211
        if (_virtual_space.uncommitted_size() < byte_size) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   212
          return NULL;
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   213
        }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   214
        // else try again
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   215
      }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   216
    }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   217
  } else {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   218
    expand(word_size*HeapWordSize, _min_heap_delta_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   219
    return _the_space->allocate(word_size);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   220
  }
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   221
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   222
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   223
bool TenuredGeneration::expand(size_t bytes, size_t expand_bytes) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   224
  GCMutexLocker x(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   225
  return CardGeneration::expand(bytes, expand_bytes);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   226
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   227
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   228
size_t TenuredGeneration::unsafe_max_alloc_nogc() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   229
  return _the_space->free();
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
size_t TenuredGeneration::contiguous_available() const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   233
  return _the_space->free() + _virtual_space.uncommitted_size();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   234
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   235
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28032
diff changeset
   236
void TenuredGeneration::assert_correct_size_change_locking() {
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   237
  assert_locked_or_safepoint(ExpandHeap_lock);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   238
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   239
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   240
// Currently nothing to do.
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   241
void TenuredGeneration::prepare_for_verify() {}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   242
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   243
void TenuredGeneration::object_iterate(ObjectClosure* blk) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   244
  _the_space->object_iterate(blk);
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
void TenuredGeneration::save_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   248
  _the_space->set_saved_mark();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   249
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   250
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   251
void TenuredGeneration::reset_saved_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   252
  _the_space->reset_saved_mark();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   253
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   254
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   255
bool TenuredGeneration::no_allocs_since_save_marks() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   256
  return _the_space->saved_mark_at_top();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   257
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   258
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   259
void TenuredGeneration::gc_epilogue(bool full) {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   260
  // update the generation and space performance counters
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   261
  update_counters();
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   262
  if (ZapUnusedHeapArea) {
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28032
diff changeset
   263
    _the_space->check_mangled_unused_area_complete();
27904
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
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   267
void TenuredGeneration::record_spaces_top() {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   268
  assert(ZapUnusedHeapArea, "Not mangling unused space");
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28032
diff changeset
   269
  _the_space->set_top_for_allocations();
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   270
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   271
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   272
void TenuredGeneration::verify() {
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28032
diff changeset
   273
  _the_space->verify();
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   274
}
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   275
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   276
void TenuredGeneration::print_on(outputStream* st)  const {
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   277
  Generation::print_on(st);
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   278
  st->print("   the");
28033
ab63acbd99ec 8066782: Move common code from CMSGeneration and TenuredGeneration to CardGeneration
brutisso
parents: 28032
diff changeset
   279
  _the_space->print_on(st);
27904
d606512952cc 8065993: Merge OneContigSpaceCardGeneration with TenuredGeneration
brutisso
parents: 27898
diff changeset
   280
}