Fix generic JNI stubs to not discard the Java native frame.
Change-Id: Ic856b442fdde5ce91673fc5856eb0dfc84c75d28
diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S
index c2acdd1..47bc5ea 100644
--- a/runtime/arch/x86/quick_entrypoints_x86.S
+++ b/runtime/arch/x86/quick_entrypoints_x86.S
@@ -1349,7 +1349,7 @@
// Check for error = 0.
test %eax, %eax
- jz .Lentry_error
+ jz .Lexception_in_native
// Release part of the alloca.
movl %edx, %esp
@@ -1371,15 +1371,16 @@
pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current().
call SYMBOL(artQuickGenericJniEndTrampoline)
- // Tear down the alloca.
- movl %ebp, %esp
- CFI_DEF_CFA_REGISTER(esp)
-
// Pending exceptions possible.
mov %fs:THREAD_EXCEPTION_OFFSET, %ebx
testl %ebx, %ebx
jnz .Lexception_in_native
+ // Tear down the alloca.
+ movl %ebp, %esp
+ CFI_DEF_CFA_REGISTER(esp)
+
+
// Tear down the callee-save frame.
// Remove space for FPR args and EAX
addl LITERAL(4 + 4 * 8), %esp
@@ -1397,11 +1398,11 @@
movd %edx, %xmm1
punpckldq %xmm1, %xmm0
ret
-.Lentry_error:
- movl %ebp, %esp
- CFI_DEF_CFA_REGISTER(esp)
.Lexception_in_native:
- RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME
+ movl %fs:THREAD_TOP_QUICK_FRAME_OFFSET, %esp
+ // Do a call to push a new save-all frame required by the runtime.
+ call .Lexception_call
+.Lexception_call:
DELIVER_PENDING_EXCEPTION
END_FUNCTION art_quick_generic_jni_trampoline