hotspot/test/compiler/gcbarriers/PreserveFPRegistersTest.java
author zmajo
Thu, 31 Mar 2016 16:09:29 +0200
changeset 36845 bb127602cd19
parent 36832 ead44efe160f
child 40042 2d24b79db99b
permissions -rw-r--r--
8153195: Quarantine compiler/gcbarriers/PreserveFPRegistersTest.java Summary: Quarantine test. Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36832
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     1
/*
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     4
 *
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     8
 *
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    14
 *
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    18
 *
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    21
 * questions.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    22
 *
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    23
 */
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    24
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    25
/**
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    26
 * @test
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    27
 * @bug 8148175
36845
bb127602cd19 8153195: Quarantine compiler/gcbarriers/PreserveFPRegistersTest.java
zmajo
parents: 36832
diff changeset
    28
 * @ignore 8153194
36832
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    29
 * @run main/othervm/timeout=300 -Xbatch -Xmx128m PreserveFPRegistersTest
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    30
 */
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    31
public class PreserveFPRegistersTest {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    32
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    33
    public static void main(String... args) throws InterruptedException {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    34
        new PreserveFPRegistersTest().go();
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    35
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    36
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    37
    public final Object[][] storage;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    38
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    39
    /**
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    40
     * Number of objects per region.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    41
     */
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    42
    public final int K = 10;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    43
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    44
    /**
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    45
     * Length of object array: sizeOf(Object[N]) ~= regionSize / K .
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    46
     */
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    47
    public final int N;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    48
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    49
    /**
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    50
     * How many regions involved into testing.
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    51
     */
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    52
    public final int regionCount;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    53
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    54
    PreserveFPRegistersTest() {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    55
        long regionSize = 1_000_000; //WB.g1RegionSize();
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    56
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    57
        Runtime rt = Runtime.getRuntime();
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    58
        long used = rt.totalMemory() - rt.freeMemory();
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    59
        long totalFree = rt.maxMemory() - used;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    60
        regionCount = (int) ( (totalFree / regionSize) * 0.9);
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    61
        int refSize = 4;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    62
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    63
        N = (int) ((regionSize / K ) / refSize) - 5;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    64
        storage = new Object[regionCount * K][];
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    65
        for (int i = 0; i < storage.length; i++) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    66
            storage[i] = new Object[N];
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    67
        }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    68
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    69
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    70
    public void go() throws InterruptedException {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    71
        final float FINAL = getValue();
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    72
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    73
        for (int to = 0; to < regionCount; to++) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    74
            Object celebrity = storage[to * K];
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    75
            for (int from = 0; from < regionCount; from++) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    76
                for (int rn = 0; rn != 100; rn++) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    77
                    storage[getY(to, from, rn)][getX(to, from, rn)] = celebrity;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    78
                }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    79
                if (FINAL != getValue()) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    80
                    throw new AssertionError("Final value has changed: " + FINAL + " != " + getValue());
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    81
                }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    82
            }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    83
        }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    84
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    85
        System.out.println("TEST PASSED");
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    86
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    87
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    88
    public float getValue() {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    89
        return 6;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    90
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    91
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    92
    private int getX(int to, int from, int rn) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    93
        return (rn*regionCount + to) % N;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    94
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    95
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    96
    private int getY(int to, int from, int rn) {
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    97
        return ((rn*regionCount + to) / N + from * K) % (regionCount*K) ;
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    98
    }
ead44efe160f 8148175: C1: G1 barriers don't preserve FP registers
vlivanov
parents:
diff changeset
    99
}