ART: Support interpreter switching in x86 mterp
Because mterp only supports a subset of special modes and
instrumentation, it needs to recognize when new instrumentation
is added and bail out to the reference interpreter if needed.
The arm and arm64 mterp targets do this. This CL adds the
functionality to x86 mterp.
Change-Id: I72783577e6f26b2695677b07d8fa57fb887a36c8
diff --git a/runtime/interpreter/mterp/out/mterp_x86.S b/runtime/interpreter/mterp/out/mterp_x86.S
index b05360b..589639b 100644
--- a/runtime/interpreter/mterp/out/mterp_x86.S
+++ b/runtime/interpreter/mterp/out/mterp_x86.S
@@ -2989,6 +2989,9 @@
call SYMBOL(MterpInvokeVirtual)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3022,6 +3025,9 @@
call SYMBOL(MterpInvokeSuper)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3055,6 +3061,9 @@
call SYMBOL(MterpInvokeDirect)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3081,6 +3090,9 @@
call SYMBOL(MterpInvokeStatic)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3108,6 +3120,9 @@
call SYMBOL(MterpInvokeInterface)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3155,6 +3170,9 @@
call SYMBOL(MterpInvokeVirtualRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3181,6 +3199,9 @@
call SYMBOL(MterpInvokeSuperRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3207,6 +3228,9 @@
call SYMBOL(MterpInvokeDirectRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3233,6 +3257,9 @@
call SYMBOL(MterpInvokeStaticRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -3259,6 +3286,9 @@
call SYMBOL(MterpInvokeInterfaceRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -6002,6 +6032,9 @@
call SYMBOL(MterpInvokeVirtualQuick)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -6028,6 +6061,9 @@
call SYMBOL(MterpInvokeVirtualQuickRange)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3
@@ -12851,13 +12887,17 @@
call SYMBOL(MterpHandleException)
testb %al, %al
jz MterpExceptionReturn
- REFRESH_IBASE
movl OFF_FP_CODE_ITEM(rFP), %eax
movl OFF_FP_DEX_PC(rFP), %ecx
lea CODEITEM_INSNS_OFFSET(%eax), rPC
lea (rPC, %ecx, 2), rPC
movl rPC, OFF_FP_DEX_PC_PTR(rFP)
+ /* Do we need to switch interpreters? */
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
/* resume execution at catch block */
+ REFRESH_IBASE
FETCH_INST
GOTO_NEXT
/* NOTE: no fallthrough */
diff --git a/runtime/interpreter/mterp/x86/footer.S b/runtime/interpreter/mterp/x86/footer.S
index c67491e..64d72d7 100644
--- a/runtime/interpreter/mterp/x86/footer.S
+++ b/runtime/interpreter/mterp/x86/footer.S
@@ -115,13 +115,17 @@
call SYMBOL(MterpHandleException)
testb %al, %al
jz MterpExceptionReturn
- REFRESH_IBASE
movl OFF_FP_CODE_ITEM(rFP), %eax
movl OFF_FP_DEX_PC(rFP), %ecx
lea CODEITEM_INSNS_OFFSET(%eax), rPC
lea (rPC, %ecx, 2), rPC
movl rPC, OFF_FP_DEX_PC_PTR(rFP)
+ /* Do we need to switch interpreters? */
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
/* resume execution at catch block */
+ REFRESH_IBASE
FETCH_INST
GOTO_NEXT
/* NOTE: no fallthrough */
diff --git a/runtime/interpreter/mterp/x86/invoke.S b/runtime/interpreter/mterp/x86/invoke.S
index bbd88cf..cb74a04 100644
--- a/runtime/interpreter/mterp/x86/invoke.S
+++ b/runtime/interpreter/mterp/x86/invoke.S
@@ -16,5 +16,8 @@
call SYMBOL($helper)
testb %al, %al
jz MterpException
+ call SYMBOL(MterpShouldSwitchInterpreters)
+ testb %al, %al
+ jnz MterpFallback
RESTORE_IBASE
ADVANCE_PC_FETCH_AND_GOTO_NEXT 3