hotspot/test/compiler/floatingpoint/TestFloatJNIArgs.java
author coleenp
Wed, 10 May 2017 14:03:33 +0000
changeset 46450 7a361ede7817
parent 41694 225750a49720
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41694
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     1
/*
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016 SAP SE. All rights reserved.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     4
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     8
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    13
 * accompanied this code).
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    14
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    18
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    21
 * questions.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    22
 */
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    23
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    24
/* @test
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    25
 * @bug 8139258 8165673
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    26
 * @summary Regression test for passing float args to a jni function.
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    27
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    28
 *
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    29
 * @run main/othervm/native -Xint compiler.floatingpoint.TestFloatJNIArgs
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    30
 * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    31
 * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    32
 */
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    33
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    34
package compiler.floatingpoint;
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    35
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    36
public class TestFloatJNIArgs {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    37
    static {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    38
        try {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    39
            System.loadLibrary("TestFloatJNIArgs");
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    40
        } catch (UnsatisfiedLinkError e) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    41
            System.out.println("could not load native lib: " + e);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    42
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    43
    }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    44
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    45
    public static native float add15floats(
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    46
        float f1, float f2, float f3, float f4,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    47
        float f5, float f6, float f7, float f8,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    48
        float f9, float f10, float f11, float f12,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    49
        float f13, float f14, float f15);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    50
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    51
    public static native float add10floats(
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    52
        float f1, float f2, float f3, float f4,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    53
        float f5, float f6, float f7, float f8,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    54
        float f9, float f10);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    55
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    56
    public static native float addFloatsInts(
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    57
        float f1, float f2, float f3, float f4,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    58
        float f5, float f6, float f7, float f8,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    59
        float f9, float f10, float f11, float f12,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    60
        float f13, float f14, float f15, int a16, int a17);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    61
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    62
    public static native double add15doubles(
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    63
        double d1, double d2, double d3, double d4,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    64
        double d5, double d6, double d7, double d8,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    65
        double d9, double d10, double d11, double d12,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    66
        double d13, double d14, double d15);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    67
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    68
    static void test() throws Exception {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    69
        float sum = TestFloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    70
                                                 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    71
        if (sum != 15.0f) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    72
            throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    73
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    74
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    75
        float sum1 = TestFloatJNIArgs.add10floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    76
        if (sum1 != 10.0f) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    77
            throw new Error("Passed 10 times 1.0f to jni function which didn't add them properly: " + sum1);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    78
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    79
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    80
        float sum2 = TestFloatJNIArgs.addFloatsInts(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    81
                                                   1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1, 1);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    82
        if (sum2 != 17.0f) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    83
            throw new Error("Passed 17 times 1 to jni function which didn't add them properly: " + sum2);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    84
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    85
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    86
        double dsum = TestFloatJNIArgs.add15doubles(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    87
                                                      1.0, 1.0, 1.0, 1.0, 1.0, 1.0);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    88
        if (dsum != 15.0) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    89
            throw new Error("Passed 15 times 1.0 to jni function which didn't add them properly: " + dsum);
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    90
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    91
    }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    92
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    93
    public static void main(String[] args) throws Exception {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    94
        for (int i = 0; i < 200; ++i) {
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    95
            test();
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    96
        }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    97
    }
225750a49720 8165673: AArch64: Fix JNI floating point argument handling
adinn
parents:
diff changeset
    98
}