summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2018-11-09 18:55:19 +0000
committer David Srbecky <dsrbecky@google.com> 2018-11-14 10:01:02 +0000
commit790ff518ad4d08ed4fb105f5c011c0ec47e092cd (patch)
treebf9def1c8a0567905bec3946ee67fe7410ca3715
parent4630f9a032575f75be317fe0d8dc054bbce5790a (diff)
Add mterp checks after monitor entry/exit opcodes.
Check whether we are allowed to continue running in mterp. This tries to enforce that we bail out of mterp after suspend point if needed (in particular, if debugger event switches interpreters). Test: ./art/test.py -b -r --interpreter Change-Id: If2d55e5ece22831ef864c181b7d6d5c70ca50e5d
-rw-r--r--runtime/interpreter/mterp/arm/other.S6
-rw-r--r--runtime/interpreter/mterp/arm64/other.S4
-rw-r--r--runtime/interpreter/mterp/x86/invoke.S6
-rw-r--r--runtime/interpreter/mterp/x86/main.S5
-rw-r--r--runtime/interpreter/mterp/x86/other.S14
-rw-r--r--runtime/interpreter/mterp/x86_64/invoke.S6
-rw-r--r--runtime/interpreter/mterp/x86_64/main.S5
-rw-r--r--runtime/interpreter/mterp/x86_64/other.S14
8 files changed, 44 insertions, 16 deletions
diff --git a/runtime/interpreter/mterp/arm/other.S b/runtime/interpreter/mterp/arm/other.S
index 340038c83e..fcdde1e72a 100644
--- a/runtime/interpreter/mterp/arm/other.S
+++ b/runtime/interpreter/mterp/arm/other.S
@@ -159,6 +159,9 @@
cmp r0, #0
bne MterpException
FETCH_ADVANCE_INST 1
+ ldr r0, [rSELF, #THREAD_USE_MTERP_OFFSET]
+ cmp r0, #0
+ beq MterpFallback
GET_INST_OPCODE ip @ extract opcode from rINST
GOTO_OPCODE ip @ jump to next instruction
@@ -179,6 +182,9 @@
cmp r0, #0 @ failed?
bne MterpException
FETCH_ADVANCE_INST 1 @ before throw: advance rPC, load rINST
+ ldr r0, [rSELF, #THREAD_USE_MTERP_OFFSET]
+ cmp r0, #0
+ beq MterpFallback
GET_INST_OPCODE ip @ extract opcode from rINST
GOTO_OPCODE ip @ jump to next instruction
diff --git a/runtime/interpreter/mterp/arm64/other.S b/runtime/interpreter/mterp/arm64/other.S
index 024a5c8a07..f1d0ef34dc 100644
--- a/runtime/interpreter/mterp/arm64/other.S
+++ b/runtime/interpreter/mterp/arm64/other.S
@@ -146,6 +146,8 @@
bl artLockObjectFromCode
cbnz w0, MterpException
FETCH_ADVANCE_INST 1
+ ldr w0, [xSELF, #THREAD_USE_MTERP_OFFSET]
+ cbz w0, MterpFallback
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
@@ -165,6 +167,8 @@
bl artUnlockObjectFromCode // w0<- success for unlock(self, obj)
cbnz w0, MterpException
FETCH_ADVANCE_INST 1 // before throw: advance rPC, load rINST
+ ldr w0, [xSELF, #THREAD_USE_MTERP_OFFSET]
+ cbz w0, MterpFallback
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
diff --git a/runtime/interpreter/mterp/x86/invoke.S b/runtime/interpreter/mterp/x86/invoke.S
index cfb9c7c719..06cd904756 100644
--- a/runtime/interpreter/mterp/x86/invoke.S
+++ b/runtime/interpreter/mterp/x86/invoke.S
@@ -18,8 +18,7 @@
jz MterpException
ADVANCE_PC 3
movl rSELF, %eax
- movb THREAD_USE_MTERP_OFFSET(%eax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%eax)
jz MterpFallback
RESTORE_IBASE
FETCH_INST
@@ -45,8 +44,7 @@
jz MterpException
ADVANCE_PC 4
movl rSELF, %eax
- movb THREAD_USE_MTERP_OFFSET(%eax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%eax)
jz MterpFallback
RESTORE_IBASE
FETCH_INST
diff --git a/runtime/interpreter/mterp/x86/main.S b/runtime/interpreter/mterp/x86/main.S
index b233f2c522..0621fb468a 100644
--- a/runtime/interpreter/mterp/x86/main.S
+++ b/runtime/interpreter/mterp/x86/main.S
@@ -91,6 +91,8 @@ unspecified registers or condition codes.
#include "asm_support.h"
#include "interpreter/cfi_asm_support.h"
+#define LITERAL(value) $$(value)
+
/*
* Handle mac compiler specific
*/
@@ -561,8 +563,7 @@ MterpException:
movl rPC, OFF_FP_DEX_PC_PTR(rFP)
/* Do we need to switch interpreters? */
movl rSELF, %eax
- movb THREAD_USE_MTERP_OFFSET(%eax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%eax)
jz MterpFallback
/* resume execution at catch block */
REFRESH_IBASE
diff --git a/runtime/interpreter/mterp/x86/other.S b/runtime/interpreter/mterp/x86/other.S
index 5de33813b8..270ccb688c 100644
--- a/runtime/interpreter/mterp/x86/other.S
+++ b/runtime/interpreter/mterp/x86/other.S
@@ -132,7 +132,12 @@
RESTORE_IBASE
testb %al, %al
jnz MterpException
- ADVANCE_PC_FETCH_AND_GOTO_NEXT 1
+ ADVANCE_PC 1
+ movl rSELF, %eax
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%eax)
+ jz MterpFallback
+ FETCH_INST
+ GOTO_NEXT
%def op_monitor_exit():
/*
@@ -152,7 +157,12 @@
RESTORE_IBASE
testb %al, %al
jnz MterpException
- ADVANCE_PC_FETCH_AND_GOTO_NEXT 1
+ ADVANCE_PC 1
+ movl rSELF, %eax
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%eax)
+ jz MterpFallback
+ FETCH_INST
+ GOTO_NEXT
%def op_move(is_object="0"):
/* for move, move-object, long-to-int */
diff --git a/runtime/interpreter/mterp/x86_64/invoke.S b/runtime/interpreter/mterp/x86_64/invoke.S
index f727915265..15b48c91dc 100644
--- a/runtime/interpreter/mterp/x86_64/invoke.S
+++ b/runtime/interpreter/mterp/x86_64/invoke.S
@@ -16,8 +16,7 @@
jz MterpException
ADVANCE_PC 3
movq rSELF, %rax
- movb THREAD_USE_MTERP_OFFSET(%rax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%rax)
jz MterpFallback
FETCH_INST
GOTO_NEXT
@@ -40,8 +39,7 @@
jz MterpException
ADVANCE_PC 4
movq rSELF, %rax
- movb THREAD_USE_MTERP_OFFSET(%rax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%rax)
jz MterpFallback
FETCH_INST
GOTO_NEXT
diff --git a/runtime/interpreter/mterp/x86_64/main.S b/runtime/interpreter/mterp/x86_64/main.S
index 75eb00c461..4609067a5a 100644
--- a/runtime/interpreter/mterp/x86_64/main.S
+++ b/runtime/interpreter/mterp/x86_64/main.S
@@ -87,6 +87,8 @@ unspecified registers or condition codes.
#include "asm_support.h"
#include "interpreter/cfi_asm_support.h"
+#define LITERAL(value) $$(value)
+
/*
* Handle mac compiler specific
*/
@@ -527,8 +529,7 @@ MterpException:
movq rPC, OFF_FP_DEX_PC_PTR(rFP)
/* Do we need to switch interpreters? */
movq rSELF, %rax
- movb THREAD_USE_MTERP_OFFSET(%rax), %al
- testb %al, %al
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%rax)
jz MterpFallback
/* resume execution at catch block */
REFRESH_IBASE
diff --git a/runtime/interpreter/mterp/x86_64/other.S b/runtime/interpreter/mterp/x86_64/other.S
index 849155ca8f..412389f3ed 100644
--- a/runtime/interpreter/mterp/x86_64/other.S
+++ b/runtime/interpreter/mterp/x86_64/other.S
@@ -108,7 +108,12 @@
call SYMBOL(artLockObjectFromCode) # (object, self)
testq %rax, %rax
jnz MterpException
- ADVANCE_PC_FETCH_AND_GOTO_NEXT 1
+ ADVANCE_PC 1
+ movq rSELF, %rax
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%rax)
+ jz MterpFallback
+ FETCH_INST
+ GOTO_NEXT
%def op_monitor_exit():
/*
@@ -125,7 +130,12 @@
call SYMBOL(artUnlockObjectFromCode) # (object, self)
testq %rax, %rax
jnz MterpException
- ADVANCE_PC_FETCH_AND_GOTO_NEXT 1
+ ADVANCE_PC 1
+ movq rSELF, %rax
+ cmpb LITERAL(0), THREAD_USE_MTERP_OFFSET(%rax)
+ jz MterpFallback
+ FETCH_INST
+ GOTO_NEXT
%def op_move(is_object="0"):
/* for move, move-object, long-to-int */