diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/dex/quick/arm/codegen_arm.h | 2 | ||||
| -rw-r--r-- | compiler/dex/quick/arm/target_arm.cc | 4 | ||||
| -rw-r--r-- | compiler/dex/quick/arm64/codegen_arm64.h | 2 | ||||
| -rw-r--r-- | compiler/dex/quick/arm64/target_arm64.cc | 4 | ||||
| -rw-r--r-- | compiler/dex/quick/gen_common.cc | 14 | ||||
| -rw-r--r-- | compiler/dex/quick/mips/codegen_mips.h | 4 | ||||
| -rw-r--r-- | compiler/dex/quick/mips/target_mips.cc | 42 | ||||
| -rw-r--r-- | compiler/dex/quick/mips/utility_mips.cc | 21 | ||||
| -rw-r--r-- | compiler/dex/quick/mir_to_lir.cc | 6 | ||||
| -rw-r--r-- | compiler/dex/quick/mir_to_lir.h | 2 | ||||
| -rw-r--r-- | compiler/dex/quick/x86/codegen_x86.h | 2 | ||||
| -rwxr-xr-x | compiler/dex/quick/x86/target_x86.cc | 4 | ||||
| -rw-r--r-- | compiler/oat_test.cc | 2 |
13 files changed, 57 insertions, 52 deletions
diff --git a/compiler/dex/quick/arm/codegen_arm.h b/compiler/dex/quick/arm/codegen_arm.h index d4b0de7b4e..582af510f3 100644 --- a/compiler/dex/quick/arm/codegen_arm.h +++ b/compiler/dex/quick/arm/codegen_arm.h @@ -85,8 +85,6 @@ class ArmMir2Lir FINAL : public Mir2Lir { size_t GetInsnSize(LIR* lir) OVERRIDE; bool IsUnconditionalBranch(LIR* lir); - // Check support for volatile load/store of a given size. - bool SupportsVolatileLoadStore(OpSize size) OVERRIDE; // Get the register class for load/store of a field. RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; diff --git a/compiler/dex/quick/arm/target_arm.cc b/compiler/dex/quick/arm/target_arm.cc index ef94bbc3cc..8cc7596c6d 100644 --- a/compiler/dex/quick/arm/target_arm.cc +++ b/compiler/dex/quick/arm/target_arm.cc @@ -538,10 +538,6 @@ bool ArmMir2Lir::IsUnconditionalBranch(LIR* lir) { return ((lir->opcode == kThumbBUncond) || (lir->opcode == kThumb2BUncond)); } -bool ArmMir2Lir::SupportsVolatileLoadStore(OpSize size) { - return true; -} - RegisterClass ArmMir2Lir::RegClassForFieldLoadStore(OpSize size, bool is_volatile) { if (UNLIKELY(is_volatile)) { // On arm, atomic 64-bit load/store requires a core register pair. diff --git a/compiler/dex/quick/arm64/codegen_arm64.h b/compiler/dex/quick/arm64/codegen_arm64.h index de976531c2..c62b4fe372 100644 --- a/compiler/dex/quick/arm64/codegen_arm64.h +++ b/compiler/dex/quick/arm64/codegen_arm64.h @@ -146,8 +146,6 @@ class Arm64Mir2Lir FINAL : public Mir2Lir { size_t GetInsnSize(LIR* lir) OVERRIDE; bool IsUnconditionalBranch(LIR* lir); - // Check support for volatile load/store of a given size. - bool SupportsVolatileLoadStore(OpSize size) OVERRIDE; // Get the register class for load/store of a field. RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; diff --git a/compiler/dex/quick/arm64/target_arm64.cc b/compiler/dex/quick/arm64/target_arm64.cc index 6a27ad0b14..c3bbb4497b 100644 --- a/compiler/dex/quick/arm64/target_arm64.cc +++ b/compiler/dex/quick/arm64/target_arm64.cc @@ -569,10 +569,6 @@ bool Arm64Mir2Lir::IsUnconditionalBranch(LIR* lir) { return (lir->opcode == kA64B1t); } -bool Arm64Mir2Lir::SupportsVolatileLoadStore(OpSize size) { - return true; -} - RegisterClass Arm64Mir2Lir::RegClassForFieldLoadStore(OpSize size, bool is_volatile) { if (UNLIKELY(is_volatile)) { // On arm64, fp register load/store is atomic only for single bytes. diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index 1fc0cff678..5d1b1fb072 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -581,8 +581,7 @@ void Mir2Lir::GenSput(MIR* mir, RegLocation rl_src, bool is_long_or_double, const MirSFieldLoweringInfo& field_info = mir_graph_->GetSFieldLoweringInfo(mir); cu_->compiler_driver->ProcessedStaticField(field_info.FastPut(), field_info.IsReferrersClass()); OpSize store_size = LoadStoreOpSize(is_long_or_double, is_object); - if (!SLOW_FIELD_PATH && field_info.FastPut() && - (!field_info.IsVolatile() || SupportsVolatileLoadStore(store_size))) { + if (!SLOW_FIELD_PATH && field_info.FastPut()) { DCHECK_GE(field_info.FieldOffset().Int32Value(), 0); RegStorage r_base; if (field_info.IsReferrersClass()) { @@ -682,8 +681,7 @@ void Mir2Lir::GenSget(MIR* mir, RegLocation rl_dest, const MirSFieldLoweringInfo& field_info = mir_graph_->GetSFieldLoweringInfo(mir); cu_->compiler_driver->ProcessedStaticField(field_info.FastGet(), field_info.IsReferrersClass()); OpSize load_size = LoadStoreOpSize(is_long_or_double, is_object); - if (!SLOW_FIELD_PATH && field_info.FastGet() && - (!field_info.IsVolatile() || SupportsVolatileLoadStore(load_size))) { + if (!SLOW_FIELD_PATH && field_info.FastGet()) { DCHECK_GE(field_info.FieldOffset().Int32Value(), 0); RegStorage r_base; if (field_info.IsReferrersClass()) { @@ -787,6 +785,8 @@ static void GenIgetCall(Mir2Lir* mir_to_lir, bool is_long_or_double, bool is_obj is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pointer_size, pGet64Instance) : (is_object ? QUICK_ENTRYPOINT_OFFSET(pointer_size, pGetObjInstance) : QUICK_ENTRYPOINT_OFFSET(pointer_size, pGet32Instance)); + // Second argument of pGetXXInstance is always a reference. + DCHECK_EQ(static_cast<unsigned int>(rl_obj.wide), 0U); mir_to_lir->CallRuntimeHelperImmRegLocation(getter_offset, field_info->FieldIndex(), rl_obj, true); } @@ -797,8 +797,7 @@ void Mir2Lir::GenIGet(MIR* mir, int opt_flags, OpSize size, const MirIFieldLoweringInfo& field_info = mir_graph_->GetIFieldLoweringInfo(mir); cu_->compiler_driver->ProcessedInstanceField(field_info.FastGet()); OpSize load_size = LoadStoreOpSize(is_long_or_double, is_object); - if (!SLOW_FIELD_PATH && field_info.FastGet() && - (!field_info.IsVolatile() || SupportsVolatileLoadStore(load_size))) { + if (!SLOW_FIELD_PATH && field_info.FastGet()) { RegisterClass reg_class = RegClassForFieldLoadStore(load_size, field_info.IsVolatile()); DCHECK_GE(field_info.FieldOffset().Int32Value(), 0); rl_obj = LoadValue(rl_obj, kRefReg); @@ -854,8 +853,7 @@ void Mir2Lir::GenIPut(MIR* mir, int opt_flags, OpSize size, const MirIFieldLoweringInfo& field_info = mir_graph_->GetIFieldLoweringInfo(mir); cu_->compiler_driver->ProcessedInstanceField(field_info.FastPut()); OpSize store_size = LoadStoreOpSize(is_long_or_double, is_object); - if (!SLOW_FIELD_PATH && field_info.FastPut() && - (!field_info.IsVolatile() || SupportsVolatileLoadStore(store_size))) { + if (!SLOW_FIELD_PATH && field_info.FastPut()) { RegisterClass reg_class = RegClassForFieldLoadStore(store_size, field_info.IsVolatile()); DCHECK_GE(field_info.FieldOffset().Int32Value(), 0); rl_obj = LoadValue(rl_obj, kRefReg); diff --git a/compiler/dex/quick/mips/codegen_mips.h b/compiler/dex/quick/mips/codegen_mips.h index 2c33377a2b..4a060863df 100644 --- a/compiler/dex/quick/mips/codegen_mips.h +++ b/compiler/dex/quick/mips/codegen_mips.h @@ -47,6 +47,8 @@ class MipsMir2Lir FINAL : public Mir2Lir { OpSize size) OVERRIDE; LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement, RegStorage r_src, OpSize size) OVERRIDE; + LIR* GenAtomic64Load(RegStorage r_base, int displacement, RegStorage r_dest); + LIR* GenAtomic64Store(RegStorage r_base, int displacement, RegStorage r_src); void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg); // Required for target - register utilities. @@ -83,8 +85,6 @@ class MipsMir2Lir FINAL : public Mir2Lir { size_t GetInsnSize(LIR* lir) OVERRIDE; bool IsUnconditionalBranch(LIR* lir); - // Check support for volatile load/store of a given size. - bool SupportsVolatileLoadStore(OpSize size) OVERRIDE; // Get the register class for load/store of a field. RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; diff --git a/compiler/dex/quick/mips/target_mips.cc b/compiler/dex/quick/mips/target_mips.cc index a5b7824cf6..4ba94c4781 100644 --- a/compiler/dex/quick/mips/target_mips.cc +++ b/compiler/dex/quick/mips/target_mips.cc @@ -496,6 +496,39 @@ LIR* MipsMir2Lir::CheckSuspendUsingLoad() { return inst; } +LIR* MipsMir2Lir::GenAtomic64Load(RegStorage r_base, int displacement, RegStorage r_dest) { + DCHECK(!r_dest.IsFloat()); // See RegClassForFieldLoadStore(). + DCHECK(r_dest.IsPair()); + ClobberCallerSave(); + LockCallTemps(); // Using fixed registers + RegStorage reg_ptr = TargetReg(kArg0); + OpRegRegImm(kOpAdd, reg_ptr, r_base, displacement); + RegStorage r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(4, pA64Load)); + LIR *ret = OpReg(kOpBlx, r_tgt); + RegStorage reg_ret = RegStorage::MakeRegPair(TargetReg(kRet0), TargetReg(kRet1)); + OpRegCopyWide(r_dest, reg_ret); + return ret; +} + +LIR* MipsMir2Lir::GenAtomic64Store(RegStorage r_base, int displacement, RegStorage r_src) { + DCHECK(!r_src.IsFloat()); // See RegClassForFieldLoadStore(). + DCHECK(r_src.IsPair()); + ClobberCallerSave(); + LockCallTemps(); // Using fixed registers + RegStorage temp_ptr = AllocTemp(); + OpRegRegImm(kOpAdd, temp_ptr, r_base, displacement); + RegStorage temp_value = AllocTempWide(); + OpRegCopyWide(temp_value, r_src); + RegStorage reg_ptr = TargetReg(kArg0); + OpRegCopy(reg_ptr, temp_ptr); + RegStorage reg_value = RegStorage::MakeRegPair(TargetReg(kArg2), TargetReg(kArg3)); + OpRegCopyWide(reg_value, temp_value); + FreeTemp(temp_ptr); + FreeTemp(temp_value); + RegStorage r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(4, pA64Store)); + return OpReg(kOpBlx, r_tgt); +} + void MipsMir2Lir::SpillCoreRegs() { if (num_core_spills_ == 0) { return; @@ -530,17 +563,12 @@ bool MipsMir2Lir::IsUnconditionalBranch(LIR* lir) { return (lir->opcode == kMipsB); } -bool MipsMir2Lir::SupportsVolatileLoadStore(OpSize size) { - // No support for 64-bit atomic load/store on mips. - return size != k64 && size != kDouble; -} - RegisterClass MipsMir2Lir::RegClassForFieldLoadStore(OpSize size, bool is_volatile) { if (UNLIKELY(is_volatile)) { - // On Mips, atomic 64-bit load/store requires an fp register. + // On Mips, atomic 64-bit load/store requires a core register. // Smaller aligned load/store is atomic for both core and fp registers. if (size == k64 || size == kDouble) { - return kFPReg; + return kCoreReg; } } // TODO: Verify that both core and fp registers are suitable for smaller sizes. diff --git a/compiler/dex/quick/mips/utility_mips.cc b/compiler/dex/quick/mips/utility_mips.cc index 75d3c5d4bf..0e8188b9d2 100644 --- a/compiler/dex/quick/mips/utility_mips.cc +++ b/compiler/dex/quick/mips/utility_mips.cc @@ -551,8 +551,9 @@ LIR* MipsMir2Lir::LoadBaseDispBody(RegStorage r_base, int displacement, RegStora LIR* MipsMir2Lir::LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size, VolatileKind is_volatile) { - if (is_volatile == kVolatile) { - DCHECK(size != k64 && size != kDouble); + if (UNLIKELY(is_volatile == kVolatile && (size == k64 || size == kDouble))) { + // Do atomic 64-bit load. + return GenAtomic64Load(r_base, displacement, r_dest); } // TODO: base this on target. @@ -654,17 +655,21 @@ LIR* MipsMir2Lir::StoreBaseDispBody(RegStorage r_base, int displacement, LIR* MipsMir2Lir::StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src, OpSize size, VolatileKind is_volatile) { if (is_volatile == kVolatile) { - DCHECK(size != k64 && size != kDouble); // Ensure that prior accesses become visible to other threads first. GenMemBarrier(kAnyStore); } - // TODO: base this on target. - if (size == kWord) { - size = k32; - } LIR* store; - store = StoreBaseDispBody(r_base, displacement, r_src, size); + if (UNLIKELY(is_volatile == kVolatile && (size == k64 || size == kDouble))) { + // Do atomic 64-bit load. + store = GenAtomic64Store(r_base, displacement, r_src); + } else { + // TODO: base this on target. + if (size == kWord) { + size = k32; + } + store = StoreBaseDispBody(r_base, displacement, r_src, size); + } if (UNLIKELY(is_volatile == kVolatile)) { // Preserve order with respect to any subsequent volatile loads. diff --git a/compiler/dex/quick/mir_to_lir.cc b/compiler/dex/quick/mir_to_lir.cc index 07c615f342..b1f0b13e81 100644 --- a/compiler/dex/quick/mir_to_lir.cc +++ b/compiler/dex/quick/mir_to_lir.cc @@ -227,9 +227,6 @@ bool Mir2Lir::GenSpecialIGet(MIR* mir, const InlineMethod& special) { bool wide = (data.op_variant == InlineMethodAnalyser::IGetVariant(Instruction::IGET_WIDE)); bool ref = (data.op_variant == InlineMethodAnalyser::IGetVariant(Instruction::IGET_OBJECT)); OpSize size = LoadStoreOpSize(wide, ref); - if (data.is_volatile && !SupportsVolatileLoadStore(size)) { - return false; - } // Point of no return - no aborts after this GenPrintLabel(mir); @@ -274,9 +271,6 @@ bool Mir2Lir::GenSpecialIPut(MIR* mir, const InlineMethod& special) { bool wide = (data.op_variant == InlineMethodAnalyser::IPutVariant(Instruction::IPUT_WIDE)); bool ref = (data.op_variant == InlineMethodAnalyser::IGetVariant(Instruction::IGET_OBJECT)); OpSize size = LoadStoreOpSize(wide, ref); - if (data.is_volatile && !SupportsVolatileLoadStore(size)) { - return false; - } // Point of no return - no aborts after this GenPrintLabel(mir); diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index c68ad6be4b..33e980fec7 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -1271,8 +1271,6 @@ class Mir2Lir : public Backend { virtual size_t GetInsnSize(LIR* lir) = 0; virtual bool IsUnconditionalBranch(LIR* lir) = 0; - // Check support for volatile load/store of a given size. - virtual bool SupportsVolatileLoadStore(OpSize size) = 0; // Get the register class for load/store of a field. virtual RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) = 0; diff --git a/compiler/dex/quick/x86/codegen_x86.h b/compiler/dex/quick/x86/codegen_x86.h index f4fa1b4b17..1e80247996 100644 --- a/compiler/dex/quick/x86/codegen_x86.h +++ b/compiler/dex/quick/x86/codegen_x86.h @@ -144,8 +144,6 @@ class X86Mir2Lir : public Mir2Lir { size_t GetInsnSize(LIR* lir) OVERRIDE; bool IsUnconditionalBranch(LIR* lir); - // Check support for volatile load/store of a given size. - bool SupportsVolatileLoadStore(OpSize size) OVERRIDE; // Get the register class for load/store of a field. RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; diff --git a/compiler/dex/quick/x86/target_x86.cc b/compiler/dex/quick/x86/target_x86.cc index bb1f379fe5..1e4494bd30 100755 --- a/compiler/dex/quick/x86/target_x86.cc +++ b/compiler/dex/quick/x86/target_x86.cc @@ -755,10 +755,6 @@ bool X86Mir2Lir::IsUnconditionalBranch(LIR* lir) { return (lir->opcode == kX86Jmp8 || lir->opcode == kX86Jmp32); } -bool X86Mir2Lir::SupportsVolatileLoadStore(OpSize size) { - return true; -} - RegisterClass X86Mir2Lir::RegClassForFieldLoadStore(OpSize size, bool is_volatile) { // X86_64 can handle any size. if (cu_->target64) { diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index 1444ca0309..8aa7b76980 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -189,7 +189,7 @@ TEST_F(OatTest, OatHeaderSizeCheck) { EXPECT_EQ(80U, sizeof(OatHeader)); EXPECT_EQ(8U, sizeof(OatMethodOffsets)); EXPECT_EQ(24U, sizeof(OatQuickMethodHeader)); - EXPECT_EQ(77 * GetInstructionSetPointerSize(kRuntimeISA), sizeof(QuickEntryPoints)); + EXPECT_EQ(79 * GetInstructionSetPointerSize(kRuntimeISA), sizeof(QuickEntryPoints)); } TEST_F(OatTest, OatHeaderIsValid) { |