diff options
Diffstat (limited to 'compiler/dex/quick/gen_invoke.cc')
-rw-r--r-- | compiler/dex/quick/gen_invoke.cc | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 1b34e99..20d683a 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -37,12 +37,12 @@ namespace art { * has a memory call operation, part 1 is a NOP for x86. For other targets, * load arguments between the two parts. */ -int Mir2Lir::CallHelperSetup(int helper_offset) { +int Mir2Lir::CallHelperSetup(ThreadOffset helper_offset) { return (cu_->instruction_set == kX86) ? 0 : LoadHelper(helper_offset); } /* NOTE: if r_tgt is a temp, it will be freed following use */ -LIR* Mir2Lir::CallHelper(int r_tgt, int helper_offset, bool safepoint_pc) { +LIR* Mir2Lir::CallHelper(int r_tgt, ThreadOffset helper_offset, bool safepoint_pc) { LIR* call_inst; if (cu_->instruction_set == kX86) { call_inst = OpThreadMem(kOpBlx, helper_offset); @@ -56,21 +56,22 @@ LIR* Mir2Lir::CallHelper(int r_tgt, int helper_offset, bool safepoint_pc) { return call_inst; } -void Mir2Lir::CallRuntimeHelperImm(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperImm(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadConstant(TargetReg(kArg0), arg0); ClobberCalleeSave(); CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperReg(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperReg(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg0), arg0); ClobberCalleeSave(); CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocation(int helper_offset, RegLocation arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegLocation(ThreadOffset helper_offset, RegLocation arg0, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg0.wide == 0) { LoadValueDirectFixed(arg0, TargetReg(kArg0)); @@ -81,7 +82,7 @@ void Mir2Lir::CallRuntimeHelperRegLocation(int helper_offset, RegLocation arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmImm(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperImmImm(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadConstant(TargetReg(kArg0), arg0); @@ -90,7 +91,7 @@ void Mir2Lir::CallRuntimeHelperImmImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmRegLocation(int helper_offset, int arg0, +void Mir2Lir::CallRuntimeHelperImmRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg1.wide == 0) { @@ -103,7 +104,7 @@ void Mir2Lir::CallRuntimeHelperImmRegLocation(int helper_offset, int arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocationImm(int helper_offset, RegLocation arg0, int arg1, +void Mir2Lir::CallRuntimeHelperRegLocationImm(ThreadOffset helper_offset, RegLocation arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadValueDirectFixed(arg0, TargetReg(kArg0)); @@ -112,7 +113,7 @@ void Mir2Lir::CallRuntimeHelperRegLocationImm(int helper_offset, RegLocation arg CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmReg(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperImmReg(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg1), arg1); @@ -121,8 +122,8 @@ void Mir2Lir::CallRuntimeHelperImmReg(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegImm(int helper_offset, int arg0, int arg1, - bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegImm(ThreadOffset helper_offset, int arg0, int arg1, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg0), arg0); LoadConstant(TargetReg(kArg1), arg1); @@ -130,7 +131,7 @@ void Mir2Lir::CallRuntimeHelperRegImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethod(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperImmMethod(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadCurrMethodDirect(TargetReg(kArg1)); LoadConstant(TargetReg(kArg0), arg0); @@ -138,7 +139,7 @@ void Mir2Lir::CallRuntimeHelperImmMethod(int helper_offset, int arg0, bool safep CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(int helper_offset, RegLocation arg0, +void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(ThreadOffset helper_offset, RegLocation arg0, RegLocation arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg0.wide == 0) { @@ -168,7 +169,8 @@ void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(int helper_offset, RegLoca CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegReg(int helper_offset, int arg0, int arg1, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegReg(ThreadOffset helper_offset, int arg0, int arg1, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); DCHECK_NE(TargetReg(kArg0), arg1); // check copy into arg0 won't clobber arg1 OpRegCopy(TargetReg(kArg0), arg0); @@ -177,7 +179,7 @@ void Mir2Lir::CallRuntimeHelperRegReg(int helper_offset, int arg0, int arg1, boo CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegRegImm(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperRegRegImm(ThreadOffset helper_offset, int arg0, int arg1, int arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); DCHECK_NE(TargetReg(kArg0), arg1); // check copy into arg0 won't clobber arg1 @@ -188,7 +190,7 @@ void Mir2Lir::CallRuntimeHelperRegRegImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(int helper_offset, +void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadValueDirectFixed(arg2, TargetReg(kArg2)); @@ -198,7 +200,7 @@ void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(int helper_offset, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethodImm(int helper_offset, int arg0, +void Mir2Lir::CallRuntimeHelperImmMethodImm(ThreadOffset helper_offset, int arg0, int arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadCurrMethodDirect(TargetReg(kArg1)); @@ -208,7 +210,7 @@ void Mir2Lir::CallRuntimeHelperImmMethodImm(int helper_offset, int arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation(int helper_offset, +void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, RegLocation arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); @@ -470,14 +472,14 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, // Disable sharpening direct_method = 0; } - int trampoline = (cu->instruction_set == kX86) ? 0 - : QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline); if (direct_method != 0) { switch (state) { case 0: // Load the trampoline target [sets kInvokeTgt]. if (cu->instruction_set != kX86) { - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), + cg->TargetReg(kInvokeTgt)); } // Get the interface Method* [sets kArg0] if (direct_method != static_cast<unsigned int>(-1)) { @@ -506,7 +508,8 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, cg->LoadCurrMethodDirect(cg->TargetReg(kArg0)); // Load the trampoline target [sets kInvokeTgt]. if (cu->instruction_set != kX86) { - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), + cg->TargetReg(kInvokeTgt)); } break; case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0] @@ -528,7 +531,7 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, return state + 1; } -static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, +static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, ThreadOffset trampoline, int state, const MethodReference& target_method, uint32_t method_idx) { Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); @@ -539,7 +542,7 @@ static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, if (state == 0) { if (cu->instruction_set != kX86) { // Load trampoline target - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), cg->TargetReg(kInvokeTgt)); } // Load kArg0 with method index CHECK_EQ(cu->dex_file, target_method.dex_file); @@ -555,7 +558,7 @@ static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -563,7 +566,7 @@ static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -571,7 +574,7 @@ static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -579,7 +582,7 @@ static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -589,7 +592,7 @@ static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu, uint32_t unused, uintptr_t unused2, uintptr_t unused3, InvokeType unused4) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -1108,9 +1111,9 @@ bool Mir2Lir::GenInlinedStringCompareTo(CallInfo* info) { bool Mir2Lir::GenInlinedCurrentThread(CallInfo* info) { RegLocation rl_dest = InlineTarget(info); RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); - int offset = Thread::PeerOffset().Int32Value(); + ThreadOffset offset = Thread::PeerOffset(); if (cu_->instruction_set == kThumb2 || cu_->instruction_set == kMips) { - LoadWordDisp(TargetReg(kSelf), offset, rl_result.low_reg); + LoadWordDisp(TargetReg(kSelf), offset.Int32Value(), rl_result.low_reg); } else { CHECK(cu_->instruction_set == kX86); reinterpret_cast<X86Mir2Lir*>(this)->OpRegThreadMem(kOpMov, rl_result.low_reg, offset); @@ -1406,7 +1409,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) { call_inst = OpMem(kOpBlx, TargetReg(kArg0), mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); } else { - int trampoline = 0; + ThreadOffset trampoline(-1); switch (info->type) { case kInterface: trampoline = fast_path ? QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline) |