quick_entrypoints_x86.S revision 24f2dfae084b2382c053f5d688fd6bb26cb8a328
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "asm_support_x86.S" 18 19// For x86, the CFA is esp+4, the address above the pushed return address on the stack. 20 21 /* 22 * Macro that sets up the callee save frame to conform with 23 * Runtime::CreateCalleeSaveMethod(kSaveAll) 24 */ 25MACRO2(SETUP_SAVE_ALL_CALLEE_SAVE_FRAME, got_reg, temp_reg) 26 PUSH edi // Save callee saves (ebx is saved/restored by the upcall) 27 PUSH esi 28 PUSH ebp 29 subl MACRO_LITERAL(12), %esp // Grow stack by 3 words. 30 CFI_ADJUST_CFA_OFFSET(12) 31 SETUP_GOT_NOSAVE RAW_VAR(got_reg, 0) 32 // Load Runtime::instance_ from GOT. 33 movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1) 34 movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1) 35 // Push save all callee-save method. 36 pushl RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1)) 37 CFI_ADJUST_CFA_OFFSET(4) 38 // Store esp as the top quick frame. 39 movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET 40 // Ugly compile-time check, but we only have the preprocessor. 41 // Last +4: implicit return address pushed on stack when caller made call. 42#if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVE != 3*4 + 16 + 4) 43#error "SAVE_ALL_CALLEE_SAVE_FRAME(X86) size not as expected." 44#endif 45END_MACRO 46 47 /* 48 * Macro that sets up the callee save frame to conform with 49 * Runtime::CreateCalleeSaveMethod(kRefsOnly) 50 */ 51MACRO2(SETUP_REFS_ONLY_CALLEE_SAVE_FRAME, got_reg, temp_reg) 52 PUSH edi // Save callee saves (ebx is saved/restored by the upcall) 53 PUSH esi 54 PUSH ebp 55 subl MACRO_LITERAL(12), %esp // Grow stack by 3 words. 56 CFI_ADJUST_CFA_OFFSET(12) 57 SETUP_GOT_NOSAVE VAR(got_reg, 0) 58 // Load Runtime::instance_ from GOT. 59 movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1) 60 movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1) 61 // Push save all callee-save method. 62 pushl RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1)) 63 CFI_ADJUST_CFA_OFFSET(4) 64 // Store esp as the top quick frame. 65 movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET 66 67 // Ugly compile-time check, but we only have the preprocessor. 68 // Last +4: implicit return address pushed on stack when caller made call. 69#if (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE != 3*4 + 16 + 4) 70#error "REFS_ONLY_CALLEE_SAVE_FRAME(X86) size not as expected." 71#endif 72END_MACRO 73 74MACRO0(RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME) 75 addl MACRO_LITERAL(16), %esp // Unwind stack up to saved values 76 CFI_ADJUST_CFA_OFFSET(-16) 77 POP ebp // Restore callee saves (ebx is saved/restored by the upcall) 78 POP esi 79 POP edi 80END_MACRO 81 82 /* 83 * Macro that sets up the callee save frame to conform with 84 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs) 85 */ 86MACRO2(SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME, got_reg, temp_reg) 87 PUSH edi // Save callee saves 88 PUSH esi 89 PUSH ebp 90 PUSH ebx // Save args 91 PUSH edx 92 PUSH ecx 93 SETUP_GOT_NOSAVE VAR(got_reg, 0) 94 // Load Runtime::instance_ from GOT. 95 movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1) 96 movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1) 97 // Push save all callee-save method. 98 pushl RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1)) 99 CFI_ADJUST_CFA_OFFSET(4) 100 // Store esp as the stop quick frame. 101 movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET 102 103 // Ugly compile-time check, but we only have the preprocessor. 104 // Last +4: implicit return address pushed on stack when caller made call. 105#if (FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE != 7*4 + 4) 106#error "REFS_AND_ARGS_CALLEE_SAVE_FRAME(X86) size not as expected." 107#endif 108END_MACRO 109 110 /* 111 * Macro that sets up the callee save frame to conform with 112 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs) where the method is passed in EAX. 113 */ 114MACRO0(SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_EAX) 115 PUSH edi // Save callee saves 116 PUSH esi 117 PUSH ebp 118 PUSH ebx // Save args 119 PUSH edx 120 PUSH ecx 121 PUSH eax // Store the ArtMethod reference at the bottom of the stack. 122 // Store esp as the stop quick frame. 123 movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET 124END_MACRO 125 126MACRO0(RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME) 127 addl MACRO_LITERAL(4), %esp // Remove padding 128 CFI_ADJUST_CFA_OFFSET(-4) 129 POP ecx // Restore args except eax 130 POP edx 131 POP ebx 132 POP ebp // Restore callee saves 133 POP esi 134 POP edi 135END_MACRO 136 137 /* 138 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending 139 * exception is Thread::Current()->exception_. 140 */ 141MACRO0(DELIVER_PENDING_EXCEPTION) 142 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save callee saves for throw 143 // Outgoing argument set up 144 subl MACRO_LITERAL(12), %esp // Alignment padding 145 CFI_ADJUST_CFA_OFFSET(12) 146 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 147 CFI_ADJUST_CFA_OFFSET(4) 148 call SYMBOL(artDeliverPendingExceptionFromCode) // artDeliverPendingExceptionFromCode(Thread*) 149 int3 // unreached 150END_MACRO 151 152MACRO2(NO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) 153 DEFINE_FUNCTION RAW_VAR(c_name, 0) 154 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save all registers as basis for long jump context 155 // Outgoing argument set up 156 subl MACRO_LITERAL(12), %esp // alignment padding 157 CFI_ADJUST_CFA_OFFSET(12) 158 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 159 CFI_ADJUST_CFA_OFFSET(4) 160 call VAR(cxx_name, 1) // cxx_name(Thread*) 161 int3 // unreached 162 END_FUNCTION RAW_VAR(c_name, 0) 163END_MACRO 164 165MACRO2(ONE_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) 166 DEFINE_FUNCTION RAW_VAR(c_name, 0) 167 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save all registers as basis for long jump context 168 mov %esp, %ecx 169 // Outgoing argument set up 170 subl MACRO_LITERAL(8), %esp // alignment padding 171 CFI_ADJUST_CFA_OFFSET(8) 172 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 173 CFI_ADJUST_CFA_OFFSET(4) 174 PUSH eax // pass arg1 175 call VAR(cxx_name, 1) // cxx_name(arg1, Thread*) 176 int3 // unreached 177 END_FUNCTION RAW_VAR(c_name, 0) 178END_MACRO 179 180MACRO2(TWO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) 181 DEFINE_FUNCTION RAW_VAR(c_name, 0) 182 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save all registers as basis for long jump context 183 // Outgoing argument set up 184 PUSH eax // alignment padding 185 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 186 CFI_ADJUST_CFA_OFFSET(4) 187 PUSH ecx // pass arg2 188 PUSH eax // pass arg1 189 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*) 190 int3 // unreached 191 END_FUNCTION RAW_VAR(c_name, 0) 192END_MACRO 193 194 /* 195 * Called by managed code to create and deliver a NullPointerException. 196 */ 197NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode 198 199 /* 200 * Called by managed code to create and deliver an ArithmeticException. 201 */ 202NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode 203 204 /* 205 * Called by managed code to create and deliver a StackOverflowError. 206 */ 207NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode 208 209 /* 210 * Called by managed code, saves callee saves and then calls artThrowException 211 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. 212 */ 213ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode 214 215 /* 216 * Called by managed code to create and deliver a NoSuchMethodError. 217 */ 218ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode 219 220 /* 221 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds 222 * index, arg2 holds limit. 223 */ 224TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode 225 226 /* 227 * All generated callsites for interface invokes and invocation slow paths will load arguments 228 * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain 229 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the 230 * stack and call the appropriate C helper. 231 * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. 232 * 233 * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting 234 * of the target Method* in r0 and method->code_ in r1. 235 * 236 * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the 237 * thread and we branch to another stub to deliver it. 238 * 239 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr 240 * pointing back to the original caller. 241 */ 242MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) 243 DEFINE_FUNCTION RAW_VAR(c_name, 0) 244 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME ebx, ebx 245 movl %esp, %edx // remember SP 246 // Outgoing argument set up 247 subl MACRO_LITERAL(12), %esp // alignment padding 248 CFI_ADJUST_CFA_OFFSET(12) 249 PUSH edx // pass SP 250 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 251 CFI_ADJUST_CFA_OFFSET(4) 252 pushl 32(%edx) // pass caller Method* 253 CFI_ADJUST_CFA_OFFSET(4) 254 PUSH ecx // pass arg2 255 PUSH eax // pass arg1 256 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) 257 movl %edx, %edi // save code pointer in EDI 258 addl MACRO_LITERAL(36), %esp // Pop arguments skip eax 259 CFI_ADJUST_CFA_OFFSET(-36) 260 POP ecx // Restore args except eax 261 POP edx 262 POP ebx 263 POP ebp // Restore callee saves 264 POP esi 265 // Swap EDI callee save with code pointer. 266 xchgl %edi, (%esp) 267 testl %eax, %eax // Branch forward if exception pending. 268 jz 1f 269 // Tail call to intended method. 270 ret 2711: 272 addl MACRO_LITERAL(4), %esp // Pop code pointer off stack 273 CFI_ADJUST_CFA_OFFSET(-4) 274 DELIVER_PENDING_EXCEPTION 275 END_FUNCTION RAW_VAR(c_name, 0) 276END_MACRO 277 278INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline 279INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck 280 281INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck 282INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck 283INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck 284INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck 285 286 /* 287 * Quick invocation stub. 288 * On entry: 289 * [sp] = return address 290 * [sp + 4] = method pointer 291 * [sp + 8] = argument array or NULL for no argument methods 292 * [sp + 12] = size of argument array in bytes 293 * [sp + 16] = (managed) thread pointer 294 * [sp + 20] = JValue* result 295 * [sp + 24] = shorty 296 */ 297DEFINE_FUNCTION art_quick_invoke_stub 298 PUSH ebp // save ebp 299 PUSH ebx // save ebx 300 PUSH esi // save esi 301 PUSH edi // save edi 302 mov %esp, %ebp // copy value of stack pointer into base pointer 303 CFI_DEF_CFA_REGISTER(ebp) 304 mov 28(%ebp), %ebx // get arg array size 305 // reserve space for return addr, method*, ebx, ebp, esi, and edi in frame 306 addl LITERAL(36), %ebx 307 // align frame size to 16 bytes 308 andl LITERAL(0xFFFFFFF0), %ebx 309 subl LITERAL(20), %ebx // remove space for return address, ebx, ebp, esi and edi 310 subl %ebx, %esp // reserve stack space for argument array 311 SETUP_GOT_NOSAVE ebx // clobbers ebx (harmless here) 312 lea 4(%esp), %eax // use stack pointer + method ptr as dest for memcpy 313 pushl 28(%ebp) // push size of region to memcpy 314 pushl 24(%ebp) // push arg array as source of memcpy 315 pushl %eax // push stack pointer as destination of memcpy 316 call PLT_SYMBOL(memcpy) // (void*, const void*, size_t) 317 addl LITERAL(12), %esp // pop arguments to memcpy 318 movl LITERAL(0), (%esp) // store NULL for method* 319 mov 20(%ebp), %eax // move method pointer into eax 320 mov 4(%esp), %ecx // copy arg1 into ecx 321 mov 8(%esp), %edx // copy arg2 into edx 322 mov 12(%esp), %ebx // copy arg3 into ebx 323 call *MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32(%eax) // call the method 324 mov %ebp, %esp // restore stack pointer 325 CFI_DEF_CFA_REGISTER(esp) 326 POP edi // pop edi 327 POP esi // pop esi 328 POP ebx // pop ebx 329 POP ebp // pop ebp 330 mov 20(%esp), %ecx // get result pointer 331 mov %eax, (%ecx) // store the result assuming its a long, int or Object* 332 mov %edx, 4(%ecx) // store the other half of the result 333 mov 24(%esp), %edx // get the shorty 334 cmpb LITERAL(68), (%edx) // test if result type char == 'D' 335 je .Lreturn_double_quick 336 cmpb LITERAL(70), (%edx) // test if result type char == 'F' 337 je .Lreturn_float_quick 338 ret 339.Lreturn_double_quick: 340 movsd %xmm0, (%ecx) // store the floating point result 341 ret 342.Lreturn_float_quick: 343 movss %xmm0, (%ecx) // store the floating point result 344 ret 345END_FUNCTION art_quick_invoke_stub 346 347MACRO3(NO_ARG_DOWNCALL, c_name, cxx_name, return_macro) 348 DEFINE_FUNCTION RAW_VAR(c_name, 0) 349 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 350 // Outgoing argument set up 351 subl MACRO_LITERAL(12), %esp // push padding 352 CFI_ADJUST_CFA_OFFSET(12) 353 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 354 CFI_ADJUST_CFA_OFFSET(4) 355 call VAR(cxx_name, 1) // cxx_name(Thread*) 356 addl MACRO_LITERAL(16), %esp // pop arguments 357 CFI_ADJUST_CFA_OFFSET(-16) 358 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 359 CALL_MACRO(return_macro, 2) // return or deliver exception 360 END_FUNCTION RAW_VAR(c_name, 0) 361END_MACRO 362 363MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro) 364 DEFINE_FUNCTION RAW_VAR(c_name, 0) 365 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 366 // Outgoing argument set up 367 subl MACRO_LITERAL(8), %esp // push padding 368 CFI_ADJUST_CFA_OFFSET(8) 369 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 370 CFI_ADJUST_CFA_OFFSET(4) 371 PUSH eax // pass arg1 372 call VAR(cxx_name, 1) // cxx_name(arg1, Thread*) 373 addl MACRO_LITERAL(16), %esp // pop arguments 374 CFI_ADJUST_CFA_OFFSET(-16) 375 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 376 CALL_MACRO(return_macro, 2) // return or deliver exception 377 END_FUNCTION RAW_VAR(c_name, 0) 378END_MACRO 379 380MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro) 381 DEFINE_FUNCTION RAW_VAR(c_name, 0) 382 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 383 // Outgoing argument set up 384 PUSH eax // push padding 385 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 386 CFI_ADJUST_CFA_OFFSET(4) 387 PUSH ecx // pass arg2 388 PUSH eax // pass arg1 389 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*) 390 addl MACRO_LITERAL(16), %esp // pop arguments 391 CFI_ADJUST_CFA_OFFSET(-16) 392 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 393 CALL_MACRO(return_macro, 2) // return or deliver exception 394 END_FUNCTION RAW_VAR(c_name, 0) 395END_MACRO 396 397MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro) 398 DEFINE_FUNCTION RAW_VAR(c_name, 0) 399 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 400 // Outgoing argument set up 401 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 402 CFI_ADJUST_CFA_OFFSET(4) 403 PUSH edx // pass arg3 404 PUSH ecx // pass arg2 405 PUSH eax // pass arg1 406 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*) 407 addl MACRO_LITERAL(16), %esp // pop arguments 408 CFI_ADJUST_CFA_OFFSET(-16) 409 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 410 CALL_MACRO(return_macro, 2) // return or deliver exception 411 END_FUNCTION RAW_VAR(c_name, 0) 412END_MACRO 413 414MACRO3(ONE_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) 415 DEFINE_FUNCTION RAW_VAR(c_name, 0) 416 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 417 // Outgoing argument set up 418 mov FRAME_SIZE_REFS_ONLY_CALLEE_SAVE(%esp), %ecx // get referrer 419 PUSH eax // push padding 420 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 421 CFI_ADJUST_CFA_OFFSET(4) 422 PUSH ecx // pass referrer 423 PUSH eax // pass arg1 424 call VAR(cxx_name, 1) // cxx_name(arg1, referrer, Thread*) 425 addl MACRO_LITERAL(16), %esp // pop arguments 426 CFI_ADJUST_CFA_OFFSET(-16) 427 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 428 CALL_MACRO(return_macro, 2) // return or deliver exception 429 END_FUNCTION RAW_VAR(c_name, 0) 430END_MACRO 431 432MACRO3(TWO_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) 433 DEFINE_FUNCTION RAW_VAR(c_name, 0) 434 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 435 // Outgoing argument set up 436 mov FRAME_SIZE_REFS_ONLY_CALLEE_SAVE(%esp), %edx // get referrer 437 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 438 CFI_ADJUST_CFA_OFFSET(4) 439 PUSH edx // pass referrer 440 PUSH ecx // pass arg2 441 PUSH eax // pass arg1 442 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, referrer, Thread*) 443 addl MACRO_LITERAL(16), %esp // pop arguments 444 CFI_ADJUST_CFA_OFFSET(-16) 445 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 446 CALL_MACRO(return_macro, 2) // return or deliver exception 447 END_FUNCTION RAW_VAR(c_name, 0) 448END_MACRO 449 450MACRO3(THREE_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) 451 DEFINE_FUNCTION RAW_VAR(c_name, 0) 452 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 453 // Outgoing argument set up 454 mov FRAME_SIZE_REFS_ONLY_CALLEE_SAVE(%esp), %ebx // get referrer 455 subl MACRO_LITERAL(12), %esp // alignment padding 456 CFI_ADJUST_CFA_OFFSET(12) 457 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 458 CFI_ADJUST_CFA_OFFSET(4) 459 PUSH ebx // pass referrer 460 PUSH edx // pass arg3 461 PUSH ecx // pass arg2 462 PUSH eax // pass arg1 463 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, referrer, Thread*) 464 addl LITERAL(32), %esp // pop arguments 465 CFI_ADJUST_CFA_OFFSET(-32) 466 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 467 CALL_MACRO(return_macro, 2) // return or deliver exception 468 END_FUNCTION RAW_VAR(c_name, 0) 469END_MACRO 470 471MACRO0(RETURN_IF_RESULT_IS_NON_ZERO) 472 testl %eax, %eax // eax == 0 ? 473 jz 1f // if eax == 0 goto 1 474 ret // return 4751: // deliver exception on current thread 476 DELIVER_PENDING_EXCEPTION 477END_MACRO 478 479MACRO0(RETURN_IF_EAX_ZERO) 480 testl %eax, %eax // eax == 0 ? 481 jnz 1f // if eax != 0 goto 1 482 ret // return 4831: // deliver exception on current thread 484 DELIVER_PENDING_EXCEPTION 485END_MACRO 486 487MACRO0(RETURN_OR_DELIVER_PENDING_EXCEPTION) 488 cmpl MACRO_LITERAL(0),%fs:THREAD_EXCEPTION_OFFSET // exception field == 0 ? 489 jne 1f // if exception field != 0 goto 1 490 ret // return 4911: // deliver exception on current thread 492 DELIVER_PENDING_EXCEPTION 493END_MACRO 494 495// Generate the allocation entrypoints for each allocator. 496// TODO: use arch/quick_alloc_entrypoints.S. Currently we don't as we need to use concatenation 497// macros to work around differences between OS/X's as and binutils as (OS/X lacks named arguments 498// to macros and the VAR macro won't concatenate arguments properly), this also breaks having 499// multi-line macros that use each other (hence using 1 macro per newline below). 500#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(c_suffix, cxx_suffix) \ 501 TWO_ARG_DOWNCALL art_quick_alloc_object ## c_suffix, artAllocObjectFromCode ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 502#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(c_suffix, cxx_suffix) \ 503 TWO_ARG_DOWNCALL art_quick_alloc_object_resolved ## c_suffix, artAllocObjectFromCodeResolved ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 504#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(c_suffix, cxx_suffix) \ 505 TWO_ARG_DOWNCALL art_quick_alloc_object_initialized ## c_suffix, artAllocObjectFromCodeInitialized ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 506#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(c_suffix, cxx_suffix) \ 507 TWO_ARG_DOWNCALL art_quick_alloc_object_with_access_check ## c_suffix, artAllocObjectFromCodeWithAccessCheck ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 508#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(c_suffix, cxx_suffix) \ 509 THREE_ARG_DOWNCALL art_quick_alloc_array ## c_suffix, artAllocArrayFromCode ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 510#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(c_suffix, cxx_suffix) \ 511 THREE_ARG_DOWNCALL art_quick_alloc_array_resolved ## c_suffix, artAllocArrayFromCodeResolved ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 512#define GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(c_suffix, cxx_suffix) \ 513 THREE_ARG_DOWNCALL art_quick_alloc_array_with_access_check ## c_suffix, artAllocArrayFromCodeWithAccessCheck ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 514#define GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(c_suffix, cxx_suffix) \ 515 THREE_ARG_DOWNCALL art_quick_check_and_alloc_array ## c_suffix, artCheckAndAllocArrayFromCode ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 516#define GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(c_suffix, cxx_suffix) \ 517 THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_with_access_check ## c_suffix, artCheckAndAllocArrayFromCodeWithAccessCheck ## cxx_suffix, RETURN_IF_RESULT_IS_NON_ZERO 518 519GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_dlmalloc, DlMalloc) 520GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_dlmalloc, DlMalloc) 521GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_dlmalloc, DlMalloc) 522GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_dlmalloc, DlMalloc) 523GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_dlmalloc, DlMalloc) 524GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_dlmalloc, DlMalloc) 525GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_dlmalloc, DlMalloc) 526GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_dlmalloc, DlMalloc) 527GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_dlmalloc, DlMalloc) 528 529GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_dlmalloc_instrumented, DlMallocInstrumented) 530GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_dlmalloc_instrumented, DlMallocInstrumented) 531GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_dlmalloc_instrumented, DlMallocInstrumented) 532GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_dlmalloc_instrumented, DlMallocInstrumented) 533GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_dlmalloc_instrumented, DlMallocInstrumented) 534GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_dlmalloc_instrumented, DlMallocInstrumented) 535GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_dlmalloc_instrumented, DlMallocInstrumented) 536GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_dlmalloc_instrumented, DlMallocInstrumented) 537GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_dlmalloc_instrumented, DlMallocInstrumented) 538 539GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc) 540GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc, RosAlloc) 541GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_rosalloc, RosAlloc) 542GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_rosalloc, RosAlloc) 543GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_rosalloc, RosAlloc) 544GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_rosalloc, RosAlloc) 545GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_rosalloc, RosAlloc) 546GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_rosalloc, RosAlloc) 547GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_rosalloc, RosAlloc) 548 549GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc_instrumented, RosAllocInstrumented) 550GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_rosalloc_instrumented, RosAllocInstrumented) 551GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_rosalloc_instrumented, RosAllocInstrumented) 552GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_rosalloc_instrumented, RosAllocInstrumented) 553GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_rosalloc_instrumented, RosAllocInstrumented) 554GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_rosalloc_instrumented, RosAllocInstrumented) 555GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_rosalloc_instrumented, RosAllocInstrumented) 556GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_rosalloc_instrumented, RosAllocInstrumented) 557GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_rosalloc_instrumented, RosAllocInstrumented) 558 559GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_bump_pointer, BumpPointer) 560GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_bump_pointer, BumpPointer) 561GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_bump_pointer, BumpPointer) 562GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_bump_pointer, BumpPointer) 563GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_bump_pointer, BumpPointer) 564GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_bump_pointer, BumpPointer) 565GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_bump_pointer, BumpPointer) 566GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_bump_pointer, BumpPointer) 567GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_bump_pointer, BumpPointer) 568 569GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_bump_pointer_instrumented, BumpPointerInstrumented) 570GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_bump_pointer_instrumented, BumpPointerInstrumented) 571GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_bump_pointer_instrumented, BumpPointerInstrumented) 572GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_bump_pointer_instrumented, BumpPointerInstrumented) 573GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_bump_pointer_instrumented, BumpPointerInstrumented) 574GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_bump_pointer_instrumented, BumpPointerInstrumented) 575GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_bump_pointer_instrumented, BumpPointerInstrumented) 576GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_bump_pointer_instrumented, BumpPointerInstrumented) 577GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_bump_pointer_instrumented, BumpPointerInstrumented) 578 579GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB) 580GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab, TLAB) 581GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_tlab, TLAB) 582GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_tlab, TLAB) 583GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_tlab, TLAB) 584GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_tlab, TLAB) 585GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_tlab, TLAB) 586GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_tlab, TLAB) 587GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_tlab, TLAB) 588 589GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab_instrumented, TLABInstrumented) 590GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_RESOLVED(_tlab_instrumented, TLABInstrumented) 591GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_INITIALIZED(_tlab_instrumented, TLABInstrumented) 592GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT_WITH_ACCESS_CHECK(_tlab_instrumented, TLABInstrumented) 593GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY(_tlab_instrumented, TLABInstrumented) 594GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_RESOLVED(_tlab_instrumented, TLABInstrumented) 595GENERATE_ALLOC_ENTRYPOINTS_ALLOC_ARRAY_WITH_ACCESS_CHECK(_tlab_instrumented, TLABInstrumented) 596GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY(_tlab_instrumented, TLABInstrumented) 597GENERATE_ALLOC_ENTRYPOINTS_CHECK_AND_ALLOC_ARRAY_WITH_ACCESS_CHECK(_tlab_instrumented, TLABInstrumented) 598 599TWO_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO 600TWO_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO 601TWO_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO 602TWO_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO 603 604TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO 605 606DEFINE_FUNCTION art_quick_lock_object 607 testl %eax, %eax // null check object/eax 608 jz .Lslow_lock 609.Lretry_lock: 610 movl MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax), %ecx // ecx := lock word 611 test LITERAL(0xC0000000), %ecx // test the 2 high bits. 612 jne .Lslow_lock // slow path if either of the two high bits are set. 613 movl %fs:THREAD_ID_OFFSET, %edx // edx := thread id 614 test %ecx, %ecx 615 jnz .Lalready_thin // lock word contains a thin lock 616 // unlocked case - %edx holds thread id with count of 0 617 movl %eax, %ecx // remember object in case of retry 618 xor %eax, %eax // eax == 0 for comparison with lock word in cmpxchg 619 lock cmpxchg %edx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%ecx) 620 jnz .Lcmpxchg_fail // cmpxchg failed retry 621 ret 622.Lcmpxchg_fail: 623 movl %ecx, %eax // restore eax 624 jmp .Lretry_lock 625.Lalready_thin: 626 cmpw %cx, %dx // do we hold the lock already? 627 jne .Lslow_lock 628 addl LITERAL(65536), %ecx // increment recursion count 629 test LITERAL(0xC0000000), %ecx // overflowed if either of top two bits are set 630 jne .Lslow_lock // count overflowed so go slow 631 // update lockword, cmpxchg not necessary as we hold lock 632 movl %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax) 633 ret 634.Lslow_lock: 635 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 636 // Outgoing argument set up 637 subl LITERAL(8), %esp // alignment padding 638 CFI_ADJUST_CFA_OFFSET(8) 639 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 640 CFI_ADJUST_CFA_OFFSET(4) 641 PUSH eax // pass object 642 call SYMBOL(artLockObjectFromCode) // artLockObjectFromCode(object, Thread*) 643 addl LITERAL(16), %esp // pop arguments 644 CFI_ADJUST_CFA_OFFSET(-16) 645 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 646 RETURN_IF_EAX_ZERO 647END_FUNCTION art_quick_lock_object 648 649DEFINE_FUNCTION art_quick_unlock_object 650 testl %eax, %eax // null check object/eax 651 jz .Lslow_unlock 652 movl MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax), %ecx // ecx := lock word 653 movl %fs:THREAD_ID_OFFSET, %edx // edx := thread id 654 test LITERAL(0xC0000000), %ecx 655 jnz .Lslow_unlock // lock word contains a monitor 656 cmpw %cx, %dx // does the thread id match? 657 jne .Lslow_unlock 658 cmpl LITERAL(65536), %ecx 659 jae .Lrecursive_thin_unlock 660 movl LITERAL(0), MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax) 661 ret 662.Lrecursive_thin_unlock: 663 subl LITERAL(65536), %ecx 664 mov %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax) 665 ret 666.Lslow_unlock: 667 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 668 // Outgoing argument set up 669 subl LITERAL(8), %esp // alignment padding 670 CFI_ADJUST_CFA_OFFSET(8) 671 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 672 CFI_ADJUST_CFA_OFFSET(4) 673 PUSH eax // pass object 674 call SYMBOL(artUnlockObjectFromCode) // artUnlockObjectFromCode(object, Thread*) 675 addl LITERAL(16), %esp // pop arguments 676 CFI_ADJUST_CFA_OFFSET(-16) 677 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 678 RETURN_IF_EAX_ZERO 679END_FUNCTION art_quick_unlock_object 680 681DEFINE_FUNCTION art_quick_is_assignable 682 PUSH eax // alignment padding 683 PUSH ecx // pass arg2 - obj->klass 684 PUSH eax // pass arg1 - checked class 685 call SYMBOL(artIsAssignableFromCode) // (Class* klass, Class* ref_klass) 686 addl LITERAL(12), %esp // pop arguments 687 CFI_ADJUST_CFA_OFFSET(-12) 688 ret 689END_FUNCTION art_quick_is_assignable 690 691DEFINE_FUNCTION art_quick_check_cast 692 PUSH eax // alignment padding 693 PUSH ecx // pass arg2 - obj->klass 694 PUSH eax // pass arg1 - checked class 695 call SYMBOL(artIsAssignableFromCode) // (Class* klass, Class* ref_klass) 696 testl %eax, %eax 697 jz 1f // jump forward if not assignable 698 addl LITERAL(12), %esp // pop arguments 699 CFI_ADJUST_CFA_OFFSET(-12) 700 ret 7011: 702 POP eax // pop arguments 703 POP ecx 704 addl LITERAL(4), %esp 705 CFI_ADJUST_CFA_OFFSET(-12) 706 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save all registers as basis for long jump context 707 // Outgoing argument set up 708 PUSH eax // alignment padding 709 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 710 CFI_ADJUST_CFA_OFFSET(4) 711 PUSH ecx // pass arg2 712 PUSH eax // pass arg1 713 call SYMBOL(artThrowClassCastException) // (Class* a, Class* b, Thread*) 714 int3 // unreached 715END_FUNCTION art_quick_check_cast 716 717 /* 718 * Entry from managed code for array put operations of objects where the value being stored 719 * needs to be checked for compatibility. 720 * eax = array, ecx = index, edx = value 721 */ 722DEFINE_FUNCTION art_quick_aput_obj_with_null_and_bound_check 723 testl %eax, %eax 724 jnz SYMBOL(art_quick_aput_obj_with_bound_check) 725 jmp SYMBOL(art_quick_throw_null_pointer_exception) 726END_FUNCTION art_quick_aput_obj_with_null_and_bound_check 727 728DEFINE_FUNCTION art_quick_aput_obj_with_bound_check 729 movl MIRROR_ARRAY_LENGTH_OFFSET(%eax), %ebx 730 cmpl %ebx, %ecx 731 jb SYMBOL(art_quick_aput_obj) 732 mov %ecx, %eax 733 mov %ebx, %ecx 734 jmp SYMBOL(art_quick_throw_array_bounds) 735END_FUNCTION art_quick_aput_obj_with_bound_check 736 737DEFINE_FUNCTION art_quick_aput_obj 738 test %edx, %edx // store of null 739 jz .Ldo_aput_null 740 movl MIRROR_OBJECT_CLASS_OFFSET(%eax), %ebx 741 movl MIRROR_CLASS_COMPONENT_TYPE_OFFSET(%ebx), %ebx 742 // value's type == array's component type - trivial assignability 743 cmpl MIRROR_OBJECT_CLASS_OFFSET(%edx), %ebx 744 jne .Lcheck_assignability 745.Ldo_aput: 746 movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) 747 movl %fs:THREAD_CARD_TABLE_OFFSET, %edx 748 shrl LITERAL(7), %eax 749 movb %dl, (%edx, %eax) 750 ret 751.Ldo_aput_null: 752 movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) 753 ret 754.Lcheck_assignability: 755 PUSH eax // save arguments 756 PUSH ecx 757 PUSH edx 758 subl LITERAL(8), %esp // alignment padding 759 CFI_ADJUST_CFA_OFFSET(8) 760 pushl MIRROR_OBJECT_CLASS_OFFSET(%edx) // pass arg2 - type of the value to be stored 761 CFI_ADJUST_CFA_OFFSET(4) 762 PUSH ebx // pass arg1 - component type of the array 763 call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b) 764 addl LITERAL(16), %esp // pop arguments 765 CFI_ADJUST_CFA_OFFSET(-16) 766 testl %eax, %eax 767 jz .Lthrow_array_store_exception 768 POP edx 769 POP ecx 770 POP eax 771 movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) // do the aput 772 movl %fs:THREAD_CARD_TABLE_OFFSET, %edx 773 shrl LITERAL(7), %eax 774 movb %dl, (%edx, %eax) 775 ret 776.Lthrow_array_store_exception: 777 POP edx 778 POP ecx 779 POP eax 780 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx // save all registers as basis for long jump context 781 // Outgoing argument set up 782 PUSH eax // alignment padding 783 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 784 CFI_ADJUST_CFA_OFFSET(4) 785 PUSH edx // pass arg2 - value 786 PUSH eax // pass arg1 - array 787 call SYMBOL(artThrowArrayStoreException) // (array, value, Thread*) 788 int3 // unreached 789END_FUNCTION art_quick_aput_obj 790 791DEFINE_FUNCTION art_quick_memcpy 792 SETUP_GOT_NOSAVE ebx // clobbers EBX 793 PUSH edx // pass arg3 794 PUSH ecx // pass arg2 795 PUSH eax // pass arg1 796 call PLT_SYMBOL(memcpy) // (void*, const void*, size_t) 797 addl LITERAL(12), %esp // pop arguments 798 CFI_ADJUST_CFA_OFFSET(-12) 799 ret 800END_FUNCTION art_quick_memcpy 801 802NO_ARG_DOWNCALL art_quick_test_suspend, artTestSuspendFromCode, ret 803 804DEFINE_FUNCTION art_quick_d2l 805 PUSH eax // alignment padding 806 PUSH ecx // pass arg2 a.hi 807 PUSH eax // pass arg1 a.lo 808 call SYMBOL(art_d2l) // (jdouble a) 809 addl LITERAL(12), %esp // pop arguments 810 CFI_ADJUST_CFA_OFFSET(-12) 811 ret 812END_FUNCTION art_quick_d2l 813 814DEFINE_FUNCTION art_quick_f2l 815 subl LITERAL(8), %esp // alignment padding 816 CFI_ADJUST_CFA_OFFSET(8) 817 PUSH eax // pass arg1 a 818 call SYMBOL(art_f2l) // (jfloat a) 819 addl LITERAL(12), %esp // pop arguments 820 CFI_ADJUST_CFA_OFFSET(-12) 821 ret 822END_FUNCTION art_quick_f2l 823 824DEFINE_FUNCTION art_quick_ldiv 825 subl LITERAL(12), %esp // alignment padding 826 CFI_ADJUST_CFA_OFFSET(12) 827 PUSH ebx // pass arg4 b.hi 828 PUSH edx // pass arg3 b.lo 829 PUSH ecx // pass arg2 a.hi 830 PUSH eax // pass arg1 a.lo 831 call SYMBOL(artLdiv) // (jlong a, jlong b) 832 addl LITERAL(28), %esp // pop arguments 833 CFI_ADJUST_CFA_OFFSET(-28) 834 ret 835END_FUNCTION art_quick_ldiv 836 837DEFINE_FUNCTION art_quick_lmod 838 subl LITERAL(12), %esp // alignment padding 839 CFI_ADJUST_CFA_OFFSET(12) 840 PUSH ebx // pass arg4 b.hi 841 PUSH edx // pass arg3 b.lo 842 PUSH ecx // pass arg2 a.hi 843 PUSH eax // pass arg1 a.lo 844 call SYMBOL(artLmod) // (jlong a, jlong b) 845 addl LITERAL(28), %esp // pop arguments 846 CFI_ADJUST_CFA_OFFSET(-28) 847 ret 848END_FUNCTION art_quick_lmod 849 850DEFINE_FUNCTION art_quick_lmul 851 imul %eax, %ebx // ebx = a.lo(eax) * b.hi(ebx) 852 imul %edx, %ecx // ecx = b.lo(edx) * a.hi(ecx) 853 mul %edx // edx:eax = a.lo(eax) * b.lo(edx) 854 add %ebx, %ecx 855 add %ecx, %edx // edx += (a.lo * b.hi) + (b.lo * a.hi) 856 ret 857END_FUNCTION art_quick_lmul 858 859DEFINE_FUNCTION art_quick_lshl 860 // ecx:eax << edx 861 xchg %edx, %ecx 862 shld %cl,%eax,%edx 863 shl %cl,%eax 864 test LITERAL(32), %cl 865 jz 1f 866 mov %eax, %edx 867 xor %eax, %eax 8681: 869 ret 870END_FUNCTION art_quick_lshl 871 872DEFINE_FUNCTION art_quick_lshr 873 // ecx:eax >> edx 874 xchg %edx, %ecx 875 shrd %cl,%edx,%eax 876 sar %cl,%edx 877 test LITERAL(32),%cl 878 jz 1f 879 mov %edx, %eax 880 sar LITERAL(31), %edx 8811: 882 ret 883END_FUNCTION art_quick_lshr 884 885DEFINE_FUNCTION art_quick_lushr 886 // ecx:eax >>> edx 887 xchg %edx, %ecx 888 shrd %cl,%edx,%eax 889 shr %cl,%edx 890 test LITERAL(32),%cl 891 jz 1f 892 mov %edx, %eax 893 xor %edx, %edx 8941: 895 ret 896END_FUNCTION art_quick_lushr 897 898ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 899ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 900ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 901ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 902ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 903ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 904ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 905 906TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 907TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 908TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 909TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 910TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 911TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 912TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION 913 914TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCode, RETURN_IF_EAX_ZERO 915TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCode, RETURN_IF_EAX_ZERO 916TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_EAX_ZERO 917TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_EAX_ZERO 918 919THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCode, RETURN_IF_EAX_ZERO 920THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCode, RETURN_IF_EAX_ZERO 921THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_EAX_ZERO 922THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_EAX_ZERO 923 924// Call artSet64InstanceFromCode with 4 word size arguments and the referrer. 925DEFINE_FUNCTION art_quick_set64_instance 926 movd %ebx, %xmm0 927 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 928 movd %xmm0, %ebx 929 // Outgoing argument set up 930 subl LITERAL(8), %esp // alignment padding 931 CFI_ADJUST_CFA_OFFSET(8) 932 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 933 CFI_ADJUST_CFA_OFFSET(4) 934 pushl (FRAME_SIZE_REFS_ONLY_CALLEE_SAVE+12)(%esp) // pass referrer 935 CFI_ADJUST_CFA_OFFSET(4) 936 PUSH ebx // pass high half of new_val 937 PUSH edx // pass low half of new_val 938 PUSH ecx // pass object 939 PUSH eax // pass field_idx 940 call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*) 941 addl LITERAL(32), %esp // pop arguments 942 CFI_ADJUST_CFA_OFFSET(-32) 943 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 944 RETURN_IF_EAX_ZERO // return or deliver exception 945END_FUNCTION art_quick_set64_instance 946 947// Call artSet64StaticFromCode with 3 word size arguments plus with the referrer in the 2nd position 948// so that new_val is aligned on even registers were we passing arguments in registers. 949DEFINE_FUNCTION art_quick_set64_static 950 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx // save ref containing registers for GC 951 mov FRAME_SIZE_REFS_ONLY_CALLEE_SAVE(%esp), %ebx // get referrer 952 subl LITERAL(12), %esp // alignment padding 953 CFI_ADJUST_CFA_OFFSET(12) 954 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 955 CFI_ADJUST_CFA_OFFSET(4) 956 PUSH edx // pass high half of new_val 957 PUSH ecx // pass low half of new_val 958 PUSH ebx // pass referrer 959 PUSH eax // pass field_idx 960 call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*) 961 addl LITERAL(32), %esp // pop arguments 962 CFI_ADJUST_CFA_OFFSET(-32) 963 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address 964 RETURN_IF_EAX_ZERO // return or deliver exception 965END_FUNCTION art_quick_set64_static 966 967DEFINE_FUNCTION art_quick_proxy_invoke_handler 968 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_EAX 969 PUSH esp // pass SP 970 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 971 CFI_ADJUST_CFA_OFFSET(4) 972 PUSH ecx // pass receiver 973 PUSH eax // pass proxy method 974 call SYMBOL(artQuickProxyInvokeHandler) // (proxy method, receiver, Thread*, SP) 975 movd %eax, %xmm0 // place return value also into floating point return value 976 movd %edx, %xmm1 977 punpckldq %xmm1, %xmm0 978 addl LITERAL(44), %esp // pop arguments 979 CFI_ADJUST_CFA_OFFSET(-44) 980 RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception 981END_FUNCTION art_quick_proxy_invoke_handler 982 983 /* 984 * Called to resolve an imt conflict. xmm0 is a hidden argument that holds the target method's 985 * dex method index. 986 */ 987DEFINE_FUNCTION art_quick_imt_conflict_trampoline 988 PUSH ecx 989 movl 8(%esp), %eax // load caller Method* 990 movl MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET(%eax), %eax // load dex_cache_resolved_methods 991 movd %xmm0, %ecx // get target method index stored in xmm0 992 movl MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4), %eax // load the target method 993 POP ecx 994 jmp SYMBOL(art_quick_invoke_interface_trampoline) 995END_FUNCTION art_quick_imt_conflict_trampoline 996 997DEFINE_FUNCTION art_quick_resolution_trampoline 998 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME ebx, ebx 999 movl %esp, %edi 1000 PUSH EDI // pass SP. do not just PUSH ESP; that messes up unwinding 1001 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 1002 CFI_ADJUST_CFA_OFFSET(4) 1003 PUSH ecx // pass receiver 1004 PUSH eax // pass method 1005 call SYMBOL(artQuickResolutionTrampoline) // (Method* called, receiver, Thread*, SP) 1006 movl %eax, %edi // remember code pointer in EDI 1007 addl LITERAL(16), %esp // pop arguments 1008 test %eax, %eax // if code pointer is NULL goto deliver pending exception 1009 jz 1f 1010 POP eax // called method 1011 POP ecx // restore args 1012 POP edx 1013 POP ebx 1014 POP ebp // restore callee saves except EDI 1015 POP esi 1016 xchgl 0(%esp),%edi // restore EDI and place code pointer as only value on stack 1017 ret // tail call into method 10181: 1019 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME 1020 DELIVER_PENDING_EXCEPTION 1021END_FUNCTION art_quick_resolution_trampoline 1022 1023DEFINE_FUNCTION art_quick_generic_jni_trampoline 1024 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME_WITH_METHOD_IN_EAX 1025 movl %esp, %ebp // save SP at callee-save frame 1026 CFI_DEF_CFA_REGISTER(ebp) 1027 subl LITERAL(5120), %esp 1028 // prepare for artQuickGenericJniTrampoline call 1029 // (Thread*, SP) 1030 // (esp) 4(esp) <= C calling convention 1031 // fs:... ebp <= where they are 1032 1033 subl LITERAL(8), %esp // Padding for 16B alignment. 1034 pushl %ebp // Pass SP (to ArtMethod). 1035 pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). 1036 call SYMBOL(artQuickGenericJniTrampoline) // (Thread*, sp) 1037 1038 // The C call will have registered the complete save-frame on success. 1039 // The result of the call is: 1040 // eax: pointer to native code, 0 on error. 1041 // edx: pointer to the bottom of the used area of the alloca, can restore stack till there. 1042 1043 // Check for error = 0. 1044 test %eax, %eax 1045 jz .Lentry_error 1046 1047 // Release part of the alloca. 1048 movl %edx, %esp 1049 1050 // On x86 there are no registers passed, so nothing to pop here. 1051 1052 // Native call. 1053 call *%eax 1054 1055 // result sign extension is handled in C code 1056 // prepare for artQuickGenericJniEndTrampoline call 1057 // (Thread*, result, result_f) 1058 // (esp) 4(esp) 12(esp) <= C calling convention 1059 // fs:... eax:edx fp0 <= where they are 1060 1061 subl LITERAL(20), %esp // Padding & pass float result. 1062 fstpl (%esp) 1063 pushl %edx // Pass int result. 1064 pushl %eax 1065 pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). 1066 call SYMBOL(artQuickGenericJniEndTrampoline) 1067 1068 // Tear down the alloca. 1069 movl %ebp, %esp 1070 CFI_DEF_CFA_REGISTER(esp) 1071 1072 // Pending exceptions possible. 1073 mov %fs:THREAD_EXCEPTION_OFFSET, %ebx 1074 testl %ebx, %ebx 1075 jnz .Lexception_in_native 1076 1077 // Tear down the callee-save frame. 1078 addl LITERAL(4), %esp // Remove padding 1079 CFI_ADJUST_CFA_OFFSET(-4) 1080 POP ecx 1081 addl LITERAL(4), %esp // Avoid edx, as it may be part of the result. 1082 CFI_ADJUST_CFA_OFFSET(-4) 1083 POP ebx 1084 POP ebp // Restore callee saves 1085 POP esi 1086 POP edi 1087 // Quick expects the return value to be in xmm0. 1088 movd %eax, %xmm0 1089 movd %edx, %xmm1 1090 punpckldq %xmm1, %xmm0 1091 ret 1092.Lentry_error: 1093 movl %ebp, %esp 1094 CFI_DEF_CFA_REGISTER(esp) 1095.Lexception_in_native: 1096 RESTORE_REFS_AND_ARGS_CALLEE_SAVE_FRAME 1097 DELIVER_PENDING_EXCEPTION 1098END_FUNCTION art_quick_generic_jni_trampoline 1099 1100DEFINE_FUNCTION art_quick_to_interpreter_bridge 1101 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME ebx, ebx // save frame 1102 mov %esp, %edx // remember SP 1103 PUSH eax // alignment padding 1104 PUSH edx // pass SP 1105 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() 1106 CFI_ADJUST_CFA_OFFSET(4) 1107 PUSH eax // pass method 1108 call SYMBOL(artQuickToInterpreterBridge) // (method, Thread*, SP) 1109 movd %eax, %xmm0 // place return value also into floating point return value 1110 movd %edx, %xmm1 1111 punpckldq %xmm1, %xmm0 1112 addl LITERAL(16), %esp // pop arguments 1113 CFI_ADJUST_CFA_OFFSET(-16) 1114 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME 1115 RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception 1116END_FUNCTION art_quick_to_interpreter_bridge 1117 1118 /* 1119 * Routine that intercepts method calls and returns. 1120 */ 1121DEFINE_FUNCTION art_quick_instrumentation_entry 1122 SETUP_REFS_AND_ARGS_CALLEE_SAVE_FRAME ebx, edx 1123 PUSH eax // Save eax which will be clobbered by the callee-save method. 1124 subl LITERAL(12), %esp // Align stack. 1125 CFI_ADJUST_CFA_OFFSET(12) 1126 pushl FRAME_SIZE_REFS_AND_ARGS_CALLEE_SAVE-4+16(%esp) // Pass LR. 1127 CFI_ADJUST_CFA_OFFSET(4) 1128 pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). 1129 CFI_ADJUST_CFA_OFFSET(4) 1130 PUSH ecx // Pass receiver. 1131 PUSH eax // Pass Method*. 1132 call SYMBOL(artInstrumentationMethodEntryFromCode) // (Method*, Object*, Thread*, LR) 1133 addl LITERAL(28), %esp // Pop arguments upto saved Method*. 1134 movl 28(%esp), %edi // Restore edi. 1135 movl %eax, 28(%esp) // Place code* over edi, just under return pc. 1136 movl SYMBOL(art_quick_instrumentation_exit)@GOT(%ebx), %ebx 1137 // Place instrumentation exit as return pc. ebx holds the GOT computed on entry. 1138 movl %ebx, 32(%esp) 1139 movl (%esp), %eax // Restore eax. 1140 movl 8(%esp), %ecx // Restore ecx. 1141 movl 12(%esp), %edx // Restore edx. 1142 movl 16(%esp), %ebx // Restore ebx. 1143 movl 20(%esp), %ebp // Restore ebp. 1144 movl 24(%esp), %esi // Restore esi. 1145 addl LITERAL(28), %esp // Wind stack back upto code*. 1146 ret // Call method (and pop). 1147END_FUNCTION art_quick_instrumentation_entry 1148 1149DEFINE_FUNCTION art_quick_instrumentation_exit 1150 pushl LITERAL(0) // Push a fake return PC as there will be none on the stack. 1151 SETUP_REFS_ONLY_CALLEE_SAVE_FRAME ebx, ebx 1152 mov %esp, %ecx // Remember SP 1153 subl LITERAL(8), %esp // Save float return value. 1154 CFI_ADJUST_CFA_OFFSET(8) 1155 movq %xmm0, (%esp) 1156 PUSH edx // Save gpr return value. 1157 PUSH eax 1158 subl LITERAL(16), %esp // Align stack 1159 CFI_ADJUST_CFA_OFFSET(16) 1160 movq %xmm0, (%esp) // Pass float return value. 1161 PUSH edx // Pass gpr return value. 1162 PUSH eax 1163 PUSH ecx // Pass SP. 1164 pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current. 1165 CFI_ADJUST_CFA_OFFSET(4) 1166 call SYMBOL(artInstrumentationMethodExitFromCode) // (Thread*, SP, gpr_result, fpr_result) 1167 mov %eax, %ecx // Move returned link register. 1168 addl LITERAL(32), %esp // Pop arguments. 1169 CFI_ADJUST_CFA_OFFSET(-32) 1170 movl %edx, %ebx // Move returned link register for deopt 1171 // (ebx is pretending to be our LR). 1172 POP eax // Restore gpr return value. 1173 POP edx 1174 movq (%esp), %xmm0 // Restore fpr return value. 1175 addl LITERAL(8), %esp 1176 CFI_ADJUST_CFA_OFFSET(-8) 1177 RESTORE_REFS_ONLY_CALLEE_SAVE_FRAME 1178 addl LITERAL(4), %esp // Remove fake return pc. 1179 jmp *%ecx // Return. 1180END_FUNCTION art_quick_instrumentation_exit 1181 1182 /* 1183 * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization 1184 * will long jump to the upcall with a special exception of -1. 1185 */ 1186DEFINE_FUNCTION art_quick_deoptimize 1187 pushl %ebx // Fake that we were called. 1188 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME ebx, ebx 1189 subl LITERAL(12), %esp // Align stack. 1190 CFI_ADJUST_CFA_OFFSET(12) 1191 pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). 1192 CFI_ADJUST_CFA_OFFSET(4) 1193 call SYMBOL(artDeoptimize) // artDeoptimize(Thread*) 1194 int3 // Unreachable. 1195END_FUNCTION art_quick_deoptimize 1196 1197 /* 1198 * String's compareTo. 1199 * 1200 * On entry: 1201 * eax: this string object (known non-null) 1202 * ecx: comp string object (known non-null) 1203 */ 1204DEFINE_FUNCTION art_quick_string_compareto 1205 PUSH esi // push callee save reg 1206 PUSH edi // push callee save reg 1207 mov MIRROR_STRING_COUNT_OFFSET(%eax), %edx 1208 mov MIRROR_STRING_COUNT_OFFSET(%ecx), %ebx 1209 mov MIRROR_STRING_VALUE_OFFSET(%eax), %esi 1210 mov MIRROR_STRING_VALUE_OFFSET(%ecx), %edi 1211 mov MIRROR_STRING_OFFSET_OFFSET(%eax), %eax 1212 mov MIRROR_STRING_OFFSET_OFFSET(%ecx), %ecx 1213 /* Build pointers to the start of string data */ 1214 lea MIRROR_CHAR_ARRAY_DATA_OFFSET(%esi, %eax, 2), %esi 1215 lea MIRROR_CHAR_ARRAY_DATA_OFFSET(%edi, %ecx, 2), %edi 1216 /* Calculate min length and count diff */ 1217 mov %edx, %ecx 1218 mov %edx, %eax 1219 subl %ebx, %eax 1220 cmovg %ebx, %ecx 1221 /* 1222 * At this point we have: 1223 * eax: value to return if first part of strings are equal 1224 * ecx: minimum among the lengths of the two strings 1225 * esi: pointer to this string data 1226 * edi: pointer to comp string data 1227 */ 1228 jecxz .Lkeep_length 1229 repe cmpsw // find nonmatching chars in [%esi] and [%edi], up to length %ecx 1230 jne .Lnot_equal 1231.Lkeep_length: 1232 POP edi // pop callee save reg 1233 POP esi // pop callee save reg 1234 ret 1235 .balign 16 1236.Lnot_equal: 1237 movzwl -2(%esi), %eax // get last compared char from this string 1238 movzwl -2(%edi), %ecx // get last compared char from comp string 1239 subl %ecx, %eax // return the difference 1240 POP edi // pop callee save reg 1241 POP esi // pop callee save reg 1242 ret 1243END_FUNCTION art_quick_string_compareto 1244 1245// Return from a nested signal: 1246// Entry: 1247// eax: address of jmp_buf in TLS 1248 1249DEFINE_FUNCTION art_nested_signal_return 1250 SETUP_GOT_NOSAVE ebx // sets %ebx for call into PLT 1251 movl LITERAL(1), %ecx 1252 pushl %ecx // second arg to longjmp (1) 1253 pushl %eax // first arg to longjmp (jmp_buf) 1254 call PLT_SYMBOL(longjmp) 1255 int3 // won't get here. 1256END_FUNCTION art_nested_signal_return 1257 1258 // TODO: implement these! 1259UNIMPLEMENTED art_quick_memcmp16 1260