hotspot/test/gc/arguments/TestG1HeapRegionSize.java
author tschatzl
Mon, 16 Sep 2013 10:20:45 +0200
changeset 19996 a98fdabb2ba9
parent 18999 a05f689a6c0c
child 27692 11c231c781dc
permissions -rw-r--r--
8024396: VM crashing with assert(!UseLargePages || UseParallelOldGC || use_large_pages) failed: Wrong alignment to use large pages Summary: Loosen wrong assert for UseParallelOldGC to UseParallelGC Reviewed-by: stefank, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18999
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     1
/*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     2
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     4
*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     7
* published by the Free Software Foundation.
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     8
*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    13
* accompanied this code).
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    14
*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    18
*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    21
* questions.
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    22
*/
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    23
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    24
/*
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    25
 * @test TestG1HeapRegionSize
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    26
 * @key gc
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    27
 * @bug 8021879
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    28
 * @summary Verify that the flag G1HeapRegionSize is updated properly
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    29
 * @run main/othervm -Xmx64m TestG1HeapRegionSize 1048576
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    30
 * @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m TestG1HeapRegionSize 2097152
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    31
 * @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m TestG1HeapRegionSize 2097152
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    32
 * @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m TestG1HeapRegionSize 33554432
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    33
 */
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    34
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    35
import sun.management.ManagementFactoryHelper;
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    36
import com.sun.management.HotSpotDiagnosticMXBean;
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    37
import com.sun.management.VMOption;
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    38
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    39
public class TestG1HeapRegionSize {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    40
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    41
  public static void main(String[] args) {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    42
    HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    43
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    44
    VMOption option = diagnostic.getVMOption("UseG1GC");
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    45
    if (option.getValue().equals("false")) {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    46
      System.out.println("Skipping this test. It is only a G1 test.");
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    47
      return;
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    48
    }
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    49
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    50
    String expectedValue = getExpectedValue(args);
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    51
    option = diagnostic.getVMOption("G1HeapRegionSize");
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    52
    if (!expectedValue.equals(option.getValue())) {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    53
      throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    54
    }
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    55
  }
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    56
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    57
  private static String getExpectedValue(String[] args) {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    58
    if (args.length != 1) {
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    59
      throw new RuntimeException("Wrong number of arguments. Expected 1 but got " + args.length);
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    60
    }
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    61
    return args[0];
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    62
  }
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    63
a05f689a6c0c 8021879: G1: G1HeapRegionSize flag value not updated correctly
brutisso
parents:
diff changeset
    64
}