diff options
author | 2019-07-29 10:18:25 +0100 | |
---|---|---|
committer | 2019-07-30 14:49:54 +0000 | |
commit | 44ca0754b3c6f11303bac876a9175bbfa95609ef (patch) | |
tree | 6f669466e6b0e750a075108cc6f8fe0a67b66658 /compiler/optimizing | |
parent | f3677471a58c2738a3d9dd05f07f01c18a5e61be (diff) |
Compiler changes for boot image extension.
Test: m test-art-host-gtest
Test: testrunnner.py --host --optimizing
Test: aosp_taimen-userdebug boots.
Test: run-gtest.sh
Test: testrunner.py --target --optimizing
Change-Id: I8e999c96ec908f26d8c529edc9d2a3be49a9379a
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 9 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm_vixl.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_mips.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_mips64.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 10 | ||||
-rw-r--r-- | compiler/optimizing/sharpening.cc | 31 |
7 files changed, 56 insertions, 34 deletions
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 43d466baf8..aeef90ac96 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -4101,7 +4101,7 @@ void CodeGeneratorARM64::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: { - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); // Add ADRP with its PC-relative method patch. vixl::aarch64::Label* adrp_label = NewBootImageMethodPatch(invoke->GetTargetMethod()); EmitAdrpPlaceholder(adrp_label, XRegisterFrom(temp)); @@ -4461,7 +4461,7 @@ void CodeGeneratorARM64::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* lin call_entrypoint_patches_.size() + baker_read_barrier_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( @@ -4688,6 +4688,8 @@ void InstructionCodeGeneratorARM64::VisitLoadClass(HLoadClass* cls) NO_THREAD_SA break; } case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: { + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); // Add ADRP with its PC-relative type patch. const DexFile& dex_file = cls->GetDexFile(); @@ -4863,7 +4865,8 @@ void InstructionCodeGeneratorARM64::VisitLoadString(HLoadString* load) NO_THREAD switch (load->GetLoadKind()) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); // Add ADRP with its PC-relative String patch. const DexFile& dex_file = load->GetDexFile(); const dex::StringIndex string_index = load->GetStringIndex(); diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc index b72a1a04fc..b3141bfa4e 100644 --- a/compiler/optimizing/code_generator_arm_vixl.cc +++ b/compiler/optimizing/code_generator_arm_vixl.cc @@ -7076,7 +7076,8 @@ void InstructionCodeGeneratorARMVIXL::VisitLoadClass(HLoadClass* cls) NO_THREAD_ break; } case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); CodeGeneratorARMVIXL::PcRelativePatchInfo* labels = codegen_->NewBootImageTypePatch(cls->GetDexFile(), cls->GetTypeIndex()); @@ -7300,7 +7301,8 @@ void InstructionCodeGeneratorARMVIXL::VisitLoadString(HLoadString* load) NO_THRE switch (load_kind) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); CodeGeneratorARMVIXL::PcRelativePatchInfo* labels = codegen_->NewBootImageStringPatch(load->GetDexFile(), load->GetStringIndex()); codegen_->EmitMovwMovtPlaceholder(labels, out); @@ -8770,7 +8772,7 @@ void CodeGeneratorARMVIXL::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: { - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); PcRelativePatchInfo* labels = NewBootImageMethodPatch(invoke->GetTargetMethod()); vixl32::Register temp_reg = RegisterFrom(temp); EmitMovwMovtPlaceholder(labels, temp_reg); @@ -9071,7 +9073,7 @@ void CodeGeneratorARMVIXL::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* l call_entrypoint_patches_.size() + baker_read_barrier_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc index 9ea9785763..eafd051064 100644 --- a/compiler/optimizing/code_generator_mips.cc +++ b/compiler/optimizing/code_generator_mips.cc @@ -1625,7 +1625,7 @@ void CodeGeneratorMIPS::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* link string_bss_entry_patches_.size() + boot_image_other_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( @@ -7998,7 +7998,7 @@ void CodeGeneratorMIPS::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: { - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); PcRelativePatchInfo* info_high = NewBootImageMethodPatch(invoke->GetTargetMethod()); PcRelativePatchInfo* info_low = NewBootImageMethodPatch(invoke->GetTargetMethod(), info_high); @@ -8220,7 +8220,8 @@ void InstructionCodeGeneratorMIPS::VisitLoadClass(HLoadClass* cls) NO_THREAD_SAF break; } case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); CodeGeneratorMIPS::PcRelativePatchInfo* info_high = codegen_->NewBootImageTypePatch(cls->GetDexFile(), cls->GetTypeIndex()); @@ -8427,7 +8428,8 @@ void InstructionCodeGeneratorMIPS::VisitLoadString(HLoadString* load) NO_THREAD_ switch (load_kind) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); CodeGeneratorMIPS::PcRelativePatchInfo* info_high = codegen_->NewBootImageStringPatch(load->GetDexFile(), load->GetStringIndex()); CodeGeneratorMIPS::PcRelativePatchInfo* info_low = diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc index 06e9e58cef..7b91a19479 100644 --- a/compiler/optimizing/code_generator_mips64.cc +++ b/compiler/optimizing/code_generator_mips64.cc @@ -1552,7 +1552,7 @@ void CodeGeneratorMIPS64::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* li string_bss_entry_patches_.size() + boot_image_other_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( @@ -6089,7 +6089,7 @@ void CodeGeneratorMIPS64::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: { - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); CodeGeneratorMIPS64::PcRelativePatchInfo* info_high = NewBootImageMethodPatch(invoke->GetTargetMethod()); CodeGeneratorMIPS64::PcRelativePatchInfo* info_low = @@ -6276,7 +6276,8 @@ void InstructionCodeGeneratorMIPS64::VisitLoadClass(HLoadClass* cls) NO_THREAD_S read_barrier_option); break; case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); CodeGeneratorMIPS64::PcRelativePatchInfo* info_high = codegen_->NewBootImageTypePatch(cls->GetDexFile(), cls->GetTypeIndex()); @@ -6424,7 +6425,8 @@ void InstructionCodeGeneratorMIPS64::VisitLoadString(HLoadString* load) NO_THREA switch (load_kind) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); CodeGeneratorMIPS64::PcRelativePatchInfo* info_high = codegen_->NewBootImageStringPatch(load->GetDexFile(), load->GetStringIndex()); CodeGeneratorMIPS64::PcRelativePatchInfo* info_low = diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 5159553bce..6728dc954a 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -4853,7 +4853,7 @@ void CodeGeneratorX86::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: { - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); Register base_reg = GetInvokeStaticOrDirectExtraParameter(invoke, temp.AsRegister<Register>()); __ leal(temp.AsRegister<Register>(), Address(base_reg, CodeGeneratorX86::kDummy32BitOffset)); @@ -5092,7 +5092,7 @@ void CodeGeneratorX86::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linke string_bss_entry_patches_.size() + boot_image_other_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( @@ -6601,7 +6601,8 @@ void InstructionCodeGeneratorX86::VisitLoadClass(HLoadClass* cls) NO_THREAD_SAFE break; } case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); Register method_address = locations->InAt(0).AsRegister<Register>(); __ leal(out, Address(method_address, CodeGeneratorX86::kDummy32BitOffset)); @@ -6798,7 +6799,8 @@ void InstructionCodeGeneratorX86::VisitLoadString(HLoadString* load) NO_THREAD_S switch (load->GetLoadKind()) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); Register method_address = locations->InAt(0).AsRegister<Register>(); __ leal(out, Address(method_address, CodeGeneratorX86::kDummy32BitOffset)); codegen_->RecordBootImageStringPatch(load); diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 8c8b5e641d..48a83206a9 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -999,7 +999,7 @@ void CodeGeneratorX86_64::GenerateStaticOrDirectCall( callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; case HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative: - DCHECK(GetCompilerOptions().IsBootImage()); + DCHECK(GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()); __ leal(temp.AsRegister<CpuRegister>(), Address::Absolute(kDummy32BitOffset, /* no_rip= */ false)); RecordBootImageMethodPatch(invoke); @@ -1193,7 +1193,7 @@ void CodeGeneratorX86_64::EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* li string_bss_entry_patches_.size() + boot_image_other_patches_.size(); linker_patches->reserve(size); - if (GetCompilerOptions().IsBootImage()) { + if (GetCompilerOptions().IsBootImage() || GetCompilerOptions().IsBootImageExtension()) { EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeMethodPatch>( boot_image_method_patches_, linker_patches); EmitPcRelativeLinkerPatches<linker::LinkerPatch::RelativeTypePatch>( @@ -5966,7 +5966,8 @@ void InstructionCodeGeneratorX86_64::VisitLoadClass(HLoadClass* cls) NO_THREAD_S break; } case HLoadClass::LoadKind::kBootImageLinkTimePcRelative: - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); DCHECK_EQ(read_barrier_option, kWithoutReadBarrier); __ leal(out, Address::Absolute(CodeGeneratorX86_64::kDummy32BitOffset, /* no_rip= */ false)); codegen_->RecordBootImageTypePatch(cls); @@ -6120,7 +6121,8 @@ void InstructionCodeGeneratorX86_64::VisitLoadString(HLoadString* load) NO_THREA switch (load->GetLoadKind()) { case HLoadString::LoadKind::kBootImageLinkTimePcRelative: { - DCHECK(codegen_->GetCompilerOptions().IsBootImage()); + DCHECK(codegen_->GetCompilerOptions().IsBootImage() || + codegen_->GetCompilerOptions().IsBootImageExtension()); __ leal(out, Address::Absolute(CodeGeneratorX86_64::kDummy32BitOffset, /* no_rip= */ false)); codegen_->RecordBootImageStringPatch(load); return; diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 77b41abf7d..b8471e3721 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -33,7 +33,6 @@ #include "nodes.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" -#include "utils/dex_cache_arrays_layout-inl.h" namespace art { @@ -50,7 +49,7 @@ static bool IsInBootImage(ArtMethod* method) { } static bool BootImageAOTCanEmbedMethod(ArtMethod* method, const CompilerOptions& compiler_options) { - DCHECK(compiler_options.IsBootImage()); + DCHECK(compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()); ScopedObjectAccess soa(Thread::Current()); ObjPtr<mirror::Class> klass = method->GetDeclaringClass(); DCHECK(klass != nullptr); @@ -88,10 +87,13 @@ HInvokeStaticOrDirect::DispatchInfo HSharpening::SharpenInvokeStaticOrDirect( // Recursive call. method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRecursive; code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallSelf; - } else if (compiler_options.IsBootImage()) { + } else if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { if (!compiler_options.GetCompilePic()) { // Test configuration, do not sharpen. method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRuntimeCall; + } else if (IsInBootImage(callee)) { + DCHECK(compiler_options.IsBootImageExtension()); + method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageRelRo; } else if (BootImageAOTCanEmbedMethod(callee, compiler_options)) { method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative; } else { @@ -161,19 +163,22 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind( HLoadClass::LoadKind desired_load_kind = HLoadClass::LoadKind::kInvalid; Runtime* runtime = Runtime::Current(); const CompilerOptions& compiler_options = codegen->GetCompilerOptions(); - if (compiler_options.IsBootImage()) { - // Compiling boot image. Check if the class is a boot image class. + if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { + // Compiling boot image or boot image extension. Check if the class is a boot image class. DCHECK(!runtime->UseJitCompilation()); if (!compiler_options.GetCompilePic()) { // Test configuration, do not sharpen. desired_load_kind = HLoadClass::LoadKind::kRuntimeCall; + } else if (klass != nullptr && runtime->GetHeap()->ObjectIsInBootImageSpace(klass.Get())) { + DCHECK(compiler_options.IsBootImageExtension()); + is_in_boot_image = true; + desired_load_kind = HLoadClass::LoadKind::kBootImageRelRo; } else if ((klass != nullptr) && compiler_options.IsImageClass(dex_file.StringByTypeIdx(type_index))) { is_in_boot_image = true; desired_load_kind = HLoadClass::LoadKind::kBootImageLinkTimePcRelative; } else { // Not a boot image class. - DCHECK(ContainsElement(compiler_options.GetDexFilesForOatFile(), &dex_file)); desired_load_kind = HLoadClass::LoadKind::kBssEntry; } } else { @@ -317,12 +322,11 @@ void HSharpening::ProcessLoadString( ObjPtr<mirror::String> string = nullptr; const CompilerOptions& compiler_options = codegen->GetCompilerOptions(); - if (compiler_options.IsBootImage()) { - // Compiling boot image. Resolve the string and allocate it if needed, to ensure - // the string will be added to the boot image. + if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { + // Compiling boot image or boot image extension. Resolve the string and allocate it + // if needed, to ensure the string will be added to the boot image. DCHECK(!runtime->UseJitCompilation()); if (compiler_options.GetCompilePic()) { - DCHECK(ContainsElement(compiler_options.GetDexFilesForOatFile(), &dex_file)); if (compiler_options.IsForceDeterminism()) { // Strings for methods we're compiling should be pre-resolved but Strings in inlined // methods may not be if these inlined methods are not in the boot image profile. @@ -337,7 +341,12 @@ void HSharpening::ProcessLoadString( CHECK(string != nullptr); } if (string != nullptr) { - desired_load_kind = HLoadString::LoadKind::kBootImageLinkTimePcRelative; + if (runtime->GetHeap()->ObjectIsInBootImageSpace(string)) { + DCHECK(compiler_options.IsBootImageExtension()); + desired_load_kind = HLoadString::LoadKind::kBootImageRelRo; + } else { + desired_load_kind = HLoadString::LoadKind::kBootImageLinkTimePcRelative; + } } else { desired_load_kind = HLoadString::LoadKind::kBssEntry; } |