test/hotspot/jtreg/compiler/runtime/TestFloatsOnStackDeopt.java
author bulasevich
Fri, 18 May 2018 13:23:28 +0300
changeset 50172 9925e9fd56ad
child 50212 c4800cdd45c7
permissions -rw-r--r--
8202710: AARCH64: sporadic jtreg test fail Reviewed-by: aph, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50172
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     1
/*
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     4
 *
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     8
 *
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    13
 * accompanied this code).
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    14
 *
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    18
 *
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    21
 * questions.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    22
 */
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    23
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    24
package compiler.runtime;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    25
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    26
/*
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    27
 * @test
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    28
 * @summary testing deoptimization on safepoint with floating point values on stack
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    29
 * @bug 8202710
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    30
 * @run main/othervm -XX:+DeoptimizeALot
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    31
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    32
 *                   compiler.runtime.TestFloatsOnStackDeopt
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    33
 */
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    34
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    35
public class TestFloatsOnStackDeopt {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    36
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    37
    private static final int ARRLEN = 97;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    38
    private static final int ITERS1 = 100;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    39
    private static final int ITERS2 = 40000;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    40
    private static final float VALUE = 15.f;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    41
    public static String dummyString = "long long string";
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    42
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    43
    static void run_loop_with_safepoint(float[] a0, float b) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    44
        // Non-counted loop with safepoint.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    45
        for (long l = 0; l < ITERS2; l++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    46
            // Counted and vectorized loop.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    47
            for (int i = 0; i < a0.length; i += 1) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    48
                a0[i] += b;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    49
            }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    50
        }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    51
    }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    52
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    53
    static int test() {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    54
        // thread provokes frequent GC - together with +DeoptimizeALot and safepoint it forces executed function deoptimization
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    55
        Thread th = new Thread() {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    56
            public void run() {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    57
                while(true) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    58
                    synchronized(this) { try { wait(1); } catch (Exception ex) {} }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    59
                    dummyString += dummyString;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    60
                    if (dummyString.length() > 1024*1024) { dummyString = "long long string"; }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    61
                }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    62
            }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    63
        };
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    64
        th.start();
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    65
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    66
        int errn = 0;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    67
        for (int j = 0; j < ITERS1; j++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    68
            float[] x0 = new float[ARRLEN];
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    69
            run_loop_with_safepoint(x0, VALUE);
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    70
            for (int i = 0; i < ARRLEN; i++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    71
                if (x0[i] != VALUE * ITERS2) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    72
                    System.err.println("(" + j + "): " + "x0[" + i + "] = " + x0[i] + " != " + VALUE * ITERS2);
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    73
                    errn++;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    74
                }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    75
                x0[i] = 0.f; // Reset
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    76
            }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    77
            if (errn > 0) break;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    78
        }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    79
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    80
        th.stop();
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    81
        return errn;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    82
    }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    83
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    84
    public static void main(String args[]) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    85
        int errn = test();
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    86
        System.err.println((errn > 0) ? "FAILED" : "PASSED");
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    87
    }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    88
}
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    89