From 4429b110c7b4d9bda2c31b4df257e840831d01f6 Mon Sep 17 00:00:00 2001 From: buzbee Date: Wed, 24 Feb 2016 15:16:46 -0800 Subject: [PATCH] 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 --- runtime/interpreter/mterp/out/mterp_x86.S | 42 ++++++++++++++++++++++++++++++- runtime/interpreter/mterp/x86/footer.S | 6 ++++- runtime/interpreter/mterp/x86/invoke.S | 3 +++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/runtime/interpreter/mterp/out/mterp_x86.S b/runtime/interpreter/mterp/out/mterp_x86.S index b05360b6a..589639bdb 100644 --- a/runtime/interpreter/mterp/out/mterp_x86.S +++ b/runtime/interpreter/mterp/out/mterp_x86.S @@ -2989,6 +2989,9 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ SYMBOL(artMterpAsmInstructionStart) = .L_op_nop 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 @@ MterpException: 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 c67491e57..64d72d770 100644 --- a/runtime/interpreter/mterp/x86/footer.S +++ b/runtime/interpreter/mterp/x86/footer.S @@ -115,13 +115,17 @@ MterpException: 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 bbd88cf40..cb74a0447 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 -- 2.11.0