| 1 |
%def header(): |
| 2 |
/* |
| 3 |
* Copyright (C) 2020 The Android Open Source Project |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
*/ |
| 17 |
|
| 18 |
/* |
| 19 |
* This is a #include, not a %include, because we want the C pre-processor |
| 20 |
* to expand the macros into assembler assignment statements. |
| 21 |
*/ |
| 22 |
#include "asm_support.h" |
| 23 |
#include "arch/arm/asm_support_arm.S" |
| 24 |
|
| 25 |
/** |
| 26 |
* ARM EABI general notes: |
| 27 |
* |
| 28 |
* r0-r3 hold first 4 args to a method; they are not preserved across method calls |
| 29 |
* r4-r8 are available for general use |
| 30 |
* r9 is given special treatment in some situations, but not for us |
| 31 |
* r10 (sl) seems to be generally available |
| 32 |
* r11 (fp) is used by gcc (unless -fomit-frame-pointer is set) |
| 33 |
* r12 (ip) is scratch -- not preserved across method calls |
| 34 |
* r13 (sp) should be managed carefully in case a signal arrives |
| 35 |
* r14 (lr) must be preserved |
| 36 |
* r15 (pc) can be tinkered with directly |
| 37 |
* |
| 38 |
* r0 holds returns of <= 4 bytes |
| 39 |
* r0-r1 hold returns of 8 bytes, low word in r0 |
| 40 |
* |
| 41 |
* Callee must save/restore r4+ (except r12) if it modifies them. If VFP |
| 42 |
* is present, registers s16-s31 (a/k/a d8-d15, a/k/a q4-q7) must be preserved, |
| 43 |
* s0-s15 (d0-d7, q0-a3) do not need to be. |
| 44 |
* |
| 45 |
* Stack is "full descending". Only the arguments that don't fit in the first 4 |
| 46 |
* registers are placed on the stack. "sp" points at the first stacked argument |
| 47 |
* (i.e. the 5th arg). |
| 48 |
* |
| 49 |
* Native ABI uses soft-float, single-precision results are in r0, |
| 50 |
* double-precision results in r0-r1. |
| 51 |
* |
| 52 |
* In the EABI, "sp" must be 64-bit aligned on entry to a function, and any |
| 53 |
* 64-bit quantities (long long, double) must be 64-bit aligned. |
| 54 |
* |
| 55 |
* Nterp notes: |
| 56 |
* |
| 57 |
* The following registers have fixed assignments: |
| 58 |
* |
| 59 |
* reg nick purpose |
| 60 |
* r5 rFP interpreted frame pointer, used for accessing locals and args |
| 61 |
* r6 rREFS base of object references of dex registers |
| 62 |
* r7 rINST first 16-bit code unit of current instruction |
| 63 |
* r8 rMR marking register |
| 64 |
* r9 rSELF self (Thread) pointer |
| 65 |
* r10 rIBASE interpreted instruction base pointer, used for computed goto |
| 66 |
* r11 rPC interpreted program counter, used for fetching instructions |
| 67 |
* |
| 68 |
* r4, ip, and lr can be used as temporary |
| 69 |
* |
| 70 |
* Note that r4 is a callee-save register in ARM EABI, but not in managed code. |
| 71 |
* |
| 72 |
*/ |
| 73 |
|
| 74 |
/* single-purpose registers, given names for clarity */ |
| 75 |
#define CFI_DEX 11 // DWARF register number of the register holding dex-pc (rPC). |
| 76 |
#define CFI_TMP 0 // DWARF register number of the first argument register (r0). |
| 77 |
#define CFI_REFS 6 |
| 78 |
#define rFP r5 |
| 79 |
#define rREFS r6 |
| 80 |
#define rINST r7 |
| 81 |
#define rSELF r9 |
| 82 |
#define rIBASE r10 |
| 83 |
#define rPC r11 |
| 84 |
|
| 85 |
// To avoid putting ifdefs arond the use of rMR, make sure it's defined. |
| 86 |
// IsNterpSupported returns false for configurations that don't have rMR (typically CMS). |
| 87 |
#ifndef rMR |
| 88 |
#define rMR r8 |
| 89 |
#endif |
| 90 |
|
| 91 |
// Temporary registers while setting up a frame. |
| 92 |
#define rNEW_FP r8 |
| 93 |
#define rNEW_REFS r10 |
| 94 |
#define CFI_NEW_REFS 10 |
| 95 |
|
| 96 |
#define CALLEE_SAVES_SIZE (9 * 4 + 16 * 4) |
| 97 |
|
| 98 |
// +4 for the ArtMethod of the caller. |
| 99 |
#define OFFSET_TO_FIRST_ARGUMENT_IN_STACK (CALLEE_SAVES_SIZE + 4) |
| 100 |
|
| 101 |
/* |
| 102 |
* Fetch the next instruction from rPC into rINST. Does not advance rPC. |
| 103 |
*/ |
| 104 |
.macro FETCH_INST |
| 105 |
ldrh rINST, [rPC] |
| 106 |
.endm |
| 107 |
|
| 108 |
/* |
| 109 |
* Fetch the next instruction from the specified offset. Advances rPC |
| 110 |
* to point to the next instruction. "count" is in 16-bit code units. |
| 111 |
* |
| 112 |
* Because of the limited size of immediate constants on ARM, this is only |
| 113 |
* suitable for small forward movements (i.e. don't try to implement "goto" |
| 114 |
* with this). |
| 115 |
* |
| 116 |
* This must come AFTER anything that can throw an exception, or the |
| 117 |
* exception catch may miss. (This also implies that it must come after |
| 118 |
* EXPORT_PC.) |
| 119 |
*/ |
| 120 |
.macro FETCH_ADVANCE_INST count |
| 121 |
ldrh rINST, [rPC, #((\count)*2)]! |
| 122 |
.endm |
| 123 |
|
| 124 |
/* |
| 125 |
* Similar to FETCH_ADVANCE_INST, but does not update xPC. Used to load |
| 126 |
* rINST ahead of possible exception point. Be sure to manually advance xPC |
| 127 |
* later. |
| 128 |
*/ |
| 129 |
.macro PREFETCH_INST count |
| 130 |
ldrh rINST, [rPC, #((\count)*2)] |
| 131 |
.endm |
| 132 |
|
| 133 |
/* Advance xPC by some number of code units. */ |
| 134 |
.macro ADVANCE count |
| 135 |
add rPC, #((\count)*2) |
| 136 |
.endm |
| 137 |
|
| 138 |
/* |
| 139 |
* Fetch the next instruction from an offset specified by "reg" and advance xPC. |
| 140 |
* xPC to point to the next instruction. "reg" must specify the distance |
| 141 |
* in bytes, *not* 16-bit code units, and may be a signed value. |
| 142 |
*/ |
| 143 |
.macro FETCH_ADVANCE_INST_RB reg |
| 144 |
ldrh rINST, [rPC, \reg]! |
| 145 |
.endm |
| 146 |
|
| 147 |
/* |
| 148 |
* Fetch a half-word code unit from an offset past the current PC. The |
| 149 |
* "count" value is in 16-bit code units. Does not advance xPC. |
| 150 |
* |
| 151 |
* The "_S" variant works the same but treats the value as signed. |
| 152 |
*/ |
| 153 |
.macro FETCH reg, count |
| 154 |
ldrh \reg, [rPC, #((\count)*2)] |
| 155 |
.endm |
| 156 |
|
| 157 |
.macro FETCH_S reg, count |
| 158 |
ldrsh \reg, [rPC, #((\count)*2)] |
| 159 |
.endm |
| 160 |
|
| 161 |
/* |
| 162 |
* Fetch one byte from an offset past the current PC. Pass in the same |
| 163 |
* "count" as you would for FETCH, and an additional 0/1 indicating which |
| 164 |
* byte of the halfword you want (lo/hi). |
| 165 |
*/ |
| 166 |
.macro FETCH_B reg, count, byte |
| 167 |
ldrb \reg, [rPC, #((\count)*2+(\byte))] |
| 168 |
.endm |
| 169 |
|
| 170 |
/* |
| 171 |
* Put the instruction's opcode field into the specified register. |
| 172 |
*/ |
| 173 |
.macro GET_INST_OPCODE reg |
| 174 |
and \reg, rINST, #255 |
| 175 |
.endm |
| 176 |
|
| 177 |
/* |
| 178 |
* Begin executing the opcode in _reg. Clobbers reg |
| 179 |
*/ |
| 180 |
|
| 181 |
.macro GOTO_OPCODE reg |
| 182 |
add pc, rIBASE, \reg, lsl #${handler_size_bits} |
| 183 |
.endm |
| 184 |
|
| 185 |
/* |
| 186 |
* Get/set value from a Dalvik register. |
| 187 |
*/ |
| 188 |
.macro GET_VREG reg, vreg |
| 189 |
ldr \reg, [rFP, \vreg, lsl #2] |
| 190 |
.endm |
| 191 |
.macro GET_VREG_OBJECT reg, vreg |
| 192 |
ldr \reg, [rREFS, \vreg, lsl #2] |
| 193 |
.endm |
| 194 |
.macro SET_VREG reg, vreg |
| 195 |
str \reg, [rFP, \vreg, lsl #2] |
| 196 |
mov \reg, #0 |
| 197 |
str \reg, [rREFS, \vreg, lsl #2] |
| 198 |
.endm |
| 199 |
.macro SET_VREG_OBJECT reg, vreg |
| 200 |
str \reg, [rFP, \vreg, lsl #2] |
| 201 |
str \reg, [rREFS, \vreg, lsl #2] |
| 202 |
.endm |
| 203 |
.macro SET_VREG_FLOAT reg, vreg, tmpreg |
| 204 |
add \tmpreg, rFP, \vreg, lsl #2 |
| 205 |
vstr \reg, [\tmpreg] |
| 206 |
mov \tmpreg, #0 |
| 207 |
str \tmpreg, [rREFS, \vreg, lsl #2] |
| 208 |
.endm |
| 209 |
.macro GET_VREG_WIDE_BY_ADDR reg0, reg1, addr |
| 210 |
ldmia \addr, {\reg0, \reg1} |
| 211 |
.endm |
| 212 |
.macro SET_VREG_WIDE_BY_ADDR reg0, reg1, addr |
| 213 |
stmia \addr, {\reg0, \reg1} |
| 214 |
.endm |
| 215 |
.macro GET_VREG_FLOAT sreg, vreg |
| 216 |
ldr \vreg, [rFP, \vreg, lsl #2] |
| 217 |
vmov \sreg, \vreg |
| 218 |
.endm |
| 219 |
.macro GET_VREG_FLOAT_BY_ADDR reg, addr |
| 220 |
vldr \reg, [\addr] |
| 221 |
.endm |
| 222 |
.macro SET_VREG_FLOAT_BY_ADDR reg, addr |
| 223 |
vstr \reg, [\addr] |
| 224 |
.endm |
| 225 |
.macro GET_VREG_DOUBLE_BY_ADDR reg, addr |
| 226 |
vldr \reg, [\addr] |
| 227 |
.endm |
| 228 |
.macro SET_VREG_DOUBLE_BY_ADDR reg, addr |
| 229 |
vstr \reg, [\addr] |
| 230 |
.endm |
| 231 |
.macro SET_VREG_SHADOW reg, vreg |
| 232 |
str \reg, [rREFS, \vreg, lsl #2] |
| 233 |
.endm |
| 234 |
.macro CLEAR_SHADOW_PAIR vreg, tmp1, tmp2 |
| 235 |
mov \tmp1, #0 |
| 236 |
add \tmp2, \vreg, #1 |
| 237 |
SET_VREG_SHADOW \tmp1, \vreg |
| 238 |
SET_VREG_SHADOW \tmp1, \tmp2 |
| 239 |
.endm |
| 240 |
.macro VREG_INDEX_TO_ADDR reg, vreg |
| 241 |
add \reg, rFP, \vreg, lsl #2 |
| 242 |
.endm |
| 243 |
|
| 244 |
// An assembly entry that has a OatQuickMethodHeader prefix. |
| 245 |
.macro OAT_ENTRY name, end |
| 246 |
.arm |
| 247 |
.type \name, #function |
| 248 |
.hidden \name |
| 249 |
.global \name |
| 250 |
.balign 16 |
| 251 |
// Padding of 3 * 4 bytes to get 16 bytes alignment of code entry. |
| 252 |
.long 0 |
| 253 |
.long 0 |
| 254 |
.long 0 |
| 255 |
// OatQuickMethodHeader. Note that the top two bits must be clear. |
| 256 |
.long (\end - \name) |
| 257 |
\name: |
| 258 |
.endm |
| 259 |
|
| 260 |
.macro SIZE name |
| 261 |
.size \name, .-\name |
| 262 |
.endm |
| 263 |
|
| 264 |
.macro NAME_START name |
| 265 |
.arm |
| 266 |
.type \name, #function |
| 267 |
.hidden \name // Hide this as a global symbol, so we do not incur plt calls. |
| 268 |
.global \name |
| 269 |
/* Cache alignment for function entry */ |
| 270 |
.balign 16 |
| 271 |
\name: |
| 272 |
.endm |
| 273 |
|
| 274 |
.macro NAME_END name |
| 275 |
SIZE \name |
| 276 |
.endm |
| 277 |
|
| 278 |
// Macro for defining entrypoints into runtime. We don't need to save registers |
| 279 |
// (we're not holding references there), but there is no |
| 280 |
// kDontSave runtime method. So just use the kSaveRefsOnly runtime method. |
| 281 |
.macro NTERP_TRAMPOLINE name, helper |
| 282 |
ENTRY \name |
| 283 |
SETUP_SAVE_REFS_ONLY_FRAME ip |
| 284 |
bl \helper |
| 285 |
RESTORE_SAVE_REFS_ONLY_FRAME |
| 286 |
REFRESH_MARKING_REGISTER |
| 287 |
ldr ip, [rSELF, #THREAD_EXCEPTION_OFFSET] @ Get exception field. |
| 288 |
cmp ip, #0 |
| 289 |
bne nterp_deliver_pending_exception |
| 290 |
bx lr |
| 291 |
END \name |
| 292 |
.endm |
| 293 |
|
| 294 |
.macro CLEAR_STATIC_VOLATILE_MARKER reg |
| 295 |
and \reg, \reg, #-2 |
| 296 |
.endm |
| 297 |
|
| 298 |
.macro CLEAR_INSTANCE_VOLATILE_MARKER reg |
| 299 |
rsb \reg, \reg, #0 |
| 300 |
.endm |
| 301 |
|
| 302 |
.macro EXPORT_PC |
| 303 |
str rPC, [rREFS, #-8] |
| 304 |
.endm |
| 305 |
|
| 306 |
.macro BRANCH |
| 307 |
add rPC, rPC, rINST, lsl #1 |
| 308 |
// Update method counter and do a suspend check if the branch is negative or zero. |
| 309 |
cmp rINST, #0 |
| 310 |
ble 2f |
| 311 |
1: |
| 312 |
FETCH_INST // load rINST |
| 313 |
GET_INST_OPCODE ip // extract opcode from rINST |
| 314 |
GOTO_OPCODE ip // jump to next instruction |
| 315 |
2: |
| 316 |
ldr r0, [sp] |
| 317 |
ldrh r2, [r0, #ART_METHOD_HOTNESS_COUNT_OFFSET] |
| 318 |
cmp r2, #NTERP_HOTNESS_VALUE |
| 319 |
beq NterpHandleHotnessOverflow |
| 320 |
add r2, r2, #-1 |
| 321 |
strh r2, [r0, #ART_METHOD_HOTNESS_COUNT_OFFSET] |
| 322 |
DO_SUSPEND_CHECK continue_label=1b |
| 323 |
b 1b |
| 324 |
.endm |
| 325 |
|
| 326 |
.macro TEST_IF_MARKING label |
| 327 |
cmp rMR, #0 |
| 328 |
bne \label |
| 329 |
.endm |
| 330 |
|
| 331 |
// Expects: |
| 332 |
// - ip and lr to be available. |
| 333 |
// Outputs: |
| 334 |
// - \registers contains the dex registers size |
| 335 |
// - \outs contains the outs size |
| 336 |
// - if load_ins is 1, \ins contains the ins |
| 337 |
// - \code_item is replaced with a pointer to the instructions |
| 338 |
.macro FETCH_CODE_ITEM_INFO code_item, registers, outs, ins, load_ins |
| 339 |
tst \code_item, #1 |
| 340 |
beq 5f |
| 341 |
bic \code_item, \code_item, #1 // Remove the extra bit that marks it's a compact dex file |
| 342 |
ldrh lr, [\code_item, #COMPACT_CODE_ITEM_FIELDS_OFFSET] |
| 343 |
ubfx \registers, lr, #COMPACT_CODE_ITEM_REGISTERS_SIZE_SHIFT, #4 |
| 344 |
ubfx \outs, lr, #COMPACT_CODE_ITEM_OUTS_SIZE_SHIFT, #4 |
| 345 |
.if \load_ins |
| 346 |
ubfx \ins, lr, #COMPACT_CODE_ITEM_INS_SIZE_SHIFT, #4 |
| 347 |
.else |
| 348 |
ubfx ip, lr, #COMPACT_CODE_ITEM_INS_SIZE_SHIFT, #4 |
| 349 |
add \registers, \registers, ip |
| 350 |
.endif |
| 351 |
|
| 352 |
ldrh lr, [\code_item, #COMPACT_CODE_ITEM_FLAGS_OFFSET] |
| 353 |
tst lr, #COMPACT_CODE_ITEM_REGISTERS_INS_OUTS_FLAGS |
| 354 |
beq 4f |
| 355 |
mov ip, \code_item |
| 356 |
tst lr, #COMPACT_CODE_ITEM_INSNS_FLAG |
| 357 |
beq 1f |
| 358 |
sub ip, ip, #4 |
| 359 |
1: |
| 360 |
tst lr, #COMPACT_CODE_ITEM_REGISTERS_FLAG |
| 361 |
beq 2f |
| 362 |
ldrh lr, [ip, #-2]! |
| 363 |
add \registers, \registers, lr |
| 364 |
ldrh lr, [\code_item, #COMPACT_CODE_ITEM_FLAGS_OFFSET] |
| 365 |
2: |
| 366 |
tst lr, #COMPACT_CODE_ITEM_INS_FLAG |
| 367 |
beq 3f |
| 368 |
ldrh lr, [ip, #-2]! |
| 369 |
.if \load_ins |
| 370 |
add \ins, \ins, lr |
| 371 |
.else |
| 372 |
add \registers, \registers, lr |
| 373 |
.endif |
| 374 |
ldrh lr, [\code_item, #COMPACT_CODE_ITEM_FLAGS_OFFSET] |
| 375 |
3: |
| 376 |
tst lr, #COMPACT_CODE_ITEM_OUTS_FLAG |
| 377 |
beq 4f |
| 378 |
ldrh lr, [ip, #-2]! |
| 379 |
add \outs, \outs, lr |
| 380 |
4: |
| 381 |
.if \load_ins |
| 382 |
add \registers, \registers, \ins |
| 383 |
.endif |
| 384 |
add \code_item, \code_item, #COMPACT_CODE_ITEM_INSNS_OFFSET |
| 385 |
b 6f |
| 386 |
5: |
| 387 |
// Fetch dex register size. |
| 388 |
ldrh \registers, [\code_item, #CODE_ITEM_REGISTERS_SIZE_OFFSET] |
| 389 |
// Fetch outs size. |
| 390 |
ldrh \outs, [\code_item, #CODE_ITEM_OUTS_SIZE_OFFSET] |
| 391 |
.if \load_ins |
| 392 |
ldrh \ins, [\code_item, #CODE_ITEM_INS_SIZE_OFFSET] |
| 393 |
.endif |
| 394 |
add \code_item, \code_item, #CODE_ITEM_INSNS_OFFSET |
| 395 |
6: |
| 396 |
.endm |
| 397 |
|
| 398 |
// Setup the stack to start executing the method. Expects: |
| 399 |
// - r0 to contain the ArtMethod |
| 400 |
// - \code_item to already contain the code item |
| 401 |
// - rINST, ip, lr to be available |
| 402 |
// |
| 403 |
// Outputs |
| 404 |
// - rINST contains the dex registers size |
| 405 |
// - ip contains the old stack pointer. |
| 406 |
// - \code_item is replaced with a pointer to the instructions |
| 407 |
// - if load_ins is 1, r4 contains the ins |
| 408 |
// |
| 409 |
.macro SETUP_STACK_FRAME code_item, refs, fp, cfi_refs, load_ins |
| 410 |
FETCH_CODE_ITEM_INFO \code_item, rINST, \refs, r4, \load_ins |
| 411 |
|
| 412 |
// Compute required frame size: ((2 * rINST) + \refs) * 4 + 12 |
| 413 |
// 12 is for saving the previous frame, pc, and method being executed. |
| 414 |
add ip, \refs, rINST, lsl #1 |
| 415 |
|
| 416 |
// Compute new stack pointer in lr |
| 417 |
sub lr, sp, #12 |
| 418 |
sub lr, lr, ip, lsl #2 |
| 419 |
// Alignment |
| 420 |
and lr, lr, #-16 |
| 421 |
|
| 422 |
// Set reference and dex registers. |
| 423 |
add \refs, lr, \refs, lsl #2 |
| 424 |
add \refs, \refs, #12 |
| 425 |
add \fp, \refs, rINST, lsl #2 |
| 426 |
|
| 427 |
// Now setup the stack pointer. |
| 428 |
mov ip, sp |
| 429 |
.cfi_def_cfa_register ip |
| 430 |
mov sp, lr |
| 431 |
str ip, [\refs, #-4] |
| 432 |
CFI_DEF_CFA_BREG_PLUS_UCONST \cfi_refs, -4, CALLEE_SAVES_SIZE |
| 433 |
|
| 434 |
// Save the ArtMethod, and use r0 as a temporary. |
| 435 |
str r0, [sp] |
| 436 |
|
| 437 |
// Put nulls in reference frame. |
| 438 |
cmp rINST, #0 |
| 439 |
beq 2f |
| 440 |
mov lr, \refs |
| 441 |
mov r0, #0 |
| 442 |
1: |
| 443 |
str r0, [lr], #4 |
| 444 |
str r0, [lr], #4 // May clear vreg[0]. |
| 445 |
cmp lr, \fp |
| 446 |
blo 1b |
| 447 |
2: |
| 448 |
ldr r0, [sp] // Reload the ArtMethod, expected by the callers. |
| 449 |
.endm |
| 450 |
|
| 451 |
// Increase method hotness and do suspend check before starting executing the method. |
| 452 |
.macro START_EXECUTING_INSTRUCTIONS |
| 453 |
ldr r0, [sp] |
| 454 |
ldrh r2, [r0, #ART_METHOD_HOTNESS_COUNT_OFFSET] |
| 455 |
cmp r2, #NTERP_HOTNESS_VALUE |
| 456 |
beq 3f |
| 457 |
add r2, r2, #-1 |
| 458 |
strh r2, [r0, #ART_METHOD_HOTNESS_COUNT_OFFSET] |
| 459 |
1: |
| 460 |
DO_SUSPEND_CHECK continue_label=2f |
| 461 |
2: |
| 462 |
FETCH_INST |
| 463 |
GET_INST_OPCODE ip |
| 464 |
GOTO_OPCODE ip |
| 465 |
3: |
| 466 |
CHECK_AND_UPDATE_SHARED_MEMORY_METHOD if_hot=4f, if_not_hot=1b |
| 467 |
4: |
| 468 |
mov r1, #0 |
| 469 |
mov r2, rFP |
| 470 |
bl nterp_hot_method |
| 471 |
b 2b |
| 472 |
.endm |
| 473 |
|
| 474 |
.macro SPILL_ALL_CALLEE_SAVES |
| 475 |
SPILL_ALL_CALLEE_SAVE_GPRS @ 9 words (36 bytes) of callee saves. |
| 476 |
vpush {s16-s31} @ 16 words (64 bytes) of floats. |
| 477 |
.cfi_adjust_cfa_offset 64 |
| 478 |
.endm |
| 479 |
|
| 480 |
.macro RESTORE_ALL_CALLEE_SAVES lr_to_pc=0 |
| 481 |
vpop {s16-s31} |
| 482 |
.cfi_adjust_cfa_offset -64 |
| 483 |
pop {r4-r7} |
| 484 |
.cfi_adjust_cfa_offset -16 |
| 485 |
.cfi_restore r4 |
| 486 |
.cfi_restore r5 |
| 487 |
.cfi_restore r6 |
| 488 |
.cfi_restore r7 |
| 489 |
// Don't restore r8, the marking register gets updated when coming back from runtime. |
| 490 |
add sp, sp, #4 |
| 491 |
.cfi_adjust_cfa_offset -4 |
| 492 |
.if \lr_to_pc |
| 493 |
pop {r9-r11, pc} @ 9 words of callee saves and args. |
| 494 |
.cfi_adjust_cfa_offset -16 |
| 495 |
.else |
| 496 |
pop {r9-r11, lr} @ 9 words of callee saves and args. |
| 497 |
.cfi_adjust_cfa_offset -16 |
| 498 |
.cfi_restore r9 |
| 499 |
.cfi_restore r10 |
| 500 |
.cfi_restore r11 |
| 501 |
.cfi_restore lr |
| 502 |
.endif |
| 503 |
.endm |
| 504 |
|
| 505 |
// Helper to setup the stack after doing a nterp to nterp call. This will setup: |
| 506 |
// - rNEW_FP: the new pointer to dex registers |
| 507 |
// - rNEW_REFS: the new pointer to references |
| 508 |
// - rPC: the new PC pointer to execute |
| 509 |
// - r2: value in instruction to decode the number of arguments. |
| 510 |
// - r3: first dex register for range invokes, up to 4 arguments for non-range invokes. |
| 511 |
// - r4: top of dex register array |
| 512 |
// |
| 513 |
// The method expects: |
| 514 |
// - r0 to contain the ArtMethod |
| 515 |
// - r4 to contain the code item |
| 516 |
.macro SETUP_STACK_FOR_INVOKE |
| 517 |
// We do the same stack overflow check as the compiler. See CanMethodUseNterp |
| 518 |
// in how we limit the maximum nterp frame size. |
| 519 |
sub ip, sp, #STACK_OVERFLOW_RESERVED_BYTES |
| 520 |
ldr ip, [ip] |
| 521 |
|
| 522 |
// Spill all callee saves to have a consistent stack frame whether we |
| 523 |
// are called by compiled code or nterp. |
| 524 |
SPILL_ALL_CALLEE_SAVES |
| 525 |
|
| 526 |
// Setup the frame. |
| 527 |
SETUP_STACK_FRAME r4, rNEW_REFS, rNEW_FP, CFI_NEW_REFS, load_ins=0 |
| 528 |
|
| 529 |
// Fetch instruction information before replacing rPC. |
| 530 |
FETCH_B r2, 0, 1 |
| 531 |
FETCH r3, 2 |
| 532 |
|
| 533 |
// Set the dex pc pointer. |
| 534 |
mov rPC, r4 |
| 535 |
|
| 536 |
// Make r4 point to the top of the dex register array. |
| 537 |
add r4, rNEW_FP, rINST, lsl #2 |
| 538 |
|
| 539 |
CFI_DEFINE_DEX_PC_WITH_OFFSET(CFI_TMP, CFI_DEX, 0) |
| 540 |
.endm |
| 541 |
|
| 542 |
// Setup arguments based on a non-range nterp to nterp call, and start executing |
| 543 |
// the method. We expect: |
| 544 |
// - rNEW_FP: the new pointer to dex registers |
| 545 |
// - rPC: the new PC pointer to execute |
| 546 |
// - r2: number of arguments (bits 4-7), 5th argument if any (bits 0-3) |
| 547 |
// - r3: up to four dex register arguments |
| 548 |
// - r4: top of dex register array |
| 549 |
// - r1: receiver if non-static. |
| 550 |
// |
| 551 |
// Uses r0 and rINST as temporaries. |
| 552 |
.macro SETUP_NON_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=0 |
| 553 |
// /* op vA, vB, {vC...vG} */ |
| 554 |
.if \is_static |
| 555 |
asrs r0, r2, #4 |
| 556 |
beq 6f |
| 557 |
.else |
| 558 |
asr r0, r2, #4 |
| 559 |
.endif |
| 560 |
mov rINST, #-4 |
| 561 |
cmp r0, #2 |
| 562 |
blt 1f |
| 563 |
beq 2f |
| 564 |
cmp r0, #4 |
| 565 |
blt 3f |
| 566 |
beq 4f |
| 567 |
|
| 568 |
// We use a decrementing rINST to store references relative |
| 569 |
// to rNEW_FP and dex registers relative to r4 |
| 570 |
// |
| 571 |
// TODO: We could set up rINST as the number of registers (this can be an additional output from |
| 572 |
// SETUP_STACK_FOR_INVOKE) and then just decrement it by one before copying each arg. |
| 573 |
// Maybe even introduce macros NEW_VREG_ADDRESS/NEW_VREG_REF_ADDRESS. |
| 574 |
5: |
| 575 |
and r2, r2, #15 |
| 576 |
GET_VREG_OBJECT r0, r2 |
| 577 |
str r0, [rNEW_FP, rINST] |
| 578 |
GET_VREG r0, r2 |
| 579 |
str r0, [r4, rINST] |
| 580 |
sub rINST, rINST, #4 |
| 581 |
4: |
| 582 |
asr r2, r3, #12 |
| 583 |
GET_VREG_OBJECT r0, r2 |
| 584 |
str r0, [rNEW_FP, rINST] |
| 585 |
GET_VREG r0, r2 |
| 586 |
str r0, [r4, rINST] |
| 587 |
sub rINST, rINST, #4 |
| 588 |
3: |
| 589 |
ubfx r2, r3, #8, #4 |
| 590 |
GET_VREG_OBJECT r0, r2 |
| 591 |
str r0, [rNEW_FP, rINST] |
| 592 |
GET_VREG r0, r2 |
| 593 |
str r0, [r4, rINST] |
| 594 |
sub rINST, rINST, #4 |
| 595 |
2: |
| 596 |
ubfx r2, r3, #4, #4 |
| 597 |
GET_VREG_OBJECT r0, r2 |
| 598 |
str r0, [rNEW_FP, rINST] |
| 599 |
GET_VREG r0, r2 |
| 600 |
str r0, [r4, rINST] |
| 601 |
.if !\is_string_init |
| 602 |
sub rINST, rINST, #4 |
| 603 |
.endif |
| 604 |
1: |
| 605 |
.if \is_string_init |
| 606 |
// Ignore the first argument |
| 607 |
.elseif \is_static |
| 608 |
and r2, r3, #0xf |
| 609 |
GET_VREG_OBJECT r0, r2 |
| 610 |
str r0, [rNEW_FP, rINST] |
| 611 |
GET_VREG r0, r2 |
| 612 |
str r0, [r4, rINST] |
| 613 |
.else |
| 614 |
str r1, [rNEW_FP, rINST] |
| 615 |
str r1, [r4, rINST] |
| 616 |
.endif |
| 617 |
|
| 618 |
6: |
| 619 |
// Start executing the method. |
| 620 |
mov rFP, rNEW_FP |
| 621 |
mov rREFS, rNEW_REFS |
| 622 |
CFI_DEF_CFA_BREG_PLUS_UCONST CFI_REFS, -4, CALLEE_SAVES_SIZE |
| 623 |
// r8 was used for setting up the frame, restore it now. |
| 624 |
REFRESH_MARKING_REGISTER |
| 625 |
// Branch to the main handler, which will reload rIBASE, |
| 626 |
// that was used for setting up the frame. |
| 627 |
b .Lexecute_instructions |
| 628 |
.endm |
| 629 |
|
| 630 |
// Setup arguments based on a range nterp to nterp call, and start executing |
| 631 |
// the method. |
| 632 |
// - rNEW_FP: the new pointer to dex registers |
| 633 |
// - rNEW_REFS: the new pointer to references |
| 634 |
// - rPC: the new PC pointer to execute |
| 635 |
// - r2: number of arguments |
| 636 |
// - r3: first dex register |
| 637 |
// - r4: top of dex register array |
| 638 |
// - r1: receiver if non-static. |
| 639 |
// |
| 640 |
// Expects r0 to be available. |
| 641 |
.macro SETUP_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=0 |
| 642 |
mov r0, #-4 |
| 643 |
.if \is_string_init |
| 644 |
// Ignore the first argument |
| 645 |
sub r2, r2, #1 |
| 646 |
add r3, r3, #1 |
| 647 |
.elseif !\is_static |
| 648 |
sub r2, r2, #1 |
| 649 |
add r3, r3, #1 |
| 650 |
.endif |
| 651 |
|
| 652 |
cmp r2, #0 |
| 653 |
beq 2f |
| 654 |
add rREFS, rREFS, r3, lsl #2 // pointer to first argument in reference array |
| 655 |
add rREFS, rREFS, r2, lsl #2 // pointer to last argument in reference array |
| 656 |
add rFP, rFP, r3, lsl #2 // pointer to first argument in register array |
| 657 |
add rFP, rFP, r2, lsl #2 // pointer to last argument in register array |
| 658 |
1: |
| 659 |
ldr r3, [rREFS, #-4]! |
| 660 |
str r3, [rNEW_FP, r0] |
| 661 |
subs r2, r2, 1 |
| 662 |
ldr r3, [rFP, #-4]! |
| 663 |
str r3, [r4, r0] |
| 664 |
sub r0, r0, 4 |
| 665 |
bne 1b |
| 666 |
2: |
| 667 |
.if \is_string_init |
| 668 |
// Ignore first argument |
| 669 |
.elseif !\is_static |
| 670 |
str r1, [rNEW_FP, r0] |
| 671 |
str r1, [r4, r0] |
| 672 |
.endif |
| 673 |
mov rFP, rNEW_FP |
| 674 |
mov rREFS, rNEW_REFS |
| 675 |
CFI_DEF_CFA_BREG_PLUS_UCONST CFI_REFS, -4, CALLEE_SAVES_SIZE |
| 676 |
// r8 was used for setting up the frame, restore it now. |
| 677 |
REFRESH_MARKING_REGISTER |
| 678 |
// Branch to the main handler, which will reload rIBASE, |
| 679 |
// that was used for setting up the frame. |
| 680 |
b .Lexecute_instructions |
| 681 |
.endm |
| 682 |
|
| 683 |
.macro GET_SHORTY dest, is_interface, is_polymorphic, is_custom |
| 684 |
push {r0-r3} |
| 685 |
.if \is_polymorphic |
| 686 |
ldr r0, [sp, #16] |
| 687 |
mov r1, rPC |
| 688 |
bl NterpGetShortyFromInvokePolymorphic |
| 689 |
.elseif \is_custom |
| 690 |
ldr r0, [sp, #16] |
| 691 |
mov r1, rPC |
| 692 |
bl NterpGetShortyFromInvokeCustom |
| 693 |
.elseif \is_interface |
| 694 |
ldr r0, [sp, #16] |
| 695 |
FETCH r1, 1 |
| 696 |
bl NterpGetShortyFromMethodId |
| 697 |
.else |
| 698 |
bl NterpGetShorty |
| 699 |
.endif |
| 700 |
mov \dest, r0 |
| 701 |
pop {r0-r3} |
| 702 |
.endm |
| 703 |
|
| 704 |
// Input: r0 contains the ArtMethod |
| 705 |
// Output: r4 contains the code item |
| 706 |
.macro GET_CODE_ITEM |
| 707 |
ldr r4, [r0, #ART_METHOD_DATA_OFFSET_32] |
| 708 |
.endm |
| 709 |
|
| 710 |
.macro DO_ENTRY_POINT_CHECK call_compiled_code, name |
| 711 |
// On entry, the method is r0, the instance is r1 |
| 712 |
ldr r2, .Lfetch_nterp_\name |
| 713 |
.Lfetch_location_\name: |
| 714 |
// Note that this won't work for thumb. |
| 715 |
sub r2, pc, r2 |
| 716 |
ldr r3, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 717 |
cmp r2, r3 |
| 718 |
bne \call_compiled_code |
| 719 |
.endm |
| 720 |
|
| 721 |
// Expects ip and lr to be available. |
| 722 |
.macro UPDATE_REGISTERS_FOR_STRING_INIT old_value, new_value |
| 723 |
mov ip, #0 |
| 724 |
1: |
| 725 |
GET_VREG_OBJECT lr, ip |
| 726 |
cmp lr, \old_value |
| 727 |
bne 2f |
| 728 |
SET_VREG_OBJECT \new_value, ip |
| 729 |
2: |
| 730 |
add ip, ip, #1 |
| 731 |
add lr, rREFS, ip, lsl #2 |
| 732 |
cmp lr, rFP |
| 733 |
bne 1b |
| 734 |
.endm |
| 735 |
|
| 736 |
// Puts the next floating point argument into the expected register, |
| 737 |
// fetching values based on a non-range invoke. |
| 738 |
// Uses ip and lr. |
| 739 |
.macro LOOP_OVER_SHORTY_LOADING_FPS dreg, sreg, inst, shorty, arg_index, finished, if_double |
| 740 |
1: // LOOP |
| 741 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 742 |
cmp ip, #0 |
| 743 |
beq \finished // if (ip == '\0') goto finished |
| 744 |
cmp ip, #68 // if (ip == 'D') goto FOUND_DOUBLE |
| 745 |
beq 2f |
| 746 |
cmp ip, #70 // if (ip == 'F') goto FOUND_FLOAT |
| 747 |
beq 3f |
| 748 |
lsr \inst, \inst, #4 |
| 749 |
add \arg_index, \arg_index, #1 |
| 750 |
// Handle extra argument in arg array taken by a long. |
| 751 |
cmp ip, #74 // if (ip != 'J') goto LOOP |
| 752 |
bne 1b |
| 753 |
lsr \inst, \inst, #4 |
| 754 |
add \arg_index, \arg_index, #1 |
| 755 |
b 1b // goto LOOP |
| 756 |
2: // FOUND_DOUBLE |
| 757 |
and ip, \inst, #0xf |
| 758 |
GET_VREG ip, ip |
| 759 |
lsr \inst, \inst, #4 |
| 760 |
add \arg_index, \arg_index, #1 |
| 761 |
cmp \arg_index, #4 |
| 762 |
beq 5f |
| 763 |
and lr, \inst, #0xf |
| 764 |
lsr \inst, \inst, #4 |
| 765 |
add \arg_index, \arg_index, #1 |
| 766 |
b 6f |
| 767 |
5: |
| 768 |
FETCH_B lr, 0, 1 |
| 769 |
and lr, lr, #0xf |
| 770 |
6: |
| 771 |
GET_VREG lr, lr |
| 772 |
vmov \dreg, ip, lr |
| 773 |
b \if_double |
| 774 |
3: // FOUND_FLOAT |
| 775 |
cmp \arg_index, #4 |
| 776 |
beq 7f |
| 777 |
and ip, \inst, #0xf |
| 778 |
lsr \inst, \inst, #4 |
| 779 |
add \arg_index, \arg_index, #1 |
| 780 |
b 8f |
| 781 |
7: |
| 782 |
FETCH_B ip, 0, 1 |
| 783 |
and ip, ip, #0xf |
| 784 |
8: |
| 785 |
GET_VREG_FLOAT \sreg, ip |
| 786 |
.endm |
| 787 |
|
| 788 |
// Puts the next int/long/object argument in the expected register, |
| 789 |
// fetching values based on a non-range invoke. |
| 790 |
// Uses ip. |
| 791 |
.macro LOOP_OVER_SHORTY_LOADING_GPRS gpr_reg, inst, shorty, arg_index, finished, if_long, is_r3 |
| 792 |
1: // LOOP |
| 793 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 794 |
cmp ip, #0 |
| 795 |
beq \finished // if (ip == '\0') goto finished |
| 796 |
cmp ip, #74 // if (ip == 'J') goto FOUND_LONG |
| 797 |
beq 2f |
| 798 |
cmp ip, #70 // if (ip == 'F') goto SKIP_FLOAT |
| 799 |
beq 3f |
| 800 |
cmp ip, #68 // if (ip == 'D') goto SKIP_DOUBLE |
| 801 |
beq 4f |
| 802 |
cmp \arg_index, #4 |
| 803 |
beq 7f |
| 804 |
and ip, \inst, #0xf |
| 805 |
lsr \inst, \inst, #4 |
| 806 |
add \arg_index, \arg_index, #1 |
| 807 |
b 8f |
| 808 |
7: |
| 809 |
FETCH_B ip, 0, 1 |
| 810 |
and ip, ip, #0xf |
| 811 |
8: |
| 812 |
GET_VREG \gpr_reg, ip |
| 813 |
b 5f |
| 814 |
2: // FOUND_LONG |
| 815 |
.if \is_r3 |
| 816 |
// Put back shorty and exit |
| 817 |
sub \shorty, \shorty, #1 |
| 818 |
b 5f |
| 819 |
.endif |
| 820 |
and ip, \inst, #0xf |
| 821 |
GET_VREG ip, ip |
| 822 |
// The only one possible for non-range long is r2-r3 |
| 823 |
mov r2, ip |
| 824 |
lsr \inst, \inst, #4 |
| 825 |
add \arg_index, \arg_index, #1 |
| 826 |
cmp \arg_index, #4 |
| 827 |
beq 9f |
| 828 |
and ip, \inst, #0xf |
| 829 |
lsr \inst, \inst, #4 |
| 830 |
b 10f |
| 831 |
9: |
| 832 |
FETCH_B ip, 0, 1 |
| 833 |
and ip, ip, #0xf |
| 834 |
10: |
| 835 |
GET_VREG ip, ip |
| 836 |
// The only one possible for non-range long is r2-r3 |
| 837 |
mov r3, ip |
| 838 |
add \arg_index, \arg_index, #1 |
| 839 |
b \if_long |
| 840 |
3: // SKIP_FLOAT |
| 841 |
lsr \inst, \inst, #4 |
| 842 |
add \arg_index, \arg_index, #1 |
| 843 |
b 1b |
| 844 |
4: // SKIP_DOUBLE |
| 845 |
lsr \inst, \inst, #8 |
| 846 |
add \arg_index, \arg_index, #2 |
| 847 |
b 1b |
| 848 |
5: |
| 849 |
.endm |
| 850 |
|
| 851 |
// Puts the next int/long/object argument in the expected stack slot, |
| 852 |
// fetching values based on a non-range invoke. |
| 853 |
// Uses ip as temporary. |
| 854 |
.macro LOOP_OVER_SHORTY_LOADING_INTs shorty, inst, arg_index, finished, is_string_init |
| 855 |
1: // LOOP |
| 856 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 857 |
cmp ip, #0 |
| 858 |
beq \finished // if (ip == '\0') goto finished |
| 859 |
cmp ip, #74 // if (ip == 'J') goto FOUND_LONG |
| 860 |
beq 2f |
| 861 |
cmp ip, #70 // if (ip == 'F') goto SKIP_FLOAT |
| 862 |
beq 3f |
| 863 |
cmp ip, #68 // if (ip == 'D') goto SKIP_DOUBLE |
| 864 |
beq 4f |
| 865 |
.if \is_string_init |
| 866 |
cmp \arg_index, #4 |
| 867 |
.else |
| 868 |
cmp \arg_index, #(4+1) // +1 for ArtMethod |
| 869 |
.endif |
| 870 |
beq 7f |
| 871 |
and ip, \inst, #0xf |
| 872 |
lsr \inst, \inst, #4 |
| 873 |
b 8f |
| 874 |
7: |
| 875 |
FETCH_B ip, 0, 1 |
| 876 |
and ip, ip, #0xf |
| 877 |
8: |
| 878 |
GET_VREG ip, ip |
| 879 |
str ip, [sp, \arg_index, lsl #2] |
| 880 |
add \arg_index, \arg_index, #1 |
| 881 |
b 1b |
| 882 |
2: // FOUND_LONG |
| 883 |
and ip, \inst, #0xf |
| 884 |
GET_VREG ip, ip |
| 885 |
str ip, [sp, \arg_index, lsl #2] |
| 886 |
lsr \inst, \inst, #4 |
| 887 |
add \arg_index, \arg_index, #1 |
| 888 |
.if \is_string_init |
| 889 |
cmp \arg_index, #4 |
| 890 |
.else |
| 891 |
cmp \arg_index, #(4+1) // +1 for ArtMethod |
| 892 |
.endif |
| 893 |
beq 9f |
| 894 |
and ip, \inst, #0xf |
| 895 |
lsr \inst, \inst, #4 |
| 896 |
b 10f |
| 897 |
9: |
| 898 |
FETCH_B ip, 0, 1 |
| 899 |
and ip, ip, #0xf |
| 900 |
10: |
| 901 |
GET_VREG ip, ip |
| 902 |
str ip, [sp, \arg_index, lsl #2] |
| 903 |
add \arg_index, \arg_index, #1 |
| 904 |
b 1b |
| 905 |
3: // SKIP_FLOAT |
| 906 |
lsr \inst, \inst, #4 |
| 907 |
add \arg_index, \arg_index, #1 |
| 908 |
b 1b |
| 909 |
4: // SKIP_DOUBLE |
| 910 |
lsr \inst, \inst, #8 |
| 911 |
add \arg_index, \arg_index, #2 |
| 912 |
b 1b |
| 913 |
.endm |
| 914 |
|
| 915 |
.macro SETUP_RETURN_VALUE shorty |
| 916 |
ldrb ip, [\shorty] |
| 917 |
cmp ip, #68 // Test if result type char == 'D'. |
| 918 |
beq 1f |
| 919 |
cmp ip, #70 // Test if result type char == 'F'. |
| 920 |
bne 2f |
| 921 |
vmov r0, s0 |
| 922 |
b 2f |
| 923 |
1: |
| 924 |
vmov r0, r1, d0 |
| 925 |
2: |
| 926 |
.endm |
| 927 |
|
| 928 |
.macro GET_SHORTY_SLOW_PATH dest, is_interface |
| 929 |
// Save all registers that can hold arguments in the fast path. |
| 930 |
vpush {s0} |
| 931 |
push {r0-r2} |
| 932 |
.if \is_interface |
| 933 |
ldr r0, [sp, #16] |
| 934 |
FETCH r1, 1 |
| 935 |
bl NterpGetShortyFromMethodId |
| 936 |
.else |
| 937 |
bl NterpGetShorty |
| 938 |
.endif |
| 939 |
mov \dest, r0 |
| 940 |
pop {r0-r2} |
| 941 |
vpop {s0} |
| 942 |
.endm |
| 943 |
|
| 944 |
.macro COMMON_INVOKE_NON_RANGE is_static=0, is_interface=0, suffix="", is_string_init=0, is_polymorphic=0, is_custom=0 |
| 945 |
.if \is_polymorphic |
| 946 |
// We always go to compiled code for polymorphic calls. |
| 947 |
.elseif \is_custom |
| 948 |
// We always go to compiled code for custom calls. |
| 949 |
.else |
| 950 |
DO_ENTRY_POINT_CHECK .Lcall_compiled_code_\suffix, \suffix |
| 951 |
GET_CODE_ITEM |
| 952 |
.if \is_string_init |
| 953 |
bl nterp_to_nterp_string_init_non_range |
| 954 |
.elseif \is_static |
| 955 |
bl nterp_to_nterp_static_non_range |
| 956 |
.else |
| 957 |
bl nterp_to_nterp_instance_non_range |
| 958 |
.endif |
| 959 |
b .Ldone_return_\suffix |
| 960 |
.Lfetch_nterp_\suffix: |
| 961 |
.word (.Lfetch_location_\suffix+8) - ExecuteNterpImpl |
| 962 |
.endif |
| 963 |
|
| 964 |
.Lcall_compiled_code_\suffix: |
| 965 |
.if \is_polymorphic |
| 966 |
// No fast path for polymorphic calls. |
| 967 |
.elseif \is_custom |
| 968 |
// No fast path for custom calls. |
| 969 |
.elseif \is_string_init |
| 970 |
// No fast path for string.init. |
| 971 |
.else |
| 972 |
ldr ip, [r0, #ART_METHOD_ACCESS_FLAGS_OFFSET] |
| 973 |
tst ip, #ART_METHOD_NTERP_INVOKE_FAST_PATH_FLAG |
| 974 |
beq .Lfast_path_with_few_args_\suffix |
| 975 |
FETCH_B rINST, 0, 1 |
| 976 |
.if \is_static |
| 977 |
asrs lr, rINST, #4 |
| 978 |
beq .Linvoke_fast_path_\suffix |
| 979 |
.else |
| 980 |
asr lr, rINST, #4 |
| 981 |
cmp lr, #1 |
| 982 |
beq .Linvoke_fast_path_\suffix |
| 983 |
.endif |
| 984 |
FETCH ip, 2 |
| 985 |
cmp lr, #2 |
| 986 |
.if \is_static |
| 987 |
blt .Lone_arg_fast_path_\suffix |
| 988 |
.endif |
| 989 |
beq .Ltwo_args_fast_path_\suffix |
| 990 |
cmp lr, #4 |
| 991 |
blt .Lthree_args_fast_path_\suffix |
| 992 |
beq .Lfour_args_fast_path_\suffix |
| 993 |
and rINST, rINST, #15 |
| 994 |
GET_VREG rINST, rINST |
| 995 |
str rINST, [sp, #(4 + 4 * 4)] |
| 996 |
.Lfour_args_fast_path_\suffix: |
| 997 |
asr rINST, ip, #12 |
| 998 |
GET_VREG rINST, rINST |
| 999 |
str rINST, [sp, #(4 + 3 * 4)] |
| 1000 |
.Lthree_args_fast_path_\suffix: |
| 1001 |
ubfx rINST, ip, #8, #4 |
| 1002 |
GET_VREG r3, rINST |
| 1003 |
.Ltwo_args_fast_path_\suffix: |
| 1004 |
ubfx rINST, ip, #4, #4 |
| 1005 |
GET_VREG r2, rINST |
| 1006 |
.Lone_arg_fast_path_\suffix: |
| 1007 |
.if \is_static |
| 1008 |
and rINST, ip, #0xf |
| 1009 |
GET_VREG r1, rINST |
| 1010 |
.else |
| 1011 |
// First argument already in r1. |
| 1012 |
.endif |
| 1013 |
.Linvoke_fast_path_\suffix: |
| 1014 |
.if \is_interface |
| 1015 |
// Setup hidden argument. |
| 1016 |
mov ip, r4 |
| 1017 |
.endif |
| 1018 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1019 |
blx lr |
| 1020 |
FETCH_ADVANCE_INST 3 |
| 1021 |
GET_INST_OPCODE ip |
| 1022 |
GOTO_OPCODE ip |
| 1023 |
|
| 1024 |
.Lfast_path_with_few_args_\suffix: |
| 1025 |
// Fast path when we have zero or one argument (modulo 'this'). If there |
| 1026 |
// is one argument, we can put it in both floating point and core register. |
| 1027 |
FETCH_B r2, 0, 1 |
| 1028 |
asr r2, r2, #4 // number of arguments |
| 1029 |
.if \is_static |
| 1030 |
cmp r2, #1 |
| 1031 |
blt .Linvoke_with_few_args_\suffix |
| 1032 |
bne .Lget_shorty_\suffix |
| 1033 |
FETCH r2, 2 |
| 1034 |
and r2, r2, #0xf // dex register of first argument |
| 1035 |
GET_VREG r1, r2 |
| 1036 |
vmov s0, r1 |
| 1037 |
.else |
| 1038 |
cmp r2, #2 |
| 1039 |
blt .Linvoke_with_few_args_\suffix |
| 1040 |
bne .Lget_shorty_\suffix |
| 1041 |
FETCH r2, 2 |
| 1042 |
ubfx r2, r2, #4, #4 // dex register of second argument |
| 1043 |
GET_VREG r2, r2 |
| 1044 |
vmov s0, r2 |
| 1045 |
.endif |
| 1046 |
.Linvoke_with_few_args_\suffix: |
| 1047 |
// Check if the next instruction is move-result or move-result-wide. |
| 1048 |
// If it is, we fetch the shorty and jump to the regular invocation. |
| 1049 |
FETCH r3, 3 |
| 1050 |
and r3, r3, #0xfe |
| 1051 |
cmp r3, #0x0a |
| 1052 |
beq .Lget_shorty_and_invoke_\suffix |
| 1053 |
.if \is_interface |
| 1054 |
// Setup hidden argument. |
| 1055 |
mov ip, r4 |
| 1056 |
.endif |
| 1057 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1058 |
blx lr |
| 1059 |
FETCH_ADVANCE_INST 3 |
| 1060 |
GET_INST_OPCODE ip |
| 1061 |
GOTO_OPCODE ip |
| 1062 |
.Lget_shorty_and_invoke_\suffix: |
| 1063 |
.if \is_interface |
| 1064 |
// Save hidden argument. |
| 1065 |
vmov s16, r4 |
| 1066 |
.endif |
| 1067 |
GET_SHORTY_SLOW_PATH rINST, \is_interface |
| 1068 |
b .Lgpr_setup_finished_\suffix |
| 1069 |
.endif |
| 1070 |
|
| 1071 |
.Lget_shorty_\suffix: |
| 1072 |
.if \is_interface |
| 1073 |
// Save hidden argument. |
| 1074 |
vmov s16, r4 |
| 1075 |
.endif |
| 1076 |
GET_SHORTY rINST, \is_interface, \is_polymorphic, \is_custom |
| 1077 |
// From this point: |
| 1078 |
// - rINST contains shorty (in callee-save to switch over return value after call). |
| 1079 |
// - r0 contains method |
| 1080 |
// - r1 contains 'this' pointer for instance method. |
| 1081 |
// We need three registers. |
| 1082 |
add r3, rINST, #1 // shorty + 1 ; ie skip return arg character |
| 1083 |
FETCH r2, 2 // arguments |
| 1084 |
.if \is_string_init |
| 1085 |
lsr r2, r2, #4 |
| 1086 |
mov r4, #1 // ignore first argument |
| 1087 |
.elseif \is_static |
| 1088 |
mov r4, #0 // arg_index |
| 1089 |
.else |
| 1090 |
lsr r2, r2, #4 |
| 1091 |
mov r4, #1 // ignore first argument |
| 1092 |
.endif |
| 1093 |
LOOP_OVER_SHORTY_LOADING_FPS d0, s0, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Ld1_s2_\suffix |
| 1094 |
.Ld1_s1_\suffix: |
| 1095 |
LOOP_OVER_SHORTY_LOADING_FPS d1, s1, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Ld2_s1_\suffix |
| 1096 |
.Ld1_s2_\suffix: |
| 1097 |
LOOP_OVER_SHORTY_LOADING_FPS d1, s2, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Ls4_\suffix |
| 1098 |
.Ld2_s3_\suffix: |
| 1099 |
LOOP_OVER_SHORTY_LOADING_FPS d2, s3, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Lxmm_setup_finished_\suffix |
| 1100 |
b .Ls4_\suffix |
| 1101 |
.Ld2_s1_\suffix: |
| 1102 |
LOOP_OVER_SHORTY_LOADING_FPS d2, s1, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Lxmm_setup_finished_\suffix |
| 1103 |
.Ls4_\suffix: |
| 1104 |
// If we arrive here, we can only have a float. |
| 1105 |
LOOP_OVER_SHORTY_LOADING_FPS d2, s4, r2, r3, r4, .Lxmm_setup_finished_\suffix, .Lxmm_setup_finished_\suffix |
| 1106 |
.Lxmm_setup_finished_\suffix: |
| 1107 |
add r4, rINST, #1 // shorty + 1 ; ie skip return arg character |
| 1108 |
FETCH r8, 2 // arguments |
| 1109 |
.if \is_string_init |
| 1110 |
lsr r8, r8, #4 |
| 1111 |
mov lr, #1 // ignore first argument |
| 1112 |
LOOP_OVER_SHORTY_LOADING_GPRS r1, r8, r4, lr, .Lgpr_setup_finished_\suffix, .Lif_long_\suffix, is_r3=0 |
| 1113 |
.elseif \is_static |
| 1114 |
mov lr, #0 // arg_index |
| 1115 |
LOOP_OVER_SHORTY_LOADING_GPRS r1, r8, r4, lr, .Lgpr_setup_finished_\suffix, .Lif_long_\suffix, is_r3=0 |
| 1116 |
.else |
| 1117 |
lsr r8, r8, #4 |
| 1118 |
mov lr, #1 // ignore first argument |
| 1119 |
.endif |
| 1120 |
LOOP_OVER_SHORTY_LOADING_GPRS r2, r8, r4, lr, .Lgpr_setup_finished_\suffix, .Lif_long_\suffix, is_r3=0 |
| 1121 |
LOOP_OVER_SHORTY_LOADING_GPRS r3, r8, r4, lr, .Lgpr_setup_finished_\suffix, .Lif_long_\suffix, is_r3=1 |
| 1122 |
.Lif_long_\suffix: |
| 1123 |
// Store in the outs array (stored above the ArtMethod in the stack). We only do this for non-string-init |
| 1124 |
// calls as the index is already adjusted above. |
| 1125 |
.if !\is_string_init |
| 1126 |
add lr, lr, #1 |
| 1127 |
.endif |
| 1128 |
LOOP_OVER_SHORTY_LOADING_INTs r4, r8, lr, .Lgpr_setup_finished_\suffix, \is_string_init |
| 1129 |
.Lgpr_setup_finished_\suffix: |
| 1130 |
REFRESH_MARKING_REGISTER // r8 was used when setting parameters, restore it. |
| 1131 |
.if \is_polymorphic |
| 1132 |
bl art_quick_invoke_polymorphic |
| 1133 |
.elseif \is_custom |
| 1134 |
bl art_quick_invoke_custom |
| 1135 |
.else |
| 1136 |
.if \is_interface |
| 1137 |
// Setup hidden argument. |
| 1138 |
vmov ip, s16 |
| 1139 |
.endif |
| 1140 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1141 |
blx lr |
| 1142 |
.endif |
| 1143 |
SETUP_RETURN_VALUE rINST |
| 1144 |
.Ldone_return_\suffix: |
| 1145 |
/* resume execution of caller */ |
| 1146 |
.if \is_string_init |
| 1147 |
FETCH ip, 2 // arguments |
| 1148 |
and ip, ip, #0xf |
| 1149 |
GET_VREG r1, ip |
| 1150 |
UPDATE_REGISTERS_FOR_STRING_INIT r1, r0 |
| 1151 |
.endif |
| 1152 |
|
| 1153 |
.if \is_polymorphic |
| 1154 |
FETCH_ADVANCE_INST 4 |
| 1155 |
.else |
| 1156 |
FETCH_ADVANCE_INST 3 |
| 1157 |
.endif |
| 1158 |
GET_INST_OPCODE ip |
| 1159 |
GOTO_OPCODE ip |
| 1160 |
.endm |
| 1161 |
|
| 1162 |
// Puts the next int/long/object argument in the expected register, |
| 1163 |
// fetching values based on a range invoke. |
| 1164 |
// Uses ip as temporary. |
| 1165 |
.macro LOOP_RANGE_OVER_SHORTY_LOADING_GPRS reg32, shorty, arg_index, stack_index, finished, if_long, is_r3 |
| 1166 |
1: // LOOP |
| 1167 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 1168 |
cmp ip, #0 |
| 1169 |
beq \finished // if (ip == '\0') goto finished |
| 1170 |
cmp ip, #74 // if (ip == 'J') goto FOUND_LONG |
| 1171 |
beq 2f |
| 1172 |
cmp ip, #70 // if (ip == 'F') goto SKIP_FLOAT |
| 1173 |
beq 3f |
| 1174 |
cmp ip, #68 // if (ip == 'D') goto SKIP_DOUBLE |
| 1175 |
beq 4f |
| 1176 |
GET_VREG \reg32, \arg_index |
| 1177 |
add \arg_index, \arg_index, #1 |
| 1178 |
add \stack_index, \stack_index, #1 |
| 1179 |
b 5f |
| 1180 |
2: // FOUND_LONG |
| 1181 |
.if \is_r3 |
| 1182 |
// Put back shorty and jump to \if_long |
| 1183 |
sub \shorty, \shorty, #1 |
| 1184 |
.else |
| 1185 |
GET_VREG r2, \arg_index |
| 1186 |
add \arg_index, \arg_index, #1 |
| 1187 |
add \stack_index, \stack_index, #1 |
| 1188 |
GET_VREG r3, \arg_index |
| 1189 |
add \arg_index, \arg_index, #1 |
| 1190 |
add \stack_index, \stack_index, #1 |
| 1191 |
.endif |
| 1192 |
b \if_long |
| 1193 |
3: // SKIP_FLOAT |
| 1194 |
add \arg_index, \arg_index, #1 |
| 1195 |
add \stack_index, \stack_index, #1 |
| 1196 |
b 1b |
| 1197 |
4: // SKIP_DOUBLE |
| 1198 |
add \arg_index, \arg_index, #2 |
| 1199 |
add \stack_index, \stack_index, #2 |
| 1200 |
b 1b |
| 1201 |
5: |
| 1202 |
.endm |
| 1203 |
|
| 1204 |
// Puts the next int/long/object argument in the expected stack slot, |
| 1205 |
// fetching values based on a range invoke. |
| 1206 |
// Uses ip as temporary. |
| 1207 |
.macro LOOP_RANGE_OVER_INTs shorty, arg_index, stack_index, finished |
| 1208 |
1: // LOOP |
| 1209 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 1210 |
cmp ip, #0 |
| 1211 |
beq \finished // if (ip == '\0') goto finished |
| 1212 |
cmp ip, #74 // if (ip == 'J') goto FOUND_LONG |
| 1213 |
beq 2f |
| 1214 |
cmp ip, #70 // if (ip == 'F') goto SKIP_FLOAT |
| 1215 |
beq 3f |
| 1216 |
cmp ip, #68 // if (ip == 'D') goto SKIP_DOUBLE |
| 1217 |
beq 4f |
| 1218 |
GET_VREG ip, \arg_index |
| 1219 |
str ip, [sp, \stack_index, lsl #2] |
| 1220 |
add \arg_index, \arg_index, #1 |
| 1221 |
add \stack_index, \stack_index, #1 |
| 1222 |
b 1b |
| 1223 |
2: // FOUND_LONG |
| 1224 |
GET_VREG ip, \arg_index |
| 1225 |
str ip, [sp, \stack_index, lsl #2] |
| 1226 |
add \arg_index, \arg_index, #1 |
| 1227 |
add \stack_index, \stack_index, #1 |
| 1228 |
GET_VREG ip, \arg_index |
| 1229 |
str ip, [sp, \stack_index, lsl #2] |
| 1230 |
add \arg_index, \arg_index, #1 |
| 1231 |
add \stack_index, \stack_index, #1 |
| 1232 |
b 1b |
| 1233 |
3: // SKIP_FLOAT |
| 1234 |
add \arg_index, \arg_index, #1 |
| 1235 |
add \stack_index, \stack_index, #1 |
| 1236 |
b 1b |
| 1237 |
4: // SKIP_DOUBLE |
| 1238 |
add \arg_index, \arg_index, #2 |
| 1239 |
add \stack_index, \stack_index, #2 |
| 1240 |
b 1b |
| 1241 |
.endm |
| 1242 |
|
| 1243 |
.macro COMMON_INVOKE_RANGE is_static=0, is_interface=0, suffix="", is_string_init=0, is_polymorphic=0, is_custom=0 |
| 1244 |
.if \is_polymorphic |
| 1245 |
// We always go to compiled code for polymorphic calls. |
| 1246 |
.elseif \is_custom |
| 1247 |
// We always go to compiled code for custom calls. |
| 1248 |
.else |
| 1249 |
DO_ENTRY_POINT_CHECK .Lcall_compiled_code_range_\suffix, range_\suffix |
| 1250 |
GET_CODE_ITEM |
| 1251 |
.if \is_string_init |
| 1252 |
bl nterp_to_nterp_string_init_range |
| 1253 |
.elseif \is_static |
| 1254 |
bl nterp_to_nterp_static_range |
| 1255 |
.else |
| 1256 |
bl nterp_to_nterp_instance_range |
| 1257 |
.endif |
| 1258 |
b .Ldone_return_range_\suffix |
| 1259 |
.Lfetch_nterp_range_\suffix: |
| 1260 |
.word (.Lfetch_location_range_\suffix+8) - ExecuteNterpImpl |
| 1261 |
.endif |
| 1262 |
|
| 1263 |
.Lcall_compiled_code_range_\suffix: |
| 1264 |
.if \is_polymorphic |
| 1265 |
// No fast path for polymorphic calls. |
| 1266 |
.elseif \is_custom |
| 1267 |
// No fast path for custom calls. |
| 1268 |
.elseif \is_string_init |
| 1269 |
// No fast path for string.init. |
| 1270 |
.else |
| 1271 |
ldr ip, [r0, #ART_METHOD_ACCESS_FLAGS_OFFSET] |
| 1272 |
tst ip, #ART_METHOD_NTERP_INVOKE_FAST_PATH_FLAG |
| 1273 |
beq .Lfast_path_with_few_args_range_\suffix |
| 1274 |
FETCH_B ip, 0, 1 // Number of arguments |
| 1275 |
.if \is_static |
| 1276 |
cmp ip, #0 |
| 1277 |
.else |
| 1278 |
cmp ip, #1 |
| 1279 |
.endif |
| 1280 |
beq .Linvoke_fast_path_range_\suffix |
| 1281 |
FETCH lr, 2 // dex register of first argument |
| 1282 |
add lr, rFP, lr, lsl #2 // location of first dex register value. |
| 1283 |
.if \is_static |
| 1284 |
cmp ip, #2 |
| 1285 |
blt .Lone_arg_fast_path_range_\suffix |
| 1286 |
beq .Ltwo_args_fast_path_range_\suffix |
| 1287 |
cmp ip, #3 |
| 1288 |
.else |
| 1289 |
cmp ip, #3 |
| 1290 |
blt .Ltwo_args_fast_path_range_\suffix |
| 1291 |
.endif |
| 1292 |
beq .Lthree_args_fast_path_range_\suffix |
| 1293 |
add rINST, sp, #4 // Add space for the ArtMethod |
| 1294 |
|
| 1295 |
.Lloop_over_fast_path_range_\suffix: |
| 1296 |
sub ip, ip, #1 |
| 1297 |
ldr r3, [lr, ip, lsl #2] |
| 1298 |
str r3, [rINST, ip, lsl #2] |
| 1299 |
cmp ip, #3 |
| 1300 |
bne .Lloop_over_fast_path_range_\suffix |
| 1301 |
|
| 1302 |
.Lthree_args_fast_path_range_\suffix: |
| 1303 |
ldr r3, [lr, #8] |
| 1304 |
.Ltwo_args_fast_path_range_\suffix: |
| 1305 |
ldr r2, [lr, #4] |
| 1306 |
.Lone_arg_fast_path_range_\suffix: |
| 1307 |
.if \is_static |
| 1308 |
ldr r1, [lr, #0] |
| 1309 |
.else |
| 1310 |
// First argument already in r1. |
| 1311 |
.endif |
| 1312 |
.Linvoke_fast_path_range_\suffix: |
| 1313 |
.if \is_interface |
| 1314 |
// Setup hidden argument. |
| 1315 |
mov ip, r4 |
| 1316 |
.endif |
| 1317 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1318 |
blx lr |
| 1319 |
FETCH_ADVANCE_INST 3 |
| 1320 |
GET_INST_OPCODE ip |
| 1321 |
GOTO_OPCODE ip |
| 1322 |
|
| 1323 |
.Lfast_path_with_few_args_range_\suffix: |
| 1324 |
// Fast path when we have zero or one argument (modulo 'this'). If there |
| 1325 |
// is one argument, we can put it in both floating point and core register. |
| 1326 |
FETCH_B r2, 0, 1 // number of arguments |
| 1327 |
.if \is_static |
| 1328 |
cmp r2, #1 |
| 1329 |
blt .Linvoke_with_few_args_range_\suffix |
| 1330 |
bne .Lget_shorty_range_\suffix |
| 1331 |
FETCH r3, 2 // dex register of first argument |
| 1332 |
GET_VREG r1, r3 |
| 1333 |
vmov s0, r1 |
| 1334 |
.else |
| 1335 |
cmp r2, #2 |
| 1336 |
blt .Linvoke_with_few_args_range_\suffix |
| 1337 |
bne .Lget_shorty_range_\suffix |
| 1338 |
FETCH r3, 2 // dex register of first argument |
| 1339 |
add r3, r3, #1 // Add 1 for next argument |
| 1340 |
GET_VREG r2, r3 |
| 1341 |
vmov s0, r2 |
| 1342 |
.endif |
| 1343 |
.Linvoke_with_few_args_range_\suffix: |
| 1344 |
// Check if the next instruction is move-result or move-result-wide. |
| 1345 |
// If it is, we fetch the shorty and jump to the regular invocation. |
| 1346 |
FETCH r3, 3 |
| 1347 |
and r3, r3, #0xfe |
| 1348 |
cmp r3, #0x0a |
| 1349 |
beq .Lget_shorty_and_invoke_range_\suffix |
| 1350 |
.if \is_interface |
| 1351 |
// Setup hidden argument. |
| 1352 |
mov ip, r4 |
| 1353 |
.endif |
| 1354 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1355 |
blx lr |
| 1356 |
FETCH_ADVANCE_INST 3 |
| 1357 |
GET_INST_OPCODE ip |
| 1358 |
GOTO_OPCODE ip |
| 1359 |
.Lget_shorty_and_invoke_range_\suffix: |
| 1360 |
.if \is_interface |
| 1361 |
// Save hidden argument. |
| 1362 |
vmov s16, r4 |
| 1363 |
.endif |
| 1364 |
GET_SHORTY_SLOW_PATH rINST, \is_interface |
| 1365 |
b .Lgpr_setup_finished_range_\suffix |
| 1366 |
.endif |
| 1367 |
|
| 1368 |
.Lget_shorty_range_\suffix: |
| 1369 |
.if \is_interface |
| 1370 |
// Save hidden argument. |
| 1371 |
vmov s16, r4 |
| 1372 |
.endif |
| 1373 |
GET_SHORTY rINST, \is_interface, \is_polymorphic, \is_custom |
| 1374 |
// From this point: |
| 1375 |
// - rINST contains shorty (in callee-save to switch over return value after call). |
| 1376 |
// - r0 contains method |
| 1377 |
// - r1 contains 'this' pointer for instance method. |
| 1378 |
// |
| 1379 |
// Save r0 and r1 before calling NterpSetupArm32Fprs. |
| 1380 |
push {r0, r1} |
| 1381 |
add r0, rINST, #1 // shorty + 1 ; ie skip return arg character |
| 1382 |
FETCH r1, 2 // arguments |
| 1383 |
.if \is_string_init |
| 1384 |
add r1, r1, #1 // arg start index |
| 1385 |
mov r2, #1 // index in stack |
| 1386 |
.elseif \is_static |
| 1387 |
mov r2, #0 // index in stack |
| 1388 |
.else |
| 1389 |
add r1, r1, #1 // arg start index |
| 1390 |
mov r2, #1 // index in stack |
| 1391 |
.endif |
| 1392 |
vpush {s0-s15} |
| 1393 |
mov r3, sp |
| 1394 |
// Pass the stack address for arguments, +16 for fprs, +2 for saved registers, |
| 1395 |
// +1 for ArtMethod. |
| 1396 |
add lr, sp, #((16 + 2 + 1) * 4) |
| 1397 |
push {rFP, lr} |
| 1398 |
bl NterpSetupArm32Fprs |
| 1399 |
add sp, sp, #8 |
| 1400 |
vpop {s0-s15} |
| 1401 |
pop {r0, r1} |
| 1402 |
.Lxmm_setup_finished_range_\suffix: |
| 1403 |
add r8, rINST, #1 // shorty + 1 ; ie skip return arg character |
| 1404 |
FETCH lr, 2 // arguments |
| 1405 |
.if \is_string_init |
| 1406 |
add lr, lr, #1 // arg start index |
| 1407 |
mov r4, #0 // index in stack |
| 1408 |
LOOP_RANGE_OVER_SHORTY_LOADING_GPRS r1, r8, lr, r4, .Lgpr_setup_finished_range_\suffix, .Lif_long_range_\suffix, is_r3=0 |
| 1409 |
.elseif \is_static |
| 1410 |
mov r4, #0 // index in stack |
| 1411 |
LOOP_RANGE_OVER_SHORTY_LOADING_GPRS r1, r8, lr, r4, .Lgpr_setup_finished_range_\suffix, .Lif_long_range_\suffix, is_r3=0 |
| 1412 |
.else |
| 1413 |
add lr, lr, #1 // arg start index |
| 1414 |
mov r4, #1 // index in stack |
| 1415 |
.endif |
| 1416 |
LOOP_RANGE_OVER_SHORTY_LOADING_GPRS r2, r8, lr, r4, .Lgpr_setup_finished_range_\suffix, .Lif_long_range_\suffix, is_r3=0 |
| 1417 |
LOOP_RANGE_OVER_SHORTY_LOADING_GPRS r3, r8, lr, r4, .Lgpr_setup_finished_range_\suffix, .Lif_long_range_\suffix, is_r3=1 |
| 1418 |
.Lif_long_range_\suffix: |
| 1419 |
// Add 1 word for the ArtMethod stored before the outs. |
| 1420 |
add r4, r4, #1 |
| 1421 |
LOOP_RANGE_OVER_INTs r8, lr, r4, .Lgpr_setup_finished_range_\suffix |
| 1422 |
.Lgpr_setup_finished_range_\suffix: |
| 1423 |
REFRESH_MARKING_REGISTER // r8 was used when setting parameters, restore it. |
| 1424 |
.if \is_polymorphic |
| 1425 |
bl art_quick_invoke_polymorphic |
| 1426 |
.elseif \is_custom |
| 1427 |
bl art_quick_invoke_custom |
| 1428 |
.else |
| 1429 |
.if \is_interface |
| 1430 |
// Setup hidden argument. |
| 1431 |
vmov ip, s16 |
| 1432 |
.endif |
| 1433 |
ldr lr, [r0, #ART_METHOD_QUICK_CODE_OFFSET_32] |
| 1434 |
blx lr |
| 1435 |
.endif |
| 1436 |
SETUP_RETURN_VALUE rINST |
| 1437 |
.Ldone_return_range_\suffix: |
| 1438 |
/* resume execution of caller */ |
| 1439 |
.if \is_string_init |
| 1440 |
FETCH ip, 2 // arguments |
| 1441 |
GET_VREG r1, ip |
| 1442 |
UPDATE_REGISTERS_FOR_STRING_INIT r1, r0 |
| 1443 |
.endif |
| 1444 |
|
| 1445 |
.if \is_polymorphic |
| 1446 |
FETCH_ADVANCE_INST 4 |
| 1447 |
.else |
| 1448 |
FETCH_ADVANCE_INST 3 |
| 1449 |
.endif |
| 1450 |
GET_INST_OPCODE ip |
| 1451 |
GOTO_OPCODE ip |
| 1452 |
.endm |
| 1453 |
|
| 1454 |
.macro WRITE_BARRIER_IF_OBJECT is_object, value, holder, label, tmp |
| 1455 |
.if \is_object |
| 1456 |
// In T32, we would use `SMART_CBZ \value, \label` |
| 1457 |
cmp \value, #0 |
| 1458 |
beq \label |
| 1459 |
ldr ip, [rSELF, #THREAD_CARD_TABLE_OFFSET] |
| 1460 |
lsr \tmp, \holder, #CARD_TABLE_CARD_SHIFT |
| 1461 |
strb ip, [ip, \tmp] |
| 1462 |
\label: |
| 1463 |
.endif |
| 1464 |
.endm |
| 1465 |
|
| 1466 |
.macro LDREXD_STREXD_LOOP addr, load1, load2, store1, store2, tmp, label |
| 1467 |
\label: |
| 1468 |
ldrexd \load1, \load2, [\addr] |
| 1469 |
strexd \tmp, \store1, \store2, [\addr] |
| 1470 |
cmp \tmp, #0 |
| 1471 |
bne \label |
| 1472 |
.endm |
| 1473 |
|
| 1474 |
.macro ATOMIC_LOAD64 addr, load1, load2, tmp, label |
| 1475 |
LDREXD_STREXD_LOOP \addr, \load1, \load2, \load1, \load2, \tmp, \label |
| 1476 |
.endm |
| 1477 |
|
| 1478 |
.macro ATOMIC_STORE64 addr, store1, store2, tmp1, tmp2, label |
| 1479 |
LDREXD_STREXD_LOOP \addr, \tmp1, \tmp2, \store1, \store2, \tmp1, \label |
| 1480 |
.endm |
| 1481 |
|
| 1482 |
// Puts the next int/long/object parameter passed in physical register |
| 1483 |
// in the expected dex register array entry, and in case of object in the |
| 1484 |
// expected reference array entry. |
| 1485 |
// Uses ip as temporary. |
| 1486 |
.macro LOOP_OVER_SHORTY_STORING_GPRS gpr_32, shorty, arg_offset, regs, refs, finished, if_long, is_r3 |
| 1487 |
1: // LOOP |
| 1488 |
ldrb ip, [\shorty], #1 // Load next character in shorty, and increment. |
| 1489 |
cmp ip, #0 |
| 1490 |
beq \finished // if (ip == '\0') goto finished |
| 1491 |
cmp ip, #74 // if (ip == 'J') goto FOUND_LONG |
| 1492 |
beq 2f |
| 1493 |
cmp ip, #70 // if (ip == 'F') goto SKIP_FLOAT |
| 1494 |
beq 3f |
| 1495 |
cmp ip, #68 // if (ip == 'D') goto SKIP_DOUBLE |
| 1496 |
beq 4f |
| 1497 |
str \gpr_32, [\regs, \arg_offset] |
| 1498 |
cmp ip, #76 // if (ip != 'L') goto NOT_REFERENCE |
| 1499 |
bne 6f |
| 1500 |
str \gpr_32, [\refs, \arg_offset] |
| 1501 |
6: // NOT_REFERENCE |
| 1502 |
add \arg_offset, \arg_offset, #4 |
| 1503 |
b 5f |
| 1504 |
2: // FOUND_LONG |
| 1505 |
.if \is_r3 |
| 1506 |
// Put back shorty and jump to \if_long |
| 1507 |
sub \shorty, \shorty, #1 |
| 1508 |
.else |
| 1509 |
// A long can only be in r2, r3 |
| 1510 |
str r2, [\regs, \arg_offset] |
| 1511 |
add \arg_offset, \arg_offset, #4 |
| 1512 |
str r3, [\regs, \arg_offset] |
| 1513 |
add \arg_offset, \arg_offset, #4 |
| 1514 |
.endif |
| 1515 |
b \if_long |
| 1516 |
3: // SKIP_FLOAT |
| 1517 |
add \arg_offset, \arg_offset, #4 |
| 1518 |
b 1b |
| 1519 |
4: // SKIP_DOUBLE |
| 1520 |
add \arg_offset, \arg_offset, #8 |
| 1521 |
b 1b |
| 1522 |
5: |
| 1523 |
.endm |
| 1524 |
|
| 1525 |
// Puts the next int/long/object parameter passed in stack |
| 1526 |
// in the expected dex register array entry, and in case of object in the |
| 1527 |
// expected reference array entry. |
| 1528 |
.macro LOOP_OVER_INTs shorty, arg_offset, regs, refs, stack_ptr, tmp1, tmp2, finished |
| 1529 |
1: // LOOP |
| 1530 |
ldrb \tmp1, [\shorty], #1 // Load next character in shorty, and increment. |
| 1531 |
cmp \tmp1, #0 |
| 1532 |
beq \finished // if (\tmp1 == '\0') goto finished |
| 1533 |
cmp \tmp1, #74 // if (\tmp1 == 'J') goto FOUND_LONG |
| 1534 |
beq 2f |
| 1535 |
cmp \tmp1, #70 // if (\tmp1 == 'F') goto SKIP_FLOAT |
| 1536 |
beq 3f |
| 1537 |
cmp \tmp1, #68 // if (\tmp1 == 'D') goto SKIP_DOUBLE |
| 1538 |
beq 4f |
| 1539 |
add \tmp2, \stack_ptr, \arg_offset |
| 1540 |
ldr \tmp2, [\tmp2, #OFFSET_TO_FIRST_ARGUMENT_IN_STACK] |
| 1541 |
str \tmp2, [\regs, \arg_offset] |
| 1542 |
cmp \tmp1, #76 // if (\tmp1 != 'L') goto loop |
| 1543 |
bne 3f |
| 1544 |
str \tmp2, [\refs, \arg_offset] |
| 1545 |
add \arg_offset, \arg_offset, #4 |
| 1546 |
b 1b |
| 1547 |
2: // FOUND_LONG |
| 1548 |
add \tmp1, \stack_ptr, \arg_offset |
| 1549 |
ldr \tmp1, [\tmp1, #OFFSET_TO_FIRST_ARGUMENT_IN_STACK] |
| 1550 |
str \tmp1, [\regs, \arg_offset] |
| 1551 |
add \arg_offset, \arg_offset, #4 |
| 1552 |
add \tmp1, \stack_ptr, \arg_offset |
| 1553 |
ldr \tmp1, [\tmp1, #OFFSET_TO_FIRST_ARGUMENT_IN_STACK] |
| 1554 |
str \tmp1, [\regs, \arg_offset] |
| 1555 |
add \arg_offset, \arg_offset, #4 |
| 1556 |
b 1b |
| 1557 |
3: // SKIP_FLOAT |
| 1558 |
add \arg_offset, \arg_offset, #4 |
| 1559 |
b 1b |
| 1560 |
4: // SKIP_DOUBLE |
| 1561 |
add \arg_offset, \arg_offset, #8 |
| 1562 |
b 1b |
| 1563 |
.endm |
| 1564 |
|
| 1565 |
.macro SETUP_REFERENCE_PARAMETER_IN_GPR gpr32, regs, refs, ins, arg_offset, finished |
| 1566 |
str \gpr32, [\regs, \arg_offset] |
| 1567 |
subs \ins, \ins, #1 |
| 1568 |
str \gpr32, [\refs, \arg_offset] |
| 1569 |
add \arg_offset, \arg_offset, #4 |
| 1570 |
beq \finished |
| 1571 |
.endm |
| 1572 |
|
| 1573 |
.macro SETUP_REFERENCE_PARAMETERS_IN_STACK regs, refs, ins, stack_ptr, arg_offset |
| 1574 |
1: |
| 1575 |
ldr ip, [\stack_ptr, \arg_offset] |
| 1576 |
subs \ins, \ins, #1 |
| 1577 |
str ip, [\regs, \arg_offset] |
| 1578 |
str ip, [\refs, \arg_offset] |
| 1579 |
add \arg_offset, \arg_offset, #4 |
| 1580 |
bne 1b |
| 1581 |
.endm |
| 1582 |
|
| 1583 |
.macro DO_SUSPEND_CHECK continue_label |
| 1584 |
// Otherwise, do a suspend check. |
| 1585 |
ldr ip, [rSELF, #THREAD_FLAGS_OFFSET] |
| 1586 |
tst ip, #THREAD_SUSPEND_OR_CHECKPOINT_REQUEST |
| 1587 |
beq \continue_label |
| 1588 |
EXPORT_PC |
| 1589 |
bl art_quick_test_suspend |
| 1590 |
.endm |
| 1591 |
|
| 1592 |
.macro CHECK_AND_UPDATE_SHARED_MEMORY_METHOD if_hot, if_not_hot |
| 1593 |
ldr ip, [r0, #ART_METHOD_ACCESS_FLAGS_OFFSET] |
| 1594 |
tst ip, #ART_METHOD_IS_MEMORY_SHARED_FLAG |
| 1595 |
beq \if_hot |
| 1596 |
ldr ip, [rSELF, #THREAD_SHARED_METHOD_HOTNESS_OFFSET] |
| 1597 |
cmp ip, #0 |
| 1598 |
beq \if_hot |
| 1599 |
add ip, ip, #-1 |
| 1600 |
str ip, [rSELF, #THREAD_SHARED_METHOD_HOTNESS_OFFSET] |
| 1601 |
b \if_not_hot |
| 1602 |
.endm |
| 1603 |
|
| 1604 |
|
| 1605 |
%def entry(): |
| 1606 |
/* |
| 1607 |
* ArtMethod entry point. |
| 1608 |
* |
| 1609 |
* On entry: |
| 1610 |
* r0 ArtMethod* callee |
| 1611 |
* rest method parameters |
| 1612 |
*/ |
| 1613 |
|
| 1614 |
OAT_ENTRY ExecuteNterpWithClinitImpl, EndExecuteNterpWithClinitImpl |
| 1615 |
// For simplicity, we don't do a read barrier here, but instead rely |
| 1616 |
// on art_quick_resolution_trampoline to always have a suspend point before |
| 1617 |
// calling back here. |
| 1618 |
ldr r4, [r0, ART_METHOD_DECLARING_CLASS_OFFSET] |
| 1619 |
ldrb ip, [r4, MIRROR_CLASS_IS_VISIBLY_INITIALIZED_OFFSET] |
| 1620 |
cmp ip, #MIRROR_CLASS_IS_VISIBLY_INITIALIZED_VALUE |
| 1621 |
bcs ExecuteNterpImpl |
| 1622 |
cmp ip, #MIRROR_CLASS_IS_INITIALIZED_VALUE |
| 1623 |
blo .Linitializing_check |
| 1624 |
dmb ish |
| 1625 |
b ExecuteNterpImpl |
| 1626 |
.Linitializing_check: |
| 1627 |
cmp ip, #MIRROR_CLASS_IS_INITIALIZING_VALUE |
| 1628 |
blo art_quick_resolution_trampoline |
| 1629 |
ldr r4, [r4, #MIRROR_CLASS_CLINIT_THREAD_ID_OFFSET] |
| 1630 |
ldr ip, [rSELF, #THREAD_TID_OFFSET] |
| 1631 |
cmp r4, ip |
| 1632 |
beq ExecuteNterpImpl |
| 1633 |
b art_quick_resolution_trampoline |
| 1634 |
EndExecuteNterpWithClinitImpl: |
| 1635 |
|
| 1636 |
OAT_ENTRY ExecuteNterpImpl, EndExecuteNterpImpl |
| 1637 |
.cfi_startproc |
| 1638 |
sub ip, sp, #STACK_OVERFLOW_RESERVED_BYTES |
| 1639 |
ldr ip, [ip] |
| 1640 |
/* Spill callee save regs */ |
| 1641 |
SPILL_ALL_CALLEE_SAVES |
| 1642 |
|
| 1643 |
ldr rPC, [r0, #ART_METHOD_DATA_OFFSET_32] |
| 1644 |
|
| 1645 |
// Setup the stack for executing the method. |
| 1646 |
SETUP_STACK_FRAME rPC, rREFS, rFP, CFI_REFS, load_ins=1 |
| 1647 |
|
| 1648 |
// Setup the parameters |
| 1649 |
cmp r4, #0 |
| 1650 |
beq .Lxmm_setup_finished |
| 1651 |
|
| 1652 |
sub rINST, rINST, r4 |
| 1653 |
ldr r8, [r0, #ART_METHOD_ACCESS_FLAGS_OFFSET] |
| 1654 |
lsl rINST, rINST, #2 // rINST is now the offset for inputs into the registers array. |
| 1655 |
mov rIBASE, ip // rIBASE contains the old stack pointer |
| 1656 |
|
| 1657 |
tst r8, #ART_METHOD_NTERP_ENTRY_POINT_FAST_PATH_FLAG |
| 1658 |
beq .Lsetup_slow_path |
| 1659 |
// Setup pointer to inputs in FP and pointer to inputs in REFS |
| 1660 |
add lr, rFP, rINST |
| 1661 |
add r8, rREFS, rINST |
| 1662 |
mov r0, #0 |
| 1663 |
SETUP_REFERENCE_PARAMETER_IN_GPR r1, lr, r8, r4, r0, .Lxmm_setup_finished |
| 1664 |
SETUP_REFERENCE_PARAMETER_IN_GPR r2, lr, r8, r4, r0, .Lxmm_setup_finished |
| 1665 |
SETUP_REFERENCE_PARAMETER_IN_GPR r3, lr, r8, r4, r0, .Lxmm_setup_finished |
| 1666 |
add rIBASE, rIBASE, #OFFSET_TO_FIRST_ARGUMENT_IN_STACK |
| 1667 |
SETUP_REFERENCE_PARAMETERS_IN_STACK lr, r8, r4, rIBASE, r0 |
| 1668 |
b .Lxmm_setup_finished |
| 1669 |
|
| 1670 |
.Lsetup_slow_path: |
| 1671 |
// If the method is not static and there is one argument ('this'), we don't need to fetch the |
| 1672 |
// shorty. |
| 1673 |
tst r8, #ART_METHOD_IS_STATIC_FLAG |
| 1674 |
bne .Lsetup_with_shorty |
| 1675 |
str r1, [rFP, rINST] |
| 1676 |
str r1, [rREFS, rINST] |
| 1677 |
cmp r4, #1 |
| 1678 |
beq .Lxmm_setup_finished |
| 1679 |
|
| 1680 |
.Lsetup_with_shorty: |
| 1681 |
// Save arguments that were passed before calling into the runtime. |
| 1682 |
// No need to save r0 (ArtMethod) as we're not using it later in this code. |
| 1683 |
// Save r4 for stack aligment. |
| 1684 |
// TODO: Get shorty in a better way and remove below |
| 1685 |
push {r1-r4} |
| 1686 |
vpush {s0-s15} |
| 1687 |
bl NterpGetShorty |
| 1688 |
vpop {s0-s15} |
| 1689 |
pop {r1-r4} |
| 1690 |
|
| 1691 |
mov ip, r8 |
| 1692 |
add r8, rREFS, rINST |
| 1693 |
add r7, rFP, rINST |
| 1694 |
mov r4, #0 |
| 1695 |
// Setup shorty, pointer to inputs in FP and pointer to inputs in REFS |
| 1696 |
add lr, r0, #1 // shorty + 1 ; ie skip return arg character |
| 1697 |
tst ip, #ART_METHOD_IS_STATIC_FLAG |
| 1698 |
bne .Lhandle_static_method |
| 1699 |
add r7, r7, #4 |
| 1700 |
add r8, r8, #4 |
| 1701 |
add rIBASE, rIBASE, #4 |
| 1702 |
b .Lcontinue_setup_gprs |
| 1703 |
.Lhandle_static_method: |
| 1704 |
LOOP_OVER_SHORTY_STORING_GPRS r1, lr, r4, r7, r8, .Lgpr_setup_finished, .Lif_long, is_r3=0 |
| 1705 |
.Lcontinue_setup_gprs: |
| 1706 |
LOOP_OVER_SHORTY_STORING_GPRS r2, lr, r4, r7, r8, .Lgpr_setup_finished, .Lif_long, is_r3=0 |
| 1707 |
LOOP_OVER_SHORTY_STORING_GPRS r3, lr, r4, r7, r8, .Lgpr_setup_finished, .Lif_long, is_r3=1 |
| 1708 |
.Lif_long: |
| 1709 |
LOOP_OVER_INTs lr, r4, r7, r8, rIBASE, ip, r1, .Lgpr_setup_finished |
| 1710 |
.Lgpr_setup_finished: |
| 1711 |
add r0, r0, #1 // shorty + 1 ; ie skip return arg character |
| 1712 |
mov r1, r7 |
| 1713 |
add r2, rIBASE, #OFFSET_TO_FIRST_ARGUMENT_IN_STACK |
| 1714 |
vpush {s0-s15} |
| 1715 |
mov r3, sp |
| 1716 |
bl NterpStoreArm32Fprs |
| 1717 |
add sp, sp, #(16 * 4) |
| 1718 |
.Lxmm_setup_finished: |
| 1719 |
CFI_DEFINE_DEX_PC_WITH_OFFSET(CFI_TMP, CFI_DEX, 0) |
| 1720 |
// r8 was used for setting up the frame, restore it now. |
| 1721 |
REFRESH_MARKING_REGISTER |
| 1722 |
.Lexecute_instructions: |
| 1723 |
// Set rIBASE |
| 1724 |
adr rIBASE, artNterpAsmInstructionStart |
| 1725 |
/* start executing the instruction at rPC */ |
| 1726 |
START_EXECUTING_INSTRUCTIONS |
| 1727 |
/* NOTE: no fallthrough */ |
| 1728 |
// cfi info continues, and covers the whole nterp implementation. |
| 1729 |
SIZE ExecuteNterpImpl |
| 1730 |
|
| 1731 |
%def opcode_pre(): |
| 1732 |
|
| 1733 |
%def fetch_from_thread_cache(dest_reg, miss_label): |
| 1734 |
// Fetch some information from the thread cache. |
| 1735 |
// Uses ip and lr as temporaries. |
| 1736 |
add ip, rSELF, #THREAD_INTERPRETER_CACHE_OFFSET // cache address |
| 1737 |
ubfx lr, rPC, #2, #THREAD_INTERPRETER_CACHE_SIZE_LOG2 // entry index |
| 1738 |
add ip, ip, lr, lsl #3 // entry address within the cache |
| 1739 |
// In T32, we would use `ldrd ip, \dest_reg, [ip]` |
| 1740 |
ldr ${dest_reg}, [ip, #4] // value (offset) |
| 1741 |
ldr ip, [ip] // entry key (pc) |
| 1742 |
cmp ip, rPC |
| 1743 |
bne ${miss_label} |
| 1744 |
|
| 1745 |
%def footer(): |
| 1746 |
/* |
| 1747 |
* =========================================================================== |
| 1748 |
* Common subroutines and data |
| 1749 |
* =========================================================================== |
| 1750 |
*/ |
| 1751 |
|
| 1752 |
.text |
| 1753 |
.align 2 |
| 1754 |
|
| 1755 |
// Enclose all code below in a symbol (which gets printed in backtraces). |
| 1756 |
NAME_START nterp_helper |
| 1757 |
|
| 1758 |
// Note: mterp also uses the common_* names below for helpers, but that's OK |
| 1759 |
// as the assembler compiled each interpreter separately. |
| 1760 |
common_errDivideByZero: |
| 1761 |
EXPORT_PC |
| 1762 |
bl art_quick_throw_div_zero |
| 1763 |
|
| 1764 |
// Expect index in r1, length in r3 |
| 1765 |
common_errArrayIndex: |
| 1766 |
EXPORT_PC |
| 1767 |
mov r0, r1 |
| 1768 |
mov r1, r3 |
| 1769 |
bl art_quick_throw_array_bounds |
| 1770 |
|
| 1771 |
common_errNullObject: |
| 1772 |
EXPORT_PC |
| 1773 |
bl art_quick_throw_null_pointer_exception |
| 1774 |
|
| 1775 |
NterpCommonInvokeStatic: |
| 1776 |
COMMON_INVOKE_NON_RANGE is_static=1, suffix="invokeStatic" |
| 1777 |
|
| 1778 |
NterpCommonInvokeStaticRange: |
| 1779 |
COMMON_INVOKE_RANGE is_static=1, suffix="invokeStatic" |
| 1780 |
|
| 1781 |
NterpCommonInvokeInstance: |
| 1782 |
COMMON_INVOKE_NON_RANGE suffix="invokeInstance" |
| 1783 |
|
| 1784 |
NterpCommonInvokeInstanceRange: |
| 1785 |
COMMON_INVOKE_RANGE suffix="invokeInstance" |
| 1786 |
|
| 1787 |
NterpCommonInvokeInterface: |
| 1788 |
COMMON_INVOKE_NON_RANGE is_interface=1, suffix="invokeInterface" |
| 1789 |
|
| 1790 |
NterpCommonInvokeInterfaceRange: |
| 1791 |
COMMON_INVOKE_RANGE is_interface=1, suffix="invokeInterface" |
| 1792 |
|
| 1793 |
NterpCommonInvokePolymorphic: |
| 1794 |
COMMON_INVOKE_NON_RANGE is_polymorphic=1, suffix="invokePolymorphic" |
| 1795 |
|
| 1796 |
NterpCommonInvokePolymorphicRange: |
| 1797 |
COMMON_INVOKE_RANGE is_polymorphic=1, suffix="invokePolymorphic" |
| 1798 |
|
| 1799 |
NterpCommonInvokeCustom: |
| 1800 |
COMMON_INVOKE_NON_RANGE is_static=1, is_custom=1, suffix="invokeCustom" |
| 1801 |
|
| 1802 |
NterpCommonInvokeCustomRange: |
| 1803 |
COMMON_INVOKE_RANGE is_static=1, is_custom=1, suffix="invokeCustom" |
| 1804 |
|
| 1805 |
NterpHandleStringInit: |
| 1806 |
COMMON_INVOKE_NON_RANGE is_string_init=1, suffix="stringInit" |
| 1807 |
|
| 1808 |
NterpHandleStringInitRange: |
| 1809 |
COMMON_INVOKE_RANGE is_string_init=1, suffix="stringInit" |
| 1810 |
|
| 1811 |
|
| 1812 |
NterpHandleHotnessOverflow: |
| 1813 |
CHECK_AND_UPDATE_SHARED_MEMORY_METHOD if_hot=1f, if_not_hot=5f |
| 1814 |
1: |
| 1815 |
mov r1, rPC |
| 1816 |
mov r2, rFP |
| 1817 |
bl nterp_hot_method |
| 1818 |
cmp r0, #0 |
| 1819 |
bne 3f |
| 1820 |
2: |
| 1821 |
FETCH_INST // load rINST |
| 1822 |
GET_INST_OPCODE ip // extract opcode from rINST |
| 1823 |
GOTO_OPCODE ip // jump to next instruction |
| 1824 |
3: |
| 1825 |
// Drop the current frame. |
| 1826 |
ldr ip, [rREFS, #-4] |
| 1827 |
mov sp, ip |
| 1828 |
.cfi_def_cfa sp, CALLEE_SAVES_SIZE |
| 1829 |
|
| 1830 |
// The transition frame of type SaveAllCalleeSaves saves r4, r8, and r9, |
| 1831 |
// but not managed ABI. So we need to restore callee-saves of the nterp frame, |
| 1832 |
// and save managed ABI callee saves, which will be restored by the callee upon |
| 1833 |
// return. |
| 1834 |
|
| 1835 |
RESTORE_ALL_CALLEE_SAVES |
| 1836 |
push {r5-r7, r10-r11, lr} |
| 1837 |
.cfi_adjust_cfa_offset 24 |
| 1838 |
.cfi_rel_offset r5, 0 |
| 1839 |
.cfi_rel_offset r6, 4 |
| 1840 |
.cfi_rel_offset r7, 8 |
| 1841 |
.cfi_rel_offset r10, 12 |
| 1842 |
.cfi_rel_offset r11, 16 |
| 1843 |
.cfi_rel_offset lr, 20 |
| 1844 |
vpush {s16-s31} |
| 1845 |
.cfi_adjust_cfa_offset 64 |
| 1846 |
|
| 1847 |
// Setup the new frame |
| 1848 |
ldr r1, [r0, #OSR_DATA_FRAME_SIZE] |
| 1849 |
// Given stack size contains all callee saved registers, remove them. |
| 1850 |
sub r1, r1, #(CALLEE_SAVES_SIZE - 12) |
| 1851 |
|
| 1852 |
// We know r1 cannot be 0, as it at least contains the ArtMethod. |
| 1853 |
|
| 1854 |
// Remember CFA in a callee-save register. |
| 1855 |
mov rINST, sp |
| 1856 |
.cfi_def_cfa_register rINST |
| 1857 |
|
| 1858 |
sub sp, sp, r1 |
| 1859 |
|
| 1860 |
add r2, r0, #OSR_DATA_MEMORY |
| 1861 |
4: |
| 1862 |
sub r1, r1, #4 |
| 1863 |
ldr ip, [r2, r1] |
| 1864 |
str ip, [sp, r1] |
| 1865 |
cmp r1, #0 |
| 1866 |
bne 4b |
| 1867 |
|
| 1868 |
// Fetch the native PC to jump to and save it in a callee-save register. |
| 1869 |
ldr rFP, [r0, #OSR_DATA_NATIVE_PC] |
| 1870 |
|
| 1871 |
// Free the memory holding OSR Data. |
| 1872 |
bl free |
| 1873 |
|
| 1874 |
// Jump to the compiled code. |
| 1875 |
bx rFP |
| 1876 |
5: |
| 1877 |
DO_SUSPEND_CHECK continue_label=2b |
| 1878 |
b 2b |
| 1879 |
|
| 1880 |
// This is the logical end of ExecuteNterpImpl, where the frame info applies. |
| 1881 |
// EndExecuteNterpImpl includes the methods below as we want the runtime to |
| 1882 |
// see them as part of the Nterp PCs. |
| 1883 |
.cfi_endproc |
| 1884 |
|
| 1885 |
nterp_to_nterp_static_non_range: |
| 1886 |
.cfi_startproc |
| 1887 |
SETUP_STACK_FOR_INVOKE |
| 1888 |
SETUP_NON_RANGE_ARGUMENTS_AND_EXECUTE is_static=1, is_string_init=0 |
| 1889 |
.cfi_endproc |
| 1890 |
|
| 1891 |
nterp_to_nterp_string_init_non_range: |
| 1892 |
.cfi_startproc |
| 1893 |
SETUP_STACK_FOR_INVOKE |
| 1894 |
SETUP_NON_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=1 |
| 1895 |
.cfi_endproc |
| 1896 |
|
| 1897 |
nterp_to_nterp_instance_non_range: |
| 1898 |
.cfi_startproc |
| 1899 |
SETUP_STACK_FOR_INVOKE |
| 1900 |
SETUP_NON_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=0 |
| 1901 |
.cfi_endproc |
| 1902 |
|
| 1903 |
nterp_to_nterp_static_range: |
| 1904 |
.cfi_startproc |
| 1905 |
SETUP_STACK_FOR_INVOKE |
| 1906 |
SETUP_RANGE_ARGUMENTS_AND_EXECUTE is_static=1, is_string_init=0 |
| 1907 |
.cfi_endproc |
| 1908 |
|
| 1909 |
nterp_to_nterp_string_init_range: |
| 1910 |
.cfi_startproc |
| 1911 |
SETUP_STACK_FOR_INVOKE |
| 1912 |
SETUP_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=1 |
| 1913 |
.cfi_endproc |
| 1914 |
|
| 1915 |
nterp_to_nterp_instance_range: |
| 1916 |
.cfi_startproc |
| 1917 |
SETUP_STACK_FOR_INVOKE |
| 1918 |
SETUP_RANGE_ARGUMENTS_AND_EXECUTE is_static=0, is_string_init=0 |
| 1919 |
.cfi_endproc |
| 1920 |
|
| 1921 |
NAME_END nterp_helper |
| 1922 |
|
| 1923 |
// This is the end of PCs contained by the OatQuickMethodHeader created for the interpreter |
| 1924 |
// entry point. |
| 1925 |
.type EndExecuteNterpImpl, #function |
| 1926 |
.hidden EndExecuteNterpImpl |
| 1927 |
.global EndExecuteNterpImpl |
| 1928 |
EndExecuteNterpImpl: |
| 1929 |
|
| 1930 |
/* |
| 1931 |
* Convert the double in r0/r1 to a long in r0/r1. |
| 1932 |
* |
| 1933 |
* We have to clip values to long min/max per the specification. The |
| 1934 |
* expected common case is a "reasonable" value that converts directly |
| 1935 |
* to modest integer. The EABI convert function isn't doing this for us. |
| 1936 |
*/ |
| 1937 |
ENTRY nterp_d2l_doconv |
| 1938 |
ubfx r2, r1, #20, #11 @ grab the exponent |
| 1939 |
movw r3, #0x43e |
| 1940 |
cmp r2, r3 @ MINLONG < x > MAXLONG? |
| 1941 |
bhs d2l_special_cases |
| 1942 |
b __aeabi_d2lz @ tail call to convert double to long |
| 1943 |
d2l_special_cases: |
| 1944 |
movw r3, #0x7ff |
| 1945 |
cmp r2, r3 |
| 1946 |
beq d2l_maybeNaN @ NaN? |
| 1947 |
d2l_notNaN: |
| 1948 |
adds r1, r1, r1 @ sign bit to carry |
| 1949 |
mov r0, #0xffffffff @ assume maxlong for lsw |
| 1950 |
mov r1, #0x7fffffff @ assume maxlong for msw |
| 1951 |
adc r0, r0, #0 |
| 1952 |
adc r1, r1, #0 @ convert maxlong to minlong if exp negative |
| 1953 |
bx lr @ return |
| 1954 |
d2l_maybeNaN: |
| 1955 |
orrs r3, r0, r1, lsl #12 |
| 1956 |
beq d2l_notNaN @ if fraction is non-zero, it's a NaN |
| 1957 |
mov r0, #0 |
| 1958 |
mov r1, #0 |
| 1959 |
bx lr @ return 0 for NaN |
| 1960 |
END nterp_d2l_doconv |
| 1961 |
|
| 1962 |
/* |
| 1963 |
* Convert the float in r0 to a long in r0/r1. |
| 1964 |
* |
| 1965 |
* We have to clip values to long min/max per the specification. The |
| 1966 |
* expected common case is a "reasonable" value that converts directly |
| 1967 |
* to modest integer. The EABI convert function isn't doing this for us. |
| 1968 |
*/ |
| 1969 |
ENTRY nterp_f2l_doconv |
| 1970 |
ubfx r2, r0, #23, #8 @ grab the exponent |
| 1971 |
cmp r2, #0xbe @ MININT < x > MAXINT? |
| 1972 |
bhs f2l_special_cases |
| 1973 |
b __aeabi_f2lz @ tail call to convert float to long |
| 1974 |
f2l_special_cases: |
| 1975 |
cmp r2, #0xff @ NaN or infinity? |
| 1976 |
beq f2l_maybeNaN |
| 1977 |
f2l_notNaN: |
| 1978 |
adds r0, r0, r0 @ sign bit to carry |
| 1979 |
mov r0, #0xffffffff @ assume maxlong for lsw |
| 1980 |
mov r1, #0x7fffffff @ assume maxlong for msw |
| 1981 |
adc r0, r0, #0 |
| 1982 |
adc r1, r1, #0 @ convert maxlong to minlong if exp negative |
| 1983 |
bx lr @ return |
| 1984 |
f2l_maybeNaN: |
| 1985 |
lsls r3, r0, #9 |
| 1986 |
beq f2l_notNaN @ if fraction is non-zero, it's a NaN |
| 1987 |
mov r0, #0 |
| 1988 |
mov r1, #0 |
| 1989 |
bx lr @ return 0 for NaN |
| 1990 |
END nterp_f2l_doconv |
| 1991 |
|
| 1992 |
// Entrypoints into runtime. |
| 1993 |
NTERP_TRAMPOLINE nterp_get_static_field, NterpGetStaticField |
| 1994 |
NTERP_TRAMPOLINE nterp_get_instance_field_offset, NterpGetInstanceFieldOffset |
| 1995 |
NTERP_TRAMPOLINE nterp_filled_new_array, NterpFilledNewArray |
| 1996 |
NTERP_TRAMPOLINE nterp_filled_new_array_range, NterpFilledNewArrayRange |
| 1997 |
NTERP_TRAMPOLINE nterp_get_class, NterpGetClass |
| 1998 |
NTERP_TRAMPOLINE nterp_allocate_object, NterpAllocateObject |
| 1999 |
NTERP_TRAMPOLINE nterp_get_method, NterpGetMethod |
| 2000 |
NTERP_TRAMPOLINE nterp_hot_method, NterpHotMethod |
| 2001 |
NTERP_TRAMPOLINE nterp_load_object, NterpLoadObject |
| 2002 |
|
| 2003 |
ENTRY nterp_deliver_pending_exception |
| 2004 |
DELIVER_PENDING_EXCEPTION |
| 2005 |
END nterp_deliver_pending_exception |
| 2006 |
|
| 2007 |
// gen_mterp.py will inline the following definitions |
| 2008 |
// within [ExecuteNterpImpl, EndExecuteNterpImpl). |
| 2009 |
%def instruction_end(): |
| 2010 |
|
| 2011 |
.type artNterpAsmInstructionEnd, #function |
| 2012 |
.hidden artNterpAsmInstructionEnd |
| 2013 |
.global artNterpAsmInstructionEnd |
| 2014 |
artNterpAsmInstructionEnd: |
| 2015 |
// artNterpAsmInstructionEnd is used as landing pad for exception handling. |
| 2016 |
FETCH_INST |
| 2017 |
GET_INST_OPCODE ip |
| 2018 |
GOTO_OPCODE ip |
| 2019 |
|
| 2020 |
%def instruction_start(): |
| 2021 |
|
| 2022 |
.type artNterpAsmInstructionStart, #function |
| 2023 |
.hidden artNterpAsmInstructionStart |
| 2024 |
.global artNterpAsmInstructionStart |
| 2025 |
artNterpAsmInstructionStart = .L_op_nop |
| 2026 |
.text |
| 2027 |
|
| 2028 |
%def opcode_name_prefix(): |
| 2029 |
% return "nterp_" |
| 2030 |
%def opcode_start(): |
| 2031 |
NAME_START nterp_${opcode} |
| 2032 |
# Explicitly restore CFA, just in case the previous opcode clobbered it (by .cfi_def_*). |
| 2033 |
CFI_DEF_CFA_BREG_PLUS_UCONST CFI_REFS, -4, CALLEE_SAVES_SIZE |
| 2034 |
%def opcode_end(): |
| 2035 |
NAME_END nterp_${opcode} |
| 2036 |
// Advance to the end of this handler. Causes error if we are past that point. |
| 2037 |
.org nterp_${opcode} + NTERP_HANDLER_SIZE // ${opcode} handler is too big! |
| 2038 |
%def opcode_slow_path_start(name): |
| 2039 |
NAME_START ${name} |
| 2040 |
%def opcode_slow_path_end(name): |
| 2041 |
NAME_END ${name} |