arm: Don't use the GOT to access art::Runtime::instance_.
Test: testrunner.py --target --32 --optimizing
Change-Id: I117be654f5b3629cb4221a0ff3a493d5268cf669
diff --git a/runtime/arch/arm/asm_support_arm.S b/runtime/arch/arm/asm_support_arm.S
index 144f761..23d82ba 100644
--- a/runtime/arch/arm/asm_support_arm.S
+++ b/runtime/arch/arm/asm_support_arm.S
@@ -73,23 +73,7 @@
.cfi_def_cfa \reg, \offset
.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
- .if .Lruntime_current\num\()_used
- .error
- .endif
- .set .Lruntime_current\num\()_used, 1
- ldr \rDest, .Lruntime_instance_\name\()_\num @ Load GOT_PREL offset of Runtime::instance_.
-.Lload_got_\name\()_\num\():
- add \rDest, pc @ Fixup GOT_PREL address.
- ldr \rDest, [\rDest] @ Load address of Runtime::instance_.
- ldr \rDest, [\rDest] @ Load Runtime::instance_.
-.endm
-
// Common ENTRY declaration code for ARM and thumb, an ENTRY should always be paired with an END.
-// Declares the RUNTIME_CURRENT[123] macros that can be used within an ENTRY and will have literals
-// generated at END.
.macro DEF_ENTRY thumb_or_arm, name, alignment
\thumb_or_arm
// Clang ignores .thumb_func and requires an explicit .thumb. Investigate whether we should still
@@ -109,21 +93,6 @@
\name:
.cfi_startproc
.fnstart
- // Track whether RUNTIME_CURRENT was used.
- .set .Lruntime_current1_used, 0
- .set .Lruntime_current2_used, 0
- .set .Lruntime_current3_used, 0
- // The RUNTIME_CURRENT macros that are bound to the \name argument of DEF_ENTRY to ensure
- // that label names are unique.
- .macro RUNTIME_CURRENT1 rDest
- RUNTIME_CURRENT \name, 1, \rDest
- .endm
- .macro RUNTIME_CURRENT2 rDest
- RUNTIME_CURRENT \name, 2, \rDest
- .endm
- .macro RUNTIME_CURRENT3 rDest
- RUNTIME_CURRENT \name, 3, \rDest
- .endm
.endm
// A thumb2 style ENTRY.
@@ -139,25 +108,8 @@
DEF_ENTRY .arm, \name, 16
.endm
-// Terminate an ENTRY and generate GOT_PREL references.
+// Terminate an ENTRY.
.macro END name
- // Generate offsets of GOT and Runtime::instance_ used in RUNTIME_CURRENT.
- .if .Lruntime_current1_used
- .Lruntime_instance_\name\()_1:
- .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_1+4)
- .endif
- .if .Lruntime_current2_used
- .Lruntime_instance_\name\()_2:
- .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_2+4)
- .endif
- .if .Lruntime_current3_used
- .Lruntime_instance_\name\()_3:
- .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_3+4)
- .endif
- // Remove the RUNTIME_CURRENTx macros so they get rebound in the next function entry.
- .purgem RUNTIME_CURRENT1
- .purgem RUNTIME_CURRENT2
- .purgem RUNTIME_CURRENT3
.fnend
.cfi_endproc
.size \name, .-\name
@@ -195,6 +147,13 @@
.cfi_adjust_cfa_offset -(\frame_adjustment)
.endm
+.macro LOAD_RUNTIME_INSTANCE rDest
+ movw \rDest, #:lower16:(_ZN3art7Runtime9instance_E - (. + 12))
+ movt \rDest, #:upper16:(_ZN3art7Runtime9instance_E - (. + 8))
+ add \rDest, pc
+ ldr \rDest, [\rDest]
+.endm
+
// Macro to refresh the Marking Register (R8).
//
// This macro must be called at the end of functions implementing
@@ -318,7 +277,7 @@
.cfi_adjust_cfa_offset 64
sub sp, #12 @ 3 words of space, bottom word will hold Method*
.cfi_adjust_cfa_offset 12
- RUNTIME_CURRENT1 \rTemp @ Load Runtime::Current into rTemp.
+ LOAD_RUNTIME_INSTANCE \rTemp @ Load Runtime::Current into rTemp.
@ Load kSaveAllCalleeSaves Method* into rTemp.
ldr \rTemp, [\rTemp, #RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET]
str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
@@ -388,7 +347,7 @@
.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_RUNTIME_INSTANCE \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.
diff --git a/runtime/arch/arm/jni_entrypoints_arm.S b/runtime/arch/arm/jni_entrypoints_arm.S
index 03b857f..96b6241 100644
--- a/runtime/arch/arm/jni_entrypoints_arm.S
+++ b/runtime/arch/arm/jni_entrypoints_arm.S
@@ -205,7 +205,7 @@
str lr, [r4, #(FRAME_SIZE_SAVE_REFS_AND_ARGS - __SIZEOF_POINTER__)]
// Replace the target method with the SaveRefsAndArgs runtime method.
- RUNTIME_CURRENT1 r1
+ LOAD_RUNTIME_INSTANCE r1
ldr r1, [r1, #RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET]
mov r2, r4 // Prepare untagged managed SP for the runtime method.
@@ -302,7 +302,7 @@
vstmia ip, {s16-s31}
// Store ArtMethod* Runtime::callee_save_methods_[kSaveAllCalleeSaves] to the managed frame.
- RUNTIME_CURRENT2 ip
+ LOAD_RUNTIME_INSTANCE ip
ldr ip, [ip, #RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET]
str ip, [r4]
diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S
index 7add6bb..7e11d32 100644
--- a/runtime/arch/arm/quick_entrypoints_arm.S
+++ b/runtime/arch/arm/quick_entrypoints_arm.S
@@ -26,7 +26,7 @@
.macro SETUP_SAVE_REFS_AND_ARGS_FRAME rTemp
SETUP_SAVE_REFS_AND_ARGS_FRAME_REGISTERS_ONLY
- RUNTIME_CURRENT3 \rTemp @ Load Runtime::Current into rTemp.
+ LOAD_RUNTIME_INSTANCE \rTemp @ Load Runtime::Current into rTemp.
@ Load kSaveRefsAndArgs Method* into rTemp.
ldr \rTemp, [\rTemp, #RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET]
str \rTemp, [sp, #0] @ Place Method* at bottom of stack.
@@ -50,7 +50,7 @@
.cfi_adjust_cfa_offset 128
sub sp, #8 @ 2 words of space, alignment padding and Method*
.cfi_adjust_cfa_offset 8
- RUNTIME_CURRENT1 \rTemp @ Load Runtime::Current into rTemp.
+ LOAD_RUNTIME_INSTANCE \rTemp @ Load Runtime::Current into rTemp.
@ Load kSaveEverything Method* into rTemp.
ldr \rTemp, [\rTemp, #\runtime_method_offset]
str \rTemp, [sp, #0] @ Place Method* at bottom of stack.