src/hotspot/share/gc/serial/serialHeap.cpp
author stefank
Mon, 07 May 2018 14:42:08 +0200
changeset 50034 01a88f825a84
parent 50033 000c697c81db
child 54678 93f09ca4a7f8
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:
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
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    39
SerialHeap::SerialHeap(GenCollectorPolicy* policy) :
49049
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    40
    GenCollectedHeap(policy,
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    41
                     Generation::DefNew,
49050
170c7b36aea6 8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 49049
diff changeset
    42
                     Generation::MarkSweepCompact,
170c7b36aea6 8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 49049
diff changeset
    43
                     "Copy:MSC"),
49049
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    44
    _eden_pool(NULL),
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    45
    _survivor_pool(NULL),
effb50eeea4e 8198528: Move GenerationSpecs from GenCollectorPolicy to GenCollectedHeap
stefank
parents: 48168
diff changeset
    46
    _old_pool(NULL) {
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    47
  _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
    48
  _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
    49
}
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    50
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    51
void SerialHeap::initialize_serviceability() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    52
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    53
  DefNewGeneration* young = young_gen();
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    54
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    55
  // 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
    56
  // 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
    57
  _eden_pool = new ContiguousSpacePool(young->eden(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    58
                                       "Eden Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    59
                                       young->max_eden_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    60
                                       false /* support_usage_threshold */);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    61
  _survivor_pool = new SurvivorContiguousSpacePool(young,
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    62
                                                   "Survivor Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    63
                                                   young->max_survivor_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    64
                                                   false /* support_usage_threshold */);
50033
000c697c81db 8202639: Use concrete Generation classes in SerialHeap and CMSHeap
stefank
parents: 49050
diff changeset
    65
  TenuredGeneration* old = old_gen();
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    66
  _old_pool = new GenerationPool(old, "Tenured Gen", true);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    67
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    68
  _young_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    69
  _young_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    70
  young->set_gc_manager(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    71
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    72
  _old_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    73
  _old_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    74
  _old_manager->add_pool(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    75
  old->set_gc_manager(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    76
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    77
}
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    78
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    79
GrowableArray<GCMemoryManager*> SerialHeap::memory_managers() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    80
  GrowableArray<GCMemoryManager*> memory_managers(2);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    81
  memory_managers.append(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    82
  memory_managers.append(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    83
  return memory_managers;
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
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    86
GrowableArray<MemoryPool*> SerialHeap::memory_pools() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    87
  GrowableArray<MemoryPool*> memory_pools(3);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    88
  memory_pools.append(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    89
  memory_pools.append(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    90
  memory_pools.append(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    91
  return memory_pools;
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    92
}