Add an arm32 port of nterp.
Currently using arm32, will try thumb once this CL lands to compare
performance.
Test: test.py, run-libcore-tests, device boots
Bug: 112676029
Change-Id: I6535e2982a3ceed83eba6664fc8ba8609974bc08
diff --git a/runtime/arch/arm/asm_support_arm.S b/runtime/arch/arm/asm_support_arm.S
index 7ffdf18..dd48d1d 100644
--- a/runtime/arch/arm/asm_support_arm.S
+++ b/runtime/arch/arm/asm_support_arm.S
@@ -36,6 +36,7 @@
.syntax unified
.arch armv7-a
+.arch_extension idiv
.thumb
.macro CFI_EXPRESSION_BREG n, b, offset
@@ -48,6 +49,22 @@
.endif
.endm
+.macro CFI_DEF_CFA_BREG_PLUS_UCONST reg, offset, size
+ .if ((\size) < 0)
+ .error "Size should be positive"
+ .endif
+ .if (((\offset) < -0x40) || ((\offset) >= 0x40))
+ .error "Unsupported offset"
+ .endif
+ .if ((\size) < 0x80)
+ CFI_DEF_CFA_BREG_PLUS_UCONST_1_1(\reg, \offset, \size)
+ .elseif ((\size) < 0x4000)
+ CFI_DEF_CFA_BREG_PLUS_UCONST_1_2(\reg, \offset, \size)
+ .else
+ .error "Unsupported size"
+ .endif
+.endm
+
// Macro to generate the value of Runtime::Current into rDest. As it uses labels
// then the labels need to be unique. We bind these to the function name in the ENTRY macros.
.macro RUNTIME_CURRENT name, num, rDest
@@ -290,4 +307,73 @@
DELIVER_PENDING_EXCEPTION_FRAME_READY
.endm
+.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_REG reg
+ ldr \reg, [rSELF, #THREAD_EXCEPTION_OFFSET] @ Get exception field.
+ cbnz \reg, 1f
+ bx lr
+1:
+ DELIVER_PENDING_EXCEPTION
+.endm
+
+.macro RETURN_OR_DELIVER_PENDING_EXCEPTION_R1
+ RETURN_OR_DELIVER_PENDING_EXCEPTION_REG r1
+.endm
+
+.macro RETURN_OR_DELIVER_PENDING_EXCEPTION
+ ldr ip, [rSELF, #THREAD_EXCEPTION_OFFSET] @ Get exception field.
+ cmp ip, #0
+ bne 1f
+ bx lr
+1:
+ DELIVER_PENDING_EXCEPTION
+.endm
+
+ /*
+ * Macro that sets up the callee save frame to conform with
+ * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly).
+ */
+.macro SETUP_SAVE_REFS_ONLY_FRAME rTemp
+ // Note: We could avoid saving R8 in the case of Baker read
+ // barriers, as it is overwritten by REFRESH_MARKING_REGISTER
+ // later; but it's not worth handling this special case.
+ push {r5-r8, r10-r11, lr} @ 7 words of callee saves
+ .cfi_adjust_cfa_offset 28
+ .cfi_rel_offset r5, 0
+ .cfi_rel_offset r6, 4
+ .cfi_rel_offset r7, 8
+ .cfi_rel_offset r8, 12
+ .cfi_rel_offset r10, 16
+ .cfi_rel_offset r11, 20
+ .cfi_rel_offset lr, 24
+ sub sp, #4 @ bottom word will hold Method*
+ .cfi_adjust_cfa_offset 4
+ RUNTIME_CURRENT2 \rTemp @ Load Runtime::Current into rTemp.
+ @ Load kSaveRefsOnly Method* into rTemp.
+ ldr \rTemp, [\rTemp, #RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET]
+ str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
+ str sp, [rSELF, #THREAD_TOP_QUICK_FRAME_OFFSET] @ Place sp in Thread::Current()->top_quick_frame.
+
+ // Ugly compile-time check, but we only have the preprocessor.
+#if (FRAME_SIZE_SAVE_REFS_ONLY != 28 + 4)
+#error "FRAME_SIZE_SAVE_REFS_ONLY(ARM) size not as expected."
+#endif
+.endm
+
+.macro RESTORE_SAVE_REFS_ONLY_FRAME
+ add sp, #4 @ bottom word holds Method*
+ .cfi_adjust_cfa_offset -4
+ // Note: Likewise, we could avoid restoring R8 in the case of Baker
+ // read barriers, as it is overwritten by REFRESH_MARKING_REGISTER
+ // later; but it's not worth handling this special case.
+ pop {r5-r8, r10-r11, lr} @ 7 words of callee saves
+ .cfi_restore r5
+ .cfi_restore r6
+ .cfi_restore r7
+ .cfi_restore r8
+ .cfi_restore r10
+ .cfi_restore r11
+ .cfi_restore lr
+ .cfi_adjust_cfa_offset -28
+.endm
+
#endif // ART_RUNTIME_ARCH_X86_ASM_SUPPORT_X86_S_