test/hotspot/jtreg/compiler/runtime/TestFloatsOnStackDeopt.java
author bulasevich
Tue, 22 May 2018 14:54:55 +0200
changeset 50212 c4800cdd45c7
parent 50172 9925e9fd56ad
permissions -rw-r--r--
8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL Reviewed-by: redestad
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";
50212
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    42
    static volatile boolean pleaseStop = false;
50172
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    43
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    44
    static void run_loop_with_safepoint(float[] a0, float b) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    45
        // Non-counted loop with safepoint.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    46
        for (long l = 0; l < ITERS2; l++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    47
            // Counted and vectorized loop.
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    48
            for (int i = 0; i < a0.length; i += 1) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    49
                a0[i] += b;
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
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    54
    static int test() {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    55
        // 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
    56
        Thread th = new Thread() {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    57
            public void run() {
50212
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    58
                while (!pleaseStop) {
50172
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    59
                    synchronized(this) { try { wait(1); } catch (Exception ex) {} }
50212
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    60
                    dummyString = new StringBuilder(dummyString).append(dummyString).toString();
50172
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    61
                    if (dummyString.length() > 1024*1024) { dummyString = "long long string"; }
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
        };
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    65
        th.start();
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    66
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    67
        int errn = 0;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    68
        for (int j = 0; j < ITERS1; j++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    69
            float[] x0 = new float[ARRLEN];
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    70
            run_loop_with_safepoint(x0, VALUE);
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    71
            for (int i = 0; i < ARRLEN; i++) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    72
                if (x0[i] != VALUE * ITERS2) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    73
                    System.err.println("(" + j + "): " + "x0[" + i + "] = " + x0[i] + " != " + VALUE * ITERS2);
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    74
                    errn++;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    75
                }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    76
                x0[i] = 0.f; // Reset
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    77
            }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    78
            if (errn > 0) break;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    79
        }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    80
50212
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    81
        pleaseStop = true;
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    82
        try {
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    83
            th.join();
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    84
        } catch (InterruptedException e) {
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    85
            throw new Error("InterruptedException in main thread ", e);
c4800cdd45c7 8203431: TestFloatsOnStackDeopt.java throws java.lang.LinkageError: loader <bootstrap> attempted duplicate class definition for java.lang.invoke.BoundMethodHandle$Species_LLL
bulasevich
parents: 50172
diff changeset
    86
        }
50172
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    87
        return errn;
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    88
    }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    89
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    90
    public static void main(String args[]) {
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    91
        int errn = test();
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    92
        System.err.println((errn > 0) ? "FAILED" : "PASSED");
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    93
    }
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    94
}
9925e9fd56ad 8202710: AARCH64: sporadic jtreg test fail
bulasevich
parents:
diff changeset
    95