src/hotspot/share/gc/parallel/parallelArguments.cpp
author manc
Fri, 07 Dec 2018 12:46:31 +0800
changeset 52904 d2f118d3f8e7
parent 52148 2d9f8845d0ae
child 53117 37930c6ba6d7
permissions -rw-r--r--
8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy Summary: Consolidate code related to GC threads calculation into a single class Reviewed-by: tschatzl, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     1
/*
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 49629
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     3
 * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     5
 *
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     8
 * published by the Free Software Foundation.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
     9
 *
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    14
 * accompanied this code).
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    15
 *
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    19
 *
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    22
 * questions.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    23
 *
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    24
 */
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    25
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    26
#include "precompiled.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    27
#include "gc/parallel/parallelArguments.hpp"
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    28
#include "gc/parallel/parallelScavengeHeap.hpp"
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    29
#include "gc/shared/adaptiveSizePolicy.hpp"
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    30
#include "gc/shared/collectorPolicy.hpp"
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    31
#include "gc/shared/gcArguments.inline.hpp"
52904
d2f118d3f8e7 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
manc
parents: 52148
diff changeset
    32
#include "gc/shared/workerPolicy.hpp"
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    33
#include "runtime/globals.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    34
#include "runtime/globals_extension.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    35
#include "runtime/java.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    36
#include "utilities/defaultStream.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    37
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    38
size_t ParallelArguments::conservative_max_heap_alignment() {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    39
  return CollectorPolicy::compute_heap_alignment();
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    40
}
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    41
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents: 47913
diff changeset
    42
void ParallelArguments::initialize() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents: 47913
diff changeset
    43
  GCArguments::initialize();
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    44
  assert(UseParallelGC || UseParallelOldGC, "Error");
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    45
  // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    46
  if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    47
    FLAG_SET_DEFAULT(UseParallelOldGC, true);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    48
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    49
  FLAG_SET_DEFAULT(UseParallelGC, true);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    50
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    51
  // If no heap maximum was requested explicitly, use some reasonable fraction
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    52
  // of the physical memory, up to a maximum of 1GB.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    53
  FLAG_SET_DEFAULT(ParallelGCThreads,
52904
d2f118d3f8e7 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
manc
parents: 52148
diff changeset
    54
                   WorkerPolicy::parallel_worker_threads());
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    55
  if (ParallelGCThreads == 0) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    56
    jio_fprintf(defaultStream::error_stream(),
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    57
        "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    58
    vm_exit(1);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    59
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    60
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    61
  if (UseAdaptiveSizePolicy) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    62
    // We don't want to limit adaptive heap sizing's freedom to adjust the heap
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    63
    // unless the user actually sets these flags.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    64
    if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    65
      FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    66
    }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    67
    if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    68
      FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    69
    }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    70
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    71
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    72
  // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    73
  // SurvivorRatio has been set, reset their default values to SurvivorRatio +
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    74
  // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    75
  // See CR 6362902 for details.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    76
  if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    77
    if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    78
       FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    79
    }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    80
    if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    81
      FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    82
    }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    83
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    84
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    85
  if (UseParallelOldGC) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    86
    // Par compact uses lower default values since they are treated as
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    87
    // minimums.  These are different defaults because of the different
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    88
    // interpretation and are not ergonomically set.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    89
    if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    90
      FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    91
    }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    92
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    93
}
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    94
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    95
CollectedHeap* ParallelArguments::create_heap() {
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    96
  return create_heap_with_policy<ParallelScavengeHeap, GenerationSizer>();
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    97
}