src/hotspot/share/gc/serial/serialHeap.cpp
author stefank
Thu, 22 Feb 2018 18:36:07 +0100
changeset 49047 8f004146e407
parent 48168 cb5d2d4453d0
child 49049 effb50eeea4e
permissions -rw-r--r--
8198515: Extract SoftReferencePolicy code out of CollectorPolicy Reviewed-by: pliden, 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"
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    26
#include "gc/serial/defNewGeneration.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"
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    28
#include "gc/shared/genMemoryPools.hpp"
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    29
#include "services/memoryManager.hpp"
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    30
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    31
SerialHeap::SerialHeap(GenCollectorPolicy* policy) :
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    32
  GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    33
  _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
    34
  _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
    35
}
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    36
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    37
void SerialHeap::initialize_serviceability() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    38
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    39
  DefNewGeneration* young = (DefNewGeneration*) young_gen();
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    40
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    41
  // 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
    42
  // 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
    43
  _eden_pool = new ContiguousSpacePool(young->eden(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    44
                                       "Eden Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    45
                                       young->max_eden_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    46
                                       false /* support_usage_threshold */);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    47
  _survivor_pool = new SurvivorContiguousSpacePool(young,
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    48
                                                   "Survivor Space",
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    49
                                                   young->max_survivor_size(),
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    50
                                                   false /* support_usage_threshold */);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    51
  Generation* old = old_gen();
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    52
  _old_pool = new GenerationPool(old, "Tenured Gen", true);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    53
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    54
  _young_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    55
  _young_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    56
  young->set_gc_manager(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    57
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    58
  _old_manager->add_pool(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    59
  _old_manager->add_pool(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    60
  _old_manager->add_pool(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    61
  old->set_gc_manager(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    62
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    63
}
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    64
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    65
void SerialHeap::check_gen_kinds() {
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    66
  assert(young_gen()->kind() == Generation::DefNew,
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    67
         "Wrong youngest generation type");
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    68
  assert(old_gen()->kind() == Generation::MarkSweepCompact,
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    69
         "Wrong generation kind");
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
diff changeset
    70
}
48168
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
GrowableArray<GCMemoryManager*> SerialHeap::memory_managers() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    73
  GrowableArray<GCMemoryManager*> memory_managers(2);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    74
  memory_managers.append(_young_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    75
  memory_managers.append(_old_manager);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    76
  return memory_managers;
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    77
}
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    78
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    79
GrowableArray<MemoryPool*> SerialHeap::memory_pools() {
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    80
  GrowableArray<MemoryPool*> memory_pools(3);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    81
  memory_pools.append(_eden_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    82
  memory_pools.append(_survivor_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    83
  memory_pools.append(_old_pool);
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    84
  return memory_pools;
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47819
diff changeset
    85
}