src/hotspot/share/gc/g1/g1Arguments.cpp
author stefank
Wed, 22 May 2019 13:06:31 +0200
changeset 54983 81becad91321
parent 54678 93f09ca4a7f8
child 55161 1a7f82c98eee
permissions -rw-r--r--
8224203: Remove need to specify type when using FLAG_SET macros Reviewed-by: rehn, pliden, coleenp
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
/*
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
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/g1/g1Arguments.hpp"
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 48145
diff changeset
    29
#include "gc/g1/g1HeapVerifier.hpp"
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    30
#include "gc/g1/heapRegion.hpp"
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    31
#include "gc/g1/heapRegionRemSet.hpp"
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    32
#include "gc/shared/cardTableRS.hpp"
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    33
#include "gc/shared/gcArguments.hpp"
52904
d2f118d3f8e7 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
manc
parents: 52894
diff changeset
    34
#include "gc/shared/workerPolicy.hpp"
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    35
#include "runtime/globals.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    36
#include "runtime/globals_extension.hpp"
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    37
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    38
static const double MaxRamFractionForYoung = 0.8;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    39
size_t G1Arguments::MaxMemoryForYoung;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    40
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    41
static size_t calculate_heap_alignment(size_t space_alignment) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    42
  size_t card_table_alignment = CardTableRS::ct_max_alignment_constraint();
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    43
  size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    44
  return MAX3(card_table_alignment, space_alignment, page_size);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    45
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    46
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    47
void G1Arguments::initialize_alignments() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    48
  // Set up the region size and associated fields.
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    49
  //
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    50
  // There is a circular dependency here. We base the region size on the heap
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    51
  // size, but the heap size should be aligned with the region size. To get
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    52
  // around this we use the unaligned values for the heap.
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    53
  HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    54
  HeapRegionRemSet::setup_remset_size();
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    55
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    56
  SpaceAlignment = HeapRegion::GrainBytes;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    57
  HeapAlignment = calculate_heap_alignment(SpaceAlignment);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    58
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    59
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    60
size_t G1Arguments::conservative_max_heap_alignment() {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    61
  return HeapRegion::max_region_size();
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    62
}
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
    63
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    64
void G1Arguments::initialize_verification_types() {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    65
  if (strlen(VerifyGCType) > 0) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    66
    const char delimiter[] = " ,\n";
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    67
    size_t length = strlen(VerifyGCType);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    68
    char* type_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    69
    strncpy(type_list, VerifyGCType, length + 1);
52894
8df9cf767f79 8214773: Replace use of thread unsafe strtok
neliasso
parents: 52811
diff changeset
    70
    char* save_ptr;
8df9cf767f79 8214773: Replace use of thread unsafe strtok
neliasso
parents: 52811
diff changeset
    71
8df9cf767f79 8214773: Replace use of thread unsafe strtok
neliasso
parents: 52811
diff changeset
    72
    char* token = strtok_r(type_list, delimiter, &save_ptr);
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    73
    while (token != NULL) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    74
      parse_verification_type(token);
52894
8df9cf767f79 8214773: Replace use of thread unsafe strtok
neliasso
parents: 52811
diff changeset
    75
      token = strtok_r(NULL, delimiter, &save_ptr);
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    76
    }
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    77
    FREE_C_HEAP_ARRAY(char, type_list);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    78
  }
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    79
}
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    80
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    81
void G1Arguments::parse_verification_type(const char* type) {
50787
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 50624
diff changeset
    82
  if (strcmp(type, "young-normal") == 0) {
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 50624
diff changeset
    83
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyYoungNormal);
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 50624
diff changeset
    84
  } else if (strcmp(type, "concurrent-start") == 0) {
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 50624
diff changeset
    85
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyConcurrentStart);
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    86
  } else if (strcmp(type, "mixed") == 0) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    87
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyMixed);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    88
  } else if (strcmp(type, "remark") == 0) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    89
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyRemark);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    90
  } else if (strcmp(type, "cleanup") == 0) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    91
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyCleanup);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    92
  } else if (strcmp(type, "full") == 0) {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    93
    G1HeapVerifier::enable_verification_type(G1HeapVerifier::G1VerifyFull);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    94
  } else {
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    95
    log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available types are: "
50787
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 50624
diff changeset
    96
                            "young-normal, concurrent-start, mixed, remark, cleanup and full", type);
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    97
  }
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    98
}
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
    99
49629
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents: 49602
diff changeset
   100
void G1Arguments::initialize() {
b786280276dc 8199925: Break out GC selection logic from GCArguments to GCConfig
pliden
parents: 49602
diff changeset
   101
  GCArguments::initialize();
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   102
  assert(UseG1GC, "Error");
52904
d2f118d3f8e7 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
manc
parents: 52894
diff changeset
   103
  FLAG_SET_DEFAULT(ParallelGCThreads, WorkerPolicy::parallel_worker_threads());
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   104
  if (ParallelGCThreads == 0) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   105
    assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   106
    vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   107
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   108
52811
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   109
  // When dumping the CDS archive we want to reduce fragmentation by
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   110
  // triggering a full collection. To get as low fragmentation as
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   111
  // possible we only use one worker thread.
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   112
  if (DumpSharedSpaces) {
54983
81becad91321 8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents: 54678
diff changeset
   113
    FLAG_SET_ERGO(ParallelGCThreads, 1);
52811
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   114
  }
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 52148
diff changeset
   115
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   116
  if (FLAG_IS_DEFAULT(G1ConcRefinementThreads)) {
54983
81becad91321 8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents: 54678
diff changeset
   117
    FLAG_SET_ERGO(G1ConcRefinementThreads, ParallelGCThreads);
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   118
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   119
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   120
  // MarkStackSize will be set (if it hasn't been set by the user)
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   121
  // when concurrent marking is initialized.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   122
  // Its value will be based upon the number of parallel marking threads.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   123
  // But we do set the maximum mark stack size here.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   124
  if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   125
    FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   126
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   127
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   128
  if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   129
    // In G1, we want the default GC overhead goal to be higher than
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   130
    // it is for PS, or the heap might be expanded too aggressively.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   131
    // We set it here to ~8%.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   132
    FLAG_SET_DEFAULT(GCTimeRatio, 12);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   133
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   134
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   135
  // Below, we might need to calculate the pause time interval based on
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   136
  // the pause target. When we do so we are going to give G1 maximum
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   137
  // flexibility and allow it to do pauses when it needs to. So, we'll
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   138
  // arrange that the pause interval to be pause time target + 1 to
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   139
  // ensure that a) the pause time target is maximized with respect to
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   140
  // the pause interval and b) we maintain the invariant that pause
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   141
  // time target < pause interval. If the user does not want this
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   142
  // maximum flexibility, they will have to set the pause interval
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   143
  // explicitly.
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   144
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   145
  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   146
    // The default pause time target in G1 is 200ms
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   147
    FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   148
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   149
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   150
  // Then, if the interval parameter was not set, set it according to
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   151
  // the pause time target (this will also deal with the case when the
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   152
  // pause time target is the default value).
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   153
  if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   154
    FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   155
  }
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   156
50624
724ed31f9d05 8205043: Make parallel reference processing default for G1
tschatzl
parents: 49982
diff changeset
   157
  if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) {
724ed31f9d05 8205043: Make parallel reference processing default for G1
tschatzl
parents: 49982
diff changeset
   158
    FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
724ed31f9d05 8205043: Make parallel reference processing default for G1
tschatzl
parents: 49982
diff changeset
   159
  }
724ed31f9d05 8205043: Make parallel reference processing default for G1
tschatzl
parents: 49982
diff changeset
   160
47901
4c42aa431f40 8189171: Move GC argument processing into GC specific classes
rkennke
parents:
diff changeset
   161
  log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
48145
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   162
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49629
diff changeset
   163
  // By default do not let the target stack size to be more than 1/4 of the entries
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49629
diff changeset
   164
  if (FLAG_IS_DEFAULT(GCDrainStackTargetSize)) {
54983
81becad91321 8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents: 54678
diff changeset
   165
    FLAG_SET_ERGO(GCDrainStackTargetSize, MIN2(GCDrainStackTargetSize, (uintx)TASKQUEUE_SIZE / 4));
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49629
diff changeset
   166
  }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49629
diff changeset
   167
48145
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   168
#ifdef COMPILER2
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   169
  // Enable loop strip mining to offer better pause time guarantees
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   170
  if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   171
    FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
48316
4d28288c9f9e 8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents: 48179
diff changeset
   172
    if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
4d28288c9f9e 8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents: 48179
diff changeset
   173
      FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
4d28288c9f9e 8192908: -XX:+UseCountedLoopSafepoints alone doesn't disable strip mining with G1
roland
parents: 48179
diff changeset
   174
    }
48145
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   175
  }
f913f6dba2d3 8186027: C2: loop strip mining
roland
parents: 47913
diff changeset
   176
#endif
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
   177
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 49010
diff changeset
   178
  initialize_verification_types();
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 48145
diff changeset
   179
}
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 48145
diff changeset
   180
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   181
static size_t calculate_reasonable_max_memory_for_young(FormatBuffer<100> &calc_str, double max_ram_fraction_for_young) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   182
  julong phys_mem;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   183
  // If MaxRam is specified, we use that as maximum physical memory available.
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   184
  if (FLAG_IS_DEFAULT(MaxRAM)) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   185
    phys_mem = os::physical_memory();
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   186
    calc_str.append("Physical_Memory");
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 52904
diff changeset
   187
  } else {
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   188
    phys_mem = (julong)MaxRAM;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   189
    calc_str.append("MaxRAM");
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   190
  }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   191
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   192
  julong reasonable_max = phys_mem;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   193
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   194
  // If either MaxRAMFraction or MaxRAMPercentage is specified, we use them to calculate
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   195
  // reasonable max size of young generation.
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   196
  if (!FLAG_IS_DEFAULT(MaxRAMFraction)) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   197
    reasonable_max = (julong)(phys_mem / MaxRAMFraction);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   198
    calc_str.append(" / MaxRAMFraction");
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   199
  }  else if (!FLAG_IS_DEFAULT(MaxRAMPercentage)) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   200
    reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   201
    calc_str.append(" * MaxRAMPercentage / 100");
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   202
  }  else {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   203
    // We use our own fraction to calculate max size of young generation.
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   204
    reasonable_max = phys_mem * max_ram_fraction_for_young;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   205
    calc_str.append(" * %0.2f", max_ram_fraction_for_young);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   206
  }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   207
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   208
  return (size_t)reasonable_max;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   209
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   210
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   211
void G1Arguments::initialize_heap_flags_and_sizes() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   212
  if (AllocateOldGenAt != NULL) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   213
    initialize_heterogeneous();
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 52904
diff changeset
   214
  }
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   215
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   216
  GCArguments::initialize_heap_flags_and_sizes();
47913
cde4a65ba47d 8189389: Move heap creation into GC interface
rkennke
parents: 47901
diff changeset
   217
}
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   218
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   219
void G1Arguments::initialize_heterogeneous() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   220
  FormatBuffer<100> calc_str("");
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   221
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   222
  MaxMemoryForYoung = calculate_reasonable_max_memory_for_young(calc_str, MaxRamFractionForYoung);
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   223
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   224
  if (MaxNewSize > MaxMemoryForYoung) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   225
    if (FLAG_IS_CMDLINE(MaxNewSize)) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   226
      log_warning(gc, ergo)("Setting MaxNewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s))",
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   227
                            MaxMemoryForYoung, calc_str.buffer());
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   228
    } else {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   229
      log_info(gc, ergo)("Setting MaxNewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s)). "
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   230
                         "Dram usage can be lowered by setting MaxNewSize to a lower value", MaxMemoryForYoung, calc_str.buffer());
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   231
    }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   232
    MaxNewSize = MaxMemoryForYoung;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   233
  }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   234
  if (NewSize > MaxMemoryForYoung) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   235
    if (FLAG_IS_CMDLINE(NewSize)) {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   236
      log_warning(gc, ergo)("Setting NewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s))",
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   237
                            MaxMemoryForYoung, calc_str.buffer());
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   238
    }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   239
    NewSize = MaxMemoryForYoung;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   240
  }
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   241
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   242
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   243
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   244
CollectedHeap* G1Arguments::create_heap() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   245
  return new G1CollectedHeap();
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   246
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   247
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   248
bool G1Arguments::is_heterogeneous_heap() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   249
  return AllocateOldGenAt != NULL;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   250
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   251
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   252
size_t G1Arguments::reasonable_max_memory_for_young() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   253
  return MaxMemoryForYoung;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   254
}
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   255
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   256
size_t G1Arguments::heap_reserved_size_bytes() {
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   257
  return (is_heterogeneous_heap() ? 2 : 1) * MaxHeapSize;
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
   258
}