summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/class_linker.cc3
-rw-r--r--src/common_test.h12
-rw-r--r--src/compiler.cc127
-rw-r--r--src/compiler.h33
-rw-r--r--src/compiler/Compiler.h8
-rw-r--r--src/compiler/CompilerIR.h8
-rw-r--r--src/compiler/Dataflow.cc2
-rw-r--r--src/compiler/Frontend.cc104
-rw-r--r--src/compiler/Ralloc.cc7
-rw-r--r--src/compiler/codegen/MethodBitcode.cc3
-rw-r--r--src/compiler_llvm/compilation_unit.cc10
-rw-r--r--src/compiler_llvm/compilation_unit.h6
-rw-r--r--src/compiler_llvm/compiler_llvm.cc38
-rw-r--r--src/compiler_llvm/compiler_llvm.h2
-rw-r--r--src/compiler_llvm/gbc_expander.cc18
-rw-r--r--src/compiler_llvm/stub_compiler.cc4
-rw-r--r--src/dex2oat.cc60
-rw-r--r--src/greenland/ir_builder.h4
-rw-r--r--src/modifiers.h2
-rw-r--r--src/oat_file.cc4
-rw-r--r--src/oat_test.cc10
-rw-r--r--src/oatdump.cc5
-rw-r--r--src/thread.cc3
-rw-r--r--src/thread.h6
-rw-r--r--src/trace.cc1
-rw-r--r--src/verifier/method_verifier.cc16
-rw-r--r--src/verifier/method_verifier.h10
27 files changed, 214 insertions, 292 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc
index a76c9c85d3..d28d729826 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1584,7 +1584,8 @@ void ClassLinker::LoadClass(const DexFile& dex_file,
klass->SetClass(GetClassRoot(kJavaLangClass));
uint32_t access_flags = dex_class_def.access_flags_;
// Make sure that none of our runtime-only flags are set.
- CHECK_EQ(access_flags & ~kAccJavaFlagsMask, 0U);
+ // TODO: JACK CLASS ACCESS (HACK TO BE REMOVED)
+ CHECK_EQ(access_flags & ~(kAccJavaFlagsMask | kAccClassJack), 0U);
klass->SetAccessFlags(access_flags);
klass->SetClassLoader(class_loader);
DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot);
diff --git a/src/common_test.h b/src/common_test.h
index 560edeb86d..964db64c69 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -353,6 +353,16 @@ class CommonTest : public testing::Test {
#elif defined(__i386__)
instruction_set = kX86;
#endif
+
+ // TODO: make selectable
+#if defined(ART_USE_PORTABLE_COMPILER)
+ CompilerBackend compiler_backend = kPortable;
+#elif defined(ART_USE_LLVM_COMPILER)
+ CompilerBackend compiler_backend = kIceland; // TODO: remove
+#else
+ CompilerBackend compiler_backend = kQuick;
+#endif
+
runtime_->SetJniDlsymLookupStub(Compiler::CreateJniDlsymLookupStub(instruction_set));
runtime_->SetAbstractMethodErrorStubArray(Compiler::CreateAbstractMethodErrorStub(instruction_set));
for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) {
@@ -374,7 +384,7 @@ class CommonTest : public testing::Test {
}
class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
image_classes_.reset(new std::set<std::string>);
- compiler_.reset(new Compiler(instruction_set, true, 2, false, image_classes_.get(),
+ compiler_.reset(new Compiler(compiler_backend, instruction_set, true, 2, false, image_classes_.get(),
true, true));
runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test
diff --git a/src/compiler.cc b/src/compiler.cc
index ddf9e87e74..4029a01c5d 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -232,7 +232,7 @@ class AOTCompilationStats {
DISALLOW_COPY_AND_ASSIGN(AOTCompilationStats);
};
-static std::string MakeCompilerSoName(InstructionSet instruction_set) {
+static std::string MakeCompilerSoName(CompilerBackend compiler_backend, InstructionSet instruction_set) {
// TODO: is the ARM/Thumb2 instruction set distinction really buying us anything,
// or just causing hassle like this?
if (instruction_set == kThumb2) {
@@ -250,13 +250,12 @@ static std::string MakeCompilerSoName(InstructionSet instruction_set) {
const char* suffix = (kIsDebugBuild ? "d" : "");
// Work out the filename for the compiler library.
-#if defined(ART_USE_LLVM_COMPILER)
- std::string library_name(StringPrintf("art%s-compiler-llvm", suffix));
-#elif defined(ART_USE_GREENLAND_COMPILER)
- std::string library_name(StringPrintf("art%s-compiler-greenland", suffix));
-#else
- std::string library_name(StringPrintf("art%s-compiler-%s", suffix, instruction_set_name.c_str()));
-#endif
+ std::string library_name;
+ if ((compiler_backend == kPortable) || (compiler_backend == kIceland)) {
+ library_name = StringPrintf("art%s-compiler-llvm", suffix);
+ } else {
+ library_name = StringPrintf("art%s-compiler-%s", suffix, instruction_set_name.c_str());
+ }
std::string filename(StringPrintf(OS_SHARED_LIB_FORMAT_STR, library_name.c_str()));
#if defined(__APPLE__)
@@ -292,16 +291,15 @@ static Fn FindFunction(const std::string& compiler_so_name, void* library, const
return fn;
}
-Compiler::Compiler(InstructionSet instruction_set, bool image, size_t thread_count,
- bool support_debugging, const std::set<std::string>* image_classes,
+Compiler::Compiler(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image,
+ size_t thread_count, bool support_debugging, const std::set<std::string>* image_classes,
bool dump_stats, bool dump_timings)
- : instruction_set_(instruction_set),
+ : compiler_backend_(compiler_backend),
+ instruction_set_(instruction_set),
compiled_classes_lock_("compiled classes lock"),
compiled_methods_lock_("compiled method lock"),
compiled_invoke_stubs_lock_("compiled invoke stubs lock"),
-#if defined(ART_USE_LLVM_COMPILER)
compiled_proxy_stubs_lock_("compiled proxy stubs lock"),
-#endif
image_(image),
thread_count_(thread_count),
support_debugging_(support_debugging),
@@ -317,7 +315,7 @@ Compiler::Compiler(InstructionSet instruction_set, bool image, size_t thread_cou
create_invoke_stub_(NULL),
thread_pool_(new ThreadPool(thread_count))
{
- std::string compiler_so_name(MakeCompilerSoName(instruction_set_));
+ std::string compiler_so_name(MakeCompilerSoName(compiler_backend_, instruction_set_));
compiler_library_ = dlopen(compiler_so_name.c_str(), RTLD_LAZY);
if (compiler_library_ == NULL) {
LOG(FATAL) << "Couldn't find compiler library " << compiler_so_name << ": " << dlerror();
@@ -326,36 +324,29 @@ Compiler::Compiler(InstructionSet instruction_set, bool image, size_t thread_cou
CHECK_PTHREAD_CALL(pthread_key_create, (&tls_key_, NULL), "compiler tls key");
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
- // Initialize compiler_context_
+ // TODO: more work needed to combine initializations and allow per-method backend selection
typedef void (*InitCompilerContextFn)(Compiler&);
-
- InitCompilerContextFn init_compiler_context =
- FindFunction<void (*)(Compiler&)>(compiler_so_name,
- compiler_library_,
- "ArtInitCompilerContext");
-
- init_compiler_context(*this);
-#elif defined(ART_USE_QUICK_COMPILER)
- // Initialize compiler_context_
- typedef void (*InitCompilerContextFn)(Compiler&);
-
- InitCompilerContextFn init_compiler_context =
- FindFunction<void (*)(Compiler&)>(compiler_so_name,
- compiler_library_,
- "ArtInitQuickCompilerContext");
+ InitCompilerContextFn init_compiler_context;
+ if ((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)){
+ // Initialize compiler_context_
+ init_compiler_context = FindFunction<void (*)(Compiler&)>(compiler_so_name,
+ compiler_library_, "ArtInitCompilerContext");
+ compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileMethod");
+ } else {
+ init_compiler_context = FindFunction<void (*)(Compiler&)>(compiler_so_name,
+ compiler_library_, "ArtInitQuickCompilerContext");
+ compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtQuickCompileMethod");
+ }
init_compiler_context(*this);
-#endif
- compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileMethod");
jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtJniCompileMethod");
create_invoke_stub_ = FindFunction<CreateInvokeStubFn>(compiler_so_name, compiler_library_, "ArtCreateInvokeStub");
-#if defined(ART_USE_LLVM_COMPILER)
- create_proxy_stub_ = FindFunction<CreateProxyStubFn>(
- compiler_so_name, compiler_library_, "ArtCreateProxyStub");
-#endif
+ if ((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)) {
+ create_proxy_stub_ = FindFunction<CreateProxyStubFn>(
+ compiler_so_name, compiler_library_, "ArtCreateProxyStub");
+ }
CHECK(!Runtime::Current()->IsStarted());
if (!image_) {
@@ -377,12 +368,10 @@ Compiler::~Compiler() {
MutexLock mu(self, compiled_invoke_stubs_lock_);
STLDeleteValues(&compiled_invoke_stubs_);
}
-#if defined(ART_USE_LLVM_COMPILER)
{
MutexLock mu(self, compiled_proxy_stubs_lock_);
STLDeleteValues(&compiled_proxy_stubs_);
}
-#endif
{
MutexLock mu(self, compiled_methods_lock_);
STLDeleteElements(&code_to_patch_);
@@ -392,34 +381,21 @@ Compiler::~Compiler() {
STLDeleteElements(&methods_to_patch_);
}
CHECK_PTHREAD_CALL(pthread_key_delete, (tls_key_), "delete tls key");
-#if defined(ART_USE_LLVM_COMPILER)
- // Uninitialize compiler_context_
typedef void (*UninitCompilerContextFn)(Compiler&);
-
- std::string compiler_so_name(MakeCompilerSoName(instruction_set_));
-
- UninitCompilerContextFn uninit_compiler_context =
- FindFunction<void (*)(Compiler&)>(compiler_so_name,
- compiler_library_,
- "ArtUnInitCompilerContext");
-
- uninit_compiler_context(*this);
-#elif defined(ART_USE_QUICK_COMPILER)
+ std::string compiler_so_name(MakeCompilerSoName(compiler_backend_, instruction_set_));
+ UninitCompilerContextFn uninit_compiler_context;
// Uninitialize compiler_context_
- typedef void (*UninitCompilerContextFn)(Compiler&);
-
- std::string compiler_so_name(MakeCompilerSoName(instruction_set_));
-
- UninitCompilerContextFn uninit_compiler_context =
- FindFunction<void (*)(Compiler&)>(compiler_so_name,
- compiler_library_,
- "ArtUnInitQuickCompilerContext");
-
+ // TODO: rework to combine initialization/uninitialization
+ if ((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)) {
+ uninit_compiler_context = FindFunction<void (*)(Compiler&)>(compiler_so_name,
+ compiler_library_, "ArtUnInitCompilerContext");
+ } else {
+ uninit_compiler_context = FindFunction<void (*)(Compiler&)>(compiler_so_name,
+ compiler_library_, "ArtUnInitQuickCompilerContext");
+ }
uninit_compiler_context(*this);
-#endif
if (compiler_library_ != NULL) {
VLOG(compiler) << "dlclose(" << compiler_library_ << ")";
-#if !defined(ART_USE_QUICK_COMPILER)
/*
* FIXME: Temporary workaround
* Apparently, llvm is adding dctors to atexit, but if we unload
@@ -432,7 +408,6 @@ Compiler::~Compiler() {
* What's the right thing to do here?
*/
dlclose(compiler_library_);
-#endif
}
}
@@ -841,15 +816,15 @@ void Compiler::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_t
// invoked, so this can be passed to the out-of-line runtime support code.
direct_code = 0;
direct_method = 0;
-#if !defined(ART_USE_LLVM_COMPILER)
- if (sharp_type != kStatic && sharp_type != kDirect && sharp_type != kInterface) {
- return;
- }
-#else
- if (sharp_type != kStatic && sharp_type != kDirect) {
- return;
+ if ((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)) {
+ if (sharp_type != kStatic && sharp_type != kDirect) {
+ return;
+ }
+ } else {
+ if (sharp_type != kStatic && sharp_type != kDirect && sharp_type != kInterface) {
+ return;
+ }
}
-#endif
bool method_code_in_boot = method->GetDeclaringClass()->GetClassLoader() == NULL;
if (!method_code_in_boot) {
return;
@@ -1446,8 +1421,7 @@ void Compiler::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access
InsertInvokeStub(key, compiled_invoke_stub);
}
-#if defined(ART_USE_LLVM_COMPILER)
- if (!is_static) {
+ if (((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)) && !is_static) {
const CompiledInvokeStub* compiled_proxy_stub = FindProxyStub(shorty);
if (compiled_proxy_stub == NULL) {
compiled_proxy_stub = (*create_proxy_stub_)(*this, shorty, shorty_len);
@@ -1455,7 +1429,6 @@ void Compiler::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access
InsertProxyStub(shorty, compiled_proxy_stub);
}
}
-#endif
if (self->IsExceptionPending()) {
ScopedObjectAccess soa(self);
@@ -1492,7 +1465,6 @@ void Compiler::InsertInvokeStub(const std::string& key,
}
}
-#if defined(ART_USE_LLVM_COMPILER)
const CompiledInvokeStub* Compiler::FindProxyStub(const char* shorty) const {
MutexLock mu(Thread::Current(), compiled_proxy_stubs_lock_);
ProxyStubTable::const_iterator it = compiled_proxy_stubs_.find(shorty);
@@ -1515,7 +1487,6 @@ void Compiler::InsertProxyStub(const char* shorty,
compiled_proxy_stubs_.Put(shorty, compiled_proxy_stub);
}
}
-#endif
CompiledClass* Compiler::GetCompiledClass(ClassReference ref) const {
MutexLock mu(Thread::Current(), compiled_classes_lock_);
@@ -1537,17 +1508,15 @@ CompiledMethod* Compiler::GetCompiledMethod(MethodReference ref) const {
return it->second;
}
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_QUICK_COMPILER)
void Compiler::SetBitcodeFileName(std::string const& filename) {
typedef void (*SetBitcodeFileNameFn)(Compiler&, std::string const&);
SetBitcodeFileNameFn set_bitcode_file_name =
- FindFunction<SetBitcodeFileNameFn>(MakeCompilerSoName(instruction_set_),
+ FindFunction<SetBitcodeFileNameFn>(MakeCompilerSoName(compiler_backend_, instruction_set_),
compiler_library_,
"compilerLLVMSetBitcodeFileName");
set_bitcode_file_name(*this, filename);
}
-#endif
} // namespace art
diff --git a/src/compiler.h b/src/compiler.h
index 20e608db6a..ba5651336a 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -41,9 +41,15 @@ class CompilationContext;
class OatCompilationUnit;
class TimingLogger;
+enum CompilerBackend {
+ kQuick,
+ kQuickGBC,
+ kPortable,
+ kIceland // Temporary - remove soon
+};
+
// Thread-local storage compiler worker threads
class CompilerTls {
-#if defined(ART_USE_QUICK_COMPILER)
public:
CompilerTls() : llvm_info_(NULL) {}
~CompilerTls() {}
@@ -54,7 +60,6 @@ class CompilerTls {
private:
void* llvm_info_;
-#endif
};
class Compiler {
@@ -64,9 +69,9 @@ class Compiler {
// enabled. "image_classes" lets the compiler know what classes it
// can assume will be in the image, with NULL implying all available
// classes.
- explicit Compiler(InstructionSet instruction_set, bool image, size_t thread_count,
- bool support_debugging, const std::set<std::string>* image_classes,
- bool dump_stats, bool dump_timings);
+ explicit Compiler(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image,
+ size_t thread_count, bool support_debugging,
+ const std::set<std::string>* image_classes, bool dump_stats, bool dump_timings);
~Compiler();
@@ -85,6 +90,10 @@ class Compiler {
return instruction_set_;
}
+ CompilerBackend GetCompilerBackend() const {
+ return compiler_backend_;
+ }
+
bool IsImage() const {
return image_;
}
@@ -120,9 +129,7 @@ class Compiler {
const CompiledInvokeStub* FindInvokeStub(const std::string& key) const
LOCKS_EXCLUDED(compiled_invoke_stubs_lock_);
-#if defined(ART_USE_LLVM_COMPILER)
const CompiledInvokeStub* FindProxyStub(const char* shorty) const;
-#endif
// Callbacks from compiler to see what runtime checks must be generated.
@@ -176,9 +183,7 @@ class Compiler {
size_t literal_offset)
LOCKS_EXCLUDED(compiled_methods_lock_);
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_QUICK_COMPILER)
void SetBitcodeFileName(std::string const& filename);
-#endif
void SetCompilerContext(void* compiler_context) {
compiler_context_ = compiler_context;
@@ -299,13 +304,13 @@ class Compiler {
void InsertInvokeStub(const std::string& key, const CompiledInvokeStub* compiled_invoke_stub)
LOCKS_EXCLUDED(compiled_invoke_stubs_lock_);
-#if defined(ART_USE_LLVM_COMPILER)
void InsertProxyStub(const char* shorty, const CompiledInvokeStub* compiled_proxy_stub);
-#endif
std::vector<const PatchInformation*> code_to_patch_;
std::vector<const PatchInformation*> methods_to_patch_;
+ CompilerBackend compiler_backend_;
+
InstructionSet instruction_set_;
typedef SafeMap<const ClassReference, CompiledClass*> ClassTable;
@@ -323,12 +328,10 @@ class Compiler {
mutable Mutex compiled_invoke_stubs_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
InvokeStubTable compiled_invoke_stubs_ GUARDED_BY(compiled_invoke_stubs_lock_);
-#if defined(ART_USE_LLVM_COMPILER)
typedef SafeMap<std::string, const CompiledInvokeStub*> ProxyStubTable;
// Proxy stubs created for proxy invocation delegation
mutable Mutex compiled_proxy_stubs_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
ProxyStubTable compiled_proxy_stubs_ GUARDED_BY(compiled_proxy_stubs_lock_);
-#endif
bool image_;
size_t thread_count_;
@@ -342,10 +345,8 @@ class Compiler {
const std::set<std::string>* image_classes_;
-#if defined(ART_USE_LLVM_COMPILER)
typedef void (*CompilerCallbackFn)(Compiler& compiler);
typedef MutexLock* (*CompilerMutexLockFn)(Compiler& compiler);
-#endif
void* compiler_library_;
@@ -370,7 +371,6 @@ class Compiler {
pthread_key_t tls_key_;
-#if defined(ART_USE_LLVM_COMPILER)
typedef CompiledInvokeStub* (*CreateProxyStubFn)
(Compiler& compiler, const char* shorty, uint32_t shorty_len);
CreateProxyStubFn create_proxy_stub_;
@@ -385,7 +385,6 @@ class Compiler {
typedef const AbstractMethod::InvokeStub* (*CompilerGetMethodInvokeStubAddrFn)
(const Compiler& compiler, const CompiledInvokeStub* cm, const AbstractMethod* method);
CompilerGetMethodInvokeStubAddrFn compiler_get_method_invoke_stub_addr_;
-#endif
DISALLOW_COPY_AND_ASSIGN(Compiler);
diff --git a/src/compiler/Compiler.h b/src/compiler/Compiler.h
index 7eb32c2f04..11214cf971 100644
--- a/src/compiler/Compiler.h
+++ b/src/compiler/Compiler.h
@@ -20,20 +20,16 @@
#include "dex_file.h"
#include "dex_instruction.h"
-#if defined(ART_USE_QUICK_COMPILER)
namespace llvm {
class Module;
class LLVMContext;
}
-#endif
namespace art {
-#if defined(ART_USE_QUICK_COMPILER)
namespace greenland {
class IntrinsicHelper;
class IRBuilder;
}
-#endif
#define COMPILER_TRACED(X)
#define COMPILER_TRACEE(X)
@@ -141,10 +137,8 @@ enum debugControlVector {
kDebugShowNops,
kDebugCountOpcodes,
kDebugDumpCheckStats,
-#if defined(ART_USE_QUICK_COMPILER)
kDebugDumpBitcodeFile,
kDebugVerifyBitcode,
-#endif
};
enum OatMethodAttributes {
@@ -177,7 +171,6 @@ enum DataFlowAnalysisMode {
kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order
};
-#if defined(ART_USE_QUICK_COMPILER)
class LLVMInfo {
public:
LLVMInfo();
@@ -205,7 +198,6 @@ class LLVMInfo {
UniquePtr<art::greenland::IntrinsicHelper> intrinsic_helper_;
UniquePtr<art::greenland::IRBuilder> ir_builder_;
};
-#endif
struct CompilationUnit;
struct BasicBlock;
diff --git a/src/compiler/CompilerIR.h b/src/compiler/CompilerIR.h
index 5a10831a0d..d08af073d1 100644
--- a/src/compiler/CompilerIR.h
+++ b/src/compiler/CompilerIR.h
@@ -23,10 +23,8 @@
#include "CompilerUtility.h"
#include "oat_compilation_unit.h"
#include "safe_map.h"
-#if defined(ART_USE_QUICK_COMPILER)
#include "greenland/ir_builder.h"
#include "llvm/Module.h"
-#endif
namespace art {
@@ -262,9 +260,7 @@ struct BasicBlock {
bool catchEntry;
bool explicitThrow;
bool conditionalBranch;
-#if defined(ART_USE_QUICK_COMPILER)
bool hasReturn;
-#endif
uint16_t startOffset;
uint16_t nestingDepth;
BBType blockType;
@@ -384,7 +380,6 @@ struct CompilationUnit {
numArenaBlocks(0),
mstats(NULL),
checkstats(NULL),
-#if defined(ART_USE_QUICK_COMPILER)
genBitcode(false),
context(NULL),
module(NULL),
@@ -397,7 +392,6 @@ struct CompilationUnit {
tempName(0),
numShadowFrameEntries(0),
shadowMap(NULL),
-#endif
#ifndef NDEBUG
liveSReg(0),
#endif
@@ -547,7 +541,6 @@ struct CompilationUnit {
int numArenaBlocks;
Memstats* mstats;
Checkstats* checkstats;
-#if defined(ART_USE_QUICK_COMPILER)
bool genBitcode;
LLVMInfo* llvm_info;
llvm::LLVMContext* context;
@@ -567,7 +560,6 @@ struct CompilationUnit {
int numShadowFrameEntries;
int* shadowMap;
std::set<llvm::BasicBlock*> llvmBlocks;
-#endif
#ifndef NDEBUG
/*
* Sanity checking for the register temp tracking. The same ssa
diff --git a/src/compiler/Dataflow.cc b/src/compiler/Dataflow.cc
index 005857553a..c59b63708d 100644
--- a/src/compiler/Dataflow.cc
+++ b/src/compiler/Dataflow.cc
@@ -1854,12 +1854,10 @@ bool basicBlockOpt(CompilationUnit* cUnit, BasicBlock* bb)
case Instruction::CMPG_FLOAT:
case Instruction::CMPG_DOUBLE:
case Instruction::CMP_LONG:
-#if defined(ART_USE_QUICK_COMPILER)
if (cUnit->genBitcode) {
// Bitcode doesn't allow this optimization.
break;
}
-#endif
if (mir->next != NULL) {
MIR* mirNext = mir->next;
Instruction::Code brOpcode = mirNext->dalvikInsn.opcode;
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index c19751dfa3..c5d5c21d43 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -21,7 +21,6 @@
#include "object.h"
#include "runtime.h"
-#if defined(ART_USE_QUICK_COMPILER)
#include <llvm/Support/Threading.h>
namespace {
@@ -32,11 +31,9 @@ namespace {
llvm::llvm_start_multithreaded();
}
}
-#endif
namespace art {
-#if defined(ART_USE_QUICK_COMPILER)
LLVMInfo::LLVMInfo() {
#if !defined(ART_USE_LLVM_COMPILER)
pthread_once(&llvm_multi_init, InitializeLLVMForQuick);
@@ -62,7 +59,6 @@ extern "C" void ArtUnInitQuickCompilerContext(art::Compiler& compiler) {
delete reinterpret_cast<LLVMInfo*>(compiler.GetCompilerContext());
compiler.SetCompilerContext(NULL);
}
-#endif
/* Default optimizer/debug setting for the compiler. */
static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations
@@ -94,10 +90,8 @@ static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes
//(1 << kDebugShowNops) |
//(1 << kDebugCountOpcodes) |
//(1 << kDebugDumpCheckStats) |
-#if defined(ART_USE_QUICK_COMPILER)
//(1 << kDebugDumpBitcodeFile) |
//(1 << kDebugVerifyBitcode) |
-#endif
0;
inline bool contentIsInsn(const u2* codePtr) {
@@ -788,14 +782,12 @@ void oatInit(CompilationUnit* cUnit, const Compiler& compiler) {
}
CompiledMethod* compileMethod(Compiler& compiler,
+ const CompilerBackend compilerBackend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
uint32_t method_idx, jobject class_loader,
- const DexFile& dex_file
-#if defined(ART_USE_QUICK_COMPILER)
- , LLVMInfo* llvm_info,
- bool gbcOnly
-#endif
+ const DexFile& dex_file,
+ LLVMInfo* llvm_info
)
{
VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "...";
@@ -824,16 +816,18 @@ CompiledMethod* compileMethod(Compiler& compiler,
cUnit->numIns = code_item->ins_size_;
cUnit->numRegs = code_item->registers_size_ - cUnit->numIns;
cUnit->numOuts = code_item->outs_size_;
-#if defined(ART_USE_QUICK_COMPILER)
DCHECK((cUnit->instructionSet == kThumb2) ||
(cUnit->instructionSet == kX86) ||
(cUnit->instructionSet == kMips));
- cUnit->llvm_info = llvm_info;
- if (cUnit->instructionSet == kThumb2) {
- // TODO: remove this once x86 is tested
+ if ((compilerBackend == kQuickGBC) || (compilerBackend == kPortable)) {
cUnit->genBitcode = true;
}
-#endif
+ DCHECK_NE(compilerBackend, kIceland); // TODO: remove when Portable/Iceland merge complete
+ // TODO: remove this once x86 is tested
+ if (cUnit->genBitcode && (cUnit->instructionSet != kThumb2)) {
+ UNIMPLEMENTED(WARNING) << "GBC generation untested for non-Thumb targets";
+ }
+ cUnit->llvm_info = llvm_info;
/* Adjust this value accordingly once inlining is performed */
cUnit->numDalvikRegisters = code_item->registers_size_;
// TODO: set this from command line
@@ -848,13 +842,9 @@ CompiledMethod* compileMethod(Compiler& compiler,
cUnit->printMe = VLOG_IS_ON(compiler) ||
(cUnit->enableDebug & (1 << kDebugVerbose));
}
-#if defined(ART_USE_QUICK_COMPILER)
- if (cUnit->genBitcode) {
#ifndef NDEBUG
+ if (cUnit->genBitcode) {
cUnit->enableDebug |= (1 << kDebugVerifyBitcode);
-#endif
- //cUnit->printMe = true;
- //cUnit->enableDebug |= (1 << kDebugDumpBitcodeFile);
}
#endif
@@ -1098,21 +1088,14 @@ if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboa
}
if (cUnit->qdMode) {
-#if !defined(ART_USE_QUICK_COMPILER)
// Bitcode generation requires full dataflow analysis
- cUnit->disableDataflow = true;
-#endif
+ cUnit->disableDataflow = !cUnit->genBitcode;
// Disable optimization which require dataflow/ssa
- cUnit->disableOpt |=
-#if !defined(ART_USE_QUICK_COMPILER)
- (1 << kNullCheckElimination) |
-#endif
- (1 << kBBOpt) |
- (1 << kPromoteRegs);
+ cUnit->disableOpt |= (1 << kBBOpt) | (1 << kPromoteRegs) | (1 << kNullCheckElimination);
if (cUnit->printMe) {
LOG(INFO) << "QD mode enabled: "
<< PrettyMethod(method_idx, dex_file)
- << " too big: " << cUnit->numBlocks;
+ << " num blocks: " << cUnit->numBlocks;
}
}
@@ -1168,12 +1151,11 @@ if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboa
/* Allocate Registers using simple local allocation scheme */
oatSimpleRegAlloc(cUnit.get());
-#if defined(ART_USE_QUICK_COMPILER)
/* Go the LLVM path? */
if (cUnit->genBitcode) {
// MIR->Bitcode
oatMethodMIR2Bitcode(cUnit.get());
- if (gbcOnly) {
+ if (compilerBackend == kPortable) {
// all done
oatArenaReset(cUnit.get());
return NULL;
@@ -1181,7 +1163,6 @@ if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboa
// Bitcode->LIR
oatMethodBitcode2LIR(cUnit.get());
} else {
-#endif
if (specialCase != kNoHandler) {
/*
* Custom codegen for special cases. If for any reason the
@@ -1195,9 +1176,7 @@ if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboa
if (cUnit->firstLIRInsn == NULL) {
oatMethodMIR2LIR(cUnit.get());
}
-#if defined(ART_USE_QUICK_COMPILER)
}
-#endif
// Debugging only
if (cUnit->enableDebug & (1 << kDebugDumpCFG)) {
@@ -1268,55 +1247,30 @@ if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboa
return result;
}
-#if defined(ART_USE_QUICK_COMPILER)
CompiledMethod* oatCompileMethod(Compiler& compiler,
+ const CompilerBackend backend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
uint32_t method_idx, jobject class_loader,
- const DexFile& dex_file)
+ const DexFile& dex_file,
+ LLVMInfo* llvmInfo)
{
- return compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
- dex_file, NULL, false);
+ return compileMethod(compiler, backend, code_item, access_flags, invoke_type, method_idx, class_loader,
+ dex_file, llvmInfo);
}
-/*
- * Given existing llvm module, context, intrinsic_helper and IRBuilder,
- * add the bitcode for the method described by code_item to the module.
- */
-void oatCompileMethodToGBC(Compiler& compiler,
- const DexFile::CodeItem* code_item,
- uint32_t access_flags, InvokeType invoke_type,
- uint32_t method_idx, jobject class_loader,
- const DexFile& dex_file,
- LLVMInfo* llvm_info)
-{
- compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
- dex_file, llvm_info, true);
-}
-#else
-CompiledMethod* oatCompileMethod(Compiler& compiler,
- const DexFile::CodeItem* code_item,
- uint32_t access_flags, InvokeType invoke_type,
- uint32_t method_idx, jobject class_loader,
- const DexFile& dex_file)
-{
- return compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
- dex_file);
-}
-#endif
-
} // namespace art
-#if !defined(ART_USE_LLVM_COMPILER)
extern "C" art::CompiledMethod*
- ArtCompileMethod(art::Compiler& compiler,
- const art::DexFile::CodeItem* code_item,
- uint32_t access_flags, art::InvokeType invoke_type,
- uint32_t method_idx, jobject class_loader,
- const art::DexFile& dex_file)
+ ArtQuickCompileMethod(art::Compiler& compiler,
+ const art::DexFile::CodeItem* code_item,
+ uint32_t access_flags, art::InvokeType invoke_type,
+ uint32_t method_idx, jobject class_loader,
+ const art::DexFile& dex_file)
{
CHECK_EQ(compiler.GetInstructionSet(), art::oatInstructionSet());
- return art::oatCompileMethod(compiler, code_item, access_flags, invoke_type,
- method_idx, class_loader, dex_file);
+ // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default
+ art::CompilerBackend backend = compiler.GetCompilerBackend();
+ return art::oatCompileMethod(compiler, backend, code_item, access_flags, invoke_type,
+ method_idx, class_loader, dex_file, NULL /* use thread llvmInfo */);
}
-#endif
diff --git a/src/compiler/Ralloc.cc b/src/compiler/Ralloc.cc
index bf69ce4086..ca25b38fdc 100644
--- a/src/compiler/Ralloc.cc
+++ b/src/compiler/Ralloc.cc
@@ -485,19 +485,12 @@ void oatSimpleRegAlloc(CompilationUnit* cUnit)
}
}
-#if defined(ART_USE_QUICK_COMPILER)
if (!cUnit->genBitcode) {
/* Remap names */
oatDataFlowAnalysisDispatcher(cUnit, remapNames,
kPreOrderDFSTraversal,
false /* isIterative */);
}
-#else
- /* Remap names */
- oatDataFlowAnalysisDispatcher(cUnit, remapNames,
- kPreOrderDFSTraversal,
- false /* isIterative */);
-#endif
/* Do type & size inference pass */
oatDataFlowAnalysisDispatcher(cUnit, inferTypeAndSize,
diff --git a/src/compiler/codegen/MethodBitcode.cc b/src/compiler/codegen/MethodBitcode.cc
index cf07ea45c3..79208833f1 100644
--- a/src/compiler/codegen/MethodBitcode.cc
+++ b/src/compiler/codegen/MethodBitcode.cc
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#if defined(ART_USE_QUICK_COMPILER)
#include "object_utils.h"
#include <llvm/Support/ToolOutputFile.h>
@@ -3537,5 +3536,3 @@ void oatMethodBitcode2LIR(CompilationUnit* cUnit)
} // namespace art
-
-#endif // ART_USE_QUICK_COMPILER
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index ba71aee01d..a27ea6e41a 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -154,7 +154,7 @@ namespace compiler_llvm {
llvm::FunctionPass*
CreateGBCExpanderPass(const greenland::IntrinsicHelper& intrinsic_helper,
IRBuilder& irb);
-#elif defined(ART_USE_QUICK_COMPILER)
+#elif defined(ART_USE_PORTABLE_COMPILER)
llvm::FunctionPass*
CreateGBCExpanderPass(const greenland::IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
Compiler* compiler, OatCompilationUnit* oat_compilation_unit);
@@ -166,7 +166,7 @@ llvm::Module* makeLLVMModuleContents(llvm::Module* module);
CompilationUnit::CompilationUnit(const CompilerLLVM* compiler_llvm,
size_t cunit_idx)
: compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
-#if !defined(ART_USE_QUICK_COMPILER)
+#if !defined(ART_USE_PORTABLE_COMPILER)
context_.reset(new llvm::LLVMContext());
module_ = new llvm::Module("art", *context_);
#else
@@ -210,7 +210,7 @@ CompilationUnit::CompilationUnit(const CompilerLLVM* compiler_llvm,
CompilationUnit::~CompilationUnit() {
#if defined(ART_USE_DEXLANG_FRONTEND)
delete dex_lang_ctx_;
-#elif defined(ART_USE_QUICK_COMPILER)
+#elif defined(ART_USE_PORTABLE_COMPILER)
llvm::LLVMContext* llvm_context = context_.release(); // Managed by llvm_info_
CHECK(llvm_context != NULL);
#endif
@@ -330,7 +330,7 @@ bool CompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
// regular FunctionPass.
#if defined(ART_USE_DEXLANG_FRONTEND)
fpm.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get()));
-#elif defined(ART_USE_QUICK_COMPILER)
+#elif defined(ART_USE_PORTABLE_COMPILER)
fpm.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
compiler_, oat_compilation_unit_));
#endif
@@ -340,7 +340,7 @@ bool CompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
llvm::FunctionPassManager fpm2(module_);
#if defined(ART_USE_DEXLANG_FRONTEND)
fpm2.add(CreateGBCExpanderPass(dex_lang_ctx_->GetIntrinsicHelper(), *irb_.get()));
-#elif defined(ART_USE_QUICK_COMPILER)
+#elif defined(ART_USE_PORTABLE_COMPILER)
fpm2.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
compiler_, oat_compilation_unit_));
#endif
diff --git a/src/compiler_llvm/compilation_unit.h b/src/compiler_llvm/compilation_unit.h
index 6ad7ee1ad0..0b40388cee 100644
--- a/src/compiler_llvm/compilation_unit.h
+++ b/src/compiler_llvm/compilation_unit.h
@@ -28,7 +28,7 @@
#include "runtime_support_func.h"
#include "safe_map.h"
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
# include "compiler/Dalvik.h"
# include "compiler.h"
# include "oat_compilation_unit.h"
@@ -90,7 +90,7 @@ class CompilationUnit {
bitcode_filename_ = bitcode_filename;
}
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
LLVMInfo* GetQuickContext() const {
return llvm_info_.get();
}
@@ -124,7 +124,7 @@ class CompilationUnit {
#if defined(ART_USE_DEXLANG_FRONTEND)
greenland::DexLang::Context* dex_lang_ctx_;
#endif
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
UniquePtr<LLVMInfo> llvm_info_;
Compiler* compiler_;
OatCompilationUnit* oat_compilation_unit_;
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index a964b4009b..aa5ec82ad6 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -38,14 +38,15 @@
#include <llvm/Support/TargetSelect.h>
#include <llvm/Support/Threading.h>
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
namespace art {
-void oatCompileMethodToGBC(Compiler& compiler,
- const DexFile::CodeItem* code_item,
- uint32_t access_flags, InvokeType invoke_type,
- uint32_t method_idx, jobject class_loader,
- const DexFile& dex_file,
- LLVMInfo* llvm_info);
+void oatCompileMethod(Compiler& compiler,
+ const CompilerBackend compilerBackend,
+ const DexFile::CodeItem* code_item,
+ uint32_t access_flags, InvokeType invoke_type,
+ uint32_t method_idx, jobject class_loader,
+ const DexFile& dex_file,
+ LLVMInfo* llvm_info);
}
#endif
@@ -152,7 +153,7 @@ CompileDexMethod(OatCompilationUnit* oat_compilation_unit, InvokeType invoke_typ
return new CompiledMethod(cunit->GetInstructionSet(),
cunit->GetCompiledCode());
-#elif defined(ART_USE_QUICK_COMPILER)
+#elif defined(ART_USE_PORTABLE_COMPILER)
std::string methodName(PrettyMethod(oat_compilation_unit->GetDexMethodIndex(),
*oat_compilation_unit->GetDexFile()));
if (insn_set_ == kX86) {
@@ -162,16 +163,17 @@ CompileDexMethod(OatCompilationUnit* oat_compilation_unit, InvokeType invoke_typ
return method_compiler->Compile();
} else {
- // Use quick
- oatCompileMethodToGBC(*compiler_,
- oat_compilation_unit->GetCodeItem(),
- oat_compilation_unit->access_flags_,
- invoke_type,
- oat_compilation_unit->GetDexMethodIndex(),
- oat_compilation_unit->GetClassLoader(),
- *oat_compilation_unit->GetDexFile(),
- cunit->GetQuickContext()
- );
+ // TODO: consolidate ArtCompileMethods
+ oatCompileMethod(*compiler_,
+ kPortable,
+ oat_compilation_unit->GetCodeItem(),
+ oat_compilation_unit->access_flags_,
+ invoke_type,
+ oat_compilation_unit->GetDexMethodIndex(),
+ oat_compilation_unit->GetClassLoader(),
+ *oat_compilation_unit->GetDexFile(),
+ cunit->GetQuickContext()
+ );
cunit->SetCompiler(compiler_);
cunit->SetOatCompilationUnit(oat_compilation_unit);
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 39223ef125..0867e566e9 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -77,7 +77,7 @@ class CompilerLLVM {
CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit,
InvokeType invoke_type);
-#if defined(ART_USE_LLVM_COMPILER) && defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func);
#endif
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler_llvm/gbc_expander.cc
index 484dd77e3a..18cef411c3 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler_llvm/gbc_expander.cc
@@ -370,7 +370,7 @@ bool GBCExpanderPass::runOnFunction(llvm::Function& func) {
func_ = &func;
changed_ = false; // Assume unchanged
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
basic_blocks_.resize(code_item_->insns_size_in_code_units_);
basic_block_landing_pads_.resize(code_item_->tries_size_, NULL);
basic_block_unwind_ = NULL;
@@ -1032,7 +1032,7 @@ llvm::Value* GBCExpanderPass::Expand_DivRem(llvm::CallInst& call_inst,
bool is_div, JType op_jty) {
llvm::Value* dividend = call_inst.getArgOperand(0);
llvm::Value* divisor = call_inst.getArgOperand(1);
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
EmitGuard_DivZeroException(dex_pc, divisor, op_jty);
#endif
@@ -1145,7 +1145,7 @@ void GBCExpanderPass::Expand_SetShadowFrameEntry(llvm::Value* obj,
};
llvm::Value* entry_addr = irb_.CreateGEP(shadow_frame_, gep_index);
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
if (obj->getType() != irb_.getJObjectTy()) {
obj = irb_.getJNull();
}
@@ -1155,7 +1155,7 @@ void GBCExpanderPass::Expand_SetShadowFrameEntry(llvm::Value* obj,
}
void GBCExpanderPass::Expand_PopShadowFrame() {
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
if (old_shadow_frame_ == NULL) {
return;
}
@@ -1191,7 +1191,7 @@ void GBCExpanderPass::InsertStackOverflowCheck(llvm::Function& func) {
// alloca instructions)
EmitStackOverflowCheck(&*first_non_alloca);
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
irb_.Runtime().EmitTestSuspend();
#endif
@@ -2385,7 +2385,7 @@ void GBCExpanderPass::EmitMarkGCCard(llvm::Value* value, llvm::Value* target_add
}
void GBCExpanderPass::EmitUpdateDexPC(uint32_t dex_pc) {
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
if (shadow_frame_ == NULL) {
return;
}
@@ -2477,7 +2477,7 @@ llvm::FunctionType* GBCExpanderPass::GetFunctionType(uint32_t method_idx,
// Get return type
char ret_shorty = shorty[0];
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
ret_shorty = art::remapShorty(ret_shorty);
#endif
llvm::Type* ret_type = irb_.getJType(ret_shorty, kAccurate);
@@ -2492,7 +2492,7 @@ llvm::FunctionType* GBCExpanderPass::GetFunctionType(uint32_t method_idx,
}
for (uint32_t i = 1; i < shorty_size; ++i) {
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
char shorty_type = art::remapShorty(shorty[i]);
args_type.push_back(irb_.getJType(shorty_type, kAccurate));
#else
@@ -2627,7 +2627,7 @@ llvm::BasicBlock* GBCExpanderPass::GetUnwindBasicBlock() {
// Emit the code to return default value (zero) for the given return type.
char ret_shorty = oat_compilation_unit_->GetShorty()[0];
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
ret_shorty = art::remapShorty(ret_shorty);
#endif
if (ret_shorty == 'V') {
diff --git a/src/compiler_llvm/stub_compiler.cc b/src/compiler_llvm/stub_compiler.cc
index 3ac5f2acca..4854c9fa29 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler_llvm/stub_compiler.cc
@@ -151,7 +151,7 @@ CompiledInvokeStub* StubCompiler::CreateInvokeStub(bool is_static,
llvm::Value* code_addr = irb_.CreateLoad(code_field_addr, kTBAAJRuntime);
llvm::CallInst* retval = irb_.CreateCall(code_addr, args);
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
for (size_t i = 1; i < shorty_size; ++i) {
switch(shorty[i]) {
case 'Z':
@@ -216,7 +216,7 @@ CompiledInvokeStub* StubCompiler::CreateProxyStub(const char* shorty) {
llvm::Function* func =
llvm::Function::Create(accurate_func_type, llvm::Function::ExternalLinkage,
func_name, module_);
-#if defined(ART_USE_QUICK_COMPILER)
+#if defined(ART_USE_PORTABLE_COMPILER)
switch(shorty[0]) {
case 'Z':
case 'C':
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 20872e1aa4..a8f42afbd0 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -83,11 +83,9 @@ static void Usage(const char* fmt, ...) {
UsageError(" to the file descriptor specified by --oat-fd.");
UsageError(" Example: --oat-location=/data/art-cache/system@app@Calculator.apk.oat");
UsageError("");
-#if defined(ART_USE_LLVM_COMPILER)
UsageError(" --bitcode=<file.bc>: specifies the optional bitcode filename.");
UsageError(" Example: --bitcode=/system/framework/boot.bc");
UsageError("");
-#endif
UsageError(" --image=<file.art>: specifies the output image filename.");
UsageError(" Example: --image=/system/framework/boot.art");
UsageError("");
@@ -111,6 +109,10 @@ static void Usage(const char* fmt, ...) {
UsageError(" Example: --instruction-set=x86");
UsageError(" Default: arm");
UsageError("");
+ UsageError(" --compiler-backend=(Quick|QuickGBC|Portable): select compiler backend");
+ UsageError(" set.");
+ UsageError(" Example: --instruction-set=Portable");
+ UsageError(" Default: Quick");
UsageError(" --runtime-arg <argument>: used to specify various arguments for the runtime,");
UsageError(" such as initial heap size, maximum heap size, and verbose output.");
UsageError(" Use a separate --runtime-arg switch for each argument.");
@@ -122,14 +124,15 @@ static void Usage(const char* fmt, ...) {
class Dex2Oat {
public:
- static bool Create(Dex2Oat** p_dex2oat, Runtime::Options& options, InstructionSet instruction_set,
- size_t thread_count, bool support_debugging)
+ static bool Create(Dex2Oat** p_dex2oat, Runtime::Options& options, CompilerBackend compiler_backend,
+ InstructionSet instruction_set, size_t thread_count, bool support_debugging)
SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_) {
if (!CreateRuntime(options, instruction_set)) {
*p_dex2oat = NULL;
return false;
}
- *p_dex2oat = new Dex2Oat(Runtime::Current(), instruction_set, thread_count, support_debugging);
+ *p_dex2oat = new Dex2Oat(Runtime::Current(), compiler_backend, instruction_set, thread_count,
+ support_debugging);
return true;
}
@@ -209,9 +212,7 @@ class Dex2Oat {
const std::string* host_prefix,
const std::vector<const DexFile*>& dex_files,
File* oat_file,
-#if defined(ART_USE_LLVM_COMPILER)
const std::string& bitcode_filename,
-#endif
bool image,
const std::set<std::string>* image_classes,
bool dump_stats,
@@ -234,7 +235,8 @@ class Dex2Oat {
Runtime::Current()->SetCompileTimeClassPath(class_loader, class_path_files);
}
- UniquePtr<Compiler> compiler(new Compiler(instruction_set_,
+ UniquePtr<Compiler> compiler(new Compiler(compiler_backend_,
+ instruction_set_,
image,
thread_count_,
support_debugging_,
@@ -242,9 +244,9 @@ class Dex2Oat {
dump_stats,
dump_timings));
-#if defined(ART_USE_LLVM_COMPILER)
- compiler->SetBitcodeFileName(bitcode_filename);
-#endif
+ if ((compiler_backend_ == kPortable) || (compiler_backend_ == kIceland)) {
+ compiler->SetBitcodeFileName(bitcode_filename);
+ }
Thread::Current()->TransitionFromRunnableToSuspended(kNative);
@@ -295,9 +297,10 @@ class Dex2Oat {
}
private:
- explicit Dex2Oat(Runtime* runtime, InstructionSet instruction_set, size_t thread_count,
- bool support_debugging)
- : instruction_set_(instruction_set),
+ explicit Dex2Oat(Runtime* runtime, CompilerBackend compiler_backend, InstructionSet instruction_set,
+ size_t thread_count, bool support_debugging)
+ : compiler_backend_(compiler_backend),
+ instruction_set_(instruction_set),
runtime_(runtime),
thread_count_(thread_count),
support_debugging_(support_debugging),
@@ -431,6 +434,8 @@ class Dex2Oat {
return false;
}
+ const CompilerBackend compiler_backend_;
+
const InstructionSet instruction_set_;
Runtime* runtime_;
@@ -487,9 +492,7 @@ static int dex2oat(int argc, char** argv) {
std::string oat_filename;
std::string oat_location;
int oat_fd = -1;
-#if defined(ART_USE_LLVM_COMPILER)
std::string bitcode_filename;
-#endif
const char* image_classes_filename = NULL;
std::string image_filename;
std::string boot_image_filename;
@@ -498,6 +501,13 @@ static int dex2oat(int argc, char** argv) {
std::vector<const char*> runtime_args;
int thread_count = sysconf(_SC_NPROCESSORS_CONF);
bool support_debugging = false;
+#if defined(ART_USE_PORTABLE_COMPILER)
+ CompilerBackend compiler_backend = kPortable;
+#elif defined(ART_USE_LLVM_COMPILER)
+ CompilerBackend compiler_backend = kIceland;
+#else
+ CompilerBackend compiler_backend = kQuick;
+#endif
#if defined(__arm__)
InstructionSet instruction_set = kThumb2;
#elif defined(__i386__)
@@ -543,10 +553,8 @@ static int dex2oat(int argc, char** argv) {
}
} else if (option.starts_with("--oat-location=")) {
oat_location = option.substr(strlen("--oat-location=")).data();
-#if defined(ART_USE_LLVM_COMPILER)
} else if (option.starts_with("--bitcode=")) {
bitcode_filename = option.substr(strlen("--bitcode=")).data();
-#endif
} else if (option.starts_with("--image=")) {
image_filename = option.substr(strlen("--image=")).data();
} else if (option.starts_with("--image-classes=")) {
@@ -571,6 +579,18 @@ static int dex2oat(int argc, char** argv) {
} else if (instruction_set_str == "x86") {
instruction_set = kX86;
}
+ } else if (option.starts_with("--compiler-backend=")) {
+ StringPiece backend_str = option.substr(strlen("--compiler-backend=")).data();
+ if (backend_str == "Quick") {
+ compiler_backend = kQuick;
+ } else if (backend_str == "QuickGBC") {
+ compiler_backend = kQuickGBC;
+ } else if (backend_str == "Iceland") {
+ // TODO: remove this when Portable/Iceland merge complete
+ compiler_backend = kIceland;
+ } else if (backend_str == "Portable") {
+ compiler_backend = kPortable;
+ }
} else if (option == "--runtime-arg") {
if (++i >= argc) {
Usage("Missing required argument for --runtime-arg");
@@ -704,7 +724,7 @@ static int dex2oat(int argc, char** argv) {
}
Dex2Oat* p_dex2oat;
- if (!Dex2Oat::Create(&p_dex2oat, options, instruction_set, thread_count, support_debugging)) {
+ if (!Dex2Oat::Create(&p_dex2oat, options, compiler_backend, instruction_set, thread_count, support_debugging)) {
LOG(ERROR) << "Failed to create dex2oat";
return EXIT_FAILURE;
}
@@ -755,9 +775,7 @@ static int dex2oat(int argc, char** argv) {
host_prefix.get(),
dex_files,
oat_file.get(),
-#if defined(ART_USE_LLVM_COMPILER)
bitcode_filename,
-#endif
image,
image_classes.get(),
dump_stats,
diff --git a/src/greenland/ir_builder.h b/src/greenland/ir_builder.h
index baa0ae7657..ba8e5e1840 100644
--- a/src/greenland/ir_builder.h
+++ b/src/greenland/ir_builder.h
@@ -33,7 +33,6 @@ namespace llvm {
namespace art {
namespace greenland {
-#if defined(ART_USE_QUICK_COMPILER)
class InserterWithDexOffset
: public llvm::IRBuilderDefaultInserter<true> {
public:
@@ -54,9 +53,6 @@ class InserterWithDexOffset
};
typedef llvm::IRBuilder<true, llvm::NoFolder, InserterWithDexOffset> LLVMIRBuilder;
-#else
-typedef llvm::IRBuilder<true> LLVMIRBuilder;
-#endif
class IRBuilder : public LLVMIRBuilder {
public:
diff --git a/src/modifiers.h b/src/modifiers.h
index 070130fc72..ee2d4ff597 100644
--- a/src/modifiers.h
+++ b/src/modifiers.h
@@ -43,6 +43,8 @@ static const uint32_t kAccJavaFlagsMask = 0xffff; // bits set from Java sources
static const uint32_t kAccConstructor = 0x00010000; // method (dex only)
static const uint32_t kAccDeclaredSynchronized = 0x00020000; // method (dex only)
static const uint32_t kAccClassIsProxy = 0x00040000; // class (dex only)
+// TODO: JACK CLASS ACCESS (HACK TO BE REMOVED)
+static const uint32_t kAccClassJack = 0x000080000; // class (dex only)
// Special runtime-only flags.
// Note: if only kAccClassIsReference is set, we have a soft reference.
diff --git a/src/oat_file.cc b/src/oat_file.cc
index 4e05325fdf..145d2e2d62 100644
--- a/src/oat_file.cc
+++ b/src/oat_file.cc
@@ -70,11 +70,7 @@ OatFile::~OatFile() {
bool OatFile::Map(File& file,
byte* requested_base,
-#if defined(ART_USE_LLVM_COMPILER)
- RelocationBehavior reloc,
-#else
RelocationBehavior /*UNUSED*/,
-#endif
bool writable) {
OatHeader oat_header;
bool success = file.ReadFully(&oat_header, sizeof(oat_header));
diff --git a/src/oat_test.cc b/src/oat_test.cc
index 64c502d39a..bb6305a08b 100644
--- a/src/oat_test.cc
+++ b/src/oat_test.cc
@@ -65,7 +65,15 @@ TEST_F(OatTest, WriteRead) {
jobject class_loader = NULL;
if (compile) {
- compiler_.reset(new Compiler(kThumb2, false, 2, false, NULL, true, true));
+ // TODO: make selectable
+#if defined(ART_USE_PORTABLE_COMPILER)
+ CompilerBackend compiler_backend = kPortable;
+#elif defined(ART_USE_LLVM_COMPILER)
+ CompilerBackend compiler_backend = kIceland; // TODO: remove
+#else
+ CompilerBackend compiler_backend = kQuick;
+#endif
+ compiler_.reset(new Compiler(compiler_backend, kThumb2, false, 2, false, NULL, true, true));
compiler_->CompileAll(class_loader, class_linker->GetBootClassPath());
}
diff --git a/src/oatdump.cc b/src/oatdump.cc
index 4231ecf422..0db71c9521 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -247,7 +247,10 @@ class OatDumper {
UniquePtr<const OatFile::OatClass> oat_class(oat_dex_file.GetOatClass(class_def_index));
CHECK(oat_class.get() != NULL);
os << StringPrintf("%zd: %s (type_idx=%d) (", class_def_index, descriptor, class_def.class_idx_)
- << oat_class->GetStatus() << ")\n";
+ << oat_class->GetStatus() << ")"
+ // TODO: JACK CLASS ACCESS (HACK TO BE REMOVED)
+ << ( (class_def.access_flags_ & kAccClassJack) == kAccClassJack ? " (Jack)" : "" )
+ << "\n";
DumpOatClass(os, *oat_class.get(), *(dex_file.get()), class_def);
}
diff --git a/src/thread.cc b/src/thread.cc
index 055184483a..2f8a9a77f9 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -292,9 +292,6 @@ void Thread::Init(ThreadList* thread_list, JavaVMExt* java_vm) {
SetUpAlternateSignalStack();
InitCpu();
InitFunctionPointers();
-#ifdef ART_USE_GREENLAND_COMPILER
- InitRuntimeEntryPoints(&runtime_entry_points_);
-#endif
InitCardTable();
InitTid();
diff --git a/src/thread.h b/src/thread.h
index 8dbfb557c0..798e96a908 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -36,9 +36,6 @@
#include "stack_indirect_reference_table.h"
#include "trace.h"
#include "UniquePtr.h"
-#ifdef ART_USE_GREENLAND_COMPILER
-#include "greenland/runtime_entry_points.h"
-#endif
namespace art {
@@ -777,9 +774,6 @@ class PACKED Thread {
// Runtime support function pointers
// TODO: move this near the top, since changing its offset requires all oats to be recompiled!
EntryPoints entrypoints_;
-#ifdef ART_USE_GREENLAND_COMPILER
- RuntimeEntryPoints runtime_entry_points_;
-#endif
private:
// How many times has our pthread key's destructor been called?
diff --git a/src/trace.cc b/src/trace.cc
index d0132e1f4e..753b80faec 100644
--- a/src/trace.cc
+++ b/src/trace.cc
@@ -241,6 +241,7 @@ const void* Trace::GetSavedCodeFromMap(const AbstractMethod* method) {
void Trace::SaveAndUpdateCode(AbstractMethod* method) {
#if defined(ART_USE_LLVM_COMPILER)
+ UNUSED(method);
UNIMPLEMENTED(FATAL);
#else
void* trace_stub = GetLogTraceEntryPoint();
diff --git a/src/verifier/method_verifier.cc b/src/verifier/method_verifier.cc
index 67507bc3c6..bd77a3cbbc 100644
--- a/src/verifier/method_verifier.cc
+++ b/src/verifier/method_verifier.cc
@@ -32,7 +32,7 @@
#include "runtime.h"
#include "stringpiece.h"
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
#include "greenland/backend_types.h"
#include "greenland/inferred_reg_category_map.h"
#endif
@@ -962,7 +962,7 @@ bool MethodVerifier::CheckVarArgRangeRegs(uint32_t vA, uint32_t vC) {
return true;
}
-#if !defined(ART_USE_LLVM_COMPILER) && !defined(ART_USE_GREENLAND_COMPILER)
+#if !defined(ART_USE_LLVM_COMPILER)
static const std::vector<uint8_t>* CreateLengthPrefixedDexGcMap(const std::vector<uint8_t>& gc_map) {
std::vector<uint8_t>* length_prefixed_gc_map = new std::vector<uint8_t>;
length_prefixed_gc_map->push_back((gc_map.size() & 0xff000000) >> 24);
@@ -1012,7 +1012,7 @@ bool MethodVerifier::VerifyCodeFlow() {
Compiler::MethodReference ref(dex_file_, method_idx_);
-#if !defined(ART_USE_LLVM_COMPILER) && !defined(ART_USE_GREENLAND_COMPILER)
+#if !defined(ART_USE_LLVM_COMPILER)
/* Generate a register map and add it to the method. */
UniquePtr<const std::vector<uint8_t> > map(GenerateGcMap());
@@ -1026,7 +1026,7 @@ bool MethodVerifier::VerifyCodeFlow() {
const std::vector<uint8_t>* dex_gc_map = CreateLengthPrefixedDexGcMap(*(map.get()));
verifier::MethodVerifier::SetDexGcMap(ref, *dex_gc_map);
-#else // defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#else // defined(ART_USE_LLVM_COMPILER)
/* Generate Inferred Register Category for LLVM-based Code Generator */
const InferredRegCategoryMap* table = GenerateInferredRegCategoryMap();
verifier::MethodVerifier::SetInferredRegCategoryMap(ref, *table);
@@ -3262,7 +3262,7 @@ MethodVerifier::DexGcMapTable* MethodVerifier::dex_gc_maps_ = NULL;
Mutex* MethodVerifier::rejected_classes_lock_ = NULL;
MethodVerifier::RejectedClassesTable* MethodVerifier::rejected_classes_ = NULL;
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
Mutex* MethodVerifier::inferred_reg_category_maps_lock_ = NULL;
MethodVerifier::InferredRegCategoryMapTable* MethodVerifier::inferred_reg_category_maps_ = NULL;
#endif
@@ -3281,7 +3281,7 @@ void MethodVerifier::Init() {
rejected_classes_ = new MethodVerifier::RejectedClassesTable;
}
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
inferred_reg_category_maps_lock_ = new Mutex("verifier GC maps lock");
{
MutexLock mu(self, *inferred_reg_category_maps_lock_);
@@ -3309,7 +3309,7 @@ void MethodVerifier::Shutdown() {
delete rejected_classes_lock_;
rejected_classes_lock_ = NULL;
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
{
MutexLock mu(self, *inferred_reg_category_maps_lock_);
STLDeleteValues(inferred_reg_category_maps_);
@@ -3334,7 +3334,7 @@ bool MethodVerifier::IsClassRejected(Compiler::ClassReference ref) {
return (rejected_classes_->find(ref) != rejected_classes_->end());
}
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
const greenland::InferredRegCategoryMap* MethodVerifier::GenerateInferredRegCategoryMap() {
uint32_t insns_size = code_item_->insns_size_in_code_units_;
uint16_t regs_size = code_item_->registers_size_;
diff --git a/src/verifier/method_verifier.h b/src/verifier/method_verifier.h
index 6765c1015b..42283a2e19 100644
--- a/src/verifier/method_verifier.h
+++ b/src/verifier/method_verifier.h
@@ -39,7 +39,7 @@ namespace art {
struct ReferenceMap2Visitor;
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
namespace greenland {
class InferredRegCategoryMap;
} // namespace greenland
@@ -143,7 +143,7 @@ class PcToRegisterLineTable {
// The verifier
class MethodVerifier {
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
typedef greenland::InferredRegCategoryMap InferredRegCategoryMap;
#endif
@@ -203,7 +203,7 @@ class MethodVerifier {
static void Init();
static void Shutdown();
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
static const InferredRegCategoryMap* GetInferredRegCategoryMap(Compiler::MethodReference ref)
LOCKS_EXCLUDED(inferred_reg_category_maps_lock_);
#endif
@@ -554,7 +554,7 @@ class MethodVerifier {
// Get a type representing the declaring class of the method.
const RegType& GetDeclaringClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
/*
* Generate the inferred register category for LLVM-based code generator.
* Returns a pointer to a two-dimension Class array, or NULL on failure.
@@ -589,7 +589,7 @@ class MethodVerifier {
static Mutex* rejected_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
static RejectedClassesTable* rejected_classes_;
-#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
+#if defined(ART_USE_LLVM_COMPILER)
// All the inferred register category maps that the verifier has created.
typedef SafeMap<const Compiler::MethodReference,
const InferredRegCategoryMap*> InferredRegCategoryMapTable;