Move the Compiler to CompilerDriver.
Change-Id: I0bb4d3c2b79b45fd8ef180688c767712b0c55978
diff --git a/src/compiler/dex/compiler_internals.h b/src/compiler/dex/compiler_internals.h
index c85700a..8a44bb8 100644
--- a/src/compiler/dex/compiler_internals.h
+++ b/src/compiler/dex/compiler_internals.h
@@ -25,7 +25,7 @@
#include "base/logging.h"
#include "class_linker.h"
#include "quick/codegen.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
#include "compiler_ir.h"
#include "compiler_utility.h"
#include "frontend.h"
diff --git a/src/compiler/dex/compiler_ir.h b/src/compiler/dex/compiler_ir.h
index c961d0b..04dee77 100644
--- a/src/compiler/dex/compiler_ir.h
+++ b/src/compiler/dex/compiler_ir.h
@@ -19,7 +19,7 @@
#include <vector>
#include "dex_instruction.h"
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
#include "compiler_utility.h"
#include "oat_compilation_unit.h"
#include "safe_map.h"
@@ -274,7 +274,7 @@
struct CompilationUnit {
CompilationUnit()
: num_blocks(0),
- compiler(NULL),
+ compiler_driver(NULL),
class_linker(NULL),
dex_file(NULL),
class_loader(NULL),
@@ -366,7 +366,7 @@
int num_blocks;
GrowableList block_list;
- Compiler* compiler; // Compiler driving this compiler.
+ CompilerDriver* compiler_driver;
ClassLinker* class_linker; // Linker to resolve fields and methods.
const DexFile* dex_file; // DexFile containing the method being compiled.
jobject class_loader; // compiling method's class loader.
diff --git a/src/compiler/dex/dataflow.cc b/src/compiler/dex/dataflow.cc
index 2ce16a4..0fa9ab1 100644
--- a/src/compiler/dex/dataflow.cc
+++ b/src/compiler/dex/dataflow.cc
@@ -2501,9 +2501,9 @@
uintptr_t direct_code;
uintptr_t direct_method;
bool fast_path =
- cu->compiler->ComputeInvokeInfo(dex_method_idx, &m_unit, type,
- vtable_idx, direct_code,
- direct_method) &&
+ cu->compiler_driver->ComputeInvokeInfo(dex_method_idx, &m_unit, type,
+ vtable_idx, direct_code,
+ direct_method) &&
!SLOW_INVOKE_PATH;
return (((type == kDirect) || (type == kStatic)) &&
fast_path && ((direct_code == 0) || (direct_method == 0)));
diff --git a/src/compiler/dex/frontend.cc b/src/compiler/dex/frontend.cc
index 4619052..510e08a 100644
--- a/src/compiler/dex/frontend.cc
+++ b/src/compiler/dex/frontend.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "compiler.h"
+#include "compiler/driver/compiler_driver.h"
#include "compiler_internals.h"
#include "dataflow.h"
#include "ssa_transformation.h"
@@ -57,13 +57,13 @@
LLVMInfo::~LLVMInfo() {
}
-extern "C" void ArtInitQuickCompilerContext(art::Compiler& compiler) {
+extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver& compiler) {
CHECK(compiler.GetCompilerContext() == NULL);
LLVMInfo* llvm_info = new LLVMInfo();
compiler.SetCompilerContext(llvm_info);
}
-extern "C" void ArtUnInitQuickCompilerContext(art::Compiler& compiler) {
+extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& compiler) {
delete reinterpret_cast<LLVMInfo*>(compiler.GetCompilerContext());
compiler.SetCompilerContext(NULL);
}
@@ -755,7 +755,7 @@
return new_block;
}
-void CompilerInit(CompilationUnit* cu, const Compiler& compiler) {
+void CompilerInit(CompilationUnit* cu, const CompilerDriver& compiler) {
bool success = false;
switch (compiler.GetInstructionSet()) {
case kThumb2:
@@ -777,7 +777,7 @@
}
}
-static CompiledMethod* CompileMethod(Compiler& compiler,
+static CompiledMethod* CompileMethod(CompilerDriver& compiler,
const CompilerBackend compiler_backend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
@@ -797,7 +797,7 @@
CompilerInit(cu.get(), compiler);
- cu->compiler = &compiler;
+ cu->compiler_driver = &compiler;
cu->class_linker = class_linker;
cu->dex_file = &dex_file;
cu->class_def_idx = class_def_idx;
@@ -1228,7 +1228,7 @@
return result;
}
-CompiledMethod* CompileOneMethod(Compiler& compiler,
+CompiledMethod* CompileOneMethod(CompilerDriver& compiler,
const CompilerBackend backend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
@@ -1243,7 +1243,7 @@
} // namespace art
extern "C" art::CompiledMethod*
- ArtQuickCompileMethod(art::Compiler& compiler,
+ ArtQuickCompileMethod(art::CompilerDriver& compiler,
const art::DexFile::CodeItem* code_item,
uint32_t access_flags, art::InvokeType invoke_type,
uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
diff --git a/src/compiler/dex/frontend.h b/src/compiler/dex/frontend.h
index f3e38c2..4e65d12 100644
--- a/src/compiler/dex/frontend.h
+++ b/src/compiler/dex/frontend.h
@@ -141,7 +141,7 @@
} // namespace art
-extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler,
+extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
diff --git a/src/compiler/dex/portable/mir_to_gbc.cc b/src/compiler/dex/portable/mir_to_gbc.cc
index 66efd64..18a87c3 100644
--- a/src/compiler/dex/portable/mir_to_gbc.cc
+++ b/src/compiler/dex/portable/mir_to_gbc.cc
@@ -196,7 +196,7 @@
{
LLVMInfo* llvm_info = cu->llvm_info;
if (llvm_info == NULL) {
- CompilerTls* tls = cu->compiler->GetTls();
+ CompilerTls* tls = cu->compiler_driver->GetTls();
CHECK(tls != NULL);
llvm_info = static_cast<LLVMInfo*>(tls->GetLLVMInfo());
if (llvm_info == NULL) {
@@ -1032,9 +1032,9 @@
case Instruction::RETURN_VOID: {
if (((cu->access_flags & kAccConstructor) != 0) &&
- cu->compiler->RequiresConstructorBarrier(Thread::Current(),
- cu->dex_file,
- cu->class_def_idx)) {
+ cu->compiler_driver->RequiresConstructorBarrier(Thread::Current(),
+ cu->dex_file,
+ cu->class_def_idx)) {
EmitConstructorBarrier(cu);
}
if (!(cu->attrs & METHOD_IS_LEAF)) {
diff --git a/src/compiler/dex/quick/codegen_util.cc b/src/compiler/dex/quick/codegen_util.cc
index 06221f8..a7ca77a 100644
--- a/src/compiler/dex/quick/codegen_util.cc
+++ b/src/compiler/dex/quick/codegen_util.cc
@@ -58,7 +58,7 @@
*cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx,
cu->access_flags);
- return cu->compiler->ComputeInstanceFieldInfo(field_idx, &m_unit,
+ return cu->compiler_driver->ComputeInstanceFieldInfo(field_idx, &m_unit,
field_offset, is_volatile, is_put);
}
@@ -562,12 +562,12 @@
data_lir = cu->code_literal_list;
while (data_lir != NULL) {
uint32_t target = data_lir->operands[0];
- cu->compiler->AddCodePatch(cu->dex_file,
- cu->method_idx,
- cu->invoke_type,
- target,
- static_cast<InvokeType>(data_lir->operands[1]),
- cu->code_buffer.size());
+ cu->compiler_driver->AddCodePatch(cu->dex_file,
+ cu->method_idx,
+ cu->invoke_type,
+ target,
+ static_cast<InvokeType>(data_lir->operands[1]),
+ cu->code_buffer.size());
const DexFile::MethodId& id = cu->dex_file->GetMethodId(target);
// unique based on target to ensure code deduplication works
uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);
@@ -577,12 +577,12 @@
data_lir = cu->method_literal_list;
while (data_lir != NULL) {
uint32_t target = data_lir->operands[0];
- cu->compiler->AddMethodPatch(cu->dex_file,
- cu->method_idx,
- cu->invoke_type,
- target,
- static_cast<InvokeType>(data_lir->operands[1]),
- cu->code_buffer.size());
+ cu->compiler_driver->AddMethodPatch(cu->dex_file,
+ cu->method_idx,
+ cu->invoke_type,
+ target,
+ static_cast<InvokeType>(data_lir->operands[1]),
+ cu->code_buffer.size());
const DexFile::MethodId& id = cu->dex_file->GetMethodId(target);
// unique based on target to ensure code deduplication works
uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);
@@ -821,7 +821,7 @@
max_native_offset = native_offset;
}
}
- Compiler::MethodReference method_ref(cu->dex_file, cu->method_idx);
+ CompilerDriver::MethodReference method_ref(cu->dex_file, cu->method_idx);
const std::vector<uint8_t>* gc_map_raw = verifier::MethodVerifier::GetDexGcMap(method_ref);
verifier::DexPcToReferenceMap dex_gc_map(&(*gc_map_raw)[4], gc_map_raw->size() - 4);
// Compute native offset to references size.
diff --git a/src/compiler/dex/quick/gen_common.cc b/src/compiler/dex/quick/gen_common.cc
index bc022fc..e3791ce 100644
--- a/src/compiler/dex/quick/gen_common.cc
+++ b/src/compiler/dex/quick/gen_common.cc
@@ -221,9 +221,9 @@
{
FlushAllRegs(cu); /* Everything to home location */
int func_offset;
- if (cu->compiler->CanAccessTypeWithoutChecks(cu->method_idx,
- *cu->dex_file,
- type_idx)) {
+ if (cu->compiler_driver->CanAccessTypeWithoutChecks(cu->method_idx,
+ *cu->dex_file,
+ type_idx)) {
func_offset = ENTRYPOINT_OFFSET(pAllocArrayFromCode);
} else {
func_offset= ENTRYPOINT_OFFSET(pAllocArrayFromCodeWithAccessCheck);
@@ -245,9 +245,9 @@
int type_idx = info->index;
FlushAllRegs(cu); /* Everything to home location */
int func_offset;
- if (cu->compiler->CanAccessTypeWithoutChecks(cu->method_idx,
- *cu->dex_file,
- type_idx)) {
+ if (cu->compiler_driver->CanAccessTypeWithoutChecks(cu->method_idx,
+ *cu->dex_file,
+ type_idx)) {
func_offset = ENTRYPOINT_OFFSET(pCheckAndAllocArrayFromCode);
} else {
func_offset = ENTRYPOINT_OFFSET(pCheckAndAllocArrayFromCodeWithAccessCheck);
@@ -358,10 +358,10 @@
cu->class_def_idx, cu->method_idx, cu->access_flags);
bool fast_path =
- cu->compiler->ComputeStaticFieldInfo(field_idx, &m_unit,
- field_offset, ssb_index,
- is_referrers_class, is_volatile,
- true);
+ cu->compiler_driver->ComputeStaticFieldInfo(field_idx, &m_unit,
+ field_offset, ssb_index,
+ is_referrers_class, is_volatile,
+ true);
if (fast_path && !SLOW_FIELD_PATH) {
DCHECK_GE(field_offset, 0);
int rBase;
@@ -452,10 +452,10 @@
cu->access_flags);
bool fast_path =
- cu->compiler->ComputeStaticFieldInfo(field_idx, &m_unit,
- field_offset, ssb_index,
- is_referrers_class, is_volatile,
- false);
+ cu->compiler_driver->ComputeStaticFieldInfo(field_idx, &m_unit,
+ field_offset, ssb_index,
+ is_referrers_class, is_volatile,
+ false);
if (fast_path && !SLOW_FIELD_PATH) {
DCHECK_GE(field_offset, 0);
int rBase;
@@ -783,7 +783,7 @@
RegLocation rl_method = LoadCurrMethod(cu);
int res_reg = AllocTemp(cu);
RegLocation rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
- if (!cu->compiler->CanAccessTypeWithoutChecks(cu->method_idx,
+ if (!cu->compiler_driver->CanAccessTypeWithoutChecks(cu->method_idx,
*cu->dex_file,
type_idx)) {
// Call out to helper which resolves type and verifies access.
@@ -801,7 +801,7 @@
mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*)
* type_idx);
LoadWordDisp(cu, res_reg, offset_of_type, rl_result.low_reg);
- if (!cu->compiler->CanAssumeTypeIsPresentInDexCache(*cu->dex_file,
+ if (!cu->compiler_driver->CanAssumeTypeIsPresentInDexCache(*cu->dex_file,
type_idx) || SLOW_TYPE_PATH) {
// Slow path, at runtime test if type is null and if so initialize
FlushAllRegs(cu);
@@ -842,7 +842,7 @@
/* NOTE: Most strings should be available at compile time */
int32_t offset_of_string = mirror::Array::DataOffset(sizeof(mirror::String*)).Int32Value() +
(sizeof(mirror::String*) * string_idx);
- if (!cu->compiler->CanAssumeStringIsPresentInDexCache(
+ if (!cu->compiler_driver->CanAssumeStringIsPresentInDexCache(
*cu->dex_file, string_idx) || SLOW_STRING_PATH) {
// slow path, resolve string if not in dex cache
FlushAllRegs(cu);
@@ -900,7 +900,7 @@
// alloc will always check for resolution, do we also need to verify
// access because the verifier was unable to?
int func_offset;
- if (cu->compiler->CanAccessInstantiableTypeWithoutChecks(
+ if (cu->compiler_driver->CanAccessInstantiableTypeWithoutChecks(
cu->method_idx, *cu->dex_file, type_idx)) {
func_offset = ENTRYPOINT_OFFSET(pAllocObjectFromCode);
} else {
@@ -925,7 +925,7 @@
LockCallTemps(cu);
LoadCurrMethodDirect(cu, TargetReg(kArg1)); // kArg1 <= current Method*
int class_reg = TargetReg(kArg2); // kArg2 will hold the Class*
- if (!cu->compiler->CanAccessTypeWithoutChecks(cu->method_idx,
+ if (!cu->compiler_driver->CanAccessTypeWithoutChecks(cu->method_idx,
*cu->dex_file,
type_idx)) {
// Check we have access to type_idx and if not throw IllegalAccessError,
@@ -943,7 +943,7 @@
mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*)
* type_idx);
LoadWordDisp(cu, class_reg, offset_of_type, class_reg);
- if (!cu->compiler->CanAssumeTypeIsPresentInDexCache(
+ if (!cu->compiler_driver->CanAssumeTypeIsPresentInDexCache(
*cu->dex_file, type_idx)) {
// Need to test presence of type in dex cache at runtime
LIR* hop_branch = OpCmpImmBranch(cu, kCondNe, class_reg, 0, NULL);
@@ -1010,7 +1010,7 @@
LockCallTemps(cu);
LoadCurrMethodDirect(cu, TargetReg(kArg1)); // kArg1 <= current Method*
int class_reg = TargetReg(kArg2); // kArg2 will hold the Class*
- if (!cu->compiler->CanAccessTypeWithoutChecks(cu->method_idx,
+ if (!cu->compiler_driver->CanAccessTypeWithoutChecks(cu->method_idx,
*cu->dex_file,
type_idx)) {
// Check we have access to type_idx and if not throw IllegalAccessError,
@@ -1027,7 +1027,7 @@
mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() +
(sizeof(mirror::Class*) * type_idx);
LoadWordDisp(cu, class_reg, offset_of_type, class_reg);
- if (!cu->compiler->CanAssumeTypeIsPresentInDexCache(
+ if (!cu->compiler_driver->CanAssumeTypeIsPresentInDexCache(
*cu->dex_file, type_idx)) {
// Need to test presence of type in dex cache at runtime
LIR* hop_branch = OpCmpImmBranch(cu, kCondNe, class_reg, 0, NULL);
diff --git a/src/compiler/dex/quick/gen_invoke.cc b/src/compiler/dex/quick/gen_invoke.cc
index 9a1fa5c..3fe797c 100644
--- a/src/compiler/dex/quick/gen_invoke.cc
+++ b/src/compiler/dex/quick/gen_invoke.cc
@@ -1346,9 +1346,9 @@
uintptr_t direct_method;
bool skip_this;
bool fast_path =
- cu->compiler->ComputeInvokeInfo(dex_method_idx, &m_unit, info->type,
- vtable_idx, direct_code,
- direct_method)
+ cu->compiler_driver->ComputeInvokeInfo(dex_method_idx, &m_unit, info->type,
+ vtable_idx, direct_code,
+ direct_method)
&& !SLOW_INVOKE_PATH;
if (info->type == kInterface) {
if (fast_path) {
diff --git a/src/compiler/dex/quick/mir_to_lir.cc b/src/compiler/dex/quick/mir_to_lir.cc
index 267f61e..3cce26e 100644
--- a/src/compiler/dex/quick/mir_to_lir.cc
+++ b/src/compiler/dex/quick/mir_to_lir.cc
@@ -87,8 +87,8 @@
case Instruction::RETURN_VOID:
if (((cu->access_flags & kAccConstructor) != 0) &&
- cu->compiler->RequiresConstructorBarrier(Thread::Current(), cu->dex_file,
- cu->class_def_idx)) {
+ cu->compiler_driver->RequiresConstructorBarrier(Thread::Current(), cu->dex_file,
+ cu->class_def_idx)) {
cg->GenMemBarrier(cu, kStoreStore);
}
if (!(cu->attrs & METHOD_IS_LEAF)) {
diff --git a/src/compiler/dex/write_elf.cc b/src/compiler/dex/write_elf.cc
index 1fd8a9492..a78d98e 100644
--- a/src/compiler/dex/write_elf.cc
+++ b/src/compiler/dex/write_elf.cc
@@ -14,14 +14,17 @@
* limitations under the License.
*/
-#include "compiler.h"
#include "elf_writer.h"
#include "os.h"
-extern "C" bool WriteElf(art::Compiler& compiler,
+namespace art {
+class CompilerDriver;
+} // namespace art
+
+extern "C" bool WriteElf(art::CompilerDriver& driver,
std::vector<uint8_t>& oat_contents,
art::File* file) {
- return art::ElfWriter::Create(file, oat_contents, compiler);
+ return art::ElfWriter::Create(file, oat_contents, driver);
}
extern "C" bool FixupElf(art::File* file, uintptr_t oat_data_begin) {
return art::ElfWriter::Fixup(file, oat_data_begin);