-
Bug
-
Resolution: Fixed
-
P1
-
10, 11, 12
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8210175 | 12 | Andrew Haley | P1 | Resolved | Fixed | b09 |
JDK-8210084 | 11.0.2 | Andrew Haley | P1 | Resolved | Fixed | b01 |
JDK-8210076 | 11.0.1 | Andrew Haley | P1 | Resolved | Fixed | b08 |
JDK-8260816 | openjdk8u292 | Andrew Hughes | P1 | Resolved | Fixed | b01 |
JNI test case:
JniStaticContextFloat.c
#include <jni.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jfloat JNICALL Java_JniStaticContextFloat_staticMethodFloat1(JNIEnv *env, jclass cl, jfloat j0, jfloat j1, jfloat j2, jfloat j3)
{
if (j0 != (float) (1) || j1 != (float) (2) || j2 != (float) (4) || j3 != (float)(8))
{
printf("JNI: %f %f %f %f\n", j0, j1, j2, j3);
exit(1);
}
return 1;
}
JniStaticContextFloat.java
public class JniStaticContextFloat {
final static int Count = 1024;
public static synchronized native float staticMethodFloat1(float j0, float j1, float j2, float j3);
public static void main(String[] args) throws Exception {
System.load("/home/yangfei/test/JNI/libJniStatic.so");
for (int c = 0; c < Count; c++) {
Thread t = new Thread(new Runnable() {
public void run() {
float d = JniStaticContextFloat.staticMethodFloat1((float) (1), (float) (2), (float) (4), (float) (8));
}
});
t.start();
}
Thread.sleep(1000);
System.out.println("PASS!");
}
}
$gcc -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -shared -fpic JniStaticContextFloat.c -o libJniStatic.so
$javac JniStaticContextFloat.java
$java JniStaticContextFloat
The above testcase randomly print the following message:
JNI: 8.000000 4.000000 2.000000 1.000000
Patch contributed by guoge1@huawei.com:
diff -r a25c48c0a1ab src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Mon Jul 16 15:09:19 2018 -0700
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Thu Jul 19 15:14:08 2018 +0800
@@ -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()) {
JniStaticContextFloat.c
#include <jni.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jfloat JNICALL Java_JniStaticContextFloat_staticMethodFloat1(JNIEnv *env, jclass cl, jfloat j0, jfloat j1, jfloat j2, jfloat j3)
{
if (j0 != (float) (1) || j1 != (float) (2) || j2 != (float) (4) || j3 != (float)(8))
{
printf("JNI: %f %f %f %f\n", j0, j1, j2, j3);
exit(1);
}
return 1;
}
JniStaticContextFloat.java
public class JniStaticContextFloat {
final static int Count = 1024;
public static synchronized native float staticMethodFloat1(float j0, float j1, float j2, float j3);
public static void main(String[] args) throws Exception {
System.load("/home/yangfei/test/JNI/libJniStatic.so");
for (int c = 0; c < Count; c++) {
Thread t = new Thread(new Runnable() {
public void run() {
float d = JniStaticContextFloat.staticMethodFloat1((float) (1), (float) (2), (float) (4), (float) (8));
}
});
t.start();
}
Thread.sleep(1000);
System.out.println("PASS!");
}
}
$gcc -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -shared -fpic JniStaticContextFloat.c -o libJniStatic.so
$javac JniStaticContextFloat.java
$java JniStaticContextFloat
The above testcase randomly print the following message:
JNI: 8.000000 4.000000 2.000000 1.000000
Patch contributed by guoge1@huawei.com:
diff -r a25c48c0a1ab src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Mon Jul 16 15:09:19 2018 -0700
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp Thu Jul 19 15:14:08 2018 +0800
@@ -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()) {
- backported by
-
JDK-8210076 AArch64: Float registers incorrectly restored in JNI call
- Resolved
-
JDK-8210084 AArch64: Float registers incorrectly restored in JNI call
- Resolved
-
JDK-8210175 AArch64: Float registers incorrectly restored in JNI call
- Resolved
-
JDK-8260816 AArch64: Float registers incorrectly restored in JNI call
- Resolved
- relates to
-
JDK-8257192 Integrate AArch64 JIT port into 8u
- Resolved