hotspot/test/gc/TestObjectAlignment.java
author sla
Wed, 05 Mar 2014 20:03:32 +0100
changeset 23058 2e261b4319e9
parent 19982 f1adc8069935
child 29678 dd2f3932c21e
permissions -rw-r--r--
8036599: Use Diagnostic Commands instead of SA by default in jinfo Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19982
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     1
/*
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     4
 *
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     8
 *
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    14
 *
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    18
 *
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    21
 * questions.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    22
 */
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    23
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    24
/**
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    25
 * @test TestObjectAlignment
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    26
 * @key gc
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    27
 * @bug 8021823
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    28
 * @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    29
 * @library /testlibrary
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    30
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    31
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    32
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    33
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    34
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    35
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    36
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    37
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    38
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    39
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    40
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    41
 * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    42
 */
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    43
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    44
import com.oracle.java.testlibrary.ProcessTools;
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    45
import com.oracle.java.testlibrary.OutputAnalyzer;
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    46
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    47
public class TestObjectAlignment {
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    48
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    49
  public static byte[] garbage;
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    50
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    51
  private static boolean runsOn32bit() {
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    52
    return System.getProperty("sun.arch.data.model").equals("32");
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    53
  }
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    54
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    55
  public static void main(String[] args) throws Exception {
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    56
    if (runsOn32bit()) {
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    57
      // 32 bit VMs do not allow setting ObjectAlignmentInBytes, so there is nothing to test. We still get called.
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    58
      return;
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    59
    }
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    60
    for (int i = 0; i < 10; i++) {
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    61
      garbage = new byte[1000];
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    62
      System.gc();
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    63
    }
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    64
  }
f1adc8069935 8021823: G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
tschatzl
parents:
diff changeset
    65
}