src/hotspot/share/gc/serial/serialHeap.cpp
author stefank
Mon, 15 Apr 2019 11:47:46 +0200
changeset 54678 93f09ca4a7f8
parent 50034 01a88f825a84
child 54786 ebf733a324d4
permissions -rw-r--r--
8198505: Remove CollectorPolicy and its subclasses Reviewed-by: pliden, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     1
/*
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     4
 *
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     8
 *
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    13
 * accompanied this code).
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    14
 *
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    18
 *
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    21
 * questions.
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    22
 *
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    23
 */
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    24
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    25
#include "precompiled.hpp"
50034
01a88f825a84 8202641: Replace OOP_SINCE_SAVE_MARKS with templates
stefank
parents: 50033
diff changeset
    26
#include "gc/serial/defNewGeneration.inline.hpp"
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    27
#include "gc/serial/serialHeap.hpp"
50034
01a88f825a84 8202641: Replace OOP_SINCE_SAVE_MARKS with templates
stefank
parents: 50033
diff changeset
    28
#include "gc/serial/tenuredGeneration.inline.hpp"
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    29
#include "gc/shared/genMemoryPools.hpp"
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    30
#include "services/memoryManager.hpp"
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    31
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    32
SerialHeap* SerialHeap::heap() {
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    33
  CollectedHeap* heap = Universe::heap();
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    34
  assert(heap != NULL, "Uninitialized access to SerialHeap::heap()");
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    35
  assert(heap->kind() == CollectedHeap::Serial, "Invalid name");
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    36
  return static_cast<SerialHeap*>(heap);
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    37
}
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    38
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 50034
diff changeset
    39
SerialHeap::SerialHeap() :
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 50034
diff changeset
    40
    GenCollectedHeap(Generation::DefNew,
49050
170c7b36aea6 8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 49049
diff changeset
    41
                     Generation::MarkSweepCompact,
170c7b36aea6 8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 49049
diff changeset
    42
                     "Copy:MSC"),
49049
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    43
    _eden_pool(NULL),
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    44
    _survivor_pool(NULL),
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    45
    _old_pool(NULL) {
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    46
  _young_manager = new GCMemoryManager("Copy", "end of minor GC");
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    47
  _old_manager = new GCMemoryManager("MarkSweepCompact", "end of major GC");
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    48
}
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    49
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    50
void SerialHeap::initialize_serviceability() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    51
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    52
  DefNewGeneration* young = young_gen();
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    53
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    54
  // Add a memory pool for each space and young gen doesn't
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    55
  // support low memory detection as it is expected to get filled up.
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    56
  _eden_pool = new ContiguousSpacePool(young->eden(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    57
                                       "Eden Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    58
                                       young->max_eden_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    59
                                       false /* support_usage_threshold */);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    60
  _survivor_pool = new SurvivorContiguousSpacePool(young,
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    61
                                                   "Survivor Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    62
                                                   young->max_survivor_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    63
                                                   false /* support_usage_threshold */);
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    64
  TenuredGeneration* old = old_gen();
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    65
  _old_pool = new GenerationPool(old, "Tenured Gen", true);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    66
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    67
  _young_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    68
  _young_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    69
  young->set_gc_manager(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    70
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    71
  _old_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    72
  _old_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    73
  _old_manager->add_pool(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    74
  old->set_gc_manager(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    75
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    76
}
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    77
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    78
GrowableArray<GCMemoryManager*> SerialHeap::memory_managers() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    79
  GrowableArray<GCMemoryManager*> memory_managers(2);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    80
  memory_managers.append(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    81
  memory_managers.append(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    82
  return memory_managers;
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    83
}
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    84
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    85
GrowableArray<MemoryPool*> SerialHeap::memory_pools() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    86
  GrowableArray<MemoryPool*> memory_pools(3);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    87
  memory_pools.append(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    88
  memory_pools.append(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    89
  memory_pools.append(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    90
  return memory_pools;
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    91
}