• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_RUNTIME_ARCH_ARM_ASM_SUPPORT_ARM_S_
18 #define ART_RUNTIME_ARCH_ARM_ASM_SUPPORT_ARM_S_
19 
20 #include "asm_support_arm.h"
21 
22 // Define special registers.
23 
24 // Register holding suspend check count down.
25 #define rSUSPEND r4
26 // Register holding Thread::Current().
27 #define rSELF r9
28 
29 #if defined(USE_READ_BARRIER) && defined(USE_BAKER_READ_BARRIER)
30 // Marking Register, holding Thread::Current()->GetIsGcMarking().
31 // Only used with the Concurrent Copying (CC) garbage
32 // collector, with the Baker read barrier configuration.
33 #define rMR r8
34 #endif
35 
36 .syntax unified
37 .arch armv7-a
38 .thumb
39 
40 // Macro to generate the value of Runtime::Current into rDest. As it uses labels
41 // then the labels need to be unique. We bind these to the function name in the ENTRY macros.
42 .macro RUNTIME_CURRENT name, num, rDest
43     .if .Lruntime_current\num\()_used
44          .error
45     .endif
46     .set .Lruntime_current\num\()_used, 1
47     ldr \rDest, .Lruntime_instance_\name\()_\num  @ Load GOT_PREL offset of Runtime::instance_.
48 .Lload_got_\name\()_\num\():
49     add \rDest, pc                                @ Fixup GOT_PREL address.
50     ldr \rDest, [\rDest]                          @ Load address of Runtime::instance_.
51     ldr \rDest, [\rDest]                          @ Load Runtime::instance_.
52 .endm
53 
54 // Common ENTRY declaration code for ARM and thumb, an ENTRY should always be paired with an END.
55 // Declares the RUNTIME_CURRENT[123] macros that can be used within an ENTRY and will have literals
56 // generated at END.
57 .macro DEF_ENTRY thumb_or_arm, name
58     \thumb_or_arm
59 // Clang ignores .thumb_func and requires an explicit .thumb. Investigate whether we should still
60 // carry around the .thumb_func.
61     .ifc \thumb_or_arm, .thumb_func
62         .thumb
63     .endif
64     .type \name, #function
65     .hidden \name  // Hide this as a global symbol, so we do not incur plt calls.
66     .global \name
67     // Cache alignment for function entry.
68     .balign 16
69 \name:
70     .cfi_startproc
71     .fnstart
72     // Track whether RUNTIME_CURRENT was used.
73     .set .Lruntime_current1_used, 0
74     .set .Lruntime_current2_used, 0
75     .set .Lruntime_current3_used, 0
76     // The RUNTIME_CURRENT macros that are bound to the \name argument of DEF_ENTRY to ensure
77     // that label names are unique.
78     .macro RUNTIME_CURRENT1 rDest
79         RUNTIME_CURRENT \name, 1, \rDest
80     .endm
81     .macro RUNTIME_CURRENT2 rDest
82         RUNTIME_CURRENT \name, 2, \rDest
83     .endm
84     .macro RUNTIME_CURRENT3 rDest
85         RUNTIME_CURRENT \name, 3, \rDest
86     .endm
87 .endm
88 
89 // A thumb2 style ENTRY.
90 .macro ENTRY name
91     DEF_ENTRY .thumb_func, \name
92 .endm
93 
94 // A ARM style ENTRY.
95 .macro ARM_ENTRY name
96     DEF_ENTRY .arm, \name
97 .endm
98 
99 // Terminate an ENTRY and generate GOT_PREL references.
100 .macro END name
101      // Generate offsets of GOT and Runtime::instance_ used in RUNTIME_CURRENT.
102      .if .Lruntime_current1_used
103          .Lruntime_instance_\name\()_1:
104              .word   _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_1+4)
105      .endif
106      .if .Lruntime_current2_used
107          .Lruntime_instance_\name\()_2:
108              .word   _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_2+4)
109     .endif
110      .if .Lruntime_current3_used
111          .Lruntime_instance_\name\()_3:
112              .word   _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_3+4)
113     .endif
114     // Remove the RUNTIME_CURRENTx macros so they get rebound in the next function entry.
115     .purgem RUNTIME_CURRENT1
116     .purgem RUNTIME_CURRENT2
117     .purgem RUNTIME_CURRENT3
118     .fnend
119     .cfi_endproc
120     .size \name, .-\name
121 .endm
122 
123 // Declare an unimplemented ENTRY that will halt a debugger.
124 .macro UNIMPLEMENTED name
125     ENTRY \name
126     bkpt
127     bkpt
128     END \name
129 .endm
130 
131 // Macro to poison (negate) the reference for heap poisoning.
132 .macro POISON_HEAP_REF rRef
133 #ifdef USE_HEAP_POISONING
134     rsb \rRef, \rRef, #0
135 #endif  // USE_HEAP_POISONING
136 .endm
137 
138 // Macro to unpoison (negate) the reference for heap poisoning.
139 .macro UNPOISON_HEAP_REF rRef
140 #ifdef USE_HEAP_POISONING
141     rsb \rRef, \rRef, #0
142 #endif  // USE_HEAP_POISONING
143 .endm
144 
145 #endif  // ART_RUNTIME_ARCH_X86_ASM_SUPPORT_X86_S_
146