hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java
changeset 41703 fb19bea93d16
parent 41692 6a0b0026bc25
parent 41702 fa592dd9dcd9
child 41704 14be0ae96c86
equal deleted inserted replaced
41692:6a0b0026bc25 41703:fb19bea93d16
     1 /*
       
     2  * Copyright (c) 2015 SAP SE. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /* @test
       
    25  * @bug 8139258
       
    26  * @summary Regression test for 8139258 which failed to properly pass float args
       
    27  *          to a jni function on ppc64le.
       
    28  *
       
    29  * @run main/othervm/native -Xint compiler.floatingpoint.Test15FloatJNIArgs
       
    30  * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
       
    31  * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.Test15FloatJNIArgs
       
    32  */
       
    33 
       
    34 package compiler.floatingpoint;
       
    35 
       
    36 public class Test15FloatJNIArgs {
       
    37     static {
       
    38         try {
       
    39             System.loadLibrary("Test15FloatJNIArgs");
       
    40         } catch (UnsatisfiedLinkError e) {
       
    41             System.out.println("could not load native lib: " + e);
       
    42         }
       
    43     }
       
    44 
       
    45     public static native float add15floats(
       
    46         float f1, float f2, float f3, float f4,
       
    47         float f5, float f6, float f7, float f8,
       
    48         float f9, float f10, float f11, float f12,
       
    49         float f13, float f14, float f15);
       
    50 
       
    51     static void test() throws Exception {
       
    52         float sum = Test15FloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
       
    53                                                    1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
       
    54         if (sum != 15.0f) {
       
    55             throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);
       
    56         }
       
    57     }
       
    58 
       
    59     public static void main(String[] args) throws Exception {
       
    60         for (int i = 0; i < 200; ++i) {
       
    61             test();
       
    62         }
       
    63     }
       
    64 }