Always produce PIC code for AOT compilation.
Change sharpening to use PIC load kinds for AOT compilation
and add "Jit" to the direct addressing load kind names. Use
PIC code also for the Integer.valueOf() intrinsic codegen.
Remove all support for non-PIC linker patches.
The dex2oat --compile-pic option is retained for now but
ignored by the compiler.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing
Bug: 77856493
Change-Id: I54d666f6522f160a1b6ece4045a15d19363acbb6
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index aed04f9..f25ee9b 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -64,11 +64,11 @@
ArrayRef<const uint8_t>(raw_cfi_info2),
};
const linker::LinkerPatch raw_patches1[] = {
- linker::LinkerPatch::CodePatch(0u, nullptr, 1u),
+ linker::LinkerPatch::IntrinsicReferencePatch(0u, 0u, 0u),
linker::LinkerPatch::RelativeMethodPatch(4u, nullptr, 0u, 1u),
};
const linker::LinkerPatch raw_patches2[] = {
- linker::LinkerPatch::CodePatch(0u, nullptr, 1u),
+ linker::LinkerPatch::IntrinsicReferencePatch(0u, 0u, 0u),
linker::LinkerPatch::RelativeMethodPatch(4u, nullptr, 0u, 2u),
};
ArrayRef<const linker::LinkerPatch> patches[] = {
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index b24b036..6eca304 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -255,7 +255,6 @@
compiler_(Compiler::Create(this, compiler_kind)),
compiler_kind_(compiler_kind),
requires_constructor_barrier_lock_("constructor barrier lock"),
- non_relative_linker_patch_count_(0u),
image_classes_(std::move(image_classes)),
number_of_soft_verifier_failures_(0),
had_hard_verifier_failure_(false),
@@ -463,18 +462,7 @@
}
if (compiled_method != nullptr) {
- // Count non-relative linker patches.
- size_t non_relative_linker_patch_count = 0u;
- for (const linker::LinkerPatch& patch : compiled_method->GetPatches()) {
- if (!patch.IsPcRelative()) {
- ++non_relative_linker_patch_count;
- }
- }
- bool compile_pic = driver->GetCompilerOptions().GetCompilePic(); // Off by default
- // When compiling with PIC, there should be zero non-relative linker patches
- CHECK(!compile_pic || non_relative_linker_patch_count == 0u);
-
- driver->AddCompiledMethod(method_ref, compiled_method, non_relative_linker_patch_count);
+ driver->AddCompiledMethod(method_ref, compiled_method);
}
if (self->IsExceptionPending()) {
@@ -2697,15 +2685,12 @@
}
void CompilerDriver::AddCompiledMethod(const MethodReference& method_ref,
- CompiledMethod* const compiled_method,
- size_t non_relative_linker_patch_count) {
+ CompiledMethod* const compiled_method) {
DCHECK(GetCompiledMethod(method_ref) == nullptr) << method_ref.PrettyMethod();
MethodTable::InsertResult result = compiled_methods_.Insert(method_ref,
/*expected*/ nullptr,
compiled_method);
CHECK(result == MethodTable::kInsertResultSuccess);
- non_relative_linker_patch_count_.fetch_add(non_relative_linker_patch_count,
- std::memory_order_relaxed);
DCHECK(GetCompiledMethod(method_ref) != nullptr) << method_ref.PrettyMethod();
}
@@ -2815,10 +2800,6 @@
return is_system_class;
}
-size_t CompilerDriver::GetNonRelativeLinkerPatchCount() const {
- return non_relative_linker_patch_count_.load(std::memory_order_relaxed);
-}
-
void CompilerDriver::SetRequiresConstructorBarrier(Thread* self,
const DexFile* dex_file,
uint16_t class_def_index,
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 3d3583c..343f67c 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -148,9 +148,7 @@
CompiledMethod* GetCompiledMethod(MethodReference ref) const;
size_t GetNonRelativeLinkerPatchCount() const;
// Add a compiled method.
- void AddCompiledMethod(const MethodReference& method_ref,
- CompiledMethod* const compiled_method,
- size_t non_relative_linker_patch_count);
+ void AddCompiledMethod(const MethodReference& method_ref, CompiledMethod* const compiled_method);
CompiledMethod* RemoveCompiledMethod(const MethodReference& method_ref);
void SetRequiresConstructorBarrier(Thread* self,
@@ -435,10 +433,6 @@
// All method references that this compiler has compiled.
MethodTable compiled_methods_;
- // Number of non-relative patches in all compiled methods. These patches need space
- // in the .oat_patches ELF section if requested in the compiler options.
- Atomic<size_t> non_relative_linker_patch_count_;
-
// Image classes to be updated by PreCompile().
// TODO: Remove this member which is a non-const pointer to the CompilerOptions' data.
// Pass this explicitly to the PreCompile() which should be called directly from