diff options
Diffstat (limited to 'runtime/arch/arm')
-rw-r--r-- | runtime/arch/arm/context_arm.cc | 103 | ||||
-rw-r--r-- | runtime/arch/arm/context_arm.h | 68 | ||||
-rw-r--r-- | runtime/arch/arm/quick_entrypoints_arm.S | 1413 | ||||
-rw-r--r-- | runtime/arch/arm/quick_entrypoints_init_arm.cc | 237 | ||||
-rw-r--r-- | runtime/arch/arm/registers_arm.cc | 47 | ||||
-rw-r--r-- | runtime/arch/arm/registers_arm.h | 97 |
6 files changed, 1965 insertions, 0 deletions
diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc new file mode 100644 index 0000000..6b9538e --- /dev/null +++ b/runtime/arch/arm/context_arm.cc @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "context_arm.h" + +#include "mirror/abstract_method.h" +#include "mirror/object-inl.h" +#include "stack.h" +#include "thread.h" + +namespace art { +namespace arm { + +static const uint32_t gZero = 0; + +void ArmContext::Reset() { + for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { + gprs_[i] = NULL; + } + for (size_t i = 0; i < kNumberOfSRegisters; i++) { + fprs_[i] = NULL; + } + gprs_[SP] = &sp_; + gprs_[PC] = &pc_; + // Initialize registers with easy to spot debug values. + sp_ = ArmContext::kBadGprBase + SP; + pc_ = ArmContext::kBadGprBase + PC; +} + +void ArmContext::FillCalleeSaves(const StackVisitor& fr) { + mirror::AbstractMethod* method = fr.GetMethod(); + uint32_t core_spills = method->GetCoreSpillMask(); + uint32_t fp_core_spills = method->GetFpSpillMask(); + size_t spill_count = __builtin_popcount(core_spills); + size_t fp_spill_count = __builtin_popcount(fp_core_spills); + size_t frame_size = method->GetFrameSizeInBytes(); + if (spill_count > 0) { + // Lowest number spill is farthest away, walk registers and fill into context + int j = 1; + for (size_t i = 0; i < kNumberOfCoreRegisters; i++) { + if (((core_spills >> i) & 1) != 0) { + gprs_[i] = fr.CalleeSaveAddress(spill_count - j, frame_size); + j++; + } + } + } + if (fp_spill_count > 0) { + // Lowest number spill is farthest away, walk registers and fill into context + int j = 1; + for (size_t i = 0; i < kNumberOfSRegisters; i++) { + if (((fp_core_spills >> i) & 1) != 0) { + fprs_[i] = fr.CalleeSaveAddress(spill_count + fp_spill_count - j, frame_size); + j++; + } + } + } +} + +void ArmContext::SetGPR(uint32_t reg, uintptr_t value) { + DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); + DCHECK_NE(gprs_[reg], &gZero); // Can't overwrite this static value since they are never reset. + DCHECK(gprs_[reg] != NULL); + *gprs_[reg] = value; +} + +void ArmContext::SmashCallerSaves() { + // This needs to be 0 because we want a null/zero return value. + gprs_[R0] = const_cast<uint32_t*>(&gZero); + gprs_[R1] = const_cast<uint32_t*>(&gZero); + gprs_[R2] = NULL; + gprs_[R3] = NULL; +} + +extern "C" void art_quick_do_long_jump(uint32_t*, uint32_t*); + +void ArmContext::DoLongJump() { + uintptr_t gprs[16]; + uint32_t fprs[32]; + for (size_t i = 0; i < kNumberOfCoreRegisters; ++i) { + gprs[i] = gprs_[i] != NULL ? *gprs_[i] : ArmContext::kBadGprBase + i; + } + for (size_t i = 0; i < kNumberOfSRegisters; ++i) { + fprs[i] = fprs_[i] != NULL ? *fprs_[i] : ArmContext::kBadGprBase + i; + } + DCHECK_EQ(reinterpret_cast<uintptr_t>(Thread::Current()), gprs[TR]); + art_quick_do_long_jump(gprs, fprs); +} + +} // namespace arm +} // namespace art diff --git a/runtime/arch/arm/context_arm.h b/runtime/arch/arm/context_arm.h new file mode 100644 index 0000000..00651ff --- /dev/null +++ b/runtime/arch/arm/context_arm.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ +#define ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ + +#include "locks.h" +#include "arch/context.h" +#include "base/logging.h" +#include "registers_arm.h" + +namespace art { +namespace arm { + +class ArmContext : public Context { + public: + ArmContext() { + Reset(); + } + + virtual ~ArmContext() {} + + virtual void Reset(); + + virtual void FillCalleeSaves(const StackVisitor& fr); + + virtual void SetSP(uintptr_t new_sp) { + SetGPR(SP, new_sp); + } + + virtual void SetPC(uintptr_t new_pc) { + SetGPR(PC, new_pc); + } + + virtual uintptr_t GetGPR(uint32_t reg) { + DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); + return *gprs_[reg]; + } + + virtual void SetGPR(uint32_t reg, uintptr_t value); + virtual void SmashCallerSaves(); + virtual void DoLongJump(); + + private: + // Pointers to register locations, initialized to NULL or the specific registers below. + uintptr_t* gprs_[kNumberOfCoreRegisters]; + uint32_t* fprs_[kNumberOfSRegisters]; + // Hold values for sp and pc if they are not located within a stack frame. + uintptr_t sp_, pc_; +}; + +} // namespace arm +} // namespace art + +#endif // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_ diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S new file mode 100644 index 0000000..f19e8ba --- /dev/null +++ b/runtime/arch/arm/quick_entrypoints_arm.S @@ -0,0 +1,1413 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "asm_support.h" + + /* Deliver the given exception */ + .extern artDeliverExceptionFromCode + /* Deliver an exception pending on a thread */ + .extern artDeliverPendingException + +.macro ENTRY name + .type \name, #function + .global \name + /* Cache alignment for function entry */ + .balign 16 +\name: + .cfi_startproc + .fnstart +.endm + +.macro END name + .fnend + .cfi_endproc + .size \name, .-\name +.endm + + /* + * Macro that sets up the callee save frame to conform with + * Runtime::CreateCalleeSaveMethod(kSaveAll) + */ +.macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME + push {r4-r11, lr} @ 9 words of callee saves + .save {r4-r11, lr} + .cfi_adjust_cfa_offset 36 + .cfi_rel_offset r4, 0 + .cfi_rel_offset r5, 4 + .cfi_rel_offset r6, 8 + .cfi_rel_offset r7, 12 + .cfi_rel_offset r8, 16 + .cfi_rel_offset r9, 20 + .cfi_rel_offset r10, 24 + .cfi_rel_offset r11, 28 + .cfi_rel_offset lr, 32 + vpush {s0-s31} + .pad #128 + .cfi_adjust_cfa_offset 128 + sub sp, #12 @ 3 words of space, bottom word will hold Method* + .pad #12 + .cfi_adjust_cfa_offset 12 +.endm + + /* + * Macro that sets up the callee save frame to conform with + * Runtime::CreateCalleeSaveMethod(kRefsOnly). Restoration assumes non-moving GC. + */ +.macro SETUP_REF_ONLY_CALLEE_SAVE_FRAME + push {r5-r8, r10-r11, lr} @ 7 words of callee saves + .save {r5-r8, r10-r11, lr} + .cfi_adjust_cfa_offset 28 + .cfi_rel_offset r5, 0 + .cfi_rel_offset r6, 4 + .cfi_rel_offset r7, 8 + .cfi_rel_offset r8, 12 + .cfi_rel_offset r10, 16 + .cfi_rel_offset r11, 20 + .cfi_rel_offset lr, 24 + sub sp, #4 @ bottom word will hold Method* + .pad #4 + .cfi_adjust_cfa_offset 4 +.endm + +.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + ldr lr, [sp, #28] @ restore lr for return + add sp, #32 @ unwind stack + .cfi_adjust_cfa_offset -32 +.endm + +.macro RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN + ldr lr, [sp, #28] @ restore lr for return + add sp, #32 @ unwind stack + .cfi_adjust_cfa_offset -32 + bx lr @ return +.endm + + /* + * Macro that sets up the callee save frame to conform with + * Runtime::CreateCalleeSaveMethod(kRefsAndArgs). Restoration assumes non-moving GC. + */ +.macro SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + push {r1-r3, r5-r8, r10-r11, lr} @ 10 words of callee saves + .save {r1-r3, r5-r8, r10-r11, lr} + .cfi_adjust_cfa_offset 40 + .cfi_rel_offset r1, 0 + .cfi_rel_offset r2, 4 + .cfi_rel_offset r3, 8 + .cfi_rel_offset r5, 12 + .cfi_rel_offset r6, 16 + .cfi_rel_offset r7, 20 + .cfi_rel_offset r8, 24 + .cfi_rel_offset r10, 28 + .cfi_rel_offset r11, 32 + .cfi_rel_offset lr, 36 + sub sp, #8 @ 2 words of space, bottom word will hold Method* + .pad #8 + .cfi_adjust_cfa_offset 8 +.endm + +.macro RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME + ldr r1, [sp, #8] @ restore non-callee save r1 + ldrd r2, [sp, #12] @ restore non-callee saves r2-r3 + ldr lr, [sp, #44] @ restore lr + add sp, #48 @ rewind sp + .cfi_adjust_cfa_offset -48 +.endm + + /* + * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending + * exception is Thread::Current()->exception_ + */ +.macro DELIVER_PENDING_EXCEPTION + .fnend + .fnstart + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME @ save callee saves for throw + mov r0, r9 @ pass Thread::Current + mov r1, sp @ pass SP + b artDeliverPendingExceptionFromCode @ artDeliverPendingExceptionFromCode(Thread*, SP) +.endm + +.macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name + .extern \cxx_name +ENTRY \c_name + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context + mov r0, r9 @ pass Thread::Current + mov r1, sp @ pass SP + b \cxx_name @ \cxx_name(Thread*, SP) +END \c_name +.endm + +.macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name + .extern \cxx_name +ENTRY \c_name + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context + mov r1, r9 @ pass Thread::Current + mov r2, sp @ pass SP + b \cxx_name @ \cxx_name(Thread*, SP) +END \c_name +.endm + +.macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name + .extern \cxx_name +ENTRY \c_name + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + b \cxx_name @ \cxx_name(Thread*, SP) +END \c_name +.endm + + /* + * Called by managed code, saves callee saves and then calls artThrowException + * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. + */ +ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception_from_code, artDeliverExceptionFromCode + + /* + * Called by managed code to create and deliver a NullPointerException. + */ +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode + + /* + * Called by managed code to create and deliver an ArithmeticException. + */ +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero_from_code, artThrowDivZeroFromCode + + /* + * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds + * index, arg2 holds limit. + */ +TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds_from_code, artThrowArrayBoundsFromCode + + /* + * Called by managed code to create and deliver a StackOverflowError. + */ +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow_from_code, artThrowStackOverflowFromCode + + /* + * Called by managed code to create and deliver a NoSuchMethodError. + */ +ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode + + /* + * All generated callsites for interface invokes and invocation slow paths will load arguments + * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain + * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the + * stack and call the appropriate C helper. + * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. + * + * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting + * of the target Method* in r0 and method->code_ in r1. + * + * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the + * thread and we branch to another stub to deliver it. + * + * On success this wrapper will restore arguments and *jump* to the target, leaving the lr + * pointing back to the original caller. + */ +.macro INVOKE_TRAMPOLINE c_name, cxx_name + .extern \cxx_name +ENTRY \c_name + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME @ save callee saves in case allocation triggers GC + ldr r2, [sp, #48] @ pass caller Method* + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + bl \cxx_name @ (method_idx, this, caller, Thread*, SP) + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + mov r12, r1 @ save Method*->code_ + RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME + cmp r0, #0 @ did we find the target? + bxne r12 @ tail call to target if so + DELIVER_PENDING_EXCEPTION +END \c_name +.endm + +INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline +INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck + +INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck +INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck +INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck +INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck + + /* + * Portable invocation stub. + * On entry: + * r0 = method pointer + * r1 = argument array or NULL for no argument methods + * r2 = size of argument array in bytes + * r3 = (managed) thread pointer + * [sp] = JValue* result + * [sp + 4] = result type char + */ +ENTRY art_portable_invoke_stub + push {r0, r4, r5, r9, r11, lr} @ spill regs + .save {r0, r4, r5, r9, r11, lr} + .pad #24 + .cfi_adjust_cfa_offset 24 + .cfi_rel_offset r0, 0 + .cfi_rel_offset r4, 4 + .cfi_rel_offset r5, 8 + .cfi_rel_offset r9, 12 + .cfi_rel_offset r11, 16 + .cfi_rel_offset lr, 20 + mov r11, sp @ save the stack pointer + .cfi_def_cfa_register r11 + mov r9, r3 @ move managed thread pointer into r9 + mov r4, #SUSPEND_CHECK_INTERVAL @ reset r4 to suspend check interval + add r5, r2, #16 @ create space for method pointer in frame + and r5, #0xFFFFFFF0 @ align frame size to 16 bytes + sub sp, r5 @ reserve stack space for argument array + add r0, sp, #4 @ pass stack pointer + method ptr as dest for memcpy + bl memcpy @ memcpy (dest, src, bytes) + ldr r0, [r11] @ restore method* + ldr r1, [sp, #4] @ copy arg value for r1 + ldr r2, [sp, #8] @ copy arg value for r2 + ldr r3, [sp, #12] @ copy arg value for r3 + mov ip, #0 @ set ip to 0 + str ip, [sp] @ store NULL for method* at bottom of frame + add sp, #16 @ first 4 args are not passed on stack for portable + ldr ip, [r0, #METHOD_CODE_OFFSET] @ get pointer to the code + blx ip @ call the method + mov sp, r11 @ restore the stack pointer + ldr ip, [sp, #24] @ load the result pointer + strd r0, [ip] @ store r0/r1 into result pointer + pop {r0, r4, r5, r9, r11, lr} @ restore spill regs + .cfi_adjust_cfa_offset -24 + bx lr +END art_portable_invoke_stub + + /* + * Quick invocation stub. + * On entry: + * r0 = method pointer + * r1 = argument array or NULL for no argument methods + * r2 = size of argument array in bytes + * r3 = (managed) thread pointer + * [sp] = JValue* result + * [sp + 4] = result type char + */ +ENTRY art_quick_invoke_stub + push {r0, r4, r5, r9, r11, lr} @ spill regs + .save {r0, r4, r5, r9, r11, lr} + .pad #24 + .cfi_adjust_cfa_offset 24 + .cfi_rel_offset r0, 0 + .cfi_rel_offset r4, 4 + .cfi_rel_offset r5, 8 + .cfi_rel_offset r9, 12 + .cfi_rel_offset r11, 16 + .cfi_rel_offset lr, 20 + mov r11, sp @ save the stack pointer + .cfi_def_cfa_register r11 + mov r9, r3 @ move managed thread pointer into r9 + mov r4, #SUSPEND_CHECK_INTERVAL @ reset r4 to suspend check interval + add r5, r2, #16 @ create space for method pointer in frame + and r5, #0xFFFFFFF0 @ align frame size to 16 bytes + sub sp, r5 @ reserve stack space for argument array + add r0, sp, #4 @ pass stack pointer + method ptr as dest for memcpy + bl memcpy @ memcpy (dest, src, bytes) + ldr r0, [r11] @ restore method* + ldr r1, [sp, #4] @ copy arg value for r1 + ldr r2, [sp, #8] @ copy arg value for r2 + ldr r3, [sp, #12] @ copy arg value for r3 + mov ip, #0 @ set ip to 0 + str ip, [sp] @ store NULL for method* at bottom of frame + ldr ip, [r0, #METHOD_CODE_OFFSET] @ get pointer to the code + blx ip @ call the method + mov sp, r11 @ restore the stack pointer + ldr ip, [sp, #24] @ load the result pointer + strd r0, [ip] @ store r0/r1 into result pointer + pop {r0, r4, r5, r9, r11, lr} @ restore spill regs + .cfi_adjust_cfa_offset -24 + bx lr +END art_quick_invoke_stub + + /* + * On entry r0 is uint32_t* gprs_ and r1 is uint32_t* fprs_ + */ +ENTRY art_quick_do_long_jump + vldm r1, {s0-s31} @ load all fprs from argument fprs_ + ldr r2, [r0, #60] @ r2 = r15 (PC from gprs_ 60=4*15) + add r0, r0, #12 @ increment r0 to skip gprs_[0..2] 12=4*3 + ldm r0, {r3-r14} @ load remaining gprs from argument gprs_ + mov r0, #0 @ clear result registers r0 and r1 + mov r1, #0 + bx r2 @ do long jump +END art_quick_do_long_jump + + /* + * Entry point of native methods when JNI bug compatibility is enabled. + */ + .extern artWorkAroundAppJniBugs +ENTRY art_quick_work_around_app_jni_bugs + @ save registers that may contain arguments and LR that will be crushed by a call + push {r0-r3, lr} + .save {r0-r3, lr} + .cfi_adjust_cfa_offset 16 + .cfi_rel_offset r0, 0 + .cfi_rel_offset r1, 4 + .cfi_rel_offset r2, 8 + .cfi_rel_offset r3, 12 + sub sp, #12 @ 3 words of space for alignment + mov r0, r9 @ pass Thread::Current + mov r1, sp @ pass SP + bl artWorkAroundAppJniBugs @ (Thread*, SP) + add sp, #12 @ rewind stack + mov r12, r0 @ save target address + pop {r0-r3, lr} @ restore possibly modified argument registers + .cfi_adjust_cfa_offset -16 + bx r12 @ tail call into JNI routine +END art_quick_work_around_app_jni_bugs + + /* + * Entry from managed code that calls artHandleFillArrayDataFromCode and delivers exception on + * failure. + */ + .extern artHandleFillArrayDataFromCode +ENTRY art_quick_handle_fill_data_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artHandleFillArrayDataFromCode @ (Array*, const DexFile::Payload*, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success? + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_handle_fill_data_from_code + + /* + * Entry from managed code that calls artLockObjectFromCode, may block for GC. + */ + .extern artLockObjectFromCode +ENTRY art_quick_lock_object_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block + mov r1, r9 @ pass Thread::Current + mov r2, sp @ pass SP + bl artLockObjectFromCode @ (Object* obj, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN +END art_quick_lock_object_from_code + + /* + * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. + */ + .extern artUnlockObjectFromCode +ENTRY art_quick_unlock_object_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC + mov r1, r9 @ pass Thread::Current + mov r2, sp @ pass SP + bl artUnlockObjectFromCode @ (Object* obj, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success? + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_unlock_object_from_code + + /* + * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. + */ + .extern artCheckCastFromCode +ENTRY art_quick_check_cast_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artCheckCastFromCode @ (Class* a, Class* b, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success? + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_check_cast_from_code + + /* + * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on + * failure. + */ + .extern artCanPutArrayElementFromCode +ENTRY art_quick_can_put_array_element_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artCanPutArrayElementFromCode @ (Object* element, Class* array_class, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success? + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_can_put_array_element_from_code + + /* + * Entry from managed code when uninitialized static storage, this stub will run the class + * initializer and deliver the exception on error. On success the static storage base is + * returned. + */ + .extern artInitializeStaticStorageFromCode +ENTRY art_quick_initialize_static_storage_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + @ artInitializeStaticStorageFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) + bl artInitializeStaticStorageFromCode + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_initialize_static_storage_from_code + + /* + * Entry from managed code when dex cache misses for a type_idx + */ + .extern artInitializeTypeFromCode +ENTRY art_quick_initialize_type_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + @ artInitializeTypeFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) + bl artInitializeTypeFromCode + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_initialize_type_from_code + + /* + * Entry from managed code when type_idx needs to be checked for access and dex cache may also + * miss. + */ + .extern artInitializeTypeAndVerifyAccessFromCode +ENTRY art_quick_initialize_type_and_verify_access_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + @ artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, Method* referrer, Thread*, SP) + bl artInitializeTypeAndVerifyAccessFromCode + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_initialize_type_and_verify_access_from_code + + /* + * Called by managed code to resolve a static field and load a 32-bit primitive value. + */ + .extern artGet32StaticFromCode +ENTRY art_quick_get32_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r1, [sp, #32] @ pass referrer + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artGet32StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get32_static_from_code + + /* + * Called by managed code to resolve a static field and load a 64-bit primitive value. + */ + .extern artGet64StaticFromCode +ENTRY art_quick_get64_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r1, [sp, #32] @ pass referrer + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artGet64StaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get64_static_from_code + + /* + * Called by managed code to resolve a static field and load an object reference. + */ + .extern artGetObjStaticFromCode +ENTRY art_quick_get_obj_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r1, [sp, #32] @ pass referrer + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artGetObjStaticFromCode @ (uint32_t field_idx, const Method* referrer, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get_obj_static_from_code + + /* + * Called by managed code to resolve an instance field and load a 32-bit primitive value. + */ + .extern artGet32InstanceFromCode +ENTRY art_quick_get32_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r2, [sp, #32] @ pass referrer + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + bl artGet32InstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) + add sp, #16 @ strip the extra frame + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get32_instance_from_code + + /* + * Called by managed code to resolve an instance field and load a 64-bit primitive value. + */ + .extern artGet64InstanceFromCode +ENTRY art_quick_get64_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r2, [sp, #32] @ pass referrer + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + bl artGet64InstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get64_instance_from_code + + /* + * Called by managed code to resolve an instance field and load an object reference. + */ + .extern artGetObjInstanceFromCode +ENTRY art_quick_get_obj_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r2, [sp, #32] @ pass referrer + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + bl artGetObjInstanceFromCode @ (field_idx, Object*, referrer, Thread*, SP) + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_get_obj_instance_from_code + + /* + * Called by managed code to resolve a static field and store a 32-bit primitive value. + */ + .extern artSet32StaticFromCode +ENTRY art_quick_set32_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r2, [sp, #32] @ pass referrer + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + bl artSet32StaticFromCode @ (field_idx, new_val, referrer, Thread*, SP) + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set32_static_from_code + + /* + * Called by managed code to resolve a static field and store a 64-bit primitive value. + * On entry r0 holds field index, r1:r2 hold new_val + */ + .extern artSet64StaticFromCode +ENTRY art_quick_set64_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r3, r2 @ pass one half of wide argument + mov r2, r1 @ pass other half of wide argument + ldr r1, [sp, #32] @ pass referrer + mov r12, sp @ save SP + sub sp, #8 @ grow frame for alignment with stack args + .pad #8 + .cfi_adjust_cfa_offset 8 + push {r9, r12} @ pass Thread::Current and SP + .save {r9, r12} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r9, 0 + bl artSet64StaticFromCode @ (field_idx, referrer, new_val, Thread*, SP) + add sp, #16 @ release out args + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set64_static_from_code + + /* + * Called by managed code to resolve a static field and store an object reference. + */ + .extern artSetObjStaticFromCode +ENTRY art_quick_set_obj_static_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r2, [sp, #32] @ pass referrer + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + bl artSetObjStaticFromCode @ (field_idx, new_val, referrer, Thread*, SP) + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set_obj_static_from_code + + /* + * Called by managed code to resolve an instance field and store a 32-bit primitive value. + */ + .extern artSet32InstanceFromCode +ENTRY art_quick_set32_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r3, [sp, #32] @ pass referrer + mov r12, sp @ save SP + sub sp, #8 @ grow frame for alignment with stack args + .pad #8 + .cfi_adjust_cfa_offset 8 + push {r9, r12} @ pass Thread::Current and SP + .save {r9, r12} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r9, 0 + .cfi_rel_offset r12, 4 + bl artSet32InstanceFromCode @ (field_idx, Object*, new_val, referrer, Thread*, SP) + add sp, #16 @ release out args + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set32_instance_from_code + + /* + * Called by managed code to resolve an instance field and store a 64-bit primitive value. + */ + .extern artSet32InstanceFromCode +ENTRY art_quick_set64_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r12, sp @ save SP + sub sp, #8 @ grow frame for alignment with stack args + .pad #8 + .cfi_adjust_cfa_offset 8 + push {r9, r12} @ pass Thread::Current and SP + .save {r9, r12} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r9, 0 + bl artSet64InstanceFromCode @ (field_idx, Object*, new_val, Thread*, SP) + add sp, #16 @ release out args + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set64_instance_from_code + + /* + * Called by managed code to resolve an instance field and store an object reference. + */ + .extern artSetObjInstanceFromCode +ENTRY art_quick_set_obj_instance_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + ldr r3, [sp, #32] @ pass referrer + mov r12, sp @ save SP + sub sp, #8 @ grow frame for alignment with stack args + .pad #8 + .cfi_adjust_cfa_offset 8 + push {r9, r12} @ pass Thread::Current and SP + .save {r9, r12} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r9, 0 + bl artSetObjInstanceFromCode @ (field_idx, Object*, new_val, referrer, Thread*, SP) + add sp, #16 @ release out args + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME @ TODO: we can clearly save an add here + cmp r0, #0 @ success if result is 0 + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_set_obj_instance_from_code + + /* + * Entry from managed code to resolve a string, this stub will allocate a String and deliver an + * exception on error. On success the String is returned. R0 holds the referring method, + * R1 holds the string index. The fast path check for hit in strings cache has already been + * performed. + */ + .extern artResolveStringFromCode +ENTRY art_quick_resolve_string_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + @ artResolveStringFromCode(Method* referrer, uint32_t string_idx, Thread*, SP) + bl artResolveStringFromCode + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_resolve_string_from_code + + /* + * Called by managed code to allocate an object + */ + .extern artAllocObjectFromCode +ENTRY art_quick_alloc_object_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artAllocObjectFromCode @ (uint32_t type_idx, Method* method, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_alloc_object_from_code + + /* + * Called by managed code to allocate an object when the caller doesn't know whether it has + * access to the created type. + */ + .extern artAllocObjectFromCodeWithAccessCheck +ENTRY art_quick_alloc_object_from_code_with_access_check + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + bl artAllocObjectFromCodeWithAccessCheck @ (uint32_t type_idx, Method* method, Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_alloc_object_from_code_with_access_check + + /* + * Called by managed code to allocate an array. + */ + .extern artAllocArrayFromCode +ENTRY art_quick_alloc_array_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + @ artAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t component_count, Thread*, SP) + bl artAllocArrayFromCode + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_alloc_array_from_code + + /* + * Called by managed code to allocate an array when the caller doesn't know whether it has + * access to the created type. + */ + .extern artAllocArrayFromCodeWithAccessCheck +ENTRY art_quick_alloc_array_from_code_with_access_check + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + @ artAllocArrayFromCodeWithAccessCheck(type_idx, method, component_count, Thread*, SP) + bl artAllocArrayFromCodeWithAccessCheck + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_alloc_array_from_code_with_access_check + + /* + * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. + */ + .extern artCheckAndAllocArrayFromCode +ENTRY art_quick_check_and_alloc_array_from_code + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + @ artCheckAndAllocArrayFromCode(uint32_t type_idx, Method* method, int32_t count, Thread* , SP) + bl artCheckAndAllocArrayFromCode + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_check_and_alloc_array_from_code + + /* + * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. + */ + .extern artCheckAndAllocArrayFromCodeWithAccessCheck +ENTRY art_quick_check_and_alloc_array_from_code_with_access_check + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC + mov r3, r9 @ pass Thread::Current + mov r12, sp + str r12, [sp, #-16]! @ expand the frame and pass SP + .pad #16 + .cfi_adjust_cfa_offset 16 + @ artCheckAndAllocArrayFromCodeWithAccessCheck(type_idx, method, count, Thread* , SP) + bl artCheckAndAllocArrayFromCodeWithAccessCheck + add sp, #16 @ strip the extra frame + .cfi_adjust_cfa_offset -16 + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME + cmp r0, #0 @ success if result is non-null + bxne lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_check_and_alloc_array_from_code_with_access_check + + /* + * Called by managed code when the value in rSUSPEND has been decremented to 0. + */ + .extern artTestSuspendFromCode +ENTRY art_quick_test_suspend + ldrh r0, [rSELF, #THREAD_FLAGS_OFFSET] + mov rSUSPEND, #SUSPEND_CHECK_INTERVAL @ reset rSUSPEND to SUSPEND_CHECK_INTERVAL + cmp r0, #0 @ check Thread::Current()->suspend_count_ == 0 + bxeq lr @ return if suspend_count_ == 0 + mov r0, rSELF + SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves for stack crawl + mov r1, sp + bl artTestSuspendFromCode @ (Thread*, SP) + RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN +END art_quick_test_suspend + + .extern artPortableProxyInvokeHandler +ENTRY art_portable_proxy_invoke_handler + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + str r0, [sp, #0] @ place proxy method at bottom of frame + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + blx artPortableProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + ldr lr, [sp, #44] @ restore lr + add sp, #48 @ pop frame + .cfi_adjust_cfa_offset -48 + bx lr @ return +END art_portable_proxy_invoke_handler + + /* + * Called by managed code that is attempting to call a method on a proxy class. On entry + * r0 holds the proxy method and r1 holds the receiver; r2 and r3 may contain arguments. The + * frame size of the invoked proxy method agrees with a ref and args callee save frame. + */ + .extern artQuickProxyInvokeHandler +ENTRY art_quick_proxy_invoke_handler + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + str r0, [sp, #0] @ place proxy method at bottom of frame + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + blx artQuickProxyInvokeHandler @ (Method* proxy method, receiver, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + ldr lr, [sp, #44] @ restore lr + add sp, #48 @ pop frame + .cfi_adjust_cfa_offset -48 + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_proxy_invoke_handler + + .extern artInterpreterEntry +ENTRY art_quick_interpreter_entry + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + str r0, [sp, #0] @ place proxy method at bottom of frame + mov r1, r9 @ pass Thread::Current + mov r2, sp @ pass SP + blx artInterpreterEntry @ (Method* method, Thread*, SP) + ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ + ldr lr, [sp, #44] @ restore lr + add sp, #48 @ pop frame + .cfi_adjust_cfa_offset -48 + cmp r12, #0 @ success if no exception is pending + bxeq lr @ return on success + DELIVER_PENDING_EXCEPTION +END art_quick_interpreter_entry + + /* + * Routine that intercepts method calls and returns. + */ + .extern artInstrumentationMethodEntryFromCode + .extern artInstrumentationMethodExitFromCode +ENTRY art_quick_instrumentation_entry_from_code + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + str r0, [sp, #4] @ preserve r0 + mov r12, sp @ remember sp + str lr, [sp, #-16]! @ expand the frame and pass LR + .pad #16 + .cfi_adjust_cfa_offset 16 + .cfi_rel_offset lr, 0 + mov r2, r9 @ pass Thread::Current + mov r3, r12 @ pass SP + blx artInstrumentationMethodEntryFromCode @ (Method*, Object*, Thread*, SP, LR) + add sp, #16 @ remove out argument and padding from stack + .cfi_adjust_cfa_offset -16 + mov r12, r0 @ r12 holds reference to code + ldr r0, [sp, #4] @ restore r0 + RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME + blx r12 @ call method with lr set to art_quick_instrumentation_exit_from_code +END art_quick_instrumentation_entry_from_code + .type art_quick_instrumentation_exit_from_code, #function + .global art_quick_instrumentation_exit_from_code +art_quick_instrumentation_exit_from_code: + .cfi_startproc + .fnstart + mov lr, #0 @ link register is to here, so clobber with 0 for later checks + SETUP_REF_ONLY_CALLEE_SAVE_FRAME + mov r12, sp @ remember bottom of caller's frame + push {r0-r1} @ save return value + .save {r0-r1} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r0, 0 + .cfi_rel_offset r1, 4 + sub sp, #8 @ space for return value argument + .pad #8 + .cfi_adjust_cfa_offset 8 + strd r0, [sp] @ r0/r1 -> [sp] for fpr_res + mov r2, r0 @ pass return value as gpr_res + mov r3, r1 + mov r0, r9 @ pass Thread::Current + mov r1, r12 @ pass SP + blx artInstrumentationMethodExitFromCode @ (Thread*, SP, gpr_res, fpr_res) + add sp, #8 + .cfi_adjust_cfa_offset -8 + + mov r2, r0 @ link register saved by instrumentation + mov lr, r1 @ r1 is holding link register if we're to bounce to deoptimize + pop {r0, r1} @ restore return value + add sp, #32 @ remove callee save frame + .cfi_adjust_cfa_offset -32 + bx r2 @ return +END art_quick_instrumentation_exit_from_code + + /* + * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization + * will long jump to the upcall with a special exception of -1. + */ + .extern artDeoptimize +ENTRY art_quick_deoptimize + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME + mov r0, r9 @ Set up args. + mov r1, sp + blx artDeoptimize @ artDeoptimize(Thread*, SP) +END art_quick_deoptimize + + /* + * Portable abstract method error stub. r0 contains method* on entry. SP unused in portable. + */ + .extern artThrowAbstractMethodErrorFromCode +ENTRY art_portable_abstract_method_error_stub + mov r1, r9 @ pass Thread::Current + b artThrowAbstractMethodErrorFromCode @ (Method*, Thread*, SP) +END art_portable_abstract_method_error_stub + + /* + * Quick abstract method error stub. r0 contains method* on entry. + */ +ENTRY art_quick_abstract_method_error_stub + SETUP_SAVE_ALL_CALLEE_SAVE_FRAME + mov r1, r9 @ pass Thread::Current + mov r2, sp @ pass SP + b artThrowAbstractMethodErrorFromCode @ (Method*, Thread*, SP) +END art_quick_abstract_method_error_stub + + /* + * Jni dlsym lookup stub. + */ + .extern artFindNativeMethod +ENTRY art_jni_dlsym_lookup_stub + push {r0, r1, r2, r3, lr} @ spill regs + .save {r0, r1, r2, r3, lr} + .pad #20 + .cfi_adjust_cfa_offset 20 + sub sp, #12 @ pad stack pointer to align frame + .pad #12 + .cfi_adjust_cfa_offset 12 + mov r0, r9 @ pass Thread::Current + blx artFindNativeMethod @ (Thread*) + mov r12, r0 @ save result in r12 + add sp, #12 @ restore stack pointer + .cfi_adjust_cfa_offset -12 + pop {r0, r1, r2, r3, lr} @ restore regs + .cfi_adjust_cfa_offset -20 + cmp r12, #0 @ is method code null? + bxne r12 @ if non-null, tail call to method's code + bx lr @ otherwise, return to caller to handle exception +END art_jni_dlsym_lookup_stub + + /* + * Signed 64-bit integer multiply. + * + * Consider WXxYZ (r1r0 x r3r2) with a long multiply: + * WX + * x YZ + * -------- + * ZW ZX + * YW YX + * + * The low word of the result holds ZX, the high word holds + * (ZW+YX) + (the high overflow from ZX). YW doesn't matter because + * it doesn't fit in the low 64 bits. + * + * Unlike most ARM math operations, multiply instructions have + * restrictions on using the same register more than once (Rd and Rm + * cannot be the same). + */ + /* mul-long vAA, vBB, vCC */ +ENTRY art_quick_mul_long + push {r9 - r10} + .save {r9 - r10} + .cfi_adjust_cfa_offset 8 + .cfi_rel_offset r9, 0 + .cfi_rel_offset r10, 4 + mul ip, r2, r1 @ ip<- ZxW + umull r9, r10, r2, r0 @ r9/r10 <- ZxX + mla r2, r0, r3, ip @ r2<- YxX + (ZxW) + add r10, r2, r10 @ r10<- r10 + low(ZxW + (YxX)) + mov r0,r9 + mov r1,r10 + pop {r9 - r10} + .cfi_adjust_cfa_offset -8 + bx lr +END art_quick_mul_long + + /* + * Long integer shift. This is different from the generic 32/64-bit + * binary operations because vAA/vBB are 64-bit but vCC (the shift + * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low + * 6 bits. + * On entry: + * r0: low word + * r1: high word + * r2: shift count + */ + /* shl-long vAA, vBB, vCC */ +ENTRY art_quick_shl_long + and r2, r2, #63 @ r2<- r2 & 0x3f + mov r1, r1, asl r2 @ r1<- r1 << r2 + rsb r3, r2, #32 @ r3<- 32 - r2 + orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2)) + subs ip, r2, #32 @ ip<- r2 - 32 + movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32) + mov r0, r0, asl r2 @ r0<- r0 << r2 + bx lr +END art_quick_shl_long + + /* + * Long integer shift. This is different from the generic 32/64-bit + * binary operations because vAA/vBB are 64-bit but vCC (the shift + * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low + * 6 bits. + * On entry: + * r0: low word + * r1: high word + * r2: shift count + */ + /* shr-long vAA, vBB, vCC */ +ENTRY art_quick_shr_long + and r2, r2, #63 @ r0<- r0 & 0x3f + mov r0, r0, lsr r2 @ r0<- r2 >> r2 + rsb r3, r2, #32 @ r3<- 32 - r2 + orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) + subs ip, r2, #32 @ ip<- r2 - 32 + movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32) + mov r1, r1, asr r2 @ r1<- r1 >> r2 + bx lr +END art_quick_shr_long + + /* + * Long integer shift. This is different from the generic 32/64-bit + * binary operations because vAA/vBB are 64-bit but vCC (the shift + * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low + * 6 bits. + * On entry: + * r0: low word + * r1: high word + * r2: shift count + */ + /* ushr-long vAA, vBB, vCC */ +ENTRY art_quick_ushr_long + and r2, r2, #63 @ r0<- r0 & 0x3f + mov r0, r0, lsr r2 @ r0<- r2 >> r2 + rsb r3, r2, #32 @ r3<- 32 - r2 + orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) + subs ip, r2, #32 @ ip<- r2 - 32 + movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32) + mov r1, r1, lsr r2 @ r1<- r1 >>> r2 + bx lr +END art_quick_ushr_long + + /* + * String's indexOf. + * + * On entry: + * r0: string object (known non-null) + * r1: char to match (known <= 0xFFFF) + * r2: Starting offset in string data + */ +ENTRY art_quick_indexof + push {r4, r10-r11, lr} @ 4 words of callee saves + .save {r4, r10-r11, lr} + .cfi_adjust_cfa_offset 16 + .cfi_rel_offset r4, 0 + .cfi_rel_offset r10, 4 + .cfi_rel_offset r11, 8 + .cfi_rel_offset lr, 12 + ldr r3, [r0, #STRING_COUNT_OFFSET] + ldr r12, [r0, #STRING_OFFSET_OFFSET] + ldr r0, [r0, #STRING_VALUE_OFFSET] + + /* Clamp start to [0..count] */ + cmp r2, #0 + movlt r2, #0 + cmp r2, r3 + movgt r2, r3 + + /* Build a pointer to the start of string data */ + add r0, #STRING_DATA_OFFSET + add r0, r0, r12, lsl #1 + + /* Save a copy in r12 to later compute result */ + mov r12, r0 + + /* Build pointer to start of data to compare and pre-bias */ + add r0, r0, r2, lsl #1 + sub r0, #2 + + /* Compute iteration count */ + sub r2, r3, r2 + + /* + * At this point we have: + * r0: start of data to test + * r1: char to compare + * r2: iteration count + * r12: original start of string data + * r3, r4, r10, r11 available for loading string data + */ + + subs r2, #4 + blt indexof_remainder + +indexof_loop4: + ldrh r3, [r0, #2]! + ldrh r4, [r0, #2]! + ldrh r10, [r0, #2]! + ldrh r11, [r0, #2]! + cmp r3, r1 + beq match_0 + cmp r4, r1 + beq match_1 + cmp r10, r1 + beq match_2 + cmp r11, r1 + beq match_3 + subs r2, #4 + bge indexof_loop4 + +indexof_remainder: + adds r2, #4 + beq indexof_nomatch + +indexof_loop1: + ldrh r3, [r0, #2]! + cmp r3, r1 + beq match_3 + subs r2, #1 + bne indexof_loop1 + +indexof_nomatch: + mov r0, #-1 + pop {r4, r10-r11, pc} + +match_0: + sub r0, #6 + sub r0, r12 + asr r0, r0, #1 + pop {r4, r10-r11, pc} +match_1: + sub r0, #4 + sub r0, r12 + asr r0, r0, #1 + pop {r4, r10-r11, pc} +match_2: + sub r0, #2 + sub r0, r12 + asr r0, r0, #1 + pop {r4, r10-r11, pc} +match_3: + sub r0, r12 + asr r0, r0, #1 + pop {r4, r10-r11, pc} +END art_quick_indexof + + /* + * String's compareTo. + * + * Requires rARG0/rARG1 to have been previously checked for null. Will + * return negative if this's string is < comp, 0 if they are the + * same and positive if >. + * + * On entry: + * r0: this object pointer + * r1: comp object pointer + * + */ + .extern __memcmp16 +ENTRY art_quick_string_compareto + mov r2, r0 @ this to r2, opening up r0 for return value + subs r0, r2, r1 @ Same? + bxeq lr + + push {r4, r7-r12, lr} @ 8 words - keep alignment + .save {r4, r7-r12, lr} + .cfi_adjust_cfa_offset 32 + .cfi_rel_offset r4, 0 + .cfi_rel_offset r7, 4 + .cfi_rel_offset r8, 8 + .cfi_rel_offset r9, 12 + .cfi_rel_offset r10, 16 + .cfi_rel_offset r11, 20 + .cfi_rel_offset r12, 24 + .cfi_rel_offset lr, 28 + + ldr r4, [r2, #STRING_OFFSET_OFFSET] + ldr r9, [r1, #STRING_OFFSET_OFFSET] + ldr r7, [r2, #STRING_COUNT_OFFSET] + ldr r10, [r1, #STRING_COUNT_OFFSET] + ldr r2, [r2, #STRING_VALUE_OFFSET] + ldr r1, [r1, #STRING_VALUE_OFFSET] + + /* + * At this point, we have: + * value: r2/r1 + * offset: r4/r9 + * count: r7/r10 + * We're going to compute + * r11 <- countDiff + * r10 <- minCount + */ + subs r11, r7, r10 + movls r10, r7 + + /* Now, build pointers to the string data */ + add r2, r2, r4, lsl #1 + add r1, r1, r9, lsl #1 + /* + * Note: data pointers point to previous element so we can use pre-index + * mode with base writeback. + */ + add r2, #STRING_DATA_OFFSET-2 @ offset to contents[-1] + add r1, #STRING_DATA_OFFSET-2 @ offset to contents[-1] + + /* + * At this point we have: + * r2: *this string data + * r1: *comp string data + * r10: iteration count for comparison + * r11: value to return if the first part of the string is equal + * r0: reserved for result + * r3, r4, r7, r8, r9, r12 available for loading string data + */ + + subs r10, #2 + blt do_remainder2 + + /* + * Unroll the first two checks so we can quickly catch early mismatch + * on long strings (but preserve incoming alignment) + */ + + ldrh r3, [r2, #2]! + ldrh r4, [r1, #2]! + ldrh r7, [r2, #2]! + ldrh r8, [r1, #2]! + subs r0, r3, r4 + subeqs r0, r7, r8 + bne done + cmp r10, #28 + bgt do_memcmp16 + subs r10, #3 + blt do_remainder + +loopback_triple: + ldrh r3, [r2, #2]! + ldrh r4, [r1, #2]! + ldrh r7, [r2, #2]! + ldrh r8, [r1, #2]! + ldrh r9, [r2, #2]! + ldrh r12,[r1, #2]! + subs r0, r3, r4 + subeqs r0, r7, r8 + subeqs r0, r9, r12 + bne done + subs r10, #3 + bge loopback_triple + +do_remainder: + adds r10, #3 + beq returnDiff + +loopback_single: + ldrh r3, [r2, #2]! + ldrh r4, [r1, #2]! + subs r0, r3, r4 + bne done + subs r10, #1 + bne loopback_single + +returnDiff: + mov r0, r11 + pop {r4, r7-r12, pc} + +do_remainder2: + adds r10, #2 + bne loopback_single + mov r0, r11 + pop {r4, r7-r12, pc} + + /* Long string case */ +do_memcmp16: + mov r7, r11 + add r0, r2, #2 + add r1, r1, #2 + mov r2, r10 + bl __memcmp16 + cmp r0, #0 + moveq r0, r7 +done: + pop {r4, r7-r12, pc} +END art_quick_string_compareto diff --git a/runtime/arch/arm/quick_entrypoints_init_arm.cc b/runtime/arch/arm/quick_entrypoints_init_arm.cc new file mode 100644 index 0000000..2f66b36 --- /dev/null +++ b/runtime/arch/arm/quick_entrypoints_init_arm.cc @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "entrypoints/quick/quick_entrypoints.h" +#include "runtime_support.h" + +namespace art { + +// Alloc entrypoints. +extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method); +extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); +extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t); +extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); + +// Cast entrypoints. +extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, + const mirror::Class* ref_class); +extern "C" void art_quick_can_put_array_element_from_code(void*, void*); +extern "C" void art_quick_check_cast_from_code(void*, void*); + +// DexCache entrypoints. +extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*); +extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*); +extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*); +extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t); + +// Exception entrypoints. +extern "C" void* GetAndClearException(Thread*); + +// Field entrypoints. +extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t); +extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t); +extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t); +extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t); +extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*); +extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*); +extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*); +extern "C" int32_t art_quick_get32_static_from_code(uint32_t); +extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*); +extern "C" int64_t art_quick_get64_static_from_code(uint32_t); +extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*); +extern "C" void* art_quick_get_obj_static_from_code(uint32_t); + +// FillArray entrypoint. +extern "C" void art_quick_handle_fill_data_from_code(void*, void*); + +// Lock entrypoints. +extern "C" void art_quick_lock_object_from_code(void*); +extern "C" void art_quick_unlock_object_from_code(void*); + +// Math entrypoints. +extern int32_t CmpgDouble(double a, double b); +extern int32_t CmplDouble(double a, double b); +extern int32_t CmpgFloat(float a, float b); +extern int32_t CmplFloat(float a, float b); + +// Math conversions. +extern "C" int32_t __aeabi_f2iz(float op1); // FLOAT_TO_INT +extern "C" int32_t __aeabi_d2iz(double op1); // DOUBLE_TO_INT +extern "C" float __aeabi_l2f(int64_t op1); // LONG_TO_FLOAT +extern "C" double __aeabi_l2d(int64_t op1); // LONG_TO_DOUBLE + +// Single-precision FP arithmetics. +extern "C" float fmodf(float a, float b); // REM_FLOAT[_2ADDR] + +// Double-precision FP arithmetics. +extern "C" double fmod(double a, double b); // REM_DOUBLE[_2ADDR] + +// Integer arithmetics. +extern "C" int __aeabi_idivmod(int32_t, int32_t); // [DIV|REM]_INT[_2ADDR|_LIT8|_LIT16] + +// Long long arithmetics - REM_LONG[_2ADDR] and DIV_LONG[_2ADDR] +extern "C" int64_t __aeabi_ldivmod(int64_t, int64_t); +extern "C" int64_t art_quick_mul_long(int64_t, int64_t); +extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t); +extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t); +extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t); + +// Interpreter entrypoints. +extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); +extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); + +// Intrinsic entrypoints. +extern "C" int32_t __memcmp16(void*, void*, int32_t); +extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); +extern "C" int32_t art_quick_string_compareto(void*, void*); + +// Invoke entrypoints. +extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, + mirror::Object* receiver, + mirror::AbstractMethod** sp, Thread* thread); +extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, + mirror::Object* receiver, + mirror::AbstractMethod** sp, Thread* thread); +extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); +extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); +extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); +extern "C" void art_quick_invoke_static_trampoline_with_access_check(uint32_t, void*); +extern "C" void art_quick_invoke_super_trampoline_with_access_check(uint32_t, void*); +extern "C" void art_quick_invoke_virtual_trampoline_with_access_check(uint32_t, void*); + +// Thread entrypoints. +extern void CheckSuspendFromCode(Thread* thread); +extern "C" void art_quick_test_suspend(); + +// Throw entrypoints. +extern "C" void art_quick_deliver_exception_from_code(void*); +extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit); +extern "C" void art_quick_throw_div_zero_from_code(); +extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx); +extern "C" void art_quick_throw_null_pointer_exception_from_code(); +extern "C" void art_quick_throw_stack_overflow_from_code(void*); + +void InitEntryPoints(QuickEntryPoints* points) { + // Alloc + points->pAllocArrayFromCode = art_quick_alloc_array_from_code; + points->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check; + points->pAllocObjectFromCode = art_quick_alloc_object_from_code; + points->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check; + points->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code; + points->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check; + + // Cast + points->pInstanceofNonTrivialFromCode = artIsAssignableFromCode; + points->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code; + points->pCheckCastFromCode = art_quick_check_cast_from_code; + + // DexCache + points->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code; + points->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code; + points->pInitializeTypeFromCode = art_quick_initialize_type_from_code; + points->pResolveStringFromCode = art_quick_resolve_string_from_code; + + // Field + points->pSet32Instance = art_quick_set32_instance_from_code; + points->pSet32Static = art_quick_set32_static_from_code; + points->pSet64Instance = art_quick_set64_instance_from_code; + points->pSet64Static = art_quick_set64_static_from_code; + points->pSetObjInstance = art_quick_set_obj_instance_from_code; + points->pSetObjStatic = art_quick_set_obj_static_from_code; + points->pGet32Instance = art_quick_get32_instance_from_code; + points->pGet64Instance = art_quick_get64_instance_from_code; + points->pGetObjInstance = art_quick_get_obj_instance_from_code; + points->pGet32Static = art_quick_get32_static_from_code; + points->pGet64Static = art_quick_get64_static_from_code; + points->pGetObjStatic = art_quick_get_obj_static_from_code; + + // FillArray + points->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code; + + // JNI + points->pJniMethodStart = JniMethodStart; + points->pJniMethodStartSynchronized = JniMethodStartSynchronized; + points->pJniMethodEnd = JniMethodEnd; + points->pJniMethodEndSynchronized = JniMethodEndSynchronized; + points->pJniMethodEndWithReference = JniMethodEndWithReference; + points->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; + + // Locks + points->pLockObjectFromCode = art_quick_lock_object_from_code; + points->pUnlockObjectFromCode = art_quick_unlock_object_from_code; + + // Math + points->pCmpgDouble = CmpgDouble; + points->pCmpgFloat = CmpgFloat; + points->pCmplDouble = CmplDouble; + points->pCmplFloat = CmplFloat; + points->pFmod = fmod; + points->pSqrt = sqrt; + points->pL2d = __aeabi_l2d; + points->pFmodf = fmodf; + points->pL2f = __aeabi_l2f; + points->pD2iz = __aeabi_d2iz; + points->pF2iz = __aeabi_f2iz; + points->pIdivmod = __aeabi_idivmod; + points->pD2l = art_d2l; + points->pF2l = art_f2l; + points->pLdiv = __aeabi_ldivmod; + points->pLdivmod = __aeabi_ldivmod; // result returned in r2:r3 + points->pLmul = art_quick_mul_long; + points->pShlLong = art_quick_shl_long; + points->pShrLong = art_quick_shr_long; + points->pUshrLong = art_quick_ushr_long; + + // Interpreter + points->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry; + points->pInterpreterToQuickEntry = artInterpreterToQuickEntry; + + // Intrinsics + points->pIndexOf = art_quick_indexof; + points->pMemcmp16 = __memcmp16; + points->pStringCompareTo = art_quick_string_compareto; + points->pMemcpy = memcpy; + + // Invocation + points->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline; + points->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline; + points->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; + points->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline; + points->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; + points->pInvokeStaticTrampolineWithAccessCheck = art_quick_invoke_static_trampoline_with_access_check; + points->pInvokeSuperTrampolineWithAccessCheck = art_quick_invoke_super_trampoline_with_access_check; + points->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; + + // Thread + points->pCheckSuspendFromCode = CheckSuspendFromCode; + points->pTestSuspendFromCode = art_quick_test_suspend; + + // Throws + points->pDeliverException = art_quick_deliver_exception_from_code; + points->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code; + points->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code; + points->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code; + points->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code; + points->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code; +}; + +} // namespace art diff --git a/runtime/arch/arm/registers_arm.cc b/runtime/arch/arm/registers_arm.cc new file mode 100644 index 0000000..4f04647 --- /dev/null +++ b/runtime/arch/arm/registers_arm.cc @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "registers_arm.h" + +#include <ostream> + +namespace art { +namespace arm { + +static const char* kRegisterNames[] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", + "fp", "ip", "sp", "lr", "pc" +}; +std::ostream& operator<<(std::ostream& os, const Register& rhs) { + if (rhs >= R0 && rhs <= PC) { + os << kRegisterNames[rhs]; + } else { + os << "Register[" << static_cast<int>(rhs) << "]"; + } + return os; +} + +std::ostream& operator<<(std::ostream& os, const SRegister& rhs) { + if (rhs >= S0 && rhs < kNumberOfSRegisters) { + os << "s" << static_cast<int>(rhs); + } else { + os << "SRegister[" << static_cast<int>(rhs) << "]"; + } + return os; +} + +} // namespace arm +} // namespace art diff --git a/runtime/arch/arm/registers_arm.h b/runtime/arch/arm/registers_arm.h new file mode 100644 index 0000000..932095d --- /dev/null +++ b/runtime/arch/arm/registers_arm.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_ARCH_ARM_REGISTERS_ARM_H_ +#define ART_RUNTIME_ARCH_ARM_REGISTERS_ARM_H_ + +#include <iosfwd> + +namespace art { +namespace arm { + +// Values for registers. +enum Register { + R0 = 0, + R1 = 1, + R2 = 2, + R3 = 3, + R4 = 4, + R5 = 5, + R6 = 6, + R7 = 7, + R8 = 8, + R9 = 9, + R10 = 10, + R11 = 11, + R12 = 12, + R13 = 13, + R14 = 14, + R15 = 15, + TR = 9, // thread register + FP = 11, + IP = 12, + SP = 13, + LR = 14, + PC = 15, + kNumberOfCoreRegisters = 16, + kNoRegister = -1, +}; +std::ostream& operator<<(std::ostream& os, const Register& rhs); + + +// Values for single-precision floating point registers. +enum SRegister { + S0 = 0, + S1 = 1, + S2 = 2, + S3 = 3, + S4 = 4, + S5 = 5, + S6 = 6, + S7 = 7, + S8 = 8, + S9 = 9, + S10 = 10, + S11 = 11, + S12 = 12, + S13 = 13, + S14 = 14, + S15 = 15, + S16 = 16, + S17 = 17, + S18 = 18, + S19 = 19, + S20 = 20, + S21 = 21, + S22 = 22, + S23 = 23, + S24 = 24, + S25 = 25, + S26 = 26, + S27 = 27, + S28 = 28, + S29 = 29, + S30 = 30, + S31 = 31, + kNumberOfSRegisters = 32, + kNoSRegister = -1, +}; +std::ostream& operator<<(std::ostream& os, const SRegister& rhs); + +} // namespace arm +} // namespace art + +#endif // ART_RUNTIME_ARCH_ARM_REGISTERS_ARM_H_ |