Remove CompilerDriver::support_boot_image_fixup_.
Check for non-PIC boot image as a testing config instead.
Honor the config for HInvokeStaticOrDirect sharpening.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I3645f4fefe322f1fd64ea88a2b41a35ceccea688
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 22720ce..e8e1d40 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -196,6 +196,7 @@
ApplyInstructionSet();
compiler_options_->boot_image_ = true;
+ compiler_options_->compile_pic_ = false; // Non-PIC boot image is a test configuration.
compiler_options_->SetCompilerFilter(GetCompilerFilter());
compiler_options_->image_classes_.swap(*GetImageClasses());
compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
@@ -205,8 +206,6 @@
number_of_threads_,
/* swap_fd */ -1,
GetProfileCompilationInfo()));
- // We typically don't generate an image in unit tests, disable this optimization by default.
- compiler_driver_->SetSupportBootImageFixup(false);
}
void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) {
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 7c13894..7e6fdaf 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -277,7 +277,6 @@
parallel_thread_count_(thread_count),
stats_(new AOTCompilationStats),
compiler_context_(nullptr),
- support_boot_image_fixup_(true),
compiled_method_storage_(swap_fd),
profile_compilation_info_(profile_compilation_info),
max_arena_alloc_(0),
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 8739dc3..0a8754a 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -267,14 +267,6 @@
const VerifiedMethod* GetVerifiedMethod(const DexFile* dex_file, uint32_t method_idx) const;
bool IsSafeCast(const DexCompilationUnit* mUnit, uint32_t dex_pc);
- bool GetSupportBootImageFixup() const {
- return support_boot_image_fixup_;
- }
-
- void SetSupportBootImageFixup(bool support_boot_image_fixup) {
- support_boot_image_fixup_ = support_boot_image_fixup;
- }
-
void SetCompilerContext(void* compiler_context) {
compiler_context_ = compiler_context;
}
@@ -493,8 +485,6 @@
void* compiler_context_;
- bool support_boot_image_fixup_;
-
CompiledMethodStorage compiled_method_storage_;
// Info for profile guided compilation.
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index d7bd828..a881c5e 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -155,7 +155,6 @@
/* profile_compilation_info */ nullptr));
// Disable dedupe so we can remove compiled methods.
compiler_driver_->SetDedupeEnabled(false);
- compiler_driver_->SetSupportBootImageFixup(false);
size_t thread_count = compiler_driver_->GetThreadCount();
if (compiler_options_->GetGenerateDebugInfo()) {
diff --git a/compiler/optimizing/bounds_check_elimination_test.cc b/compiler/optimizing/bounds_check_elimination_test.cc
index 1523478..7c29df8 100644
--- a/compiler/optimizing/bounds_check_elimination_test.cc
+++ b/compiler/optimizing/bounds_check_elimination_test.cc
@@ -43,7 +43,7 @@
void RunBCE() {
graph_->BuildDominatorTree();
- InstructionSimplifier(graph_, /* codegen */ nullptr, /* driver */ nullptr).Run();
+ InstructionSimplifier(graph_, /* codegen */ nullptr).Run();
SideEffectsAnalysis side_effects(graph_);
side_effects.Run();
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index a104070..3ba7414 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -949,7 +949,7 @@
invoke_instruction->GetDexPc(),
/* needs_access_check */ false);
HLoadClass::LoadKind kind = HSharpening::ComputeLoadClassKind(
- load_class, codegen_, compiler_driver_, caller_compilation_unit_);
+ load_class, codegen_, caller_compilation_unit_);
DCHECK(kind != HLoadClass::LoadKind::kInvalid)
<< "We should always be able to reference a class for inline caches";
// Load kind must be set before inserting the instruction into the graph.
@@ -2022,8 +2022,8 @@
// optimization that could lead to a HDeoptimize. The following optimizations do not.
HDeadCodeElimination dce(callee_graph, inline_stats_, "dead_code_elimination$inliner");
HConstantFolding fold(callee_graph, "constant_folding$inliner");
- HSharpening sharpening(callee_graph, codegen_, compiler_driver_);
- InstructionSimplifier simplify(callee_graph, codegen_, compiler_driver_, inline_stats_);
+ HSharpening sharpening(callee_graph, codegen_);
+ InstructionSimplifier simplify(callee_graph, codegen_, inline_stats_);
IntrinsicsRecognizer intrinsics(callee_graph, inline_stats_);
HOptimization* optimizations[] = {
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 7cda6e9..7d918c4 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1777,7 +1777,6 @@
new (allocator_) HLoadString(graph_->GetCurrentMethod(), string_index, *dex_file_, dex_pc);
HSharpening::ProcessLoadString(load_string,
code_generator_,
- compiler_driver_,
*dex_compilation_unit_,
handles_);
AppendInstruction(load_string);
@@ -1819,7 +1818,6 @@
HLoadClass::LoadKind load_kind = HSharpening::ComputeLoadClassKind(load_class,
code_generator_,
- compiler_driver_,
*dex_compilation_unit_);
if (load_kind == HLoadClass::LoadKind::kInvalid) {
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index c979a5a..70af49f 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -36,11 +36,9 @@
public:
InstructionSimplifierVisitor(HGraph* graph,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
OptimizingCompilerStats* stats)
: HGraphDelegateVisitor(graph),
codegen_(codegen),
- compiler_driver_(compiler_driver),
stats_(stats) {}
bool Run();
@@ -127,7 +125,6 @@
void SimplifyAbs(HInvoke* invoke, DataType::Type type);
CodeGenerator* codegen_;
- CompilerDriver* compiler_driver_;
OptimizingCompilerStats* stats_;
bool simplification_occurred_ = false;
int simplifications_at_current_position_ = 0;
@@ -144,7 +141,7 @@
visitor.VisitReversePostOrder();
}
- InstructionSimplifierVisitor visitor(graph_, codegen_, compiler_driver_, stats_);
+ InstructionSimplifierVisitor visitor(graph_, codegen_, stats_);
return visitor.Run();
}
@@ -2309,7 +2306,7 @@
// the invoke, as we would need to look it up in the current dex file, and it
// is unlikely that it exists. The most usual situation for such typed
// arraycopy methods is a direct pointer to the boot image.
- HSharpening::SharpenInvokeStaticOrDirect(invoke, codegen_, compiler_driver_);
+ HSharpening::SharpenInvokeStaticOrDirect(invoke, codegen_);
}
}
}
diff --git a/compiler/optimizing/instruction_simplifier.h b/compiler/optimizing/instruction_simplifier.h
index f409e87..2d134e0 100644
--- a/compiler/optimizing/instruction_simplifier.h
+++ b/compiler/optimizing/instruction_simplifier.h
@@ -24,7 +24,6 @@
namespace art {
class CodeGenerator;
-class CompilerDriver;
/**
* Implements optimizations specific to each instruction.
@@ -40,12 +39,10 @@
public:
InstructionSimplifier(HGraph* graph,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
OptimizingCompilerStats* stats = nullptr,
const char* name = kInstructionSimplifierPassName)
: HOptimization(graph, name, stats),
- codegen_(codegen),
- compiler_driver_(compiler_driver) {}
+ codegen_(codegen) {}
static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier";
@@ -53,7 +50,6 @@
private:
CodeGenerator* codegen_;
- CompilerDriver* compiler_driver_;
DISALLOW_COPY_AND_ASSIGN(InstructionSimplifier);
};
diff --git a/compiler/optimizing/optimization.cc b/compiler/optimizing/optimization.cc
index a38bd24..142ddb5 100644
--- a/compiler/optimizing/optimization.cc
+++ b/compiler/optimizing/optimization.cc
@@ -265,13 +265,13 @@
break;
}
case OptimizationPass::kSharpening:
- opt = new (allocator) HSharpening(graph, codegen, driver, pass_name);
+ opt = new (allocator) HSharpening(graph, codegen, pass_name);
break;
case OptimizationPass::kSelectGenerator:
opt = new (allocator) HSelectGenerator(graph, handles, stats, pass_name);
break;
case OptimizationPass::kInstructionSimplifier:
- opt = new (allocator) InstructionSimplifier(graph, codegen, driver, stats, pass_name);
+ opt = new (allocator) InstructionSimplifier(graph, codegen, stats, pass_name);
break;
case OptimizationPass::kIntrinsicsRecognizer:
opt = new (allocator) IntrinsicsRecognizer(graph, stats, pass_name);
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index 1e29c21..27482ac 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -21,7 +21,6 @@
#include "base/enums.h"
#include "class_linker.h"
#include "code_generator.h"
-#include "driver/compiler_driver.h"
#include "driver/compiler_options.h"
#include "driver/dex_compilation_unit.h"
#include "gc/heap.h"
@@ -42,9 +41,7 @@
for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
HInstruction* instruction = it.Current();
if (instruction->IsInvokeStaticOrDirect()) {
- SharpenInvokeStaticOrDirect(instruction->AsInvokeStaticOrDirect(),
- codegen_,
- compiler_driver_);
+ SharpenInvokeStaticOrDirect(instruction->AsInvokeStaticOrDirect(), codegen_);
}
// TODO: Move the sharpening of invoke-virtual/-interface/-super from HGraphBuilder
// here. Rewrite it to avoid the CompilerDriver's reliance on verifier data
@@ -70,12 +67,8 @@
return IsInBootImage(method) && !options.GetCompilePic();
}
-static bool BootImageAOTCanEmbedMethod(ArtMethod* method, CompilerDriver* compiler_driver) {
- const CompilerOptions& compiler_options = compiler_driver->GetCompilerOptions();
+static bool BootImageAOTCanEmbedMethod(ArtMethod* method, const CompilerOptions& compiler_options) {
DCHECK(compiler_options.IsBootImage());
- if (!compiler_driver->GetSupportBootImageFixup()) {
- return false;
- }
ScopedObjectAccess soa(Thread::Current());
ObjPtr<mirror::Class> klass = method->GetDeclaringClass();
DCHECK(klass != nullptr);
@@ -84,8 +77,7 @@
}
void HSharpening::SharpenInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke,
- CodeGenerator* codegen,
- CompilerDriver* compiler_driver) {
+ CodeGenerator* codegen) {
if (invoke->IsStringInit()) {
// Not using the dex cache arrays. But we could still try to use a better dispatch...
// TODO: Use direct_method and direct_code for the appropriate StringFactory method.
@@ -112,21 +104,29 @@
// We don't optimize for debuggable as it would prevent us from obsoleting the method in some
// situations.
+ const CompilerOptions& compiler_options = codegen->GetCompilerOptions();
if (callee == codegen->GetGraph()->GetArtMethod() && !codegen->GetGraph()->IsDebuggable()) {
// Recursive call.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRecursive;
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallSelf;
+ } else if (compiler_options.IsBootImage()) {
+ if (!compiler_options.GetCompilePic()) {
+ // Test configuration, do not sharpen.
+ method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRuntimeCall;
+ } else if (BootImageAOTCanEmbedMethod(callee, compiler_options)) {
+ method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative;
+ } else {
+ // Use PC-relative access to the .bss methods array.
+ method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBssEntry;
+ }
+ code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
} else if (Runtime::Current()->UseJitCompilation() ||
- AOTCanEmbedMethod(callee, codegen->GetCompilerOptions())) {
+ AOTCanEmbedMethod(callee, compiler_options)) {
// JIT or on-device AOT compilation referencing a boot image method.
// Use the method address directly.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kDirectAddress;
method_load_data = reinterpret_cast<uintptr_t>(callee);
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
- } else if (codegen->GetCompilerOptions().IsBootImage() &&
- BootImageAOTCanEmbedMethod(callee, compiler_driver)) {
- method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageLinkTimePcRelative;
- code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
} else if (IsInBootImage(callee)) {
// Use PC-relative access to the .data.bimg.rel.ro methods array.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageRelRo;
@@ -154,7 +154,6 @@
HLoadClass::LoadKind HSharpening::ComputeLoadClassKind(
HLoadClass* load_class,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
const DexCompilationUnit& dex_compilation_unit) {
Handle<mirror::Class> klass = load_class->GetClass();
DCHECK(load_class->GetLoadKind() == HLoadClass::LoadKind::kRuntimeCall ||
@@ -182,8 +181,8 @@
if (compiler_options.IsBootImage()) {
// Compiling boot image. Check if the class is a boot image class.
DCHECK(!runtime->UseJitCompilation());
- if (!compiler_driver->GetSupportBootImageFixup()) {
- // compiler_driver_test. Do not sharpen.
+ if (!compiler_options.GetCompilePic()) {
+ // Test configuration, do not sharpen.
desired_load_kind = HLoadClass::LoadKind::kRuntimeCall;
} else if ((klass != nullptr) &&
compiler_options.IsImageClass(dex_file.StringByTypeIdx(type_index))) {
@@ -265,7 +264,7 @@
// Try to assign a type check bitstring.
MutexLock subtype_check_lock(Thread::Current(), *Locks::subtype_check_lock_);
- if ((false) && // FIXME: Inliner does not respect compiler_driver->IsClassToCompile()
+ if ((false) && // FIXME: Inliner does not respect CompilerDriver::IsClassToCompile()
// and we're hitting an unassigned bitstring in dex2oat_image_test. b/26687569
kIsDebugBuild &&
codegen->GetCompilerOptions().IsBootImage() &&
@@ -312,7 +311,6 @@
void HSharpening::ProcessLoadString(
HLoadString* load_string,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
const DexCompilationUnit& dex_compilation_unit,
VariableSizedHandleScope* handles) {
DCHECK_EQ(load_string->GetLoadKind(), HLoadString::LoadKind::kRuntimeCall);
@@ -338,11 +336,11 @@
DCHECK(!runtime->UseJitCompilation());
string = class_linker->ResolveString(string_index, dex_cache);
CHECK(string != nullptr);
- if (compiler_driver->GetSupportBootImageFixup()) {
+ if (compiler_options.GetCompilePic()) {
DCHECK(ContainsElement(compiler_options.GetDexFilesForOatFile(), &dex_file));
desired_load_kind = HLoadString::LoadKind::kBootImageLinkTimePcRelative;
} else {
- // compiler_driver_test. Do not sharpen.
+ // Test configuration, do not sharpen.
desired_load_kind = HLoadString::LoadKind::kRuntimeCall;
}
} else if (runtime->UseJitCompilation()) {
diff --git a/compiler/optimizing/sharpening.h b/compiler/optimizing/sharpening.h
index e777328..cbac361 100644
--- a/compiler/optimizing/sharpening.h
+++ b/compiler/optimizing/sharpening.h
@@ -23,7 +23,6 @@
namespace art {
class CodeGenerator;
-class CompilerDriver;
class DexCompilationUnit;
// Optimization that tries to improve the way we dispatch methods and access types,
@@ -34,25 +33,20 @@
public:
HSharpening(HGraph* graph,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
const char* name = kSharpeningPassName)
: HOptimization(graph, name),
- codegen_(codegen),
- compiler_driver_(compiler_driver) { }
+ codegen_(codegen) { }
bool Run() OVERRIDE;
static constexpr const char* kSharpeningPassName = "sharpening";
// Used by Sharpening and InstructionSimplifier.
- static void SharpenInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke,
- CodeGenerator* codegen,
- CompilerDriver* compiler_driver);
+ static void SharpenInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke, CodeGenerator* codegen);
// Used by the builder and the inliner.
static HLoadClass::LoadKind ComputeLoadClassKind(HLoadClass* load_class,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
const DexCompilationUnit& dex_compilation_unit)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -65,13 +59,11 @@
// Used by the builder.
static void ProcessLoadString(HLoadString* load_string,
CodeGenerator* codegen,
- CompilerDriver* compiler_driver,
const DexCompilationUnit& dex_compilation_unit,
VariableSizedHandleScope* handles);
private:
CodeGenerator* codegen_;
- CompilerDriver* compiler_driver_;
};
} // namespace art