diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_generator.cc | 2 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips.cc | 39 | ||||
| -rw-r--r-- | compiler/optimizing/intrinsics_mips.cc | 10 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_cfi_test_expected.inc | 35 | ||||
| -rw-r--r-- | compiler/optimizing/sharpening.cc | 10 |
7 files changed, 66 insertions, 38 deletions
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index 0d3f849143..b0de9640fb 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -753,7 +753,7 @@ void CodeGenerator::RecordPcInfo(HInstruction* instruction, } // Collect PC infos for the mapping table. - uint32_t native_pc = GetAssembler()->CodeSize(); + uint32_t native_pc = GetAssembler()->CodePosition(); if (instruction == nullptr) { // For stack overflow checks and native-debug-info entries without dex register diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index d8866a92c1..16072d9c25 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -1209,7 +1209,9 @@ void CodeGeneratorARM::InvokeRuntime(QuickEntrypointEnum entrypoint, SlowPathCode* slow_path) { ValidateInvokeRuntime(instruction, slow_path); GenerateInvokeRuntime(GetThreadOffset<kArmPointerSize>(entrypoint).Int32Value()); - RecordPcInfo(instruction, dex_pc, slow_path); + if (EntrypointRequiresStackMap(entrypoint)) { + RecordPcInfo(instruction, dex_pc, slow_path); + } } void CodeGeneratorARM::InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset, diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 17fc13cf65..933f3e6883 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -1485,7 +1485,9 @@ void CodeGeneratorARM64::InvokeRuntime(QuickEntrypointEnum entrypoint, SlowPathCode* slow_path) { ValidateInvokeRuntime(instruction, slow_path); GenerateInvokeRuntime(GetThreadOffset<kArm64PointerSize>(entrypoint).Int32Value()); - RecordPcInfo(instruction, dex_pc, slow_path); + if (EntrypointRequiresStackMap(entrypoint)) { + RecordPcInfo(instruction, dex_pc, slow_path); + } } void CodeGeneratorARM64::InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset, diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc index 8a2f90d541..e0de03bf8f 100644 --- a/compiler/optimizing/code_generator_mips.cc +++ b/compiler/optimizing/code_generator_mips.cc @@ -792,12 +792,24 @@ void CodeGeneratorMIPS::GenerateFrameExit() { // TODO: __ cfi().Restore(DWARFReg(reg)); } - __ DecreaseFrameSize(GetFrameSize()); + size_t frame_size = GetFrameSize(); + // Adjust the stack pointer in the delay slot if doing so doesn't break CFI. + bool exchange = IsInt<16>(static_cast<int32_t>(frame_size)); + bool reordering = __ SetReorder(false); + if (exchange) { + __ Jr(RA); + __ DecreaseFrameSize(frame_size); // Single instruction in delay slot. + } else { + __ DecreaseFrameSize(frame_size); + __ Jr(RA); + __ Nop(); // In delay slot. + } + __ SetReorder(reordering); + } else { + __ Jr(RA); + __ NopIfNoReordering(); } - __ Jr(RA); - __ Nop(); - __ cfi().RestoreState(); __ cfi().DefCFAOffset(GetFrameSize()); } @@ -1251,6 +1263,7 @@ void CodeGeneratorMIPS::InvokeRuntime(int32_t entry_point_offset, uint32_t dex_pc, SlowPathCode* slow_path, bool is_direct_entrypoint) { + bool reordering = __ SetReorder(false); __ LoadFromOffset(kLoadWord, T9, TR, entry_point_offset); __ Jalr(T9); if (is_direct_entrypoint) { @@ -1262,6 +1275,7 @@ void CodeGeneratorMIPS::InvokeRuntime(int32_t entry_point_offset, } else { __ Nop(); // In delay slot. } + __ SetReorder(reordering); RecordPcInfo(instruction, dex_pc, slow_path); } @@ -3953,7 +3967,7 @@ void InstructionCodeGeneratorMIPS::VisitInvokeInterface(HInvokeInterface* invoke __ LoadFromOffset(kLoadWord, T9, temp, entry_point.Int32Value()); // T9(); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); DCHECK(!codegen_->IsLeafMethod()); codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); } @@ -4254,7 +4268,7 @@ void CodeGeneratorMIPS::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke // T9 prepared above for better instruction scheduling. // T9() __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); break; case HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative: // TODO: Implement this type. @@ -4270,7 +4284,7 @@ void CodeGeneratorMIPS::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke kMipsPointerSize).Int32Value()); // T9() __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); break; } DCHECK(!IsLeafMethod()); @@ -4312,7 +4326,7 @@ void CodeGeneratorMIPS::GenerateVirtualCall(HInvokeVirtual* invoke, Location tem __ LoadFromOffset(kLoadWord, T9, temp, entry_point.Int32Value()); // T9(); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); } void InstructionCodeGeneratorMIPS::VisitInvokeVirtual(HInvokeVirtual* invoke) { @@ -4421,6 +4435,7 @@ void InstructionCodeGeneratorMIPS::VisitLoadClass(HLoadClass* cls) { DCHECK(!kEmitCompilerReadBarrier); CodeGeneratorMIPS::PcRelativePatchInfo* info = codegen_->NewPcRelativeTypePatch(cls->GetDexFile(), cls->GetTypeIndex()); + bool reordering = __ SetReorder(false); if (isR6) { __ Bind(&info->high_label); __ Bind(&info->pc_rel_label); @@ -4436,6 +4451,7 @@ void InstructionCodeGeneratorMIPS::VisitLoadClass(HLoadClass* cls) { // Add a 32-bit offset to PC. __ Addu(out, out, base_or_current_method_reg); } + __ SetReorder(reordering); break; } case HLoadClass::LoadKind::kBootImageAddress: { @@ -4579,6 +4595,7 @@ void InstructionCodeGeneratorMIPS::VisitLoadString(HLoadString* load) { DCHECK(!kEmitCompilerReadBarrier); CodeGeneratorMIPS::PcRelativePatchInfo* info = codegen_->NewPcRelativeStringPatch(load->GetDexFile(), load->GetStringIndex()); + bool reordering = __ SetReorder(false); if (isR6) { __ Bind(&info->high_label); __ Bind(&info->pc_rel_label); @@ -4594,6 +4611,7 @@ void InstructionCodeGeneratorMIPS::VisitLoadString(HLoadString* load) { // Add a 32-bit offset to PC. __ Addu(out, out, base_or_current_method_reg); } + __ SetReorder(reordering); return; // No dex cache slow path. } case HLoadString::LoadKind::kBootImageAddress: { @@ -4851,7 +4869,7 @@ void InstructionCodeGeneratorMIPS::VisitNewInstance(HNewInstance* instruction) { __ LoadFromOffset(kLoadWord, temp, TR, QUICK_ENTRY_POINT(pNewEmptyString)); __ LoadFromOffset(kLoadWord, T9, temp, code_offset.Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); } else { codegen_->InvokeRuntime( @@ -5751,7 +5769,7 @@ void InstructionCodeGeneratorMIPS::VisitMipsDexCacheArraysBase(HMipsDexCacheArra Register reg = base->GetLocations()->Out().AsRegister<Register>(); CodeGeneratorMIPS::PcRelativePatchInfo* info = codegen_->NewPcRelativeDexCacheArrayPatch(base->GetDexFile(), base->GetElementOffset()); - + bool reordering = __ SetReorder(false); if (codegen_->GetInstructionSetFeatures().IsR6()) { __ Bind(&info->high_label); __ Bind(&info->pc_rel_label); @@ -5769,6 +5787,7 @@ void InstructionCodeGeneratorMIPS::VisitMipsDexCacheArraysBase(HMipsDexCacheArra __ Addu(reg, reg, RA); // TODO: Can we share this code with that of VisitMipsComputeBaseMethodAddress()? } + __ SetReorder(reordering); } void LocationsBuilderMIPS::VisitInvokeUnresolved(HInvokeUnresolved* invoke) { diff --git a/compiler/optimizing/intrinsics_mips.cc b/compiler/optimizing/intrinsics_mips.cc index 6e5eb6622b..862a93f9d6 100644 --- a/compiler/optimizing/intrinsics_mips.cc +++ b/compiler/optimizing/intrinsics_mips.cc @@ -1901,7 +1901,7 @@ void IntrinsicCodeGeneratorMIPS::VisitStringCompareTo(HInvoke* invoke) { TR, QUICK_ENTRYPOINT_OFFSET(kMipsPointerSize, pStringCompareTo).Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); __ Bind(slow_path->GetExitLabel()); } @@ -2060,7 +2060,7 @@ static void GenerateStringIndexOf(HInvoke* invoke, TR, QUICK_ENTRYPOINT_OFFSET(kMipsPointerSize, pIndexOf).Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); if (slow_path != nullptr) { __ Bind(slow_path->GetExitLabel()); @@ -2146,7 +2146,7 @@ void IntrinsicCodeGeneratorMIPS::VisitStringNewStringFromBytes(HInvoke* invoke) TR, QUICK_ENTRYPOINT_OFFSET(kMipsPointerSize, pAllocStringFromBytes).Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); __ Bind(slow_path->GetExitLabel()); } @@ -2179,7 +2179,7 @@ void IntrinsicCodeGeneratorMIPS::VisitStringNewStringFromChars(HInvoke* invoke) TR, QUICK_ENTRYPOINT_OFFSET(kMipsPointerSize, pAllocStringFromChars).Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); } @@ -2208,7 +2208,7 @@ void IntrinsicCodeGeneratorMIPS::VisitStringNewStringFromString(HInvoke* invoke) TR, QUICK_ENTRYPOINT_OFFSET(kMipsPointerSize, pAllocStringFromString).Int32Value()); __ Jalr(T9); - __ Nop(); + __ NopIfNoReordering(); codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); __ Bind(slow_path->GetExitLabel()); } diff --git a/compiler/optimizing/optimizing_cfi_test_expected.inc b/compiler/optimizing/optimizing_cfi_test_expected.inc index 05eb06333e..6c5030c9cb 100644 --- a/compiler/optimizing/optimizing_cfi_test_expected.inc +++ b/compiler/optimizing/optimizing_cfi_test_expected.inc @@ -144,12 +144,12 @@ static constexpr uint8_t expected_asm_kMips[] = { 0x34, 0x00, 0xB0, 0xAF, 0x28, 0x00, 0xB6, 0xF7, 0x20, 0x00, 0xB4, 0xF7, 0x00, 0x00, 0xA4, 0xAF, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xB1, 0x8F, 0x34, 0x00, 0xB0, 0x8F, 0x28, 0x00, 0xB6, 0xD7, 0x20, 0x00, 0xB4, 0xD7, - 0x40, 0x00, 0xBD, 0x27, 0x09, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x00, 0xE0, 0x03, 0x40, 0x00, 0xBD, 0x27, }; static constexpr uint8_t expected_cfi_kMips[] = { 0x44, 0x0E, 0x40, 0x44, 0x9F, 0x01, 0x44, 0x91, 0x02, 0x44, 0x90, 0x03, - 0x4C, 0x0A, 0x44, 0xDF, 0x44, 0xD1, 0x44, 0xD0, 0x4C, 0x0E, 0x00, 0x48, - 0x0B, 0x0E, 0x40, + 0x4C, 0x0A, 0x44, 0xDF, 0x44, 0xD1, 0x44, 0xD0, 0x50, 0x0E, 0x00, 0x0B, + 0x0E, 0x40, }; // 0x00000000: addiu r29, r29, -64 // 0x00000004: .cfi_def_cfa_offset: 64 @@ -171,12 +171,11 @@ static constexpr uint8_t expected_cfi_kMips[] = { // 0x00000028: .cfi_restore: r16 // 0x00000028: ldc1 f22, +40(r29) // 0x0000002c: ldc1 f20, +32(r29) -// 0x00000030: addiu r29, r29, 64 -// 0x00000034: .cfi_def_cfa_offset: 0 -// 0x00000034: jr r31 -// 0x00000038: nop -// 0x0000003c: .cfi_restore_state -// 0x0000003c: .cfi_def_cfa_offset: 64 +// 0x00000030: jr r31 +// 0x00000034: addiu r29, r29, 64 +// 0x00000038: .cfi_def_cfa_offset: 0 +// 0x00000038: .cfi_restore_state +// 0x00000038: .cfi_def_cfa_offset: 64 static constexpr uint8_t expected_asm_kMips64[] = { 0xD8, 0xFF, 0xBD, 0x67, 0x20, 0x00, 0xBF, 0xFF, 0x18, 0x00, 0xB1, 0xFF, @@ -348,14 +347,13 @@ static constexpr uint8_t expected_asm_kMips_adjust_head[] = { }; static constexpr uint8_t expected_asm_kMips_adjust_tail[] = { 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xB1, 0x8F, 0x34, 0x00, 0xB0, 0x8F, - 0x28, 0x00, 0xB6, 0xD7, 0x20, 0x00, 0xB4, 0xD7, 0x40, 0x00, 0xBD, 0x27, - 0x09, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x28, 0x00, 0xB6, 0xD7, 0x20, 0x00, 0xB4, 0xD7, 0x09, 0x00, 0xE0, 0x03, + 0x40, 0x00, 0xBD, 0x27, }; static constexpr uint8_t expected_cfi_kMips_adjust[] = { 0x44, 0x0E, 0x40, 0x44, 0x9F, 0x01, 0x44, 0x91, 0x02, 0x44, 0x90, 0x03, 0x54, 0x0E, 0x44, 0x60, 0x0E, 0x40, 0x04, 0x04, 0x00, 0x02, 0x00, 0x0A, - 0x44, 0xDF, 0x44, 0xD1, 0x44, 0xD0, 0x4C, 0x0E, 0x00, 0x48, 0x0B, 0x0E, - 0x40, + 0x44, 0xDF, 0x44, 0xD1, 0x44, 0xD0, 0x50, 0x0E, 0x00, 0x0B, 0x0E, 0x40, }; // 0x00000000: addiu r29, r29, -64 // 0x00000004: .cfi_def_cfa_offset: 64 @@ -392,12 +390,11 @@ static constexpr uint8_t expected_cfi_kMips_adjust[] = { // 0x00020054: .cfi_restore: r16 // 0x00020054: ldc1 f22, +40(r29) // 0x00020058: ldc1 f20, +32(r29) -// 0x0002005c: addiu r29, r29, 64 -// 0x00020060: .cfi_def_cfa_offset: 0 -// 0x00020060: jr r31 -// 0x00020064: nop -// 0x00020068: .cfi_restore_state -// 0x00020068: .cfi_def_cfa_offset: 64 +// 0x0002005c: jr r31 +// 0x00020060: addiu r29, r29, 64 +// 0x00020064: .cfi_def_cfa_offset: 0 +// 0x00020064: .cfi_restore_state +// 0x00020064: .cfi_def_cfa_offset: 64 static constexpr uint8_t expected_asm_kMips64_adjust_head[] = { 0xD8, 0xFF, 0xBD, 0x67, 0x20, 0x00, 0xBF, 0xFF, 0x18, 0x00, 0xB1, 0xFF, diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 6effc306dc..40fff8af32 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -295,7 +295,15 @@ void HSharpening::ProcessLoadString(HLoadString* load_string) { DCHECK(!runtime->UseJitCompilation()); mirror::String* string = class_linker->ResolveString(dex_file, string_index, dex_cache); CHECK(string != nullptr); - // TODO: In follow up CL, add PcRelative and Address back in. + if (compiler_driver_->GetSupportBootImageFixup()) { + DCHECK(ContainsElement(compiler_driver_->GetDexFilesForOatFile(), &dex_file)); + desired_load_kind = codegen_->GetCompilerOptions().GetCompilePic() + ? HLoadString::LoadKind::kBootImageLinkTimePcRelative + : HLoadString::LoadKind::kBootImageLinkTimeAddress; + } else { + // MIPS64 or compiler_driver_test. Do not sharpen. + DCHECK_EQ(desired_load_kind, HLoadString::LoadKind::kDexCacheViaMethod); + } } else if (runtime->UseJitCompilation()) { // TODO: Make sure we don't set the "compile PIC" flag for JIT as that's bogus. // DCHECK(!codegen_->GetCompilerOptions().GetCompilePic()); |