Skip to content

Commit

Permalink
x86: Fix JNI function 64-bit return values on 32-bit
Browse files Browse the repository at this point in the history
This patch fixes edx clobbering issue with 64-bit JNI function return values.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
  • Loading branch information
penberg committed Feb 18, 2012
1 parent 2ee893f commit 9a061b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions arch/x86/jni.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ jni_trampoline:
addl $0x4, %esp
subl $0x4, %esp # new return address

pushl %eax # save return value
# save return value
pushl %eax
pushl %edx

call vm_leave_jni
movl %eax, 0x4(%esp) # override return address
popl %eax # restore return value
movl %eax, 0x8(%esp) # override return address

# restore return value
popl %edx
popl %eax

ret
error:
Expand Down
2 changes: 2 additions & 0 deletions test/functional/java/lang/JNITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public static void testReturnPassedInt() {

public static void testReturnPassedLong() {
assertEquals(42l, staticReturnPassedLong(42l));
assertEquals(0xdeadbeefcafebabeL, staticReturnPassedLong(0xdeadbeefcafebabeL));
assertEquals(42l, jniTest.returnPassedLong(42l));
assertEquals(0xdeadbeefcafebabeL, jniTest.returnPassedLong(0xdeadbeefcafebabeL));
assertEquals(42l, staticReturnPassedLongArray(new long[]{42l})[0]);
assertEquals(42l, jniTest.returnPassedLongArray(new long[]{42l})[0]);
}
Expand Down

0 comments on commit 9a061b4

Please sign in to comment.