# HG changeset patch # User fyang # Date 1532417235 -28800 # Tue Jul 24 15:27:15 2018 +0800 # Node ID 6932cc435fb34786853ab8d8fd7cda5842fe64b2 # Parent 9c1d9d1fb5436952724f22f8aaf85277cd48ddf7 8207838: aarch64: fix the order in which float registers are restored in restore_args Summary: fix the order in which float registers are restored in restore_args for aarch64 Reviewed-by: aph Contributed-by: guoge1@huawei.com diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1107,7 +1107,7 @@ } } __ pop(x, sp); - for ( int i = first_arg ; i < arg_count ; i++ ) { + for ( int i = arg_count - 1 ; i >= first_arg ; i-- ) { if (args[i].first()->is_Register()) { ; } else if (args[i].first()->is_FloatRegister()) { diff --git a/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java --- a/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java +++ b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 SAP SE. All rights reserved. + * Copyright (c) 2015, 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ * * * @run main/othervm/native -Xint compiler.floatingpoint.TestFloatJNIArgs + * @run main/othervm/native -XX:+TieredCompilation compiler.floatingpoint.TestFloatJNIArgs + * @run main/othervm/native -XX:-TieredCompilation compiler.floatingpoint.TestFloatJNIArgs * @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs */ @@ -42,6 +44,8 @@ } } + private static final int numberOfThreads = 8; + public static native float add15floats( float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, @@ -65,6 +69,14 @@ double d9, double d10, double d11, double d12, double d13, double d14, double d15); + public static synchronized native float add5floats( + float f1, float f2, float f3, float f4, + float f5, float f6, float f7, float f8, int a9, int a10); + + public static synchronized native double add5doubles( + double f1, double f2, double f3, double f4, + double f5, double f6, double f7, double f8, int a9, int a10); + static void test() throws Exception { float sum = TestFloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); @@ -88,6 +100,38 @@ if (dsum != 15.0) { throw new Error("Passed 15 times 1.0 to jni function which didn't add them properly: " + dsum); } + + Thread[] threads = new Thread[numberOfThreads]; + + for (int i = 0; i < numberOfThreads; i++) { + threads[i] = new Thread(() -> { + for (int j = 0; j < 10000; j++) { + float f = TestFloatJNIArgs.add5floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9, 10); + if (f != 15.0f) { + throw new Error("jni function didn't add first five float args properly: " + f); + } + } + }); + threads[i].start(); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].join(); + } + + for (int i = 0; i < numberOfThreads; i++) { + threads[i] = new Thread(() -> { + for (int j = 0; j < 10000; j++) { + double d = TestFloatJNIArgs.add5doubles(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9, 10); + if (d != 15.0) { + throw new Error("jni function didn't add first five double args properly: " + d); + } + } + }); + threads[i].start(); + } + for (int i = 0; i < numberOfThreads; i++) { + threads[i].join(); + } } public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatJNIArgs.c b/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatJNIArgs.c --- a/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatJNIArgs.c +++ b/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatJNIArgs.c @@ -62,6 +62,19 @@ return f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15; } +JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add5floats + (JNIEnv *env, jclass cls, + jfloat f1, jfloat f2, jfloat f3, jfloat f4, + jfloat f5, jfloat f6, jfloat f7, jfloat f8, jint a9, jint a10) { + return f1 + f2 + f3 + f4 + f5; +} + +JNIEXPORT jdouble JNICALL Java_compiler_floatingpoint_TestFloatJNIArgs_add5doubles + (JNIEnv *env, jclass cls, + jdouble f1, jdouble f2, jdouble f3, jdouble f4, + jdouble f5, jdouble f6, jdouble f7, jdouble f8, jint a9, jint a10) { + return f1 + f2 + f3 + f4 + f5; +} #ifdef __cplusplus }