quick_entrypoints_arm64.S revision 00c1e6d5fa6c2c20f25c38591b9780114bf7ddbf
14f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber/* 24f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * Copyright (C) 2014 The Android Open Source Project 34f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * 44f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 54f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * you may not use this file except in compliance with the License. 64f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * You may obtain a copy of the License at 74f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * 84f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 94f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * 104f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * Unless required by applicable law or agreed to in writing, software 114f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 124f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * See the License for the specific language governing permissions and 144f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * limitations under the License. 154f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber */ 164f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 174f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber#include "asm_support_arm64.S" 184f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 194f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber#include "arch/quick_alloc_entrypoints.S" 204f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 214f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 224f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber /* 234f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * Macro that sets up the callee save frame to conform with 244f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber * Runtime::CreateCalleeSaveMethod(kSaveAll) 254f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber */ 264f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME 274f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber adrp x9, :got:_ZN3art7Runtime9instance_E 284f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E] 294f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 304f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // Our registers aren't intermixed - just spill in order. 314f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) . 324f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 334f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] . 344f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber ldr x9, [x9, RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET ] 354f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 364f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber sub sp, sp, #368 374f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_adjust_cfa_offset 368 384f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 394f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // Ugly compile-time check, but we only have the preprocessor. 404f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 368) 414f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber#error "SAVE_ALL_CALLEE_SAVE_FRAME(ARM64) size not as expected." 424f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber#endif 434f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 444f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // FP args 454f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d1, d2, [sp, #8] 464f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d2, d3, [sp, #24] 474f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d4, d5, [sp, #40] 484f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d6, d7, [sp, #56] 494f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 504f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // FP callee-saves 514f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d8, d9, [sp, #72] 524f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d10, d11, [sp, #88] 534f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d12, d13, [sp, #104] 544f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d14, d15, [sp, #120] 554f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 564f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d16, d17, [sp, #136] 574f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d18, d19, [sp, #152] 584f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d20, d21, [sp, #168] 594f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d22, d23, [sp, #184] 604f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d24, d25, [sp, #200] 614f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d26, d27, [sp, #216] 624f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d28, d29, [sp, #232] 634f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp d30, d31, [sp, #248] 644f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 654f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 664f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber // Callee saved. 674f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp xSELF, x19, [sp, #264] 684f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x18, 264 694f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x19, 272 704f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 714f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp x20, x21, [sp, #280] 724f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x20, 280 734f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x21, 288 744f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 754f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp x22, x23, [sp, #296] 764f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x22, 296 774f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x23, 304 784f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 794f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp x24, x25, [sp, #312] 804f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x24, 312 814f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber .cfi_rel_offset x25, 320 824f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber 834f1efc098cb5791c3e9f483f2af84aef70d2d0a0Andreas Huber stp x26, x27, [sp, #328] 84 .cfi_rel_offset x26, 328 85 .cfi_rel_offset x27, 336 86 87 stp x28, xFP, [sp, #344] // Save FP. 88 .cfi_rel_offset x28, 344 89 .cfi_rel_offset x29, 352 90 91 str xLR, [sp, #360] 92 .cfi_rel_offset x30, 360 93 94 // Loads appropriate callee-save-method 95 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs] 96 97.endm 98 99 /* 100 * Macro that sets up the callee save frame to conform with 101 * Runtime::CreateCalleeSaveMethod(kRefsOnly). 102 */ 103// WIP. 104.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME 105 adrp x9, :got:_ZN3art7Runtime9instance_E 106 ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E] 107 108 // Our registers aren't intermixed - just spill in order. 109 ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) . 110 111 // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] . 112 ldr x9, [x9, RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET ] 113 114 sub sp, sp, #176 115 .cfi_adjust_cfa_offset 176 116 117 // Ugly compile-time check, but we only have the preprocessor. 118#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 176) 119#error "REFS_ONLY_CALLEE_SAVE_FRAME(ARM64) size not as expected." 120#endif 121 122 // FP callee-saves 123 stp d8, d9, [sp, #8] 124 stp d10, d11, [sp, #24] 125 stp d12, d13, [sp, #40] 126 stp d14, d15, [sp, #56] 127 128 // Callee saved. 129 stp xSELF, x19, [sp, #72] 130 .cfi_rel_offset x18, 72 131 .cfi_rel_offset x19, 80 132 133 stp x20, x21, [sp, #88] 134 .cfi_rel_offset x20, 88 135 .cfi_rel_offset x21, 96 136 137 stp x22, x23, [sp, #104] 138 .cfi_rel_offset x22, 104 139 .cfi_rel_offset x23, 112 140 141 stp x24, x25, [sp, #120] 142 .cfi_rel_offset x24, 120 143 .cfi_rel_offset x25, 128 144 145 stp x26, x27, [sp, #136] 146 .cfi_rel_offset x26, 136 147 .cfi_rel_offset x27, 144 148 149 stp x28, xFP, [sp, #152] // Save FP. 150 .cfi_rel_offset x28, 152 151 .cfi_rel_offset x29, 160 152 153 str xLR, [sp, #168] 154 .cfi_rel_offset x30, 168 155 156 // Loads appropriate callee-save-method 157 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs] 158.endm 159 160.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME 161 // FP callee saves 162 ldp d8, d9, [sp, #8] 163 ldp d10, d11, [sp, #24] 164 ldp d12, d13, [sp, #40] 165 ldp d14, d15, [sp, #56] 166 167 // Callee saved. 168 ldp xSELF, x19, [sp, #72] 169 .cfi_restore x18 170 .cfi_restore x19 171 172 ldp x20, x21, [sp, #88] 173 .cfi_restore x20 174 .cfi_restore x21 175 176 ldp x22, x23, [sp, #104] 177 .cfi_restore x22 178 .cfi_restore x23 179 180 ldp x24, x25, [sp, #120] 181 .cfi_restore x24 182 .cfi_restore x25 183 184 ldp x26, x27, [sp, #136] 185 .cfi_restore x26 186 .cfi_restore x27 187 188 ldp x28, xFP, [sp, #152] // Save FP. 189 .cfi_restore x28 190 .cfi_restore x29 191 192 ldr xLR, [sp, #168] 193 .cfi_restore x30 194 195 add sp, sp, #176 196 .cfi_adjust_cfa_offset -176 197.endm 198 199.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN 200 brk 0 201.endm 202 203 204.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL 205 sub sp, sp, #304 206 .cfi_adjust_cfa_offset 304 207 208 // Ugly compile-time check, but we only have the preprocessor. 209#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 304) 210#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(ARM64) size not as expected." 211#endif 212 213 stp d0, d1, [sp, #16] 214 stp d2, d3, [sp, #32] 215 stp d4, d5, [sp, #48] 216 stp d6, d7, [sp, #64] 217 stp d8, d9, [sp, #80] 218 stp d10, d11, [sp, #96] 219 stp d12, d13, [sp, #112] 220 stp d14, d15, [sp, #128] 221 222 stp x1, x2, [sp, #144] 223 .cfi_rel_offset x1, 144 224 .cfi_rel_offset x2, 152 225 226 stp x3, x4, [sp, #160] 227 .cfi_rel_offset x3, 160 228 .cfi_rel_offset x4, 168 229 230 stp x5, x6, [sp, #176] 231 .cfi_rel_offset x5, 176 232 .cfi_rel_offset x6, 184 233 234 stp x7, xSELF, [sp, #192] 235 .cfi_rel_offset x7, 192 236 .cfi_rel_offset x18, 200 237 238 stp x19, x20, [sp, #208] 239 .cfi_rel_offset x19, 208 240 .cfi_rel_offset x20, 216 241 242 stp x21, x22, [sp, #224] 243 .cfi_rel_offset x21, 224 244 .cfi_rel_offset x22, 232 245 246 stp x23, x24, [sp, #240] 247 .cfi_rel_offset x23, 240 248 .cfi_rel_offset x24, 248 249 250 stp x25, x26, [sp, #256] 251 .cfi_rel_offset x25, 256 252 .cfi_rel_offset x26, 264 253 254 stp x27, x28, [sp, #272] 255 .cfi_rel_offset x27, 272 256 .cfi_rel_offset x28, 280 257 258 stp xFP, xLR, [sp, #288] 259 .cfi_rel_offset x29, 288 260 .cfi_rel_offset x30, 296 261.endm 262 263 /* 264 * Macro that sets up the callee save frame to conform with 265 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). 266 * 267 * TODO This is probably too conservative - saving FP & LR. 268 */ 269.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME 270 adrp x9, :got:_ZN3art7Runtime9instance_E 271 ldr x9, [x9, #:got_lo12:_ZN3art7Runtime9instance_E] 272 273 // Our registers aren't intermixed - just spill in order. 274 ldr x9,[x9] // x9 = & (art::Runtime * art::Runtime.instance_) . 275 276 // x9 = (ArtMethod*) Runtime.instance_.callee_save_methods[kRefAndArgs] . 277 ldr x9, [x9, RUNTIME_REF_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET ] 278 279 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL 280 281 str x9, [sp] // Store ArtMethod* Runtime::callee_save_methods_[kRefsAndArgs] 282.endm 283 284.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 285 286 ldp d0, d1, [sp, #16] 287 ldp d2, d3, [sp, #32] 288 ldp d4, d5, [sp, #48] 289 ldp d6, d7, [sp, #64] 290 ldp d8, d9, [sp, #80] 291 ldp d10, d11, [sp, #96] 292 ldp d12, d13, [sp, #112] 293 ldp d14, d15, [sp, #128] 294 295 // args. 296 ldp x1, x2, [sp, #144] 297 .cfi_restore x1 298 .cfi_restore x2 299 300 ldp x3, x4, [sp, #160] 301 .cfi_restore x3 302 .cfi_restore x4 303 304 ldp x5, x6, [sp, #176] 305 .cfi_restore x5 306 .cfi_restore x6 307 308 ldp x7, xSELF, [sp, #192] 309 .cfi_restore x7 310 .cfi_restore x18 311 312 ldp x19, x20, [sp, #208] 313 .cfi_restore x19 314 .cfi_restore x20 315 316 ldp x21, x22, [sp, #224] 317 .cfi_restore x21 318 .cfi_restore x22 319 320 ldp x23, x24, [sp, #240] 321 .cfi_restore x23 322 .cfi_restore x24 323 324 ldp x25, x26, [sp, #256] 325 .cfi_restore x25 326 .cfi_restore x26 327 328 ldp x27, x28, [sp, #272] 329 .cfi_restore x27 330 .cfi_restore x28 331 332 ldp xFP, xLR, [sp, #288] 333 .cfi_restore x29 334 .cfi_restore x30 335 336 add sp, sp, #304 337 .cfi_adjust_cfa_offset -304 338.endm 339 340.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME_NO_D0 341 342 ldr d1, [sp, #24] 343 ldp d2, d3, [sp, #32] 344 ldp d4, d5, [sp, #48] 345 ldp d6, d7, [sp, #64] 346 ldp d8, d9, [sp, #80] 347 ldp d10, d11, [sp, #96] 348 ldp d12, d13, [sp, #112] 349 ldp d14, d15, [sp, #128] 350 351 // args. 352 ldp x1, x2, [sp, #144] 353 .cfi_restore x1 354 .cfi_restore x2 355 356 ldp x3, x4, [sp, #160] 357 .cfi_restore x3 358 .cfi_restore x4 359 360 ldp x5, x6, [sp, #176] 361 .cfi_restore x5 362 .cfi_restore x6 363 364 ldp x7, xSELF, [sp, #192] 365 .cfi_restore x7 366 .cfi_restore x18 367 368 ldp x19, x20, [sp, #208] 369 .cfi_restore x19 370 .cfi_restore x20 371 372 ldp x21, x22, [sp, #224] 373 .cfi_restore x21 374 .cfi_restore x22 375 376 ldp x23, x24, [sp, #240] 377 .cfi_restore x23 378 .cfi_restore x24 379 380 ldp x25, x26, [sp, #256] 381 .cfi_restore x25 382 .cfi_restore x26 383 384 ldp x27, x28, [sp, #272] 385 .cfi_restore x27 386 .cfi_restore x28 387 388 ldp xFP, xLR, [sp, #288] 389 .cfi_restore x29 390 .cfi_restore x30 391 392 add sp, sp, #304 393 .cfi_adjust_cfa_offset -304 394.endm 395 396.macro RETURN_IF_RESULT_IS_ZERO 397 cbnz x0, 1f // result non-zero branch over 398 ret // return 3991: 400.endm 401 402.macro RETURN_IF_RESULT_IS_NON_ZERO 403 cbz x0, 1f // result zero branch over 404 ret // return 4051: 406.endm 407 408 /* 409 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending 410 * exception is Thread::Current()->exception_ 411 */ 412.macro DELIVER_PENDING_EXCEPTION 413 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME 414 mov x0, xSELF 415 mov x1, sp 416 417 // Point of no return. 418 b artDeliverPendingExceptionFromCode // artDeliverPendingExceptionFromCode(Thread*, SP) 419 brk 0 // Unreached 420.endm 421 422.macro RETURN_OR_DELIVER_PENDING_EXCEPTION 423 ldr x9, [xSELF, # THREAD_EXCEPTION_OFFSET] // Get exception field. 424 cbnz x9, 1f 425 ret 4261: 427 DELIVER_PENDING_EXCEPTION 428.endm 429 430// FIXME: Temporary fix for TR(XSELF). 431.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name 432 .extern \cxx_name 433ENTRY \c_name 434 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context 435 mov x0, x19 // pass Thread::Current 436 mov x1, sp // pass SP 437 b \cxx_name // \cxx_name(Thread*, SP) 438END \c_name 439.endm 440 441// FIXME: Temporary fix for TR(XSELF). 442.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name 443 .extern \cxx_name 444ENTRY \c_name 445 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context. 446 mov x1, x19 // pass Thread::Current. 447 mov x2, sp // pass SP. 448 b \cxx_name // \cxx_name(arg, Thread*, SP). 449 brk 0 450END \c_name 451.endm 452 453// FIXME: Temporary fix for TR(XSELF). 454.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name 455 .extern \cxx_name 456ENTRY \c_name 457 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context 458 mov x2, x19 // pass Thread::Current 459 mov x3, sp // pass SP 460 b \cxx_name // \cxx_name(arg1, arg2, Thread*, SP) 461 brk 0 462END \c_name 463.endm 464 465 /* 466 * Called by managed code, saves callee saves and then calls artThrowException 467 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. 468 */ 469ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode 470 471 /* 472 * Called by managed code to create and deliver a NullPointerException. 473 */ 474NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode 475 476 /* 477 * Called by managed code to create and deliver an ArithmeticException. 478 */ 479NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode 480 481 /* 482 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds 483 * index, arg2 holds limit. 484 */ 485TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode 486 487 /* 488 * Called by managed code to create and deliver a StackOverflowError. 489 */ 490NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode 491 492 /* 493 * Called by managed code to create and deliver a NoSuchMethodError. 494 */ 495ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode 496 497 /* 498 * TODO arm64 specifics need to be fleshed out. 499 * All generated callsites for interface invokes and invocation slow paths will load arguments 500 * as usual - except instead of loading x0 with the target Method*, x0 will contain 501 * the method_idx. This wrapper will save x1-x3, load the caller's Method*, align the 502 * stack and call the appropriate C helper. 503 * NOTE: "this" is first visible argument of the target, and so can be found in x1. 504 * 505 * The helper will attempt to locate the target and return a result in x0 consisting 506 * of the target Method* in x0 and method->code_ in x1. 507 * 508 * If unsuccessful, the helper will return NULL/NULL. There will be a pending exception in the 509 * thread and we branch to another stub to deliver it. 510 * 511 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr 512 * pointing back to the original caller. 513 */ 514.macro INVOKE_TRAMPOLINE c_name, cxx_name 515 .extern \cxx_name 516ENTRY \c_name 517 brk 0 518END \c_name 519.endm 520 521INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline 522INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck 523 524INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck 525INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck 526INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck 527INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck 528 529 530.macro INVOKE_STUB_CREATE_FRAME 531 532SAVE_SIZE=5*8 // x4, x5, SP, LR & FP saved. 533SAVE_SIZE_AND_METHOD=SAVE_SIZE+8 534 535 mov x9, sp // Save stack pointer. 536 .cfi_register sp,x9 537 538 add x10, x2, # SAVE_SIZE_AND_METHOD // calculate size of frame. 539 sub x10, sp, x10 // Calculate SP position - saves + ArtMethod* + args 540 and x10, x10, # ~0xf // Enforce 16 byte stack alignment. 541 mov sp, x10 // Set new SP. 542 543 sub x10, x9, #SAVE_SIZE // Calculate new FP (later). Done here as we must move SP 544 .cfi_def_cfa_register x10 // before this. 545 .cfi_adjust_cfa_offset SAVE_SIZE 546 547 str x9, [x10, #32] // Save old stack pointer. 548 .cfi_rel_offset sp, 32 549 550 stp x4, x5, [x10, #16] // Save result and shorty addresses. 551 .cfi_rel_offset x4, 16 552 .cfi_rel_offset x5, 24 553 554 stp xFP, xLR, [x10] // Store LR & FP. 555 .cfi_rel_offset x29, 0 556 .cfi_rel_offset x30, 8 557 558 mov xFP, x10 // Use xFP now, as it's callee-saved. 559 .cfi_def_cfa_register x29 560 mov xSELF, x3 // Move thread pointer into SELF register. 561 562 // Copy arguments into stack frame. 563 // Use simple copy routine for now. 564 // 4 bytes per slot. 565 // X1 - source address 566 // W2 - args length 567 // X9 - destination address. 568 // W10 - temporary 569 add x9, sp, #8 // Destination address is bottom of stack + NULL. 570 571 // Use \@ to differentiate between macro invocations. 572.LcopyParams\@: 573 cmp w2, #0 574 beq .LendCopyParams\@ 575 sub w2, w2, #4 // Need 65536 bytes of range. 576 ldr w10, [x1, x2] 577 str w10, [x9, x2] 578 579 b .LcopyParams\@ 580 581.LendCopyParams\@: 582 583 // Store NULL into Method* at bottom of frame. 584 str xzr, [sp] 585 586.endm 587 588.macro INVOKE_STUB_CALL_AND_RETURN 589 590 // load method-> METHOD_QUICK_CODE_OFFSET 591 ldr x9, [x0 , #METHOD_QUICK_CODE_OFFSET] 592 // Branch to method. 593 blr x9 594 595 // Restore return value address and shorty address. 596 ldp x4,x5, [xFP, #16] 597 .cfi_restore x4 598 .cfi_restore x5 599 600 // Store result (w0/x0/s0/d0) appropriately, depending on resultType. 601 ldrb w10, [x5] 602 603 // Don't set anything for a void type. 604 cmp w10, #'V' 605 beq .Lexit_art_quick_invoke_stub\@ 606 607 cmp w10, #'D' 608 bne .Lreturn_is_float\@ 609 str d0, [x4] 610 b .Lexit_art_quick_invoke_stub\@ 611 612.Lreturn_is_float\@: 613 cmp w10, #'F' 614 bne .Lreturn_is_int\@ 615 str s0, [x4] 616 b .Lexit_art_quick_invoke_stub\@ 617 618 // Just store x0. Doesn't matter if it is 64 or 32 bits. 619.Lreturn_is_int\@: 620 str x0, [x4] 621 622.Lexit_art_quick_invoke_stub\@: 623 ldr x2, [x29, #32] // Restore stack pointer. 624 mov sp, x2 625 .cfi_restore sp 626 627 ldp x29, x30, [x29] // Restore old frame pointer and link register. 628 .cfi_restore x29 629 .cfi_restore x30 630 631 ret 632 633.endm 634 635 636/* 637 * extern"C" void art_quick_invoke_stub(ArtMethod *method, x0 638 * uint32_t *args, x1 639 * uint32_t argsize, w2 640 * Thread *self, x3 641 * JValue *result, x4 642 * char *shorty); x5 643 * +----------------------+ 644 * | | 645 * | C/C++ frame | 646 * | LR'' | 647 * | FP'' | <- SP' 648 * +----------------------+ 649 * +----------------------+ 650 * | SP' | 651 * | X5 | 652 * | X4 | Saved registers 653 * | LR' | 654 * | FP' | <- FP 655 * +----------------------+ 656 * | uint32_t out[n-1] | 657 * | : : | Outs 658 * | uint32_t out[0] | 659 * | ArtMethod* NULL | <- SP 660 * +----------------------+ 661 * 662 * Outgoing registers: 663 * x0 - Method* 664 * x1-x7 - integer parameters. 665 * d0-d7 - Floating point parameters. 666 * xSELF = self 667 * SP = & of ArtMethod* 668 * x1 = "this" pointer. 669 * 670 */ 671ENTRY art_quick_invoke_stub 672 // Spill registers as per AACPS64 calling convention. 673 INVOKE_STUB_CREATE_FRAME 674 675 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. 676 // Parse the passed shorty to determine which register to load. 677 // Load addresses for routines that load WXSD registers. 678 adr x11, .LstoreW2 679 adr x12, .LstoreX2 680 adr x13, .LstoreS0 681 adr x14, .LstoreD0 682 683 // Initialize routine offsets to 0 for integers and floats. 684 // x8 for integers, x15 for floating point. 685 mov x8, #0 686 mov x15, #0 687 688 add x10, x5, #1 // Load shorty address, plus one to skip return value. 689 ldr w1, [x9],#4 // Load "this" parameter, and increment arg pointer. 690 691 // Loop to fill registers. 692.LfillRegisters: 693 ldrb w17, [x10], #1 // Load next character in signature, and increment. 694 cbz w17, .LcallFunction // Exit at end of signature. Shorty 0 terminated. 695 696 cmp w17, #'F' // is this a float? 697 bne .LisDouble 698 699 cmp x15, # 8*12 // Skip this load if all registers full. 700 beq .Ladvance4 701 702 add x17, x13, x15 // Calculate subroutine to jump to. 703 br x17 704 705.LisDouble: 706 cmp w17, #'D' // is this a double? 707 bne .LisLong 708 709 cmp x15, # 8*12 // Skip this load if all registers full. 710 beq .Ladvance8 711 712 add x17, x14, x15 // Calculate subroutine to jump to. 713 br x17 714 715.LisLong: 716 cmp w17, #'J' // is this a long? 717 bne .LisOther 718 719 cmp x8, # 6*12 // Skip this load if all registers full. 720 beq .Ladvance8 721 722 add x17, x12, x8 // Calculate subroutine to jump to. 723 br x17 724 725.LisOther: // Everything else takes one vReg. 726 cmp x8, # 6*12 // Skip this load if all registers full. 727 beq .Ladvance4 728 729 add x17, x11, x8 // Calculate subroutine to jump to. 730 br x17 731 732.Ladvance4: 733 add x9, x9, #4 734 b .LfillRegisters 735 736.Ladvance8: 737 add x9, x9, #8 738 b .LfillRegisters 739 740// Macro for loading a parameter into a register. 741// counter - the register with offset into these tables 742// size - the size of the register - 4 or 8 bytes. 743// register - the name of the register to be loaded. 744.macro LOADREG counter size register return 745 ldr \register , [x9], #\size 746 add \counter, \counter, 12 747 b \return 748.endm 749 750// Store ints. 751.LstoreW2: 752 LOADREG x8 4 w2 .LfillRegisters 753 LOADREG x8 4 w3 .LfillRegisters 754 LOADREG x8 4 w4 .LfillRegisters 755 LOADREG x8 4 w5 .LfillRegisters 756 LOADREG x8 4 w6 .LfillRegisters 757 LOADREG x8 4 w7 .LfillRegisters 758 759// Store longs. 760.LstoreX2: 761 LOADREG x8 8 x2 .LfillRegisters 762 LOADREG x8 8 x3 .LfillRegisters 763 LOADREG x8 8 x4 .LfillRegisters 764 LOADREG x8 8 x5 .LfillRegisters 765 LOADREG x8 8 x6 .LfillRegisters 766 LOADREG x8 8 x7 .LfillRegisters 767 768// Store singles. 769.LstoreS0: 770 LOADREG x15 4 s0 .LfillRegisters 771 LOADREG x15 4 s1 .LfillRegisters 772 LOADREG x15 4 s2 .LfillRegisters 773 LOADREG x15 4 s3 .LfillRegisters 774 LOADREG x15 4 s4 .LfillRegisters 775 LOADREG x15 4 s5 .LfillRegisters 776 LOADREG x15 4 s6 .LfillRegisters 777 LOADREG x15 4 s7 .LfillRegisters 778 779// Store doubles. 780.LstoreD0: 781 LOADREG x15 8 d0 .LfillRegisters 782 LOADREG x15 8 d1 .LfillRegisters 783 LOADREG x15 8 d2 .LfillRegisters 784 LOADREG x15 8 d3 .LfillRegisters 785 LOADREG x15 8 d4 .LfillRegisters 786 LOADREG x15 8 d5 .LfillRegisters 787 LOADREG x15 8 d6 .LfillRegisters 788 LOADREG x15 8 d7 .LfillRegisters 789 790 791.LcallFunction: 792 793 INVOKE_STUB_CALL_AND_RETURN 794 795END art_quick_invoke_stub 796 797/* extern"C" 798 * void art_quick_invoke_static_stub(ArtMethod *method, x0 799 * uint32_t *args, x1 800 * uint32_t argsize, w2 801 * Thread *self, x3 802 * JValue *result, x4 803 * char *shorty); x5 804 */ 805ENTRY art_quick_invoke_static_stub 806 // Spill registers as per AACPS64 calling convention. 807 INVOKE_STUB_CREATE_FRAME 808 809 // Fill registers x/w1 to x/w7 and s/d0 to s/d7 with parameters. 810 // Parse the passed shorty to determine which register to load. 811 // Load addresses for routines that load WXSD registers. 812 adr x11, .LstoreW1_2 813 adr x12, .LstoreX1_2 814 adr x13, .LstoreS0_2 815 adr x14, .LstoreD0_2 816 817 // Initialize routine offsets to 0 for integers and floats. 818 // x8 for integers, x15 for floating point. 819 mov x8, #0 820 mov x15, #0 821 822 add x10, x5, #1 // Load shorty address, plus one to skip return value. 823 824 // Loop to fill registers. 825.LfillRegisters2: 826 ldrb w17, [x10], #1 // Load next character in signature, and increment. 827 cbz w17, .LcallFunction2 // Exit at end of signature. Shorty 0 terminated. 828 829 cmp w17, #'F' // is this a float? 830 bne .LisDouble2 831 832 cmp x15, # 8*12 // Skip this load if all registers full. 833 beq .Ladvance4_2 834 835 add x17, x13, x15 // Calculate subroutine to jump to. 836 br x17 837 838.LisDouble2: 839 cmp w17, #'D' // is this a double? 840 bne .LisLong2 841 842 cmp x15, # 8*12 // Skip this load if all registers full. 843 beq .Ladvance8_2 844 845 add x17, x14, x15 // Calculate subroutine to jump to. 846 br x17 847 848.LisLong2: 849 cmp w17, #'J' // is this a long? 850 bne .LisOther2 851 852 cmp x8, # 7*12 // Skip this load if all registers full. 853 beq .Ladvance8_2 854 855 add x17, x12, x8 // Calculate subroutine to jump to. 856 br x17 857 858.LisOther2: // Everything else takes one vReg. 859 cmp x8, # 7*12 // Skip this load if all registers full. 860 beq .Ladvance4_2 861 862 add x17, x11, x8 // Calculate subroutine to jump to. 863 br x17 864 865.Ladvance4_2: 866 add x9, x9, #4 867 b .LfillRegisters2 868 869.Ladvance8_2: 870 add x9, x9, #8 871 b .LfillRegisters2 872 873// Store ints. 874.LstoreW1_2: 875 LOADREG x8 4 w1 .LfillRegisters2 876 LOADREG x8 4 w2 .LfillRegisters2 877 LOADREG x8 4 w3 .LfillRegisters2 878 LOADREG x8 4 w4 .LfillRegisters2 879 LOADREG x8 4 w5 .LfillRegisters2 880 LOADREG x8 4 w6 .LfillRegisters2 881 LOADREG x8 4 w7 .LfillRegisters2 882 883// Store longs. 884.LstoreX1_2: 885 LOADREG x8 8 x1 .LfillRegisters2 886 LOADREG x8 8 x2 .LfillRegisters2 887 LOADREG x8 8 x3 .LfillRegisters2 888 LOADREG x8 8 x4 .LfillRegisters2 889 LOADREG x8 8 x5 .LfillRegisters2 890 LOADREG x8 8 x6 .LfillRegisters2 891 LOADREG x8 8 x7 .LfillRegisters2 892 893// Store singles. 894.LstoreS0_2: 895 LOADREG x15 4 s0 .LfillRegisters2 896 LOADREG x15 4 s1 .LfillRegisters2 897 LOADREG x15 4 s2 .LfillRegisters2 898 LOADREG x15 4 s3 .LfillRegisters2 899 LOADREG x15 4 s4 .LfillRegisters2 900 LOADREG x15 4 s5 .LfillRegisters2 901 LOADREG x15 4 s6 .LfillRegisters2 902 LOADREG x15 4 s7 .LfillRegisters2 903 904// Store doubles. 905.LstoreD0_2: 906 LOADREG x15 8 d0 .LfillRegisters2 907 LOADREG x15 8 d1 .LfillRegisters2 908 LOADREG x15 8 d2 .LfillRegisters2 909 LOADREG x15 8 d3 .LfillRegisters2 910 LOADREG x15 8 d4 .LfillRegisters2 911 LOADREG x15 8 d5 .LfillRegisters2 912 LOADREG x15 8 d6 .LfillRegisters2 913 LOADREG x15 8 d7 .LfillRegisters2 914 915 916.LcallFunction2: 917 918 INVOKE_STUB_CALL_AND_RETURN 919 920END art_quick_invoke_static_stub 921 922 923 924 /* 925 * On entry x0 is uintptr_t* gprs_ and x1 is uint64_t* fprs_ 926 */ 927 928ENTRY art_quick_do_long_jump 929 // Load FPRs 930 ldp d0, d1, [x1], #16 931 ldp d2, d3, [x1], #16 932 ldp d4, d5, [x1], #16 933 ldp d6, d7, [x1], #16 934 ldp d8, d9, [x1], #16 935 ldp d10, d11, [x1], #16 936 ldp d12, d13, [x1], #16 937 ldp d14, d15, [x1], #16 938 ldp d16, d17, [x1], #16 939 ldp d18, d19, [x1], #16 940 ldp d20, d21, [x1], #16 941 ldp d22, d23, [x1], #16 942 ldp d24, d25, [x1], #16 943 ldp d26, d27, [x1], #16 944 ldp d28, d29, [x1], #16 945 ldp d30, d31, [x1] 946 947 // Load GPRs 948 // TODO: lots of those are smashed, could optimize. 949 add x0, x0, #30*8 950 ldp x30, x1, [x0], #-16 951 ldp x28, x29, [x0], #-16 952 ldp x26, x27, [x0], #-16 953 ldp x24, x25, [x0], #-16 954 ldp x22, x23, [x0], #-16 955 ldp x20, x21, [x0], #-16 956 ldp x18, x19, [x0], #-16 957 ldp x16, x17, [x0], #-16 958 ldp x14, x15, [x0], #-16 959 ldp x12, x13, [x0], #-16 960 ldp x10, x11, [x0], #-16 961 ldp x8, x9, [x0], #-16 962 ldp x6, x7, [x0], #-16 963 ldp x4, x5, [x0], #-16 964 ldp x2, x3, [x0], #-16 965 mov sp, x1 966 967 // TODO: Is it really OK to use LR for the target PC? 968 mov x0, #0 969 mov x1, #0 970 br xLR 971END art_quick_do_long_jump 972 973UNIMPLEMENTED art_quick_handle_fill_data 974 975UNIMPLEMENTED art_quick_lock_object 976UNIMPLEMENTED art_quick_unlock_object 977 978 /* 979 * Entry from managed code that calls artIsAssignableFromCode and on failure calls 980 * artThrowClassCastException. 981 */ 982 .extern artThrowClassCastException 983ENTRY art_quick_check_cast 984 // Store arguments and link register 985 sub sp, sp, #32 // Stack needs to be 16b aligned on calls 986 .cfi_adjust_cfa_offset 32 987 stp x0, x1, [sp] 988 .cfi_rel_offset x0, 0 989 .cfi_rel_offset x1, 8 990 stp xSELF, xLR, [sp, #16] 991 .cfi_rel_offset x18, 16 992 .cfi_rel_offset x30, 24 993 994 // Call runtime code 995 bl artIsAssignableFromCode 996 997 // Check for exception 998 cbz x0, .Lthrow_class_cast_exception 999 1000 // Restore and return 1001 ldp x0, x1, [sp] 1002 .cfi_restore x0 1003 .cfi_restore x1 1004 ldp xSELF, xLR, [sp, #16] 1005 .cfi_restore x18 1006 .cfi_restore x30 1007 add sp, sp, #32 1008 .cfi_adjust_cfa_offset -32 1009 ret 1010 1011.Lthrow_class_cast_exception: 1012 // Restore 1013 ldp x0, x1, [sp] 1014 .cfi_restore x0 1015 .cfi_restore x1 1016 ldp xSELF, xLR, [sp, #16] 1017 .cfi_restore x18 1018 .cfi_restore x30 1019 add sp, sp, #32 1020 .cfi_adjust_cfa_offset -32 1021 1022 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context 1023 mov x2, xSELF // pass Thread::Current 1024 mov x3, sp // pass SP 1025 b artThrowClassCastException // (Class*, Class*, Thread*, SP) 1026 brk 0 // We should not return here... 1027END art_quick_check_cast 1028 1029UNIMPLEMENTED art_quick_aput_obj_with_null_and_bound_check 1030UNIMPLEMENTED art_quick_aput_obj_with_bound_check 1031UNIMPLEMENTED art_quick_aput_obj 1032UNIMPLEMENTED art_quick_initialize_static_storage 1033UNIMPLEMENTED art_quick_initialize_type 1034UNIMPLEMENTED art_quick_initialize_type_and_verify_access 1035UNIMPLEMENTED art_quick_get32_static 1036UNIMPLEMENTED art_quick_get64_static 1037UNIMPLEMENTED art_quick_get_obj_static 1038UNIMPLEMENTED art_quick_get32_instance 1039UNIMPLEMENTED art_quick_get64_instance 1040UNIMPLEMENTED art_quick_get_obj_instance 1041UNIMPLEMENTED art_quick_set32_static 1042UNIMPLEMENTED art_quick_set64_static 1043UNIMPLEMENTED art_quick_set_obj_static 1044UNIMPLEMENTED art_quick_set32_instance 1045UNIMPLEMENTED art_quick_set64_instance 1046UNIMPLEMENTED art_quick_set_obj_instance 1047UNIMPLEMENTED art_quick_resolve_string 1048 1049// Macro to facilitate adding new allocation entrypoints. 1050// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY 1051.macro TWO_ARG_DOWNCALL name, entrypoint, return 1052 .extern \entrypoint 1053ENTRY \name 1054 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC 1055 mov x2, xSELF // pass Thread::Current 1056 mov x3, sp // pass SP 1057 bl \entrypoint // (uint32_t type_idx, Method* method, Thread*, SP) 1058 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME 1059 \return 1060 DELIVER_PENDING_EXCEPTION 1061END \name 1062.endm 1063 1064// Macro to facilitate adding new array allocation entrypoints. 1065// TODO: xSELF -> x19. Temporarily rely on xSELF being saved in REF_ONLY 1066.macro THREE_ARG_DOWNCALL name, entrypoint, return 1067 .extern \entrypoint 1068ENTRY \name 1069 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save callee saves in case of GC 1070 mov x3, xSELF // pass Thread::Current 1071 mov x4, sp // pass SP 1072 bl \entrypoint 1073 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME 1074 \return 1075 DELIVER_PENDING_EXCEPTION 1076END \name 1077.endm 1078 1079// Generate the allocation entrypoints for each allocator. 1080GENERATE_ALL_ALLOC_ENTRYPOINTS 1081 1082UNIMPLEMENTED art_quick_test_suspend 1083 1084 /* 1085 * Called by managed code that is attempting to call a method on a proxy class. On entry 1086 * x0 holds the proxy method and x1 holds the receiver; The frame size of the invoked proxy 1087 * method agrees with a ref and args callee save frame. 1088 */ 1089 .extern artQuickProxyInvokeHandler 1090ENTRY art_quick_proxy_invoke_handler 1091 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME 1092 str x0, [sp, #0] // place proxy method at bottom of frame 1093 mov x2, xSELF // pass Thread::Current 1094 mov x3, sp // pass SP 1095 bl artQuickProxyInvokeHandler // (Method* proxy method, receiver, Thread*, SP) 1096 ldr xSELF, [sp, #200] // Restore self pointer. 1097 ldr x2, [xSELF, THREAD_EXCEPTION_OFFSET] 1098 cbnz x2, .Lexception_in_proxy // success if no exception is pending 1099 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME_NO_D0 // keep d0 1100 ret // return on success 1101.Lexception_in_proxy: 1102 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 1103 DELIVER_PENDING_EXCEPTION 1104END art_quick_proxy_invoke_handler 1105 1106UNIMPLEMENTED art_quick_imt_conflict_trampoline 1107 1108 1109ENTRY art_quick_resolution_trampoline 1110 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME 1111 mov x19, x0 // save the called method 1112 mov x2, xSELF 1113 mov x3, sp 1114 bl artQuickResolutionTrampoline // (called, receiver, Thread*, SP) 1115 mov x9, x0 // Remember returned code pointer in x9. 1116 mov x0, x19 // Restore the method, before x19 is restored to on-call value 1117 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 1118 cbz x9, 1f 1119 br x9 11201: 1121 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 1122 DELIVER_PENDING_EXCEPTION 1123END art_quick_resolution_trampoline 1124 1125/* 1126 * Generic JNI frame layout: 1127 * 1128 * #-------------------# 1129 * | | 1130 * | caller method... | 1131 * #-------------------# <--- SP on entry 1132 * | Return X30/LR | 1133 * | X29/FP | callee save 1134 * | X28 | callee save 1135 * | X27 | callee save 1136 * | X26 | callee save 1137 * | X25 | callee save 1138 * | X24 | callee save 1139 * | X23 | callee save 1140 * | X22 | callee save 1141 * | X21 | callee save 1142 * | X20 | callee save 1143 * | X19 | callee save 1144 * | X7 | arg7 1145 * | X6 | arg6 1146 * | X5 | arg5 1147 * | X4 | arg4 1148 * | X3 | arg3 1149 * | X2 | arg2 1150 * | X1 | arg1 1151 * | D15 | float arg 8 1152 * | D14 | float arg 8 1153 * | D13 | float arg 8 1154 * | D12 | callee save 1155 * | D11 | callee save 1156 * | D10 | callee save 1157 * | D9 | callee save 1158 * | D8 | callee save 1159 * | D7 | float arg 8 1160 * | D6 | float arg 7 1161 * | D5 | float arg 6 1162 * | D4 | float arg 5 1163 * | D3 | float arg 4 1164 * | D2 | float arg 3 1165 * | D1 | float arg 2 1166 * | D0 | float arg 1 1167 * | RDI/Method* | <- X0 1168 * #-------------------# 1169 * | local ref cookie | // 4B 1170 * | SIRT size | // 4B 1171 * #-------------------# 1172 * | JNI Call Stack | 1173 * #-------------------# <--- SP on native call 1174 * | | 1175 * | Stack for Regs | The trampoline assembly will pop these values 1176 * | | into registers for native call 1177 * #-------------------# 1178 * | Native code ptr | 1179 * #-------------------# 1180 * | Free scratch | 1181 * #-------------------# 1182 * | Ptr to (1) | <--- SP 1183 * #-------------------# 1184 */ 1185 /* 1186 * Called to do a generic JNI down-call 1187 */ 1188ENTRY art_quick_generic_jni_trampoline 1189 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME_INTERNAL 1190 str x0, [sp, #0] // Store native ArtMethod* to bottom of stack. 1191 1192 // Save SP , so we can have static CFI info. 1193 mov x28, sp 1194 .cfi_def_cfa_register x28 1195 1196 // This looks the same, but is different: this will be updated to point to the bottom 1197 // of the frame when the SIRT is inserted. 1198 mov xFP, sp 1199 1200 mov x8, #5120 1201 sub sp, sp, x8 1202 1203 // prepare for artQuickGenericJniTrampoline call 1204 // (Thread*, SP) 1205 // x0 x1 <= C calling convention 1206 // xSELF xFP <= where they are 1207 1208 mov x0, xSELF // Thread* 1209 mov x1, xFP 1210 bl artQuickGenericJniTrampoline // (Thread*, sp) 1211 1212 // Get the updated pointer. This is the bottom of the frame _with_ SIRT. 1213 ldr xFP, [sp] 1214 add x9, sp, #8 1215 1216 cmp x0, #0 1217 b.mi .Lentry_error // Check for error, negative value. 1218 1219 // release part of the alloca. 1220 add x9, x9, x0 1221 1222 // Get the code pointer 1223 ldr xIP0, [x9, #0] 1224 1225 // Load parameters from frame into registers. 1226 // TODO Check with artQuickGenericJniTrampoline. 1227 // Also, check again APPCS64 - the stack arguments are interleaved. 1228 ldp x0, x1, [x9, #8] 1229 ldp x2, x3, [x9, #24] 1230 ldp x4, x5, [x9, #40] 1231 ldp x6, x7, [x9, #56] 1232 1233 ldp d0, d1, [x9, #72] 1234 ldp d2, d3, [x9, #88] 1235 ldp d4, d5, [x9, #104] 1236 ldp d6, d7, [x9, #120] 1237 1238 add sp, x9, #136 1239 1240 blr xIP0 // native call. 1241 1242 // Restore self pointer. 1243 ldr xSELF, [x28, #200] 1244 1245 // result sign extension is handled in C code 1246 // prepare for artQuickGenericJniEndTrampoline call 1247 // (Thread*, SP, result, result_f) 1248 // x0 x1 x2 x3 <= C calling convention 1249 mov x5, x0 // Save return value 1250 mov x0, xSELF // Thread register 1251 mov x1, xFP // Stack pointer 1252 mov x2, x5 // Result (from saved) 1253 fmov x3, d0 // d0 will contain floating point result, but needs to go into x3 1254 1255 bl artQuickGenericJniEndTrampoline 1256 1257 // Tear down the alloca. 1258 mov sp, x28 1259 .cfi_def_cfa_register sp 1260 1261 // Restore self pointer. 1262 ldr xSELF, [x28, #200] 1263 1264 // Pending exceptions possible. 1265 ldr x1, [xSELF, THREAD_EXCEPTION_OFFSET] 1266 cbnz x1, .Lexception_in_native 1267 1268 // Tear down the callee-save frame. 1269 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 1270 1271 // store into fpr, for when it's a fpr return... 1272 fmov d0, x0 1273 ret 1274 1275.Lentry_error: 1276 mov sp, x28 1277 .cfi_def_cfa_register sp 1278 ldr xSELF, [x28, #200] 1279.Lexception_in_native: 1280 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME 1281 DELIVER_PENDING_EXCEPTION 1282 1283END art_quick_generic_jni_trampoline 1284 1285/* 1286 * Called to bridge from the quick to interpreter ABI. On entry the arguments match those 1287 * of a quick call: 1288 * x0 = method being called/to bridge to. 1289 * x1..x7, d0..d7 = arguments to that method. 1290 */ 1291ENTRY art_quick_to_interpreter_bridge 1292 SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // Set up frame and save arguments. 1293 1294 // x0 will contain mirror::ArtMethod* method. 1295 mov x1, xSELF // How to get Thread::Current() ??? 1296 mov x2, sp 1297 1298 // uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, 1299 // mirror::ArtMethod** sp) 1300 bl artQuickToInterpreterBridge 1301 1302 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME // TODO: no need to restore arguments in this case. 1303 1304 fmov d0, x0 1305 1306 RETURN_OR_DELIVER_PENDING_EXCEPTION 1307END art_quick_to_interpreter_bridge 1308 1309UNIMPLEMENTED art_quick_instrumentation_entry 1310UNIMPLEMENTED art_quick_instrumentation_exit 1311UNIMPLEMENTED art_quick_deoptimize 1312UNIMPLEMENTED art_quick_mul_long 1313UNIMPLEMENTED art_quick_shl_long 1314UNIMPLEMENTED art_quick_shr_long 1315UNIMPLEMENTED art_quick_ushr_long 1316UNIMPLEMENTED art_quick_indexof 1317UNIMPLEMENTED art_quick_string_compareto 1318