libart-compiler cleanup
- Move compile-time code to src/compiler and libart-compiler
OatWriter, ImageWriter, ElfWriter, ElfFixup, ElfStripper, stub generation
- Move ClassReference and MethodReference to remove MethodVerifier dependency on CompilerDriver
- Move runtime_support_llvm.cc out of src/compiler and next to runtime_support.cc
- Change dex2oat and gtests to directly depend on libart-compiler
- Move non-common definitions from Android.common.mk to more specific makefiles
- Add LOCAL_ADDITIONAL_DEPENDENCIES on appropriate makefiles
Change-Id: I897027e69945914128f21f317a92caf9255bc600
diff --git a/src/class_reference.h b/src/class_reference.h
new file mode 100644
index 0000000..c3be720
--- /dev/null
+++ b/src/class_reference.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_CLASS_REFERENCE_H_
+#define ART_SRC_CLASS_REFERENCE_H_
+
+#include <stdint.h>
+
+namespace art {
+
+class DexFile;
+
+// A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile
+typedef std::pair<const DexFile*, uint32_t> ClassReference;
+
+inline bool operator<(const ClassReference& lhs, const ClassReference& rhs) {
+ if (lhs.second < rhs.second) {
+ return true;
+ } else if (lhs.second > rhs.second) {
+ return false;
+ } else {
+ return (lhs.first < rhs.first);
+ }
+}
+
+} // namespace art
+
+#endif // ART_SRC_CLASS_REFERENCE_H_
diff --git a/src/common_test.h b/src/common_test.h
index 11bd4f0..f03b1f9 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -188,8 +188,8 @@
const mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
const DexFile& dex_file = *dex_cache->GetDexFile();
compiled_method =
- compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(&dex_file,
- method->GetDexMethodIndex()));
+ compiler_driver_->GetCompiledMethod(MethodReference(&dex_file,
+ method->GetDexMethodIndex()));
#ifndef ART_LIGHT_MODE
CHECK(compiled_method != NULL) << PrettyMethod(method);
diff --git a/src/compiler/dex/dex_to_dex_compiler.cc b/src/compiler/dex/dex_to_dex_compiler.cc
index afb29f4..ce512ec 100644
--- a/src/compiler/dex/dex_to_dex_compiler.cc
+++ b/src/compiler/dex/dex_to_dex_compiler.cc
@@ -206,7 +206,7 @@
return;
}
uint32_t method_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
- CompilerDriver::MethodReference target_method(&GetDexFile(), method_idx);
+ MethodReference target_method(&GetDexFile(), method_idx);
InvokeType invoke_type = kVirtual;
InvokeType original_invoke_type = invoke_type;
int vtable_idx;
diff --git a/src/compiler/dex/mir_dataflow.cc b/src/compiler/dex/mir_dataflow.cc
index 3b2c1a6..381afb1 100644
--- a/src/compiler/dex/mir_dataflow.cc
+++ b/src/compiler/dex/mir_dataflow.cc
@@ -1225,7 +1225,7 @@
return false;
}
DexCompilationUnit m_unit(cu_);
- CompilerDriver::MethodReference target_method(cu_->dex_file, mir->dalvikInsn.vB);
+ MethodReference target_method(cu_->dex_file, mir->dalvikInsn.vB);
int vtable_idx;
uintptr_t direct_code;
uintptr_t direct_method;
diff --git a/src/compiler/dex/quick/codegen_util.cc b/src/compiler/dex/quick/codegen_util.cc
index ac2828c..766cdce 100644
--- a/src/compiler/dex/quick/codegen_util.cc
+++ b/src/compiler/dex/quick/codegen_util.cc
@@ -632,7 +632,7 @@
max_native_offset = native_offset;
}
}
- CompilerDriver::MethodReference method_ref(cu_->dex_file, cu_->method_idx);
+ 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 7aa71cf..2980acb 100644
--- a/src/compiler/dex/quick/gen_common.cc
+++ b/src/compiler/dex/quick/gen_common.cc
@@ -1077,7 +1077,7 @@
// Note: currently type_known_final is unused, as optimizing will only improve the performance
// of the exception throw path.
DexCompilationUnit* cu = mir_graph_->GetCurrentDexCompilationUnit();
- const CompilerDriver::MethodReference mr(cu->GetDexFile(), cu->GetDexMethodIndex());
+ const MethodReference mr(cu->GetDexFile(), cu->GetDexMethodIndex());
if (!needs_access_check && cu_->compiler_driver->IsSafeCast(mr, insn_idx)) {
// Verifier type analysis proved this check cast would never cause an exception.
return;
diff --git a/src/compiler/dex/quick/gen_invoke.cc b/src/compiler/dex/quick/gen_invoke.cc
index 4b12bb4..3bc7340 100644
--- a/src/compiler/dex/quick/gen_invoke.cc
+++ b/src/compiler/dex/quick/gen_invoke.cc
@@ -313,7 +313,7 @@
* emit the next instruction in static & direct invoke sequences.
*/
static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info,
- int state, const CompilerDriver::MethodReference& target_method,
+ int state, const MethodReference& target_method,
uint32_t unused,
uintptr_t direct_code, uintptr_t direct_method,
InvokeType type)
@@ -418,7 +418,7 @@
* kArg1 here rather than the standard LoadArgRegs.
*/
static int NextVCallInsn(CompilationUnit* cu, CallInfo* info,
- int state, const CompilerDriver::MethodReference& target_method,
+ int state, const MethodReference& target_method,
uint32_t method_idx, uintptr_t unused, uintptr_t unused2,
InvokeType unused3)
{
@@ -467,7 +467,7 @@
* which will locate the target and continue on via a tail call.
*/
static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t unused, uintptr_t unused2,
uintptr_t direct_method, InvokeType unused4)
{
@@ -535,7 +535,7 @@
}
static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline,
- int state, const CompilerDriver::MethodReference& target_method,
+ int state, const MethodReference& target_method,
uint32_t method_idx)
{
Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get());
@@ -558,7 +558,7 @@
static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info,
int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t method_idx,
uintptr_t unused, uintptr_t unused2,
InvokeType unused3)
@@ -568,7 +568,7 @@
}
static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t method_idx, uintptr_t unused,
uintptr_t unused2, InvokeType unused3)
{
@@ -577,7 +577,7 @@
}
static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t method_idx, uintptr_t unused,
uintptr_t unused2, InvokeType unused3)
{
@@ -586,7 +586,7 @@
}
static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t method_idx, uintptr_t unused,
uintptr_t unused2, InvokeType unused3)
{
@@ -596,7 +596,7 @@
static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu,
CallInfo* info, int state,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t unused,
uintptr_t unused2, uintptr_t unused3,
InvokeType unused4)
@@ -607,7 +607,7 @@
int Mir2Lir::LoadArgRegs(CallInfo* info, int call_state,
NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx, uintptr_t direct_code,
uintptr_t direct_method, InvokeType type, bool skip_this)
{
@@ -647,7 +647,7 @@
*/
int Mir2Lir::GenDalvikArgsNoRange(CallInfo* info,
int call_state, LIR** pcrLabel, NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx, uintptr_t direct_code,
uintptr_t direct_method, InvokeType type, bool skip_this)
{
@@ -747,7 +747,7 @@
*/
int Mir2Lir::GenDalvikArgsRange(CallInfo* info, int call_state,
LIR** pcrLabel, NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method,
InvokeType type, bool skip_this)
{
@@ -1373,7 +1373,7 @@
LockCallTemps();
DexCompilationUnit* cUnit = mir_graph_->GetCurrentDexCompilationUnit();
- CompilerDriver::MethodReference target_method(cUnit->GetDexFile(), info->index);
+ MethodReference target_method(cUnit->GetDexFile(), info->index);
int vtable_idx;
uintptr_t direct_code;
uintptr_t direct_method;
diff --git a/src/compiler/dex/quick/mir_to_lir.h b/src/compiler/dex/quick/mir_to_lir.h
index 9eb4524..93098db 100644
--- a/src/compiler/dex/quick/mir_to_lir.h
+++ b/src/compiler/dex/quick/mir_to_lir.h
@@ -100,7 +100,7 @@
class Mir2Lir;
typedef int (*NextCallInsn)(CompilationUnit*, CallInfo*, int,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t method_idx, uintptr_t direct_code,
uintptr_t direct_method, InvokeType type);
@@ -467,13 +467,13 @@
void FlushIns(RegLocation* ArgLocs, RegLocation rl_method);
int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx,
uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
bool skip_this);
int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx,
uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
bool skip_this);
@@ -495,7 +495,7 @@
bool GenIntrinsic(CallInfo* info);
int LoadArgRegs(CallInfo* info, int call_state,
NextCallInsn next_call_insn,
- const CompilerDriver::MethodReference& target_method,
+ const MethodReference& target_method,
uint32_t vtable_idx,
uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
bool skip_this);
diff --git a/src/compiler/dex/write_elf.cc b/src/compiler/dex/write_elf.cc
deleted file mode 100644
index d9e45a9..0000000
--- a/src/compiler/dex/write_elf.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "elf_fixup.h"
-#include "elf_stripper.h"
-#include "os.h"
-
-#if defined(ART_USE_PORTABLE_COMPILER)
-#include "elf_writer_mclinker.h"
-#else
-#include "elf_writer_quick.h"
-#endif
-
-namespace art {
-class CompilerDriver;
-class DexFile;
-} // namespace art
-
-extern "C" bool WriteElf(art::CompilerDriver& driver,
- const std::string& android_root,
- bool is_host,
- const std::vector<const art::DexFile*>& dex_files,
- std::vector<uint8_t>& oat_contents,
- art::File* file)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-#if defined(ART_USE_PORTABLE_COMPILER)
- return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, driver);
-#else
- return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, driver);
-#endif
-}
-extern "C" bool FixupElf(art::File* file, uintptr_t oat_data_begin) {
- return art::ElfFixup::Fixup(file, oat_data_begin);
-}
-extern "C" void GetOatElfInformation(art::File* file,
- size_t& oat_loaded_size,
- size_t& oat_data_offset) {
- art::ElfWriter::GetOatElfInformation(file, oat_loaded_size, oat_data_offset);
-}
-extern "C" bool StripElf(art::File* file) {
- return art::ElfStripper::Strip(file);
-}
diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc
index c8ccbe9..c876252 100644
--- a/src/compiler/driver/compiler_driver.cc
+++ b/src/compiler/driver/compiler_driver.cc
@@ -18,7 +18,6 @@
#include <vector>
-#include <dlfcn.h>
#include <unistd.h>
#include "base/stl_util.h"
@@ -48,8 +47,10 @@
#include "thread_pool.h"
#include "verifier/method_verifier.h"
-#if defined(__APPLE__)
-#include <mach-o/dyld.h>
+#if defined(ART_USE_PORTABLE_COMPILER)
+#include "compiler/elf_writer_mclinker.h"
+#else
+#include "compiler/elf_writer_quick.h"
#endif
namespace art {
@@ -281,48 +282,57 @@
DISALLOW_COPY_AND_ASSIGN(AOTCompilationStats);
};
-static std::string MakeCompilerSoName(CompilerBackend compiler_backend) {
+extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver);
+extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver& compiler);
- // Bad things happen if we pull in the libartd-compiler to a libart dex2oat or vice versa,
- // because we end up with both libart and libartd in the same address space!
- const char* suffix = (kIsDebugBuild ? "d" : "");
+extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver);
+extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& compiler);
- // Work out the filename for the compiler library.
- std::string library_name(StringPrintf("art%s-compiler", suffix));
- std::string filename(StringPrintf(OS_SHARED_LIB_FORMAT_STR, library_name.c_str()));
+extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
+ 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,
+ const art::DexFile& dex_file);
+extern "C" art::CompiledMethod* 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,
+ const art::DexFile& dex_file);
-#if defined(__APPLE__)
- // On Linux, dex2oat will have been built with an RPATH of $ORIGIN/../lib, so dlopen(3) will find
- // the .so by itself. On Mac OS, there isn't really an equivalent, so we have to manually do the
- // same work.
- uint32_t executable_path_length = 0;
- _NSGetExecutablePath(NULL, &executable_path_length);
- std::string path(executable_path_length, static_cast<char>(0));
- CHECK_EQ(_NSGetExecutablePath(&path[0], &executable_path_length), 0);
+extern "C" art::CompiledMethod* ArtCompileDEX(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,
+ const art::DexFile& dex_file);
- // Strip the "/dex2oat".
- size_t last_slash = path.find_last_of('/');
- CHECK_NE(last_slash, std::string::npos) << path;
- path.resize(last_slash);
+extern "C" art::CompiledMethod* SeaIrCompileMethod(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,
+ const art::DexFile& dex_file);
- // Strip the "/bin".
- last_slash = path.find_last_of('/');
- path.resize(last_slash);
+extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver,
+ uint32_t access_flags, uint32_t method_idx,
+ const art::DexFile& dex_file);
- filename = path + "/lib/" + filename;
-#endif
- return filename;
-}
+extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver& compiler,
+ uint32_t access_flags, uint32_t method_idx,
+ const art::DexFile& dex_file);
-template<typename Fn>
-static Fn FindFunction(const std::string& compiler_so_name, void* library, const char* name) {
- Fn fn = reinterpret_cast<Fn>(dlsym(library, name));
- if (fn == NULL) {
- LOG(FATAL) << "Couldn't find \"" << name << "\" in compiler library " << compiler_so_name << ": " << dlerror();
- }
- VLOG(compiler) << "Found \"" << name << "\" at " << reinterpret_cast<void*>(fn);
- return fn;
-}
+extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver,
+ std::string const& filename);
CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set,
bool image, DescriptorSet* image_classes,
@@ -349,13 +359,6 @@
compiler_get_method_code_addr_(NULL),
support_boot_image_fixup_(true)
{
- std::string compiler_so_name(MakeCompilerSoName(compiler_backend_));
- 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();
- }
- VLOG(compiler) << "dlopen(\"" << compiler_so_name << "\", RTLD_LAZY) returned " << compiler_library_;
-
CHECK_PTHREAD_CALL(pthread_key_create, (&tls_key_, NULL), "compiler tls key");
// TODO: more work needed to combine initializations and allow per-method backend selection
@@ -363,28 +366,28 @@
InitCompilerContextFn init_compiler_context;
if (compiler_backend_ == kPortable){
// Initialize compiler_context_
- init_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name,
- compiler_library_, "ArtInitCompilerContext");
- compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileMethod");
+ init_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtInitCompilerContext);
+ compiler_ = reinterpret_cast<CompilerFn>(ArtCompileMethod);
} else {
- init_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name,
- compiler_library_, "ArtInitQuickCompilerContext");
- compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtQuickCompileMethod");
+ init_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtInitQuickCompilerContext);
+ compiler_ = reinterpret_cast<CompilerFn>(ArtQuickCompileMethod);
}
- dex_to_dex_compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "ArtCompileDEX");
+ dex_to_dex_compiler_ = reinterpret_cast<CompilerFn>(ArtCompileDEX);
+#ifdef ART_SEA_IR_MODE
sea_ir_compiler_ = NULL;
if (Runtime::Current()->IsSeaIRMode()) {
- sea_ir_compiler_ = FindFunction<CompilerFn>(compiler_so_name, compiler_library_, "SeaIrCompileMethod");
+ sea_ir_compiler_ = reinterpret_cast<CompilerFn>(SeaIrCompileMethod);
}
+#endif
init_compiler_context(*this);
if (compiler_backend_ == kPortable) {
- jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtLLVMJniCompileMethod");
+ jni_compiler_ = reinterpret_cast<JniCompilerFn>(ArtLLVMJniCompileMethod);
} else {
- jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtQuickJniCompileMethod");
+ jni_compiler_ = reinterpret_cast<JniCompilerFn>(ArtQuickJniCompileMethod);
}
CHECK(!Runtime::Current()->IsStarted());
@@ -413,39 +416,15 @@
}
CHECK_PTHREAD_CALL(pthread_key_delete, (tls_key_), "delete tls key");
typedef void (*UninitCompilerContextFn)(CompilerDriver&);
- std::string compiler_so_name(MakeCompilerSoName(compiler_backend_));
UninitCompilerContextFn uninit_compiler_context;
// Uninitialize compiler_context_
// TODO: rework to combine initialization/uninitialization
if (compiler_backend_ == kPortable) {
- uninit_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name,
- compiler_library_, "ArtUnInitCompilerContext");
+ uninit_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtUnInitCompilerContext);
} else {
- uninit_compiler_context = FindFunction<void (*)(CompilerDriver&)>(compiler_so_name,
- compiler_library_, "ArtUnInitQuickCompilerContext");
+ uninit_compiler_context = reinterpret_cast<void (*)(CompilerDriver&)>(ArtUnInitQuickCompilerContext);
}
uninit_compiler_context(*this);
-#if 0
- if (compiler_library_ != NULL) {
- VLOG(compiler) << "dlclose(" << compiler_library_ << ")";
- /*
- * FIXME: Temporary workaround
- * Apparently, llvm is adding dctors to atexit, but if we unload
- * the library here the code will no longer be around at exit time
- * and we die a flaming death in __cxa_finalize(). Apparently, some
- * dlclose() implementations will scan the atexit list on unload and
- * handle any associated with the soon-to-be-unloaded library.
- * However, this is not required by POSIX and we don't do it.
- * See: http://b/issue?id=4998315
- * What's the right thing to do here?
- *
- * This has now been completely disabled because mclinker was
- * closing stdout on exit, which was affecting both quick and
- * portable.
- */
- dlclose(compiler_library_);
- }
-#endif
}
CompilerTls* CompilerDriver::GetTls() {
@@ -1217,9 +1196,8 @@
if (kEnableVerifierBasedSharpening && (invoke_type == kVirtual ||
invoke_type == kInterface)) {
// Did the verifier record a more precise invoke target based on its type information?
- const CompilerDriver::MethodReference caller_method(mUnit->GetDexFile(),
- mUnit->GetDexMethodIndex());
- const CompilerDriver::MethodReference* devirt_map_target =
+ const MethodReference caller_method(mUnit->GetDexFile(), mUnit->GetDexMethodIndex());
+ const MethodReference* devirt_map_target =
verifier::MethodVerifier::GetDevirtMap(caller_method, dex_pc);
if (devirt_map_target != NULL) {
mirror::DexCache* target_dex_cache =
@@ -2138,7 +2116,7 @@
}
// Record the final class status if necessary.
mirror::Class::Status status = klass->GetStatus();
- CompilerDriver::ClassReference ref(manager->GetDexFile(), class_def_index);
+ ClassReference ref(manager->GetDexFile(), class_def_index);
CompiledClass* compiled_class = manager->GetCompiler()->GetCompiledClass(ref);
if (compiled_class == NULL) {
compiled_class = new CompiledClass(status);
@@ -2287,21 +2265,16 @@
dont_compile = false;
}
if (!dont_compile) {
- bool use_sea = false;
-
- if (Runtime::Current()->IsSeaIRMode()) {
- use_sea = true;
- }
+ CompilerFn compiler = compiler_;
+#ifdef ART_SEA_IR_MODE
+ bool use_sea = Runtime::Current()->IsSeaIRMode();
+ use_sea &&= (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci"));
if (use_sea) {
- use_sea = (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci"));
+ compiler = sea_ir_compiler_;
}
- if (!use_sea) {
- compiled_method = (*compiler_)(*this, code_item, access_flags, invoke_type, class_def_idx,
- method_idx, class_loader, dex_file);
- } else {
- compiled_method = (*sea_ir_compiler_)(*this, code_item, access_flags, invoke_type, class_def_idx,
- method_idx, class_loader, dex_file);
- }
+#endif
+ compiled_method = (*compiler)(*this, code_item, access_flags, invoke_type, class_def_idx,
+ method_idx, class_loader, dex_file);
CHECK(compiled_method != NULL) << PrettyMethod(method_idx, dex_file);
} else if (allow_dex_to_dex_compilation) {
// TODO: add a mode to disable DEX-to-DEX compilation ?
@@ -2365,8 +2338,7 @@
typedef void (*SetBitcodeFileNameFn)(CompilerDriver&, std::string const&);
SetBitcodeFileNameFn set_bitcode_file_name =
- FindFunction<SetBitcodeFileNameFn>(MakeCompilerSoName(compiler_backend_), compiler_library_,
- "compilerLLVMSetBitcodeFileName");
+ reinterpret_cast<SetBitcodeFileNameFn>(compilerLLVMSetBitcodeFileName);
set_bitcode_file_name(*this, filename);
}
@@ -2386,45 +2358,16 @@
bool CompilerDriver::WriteElf(const std::string& android_root,
bool is_host,
- const std::vector<const DexFile*>& dex_files,
+ const std::vector<const art::DexFile*>& dex_files,
std::vector<uint8_t>& oat_contents,
- File* file) {
- typedef bool (*WriteElfFn)(CompilerDriver&,
- const std::string& android_root,
- bool is_host,
- const std::vector<const DexFile*>& dex_files,
- std::vector<uint8_t>&,
- File*);
- WriteElfFn WriteElf =
- FindFunction<WriteElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "WriteElf");
- Locks::mutator_lock_->AssertSharedHeld(Thread::Current());
- return WriteElf(*this, android_root, is_host, dex_files, oat_contents, file);
+ art::File* file)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+#if defined(ART_USE_PORTABLE_COMPILER)
+ return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, *this);
+#else
+ return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, *this);
+#endif
}
-
-bool CompilerDriver::FixupElf(File* file, uintptr_t oat_data_begin) const {
- typedef bool (*FixupElfFn)(File*, uintptr_t oat_data_begin);
- FixupElfFn FixupElf =
- FindFunction<FixupElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "FixupElf");
- return FixupElf(file, oat_data_begin);
-}
-
-void CompilerDriver::GetOatElfInformation(File* file,
- size_t& oat_loaded_size,
- size_t& oat_data_offset) const {
- typedef bool (*GetOatElfInformationFn)(File*, size_t& oat_loaded_size, size_t& oat_data_offset);
- GetOatElfInformationFn GetOatElfInformation =
- FindFunction<GetOatElfInformationFn>(MakeCompilerSoName(compiler_backend_), compiler_library_,
- "GetOatElfInformation");
- GetOatElfInformation(file, oat_loaded_size, oat_data_offset);
-}
-
-bool CompilerDriver::StripElf(File* file) const {
- typedef bool (*StripElfFn)(File*);
- StripElfFn StripElf =
- FindFunction<StripElfFn>(MakeCompilerSoName(compiler_backend_), compiler_library_, "StripElf");
- return StripElf(file);
-}
-
void CompilerDriver::InstructionSetToLLVMTarget(InstructionSet instruction_set,
std::string& target_triple,
std::string& target_cpu,
diff --git a/src/compiler/driver/compiler_driver.h b/src/compiler/driver/compiler_driver.h
index b37b74b..d37f494 100644
--- a/src/compiler/driver/compiler_driver.h
+++ b/src/compiler/driver/compiler_driver.h
@@ -22,11 +22,13 @@
#include <vector>
#include "base/mutex.h"
+#include "class_reference.h"
#include "compiled_class.h"
#include "compiled_method.h"
#include "dex_file.h"
#include "instruction_set.h"
#include "invoke_type.h"
+#include "method_reference.h"
#include "oat_file.h"
#include "runtime.h"
#include "safe_map.h"
@@ -114,30 +116,9 @@
const std::vector<uint8_t>* CreateInterpreterToQuickEntry() const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- // A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile
- typedef std::pair<const DexFile*, uint32_t> ClassReference;
-
CompiledClass* GetCompiledClass(ClassReference ref) const
LOCKS_EXCLUDED(compiled_classes_lock_);
- // A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile
- struct MethodReference {
- MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) {
- }
- const DexFile* dex_file;
- uint32_t dex_method_index;
- };
-
- struct MethodReferenceComparator {
- bool operator()(MethodReference mr1, MethodReference mr2) const {
- if (mr1.dex_file == mr2.dex_file) {
- return mr1.dex_method_index < mr2.dex_method_index;
- } else {
- return mr1.dex_file < mr2.dex_file;
- }
- }
- };
-
CompiledMethod* GetCompiledMethod(MethodReference ref) const
LOCKS_EXCLUDED(compiled_methods_lock_);
@@ -212,15 +193,11 @@
}
- // TODO: remove these Elf wrappers when libart links against LLVM (when separate compiler library is gone)
bool WriteElf(const std::string& android_root,
bool is_host,
const std::vector<const DexFile*>& dex_files,
std::vector<uint8_t>& oat_contents,
File* file);
- bool FixupElf(File* file, uintptr_t oat_data_begin) const;
- void GetOatElfInformation(File* file, size_t& oat_loaded_size, size_t& oat_data_offset) const;
- bool StripElf(File* file) const;
// TODO: move to a common home for llvm helpers once quick/portable are merged
static void InstructionSetToLLVMTarget(InstructionSet instruction_set,
@@ -404,7 +381,9 @@
uint32_t class_dex_idx, uint32_t method_idx,
jobject class_loader, const DexFile& dex_file);
CompilerFn compiler_;
+#ifdef ART_SEA_IR_MODE
CompilerFn sea_ir_compiler_;
+#endif
CompilerFn dex_to_dex_compiler_;
@@ -429,16 +408,6 @@
DISALLOW_COPY_AND_ASSIGN(CompilerDriver);
};
-inline bool operator<(const CompilerDriver::ClassReference& lhs, const CompilerDriver::ClassReference& rhs) {
- if (lhs.second < rhs.second) {
- return true;
- } else if (lhs.second > rhs.second) {
- return false;
- } else {
- return (lhs.first < rhs.first);
- }
-}
-
} // namespace art
#endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_
diff --git a/src/elf_fixup.cc b/src/compiler/elf_fixup.cc
similarity index 100%
rename from src/elf_fixup.cc
rename to src/compiler/elf_fixup.cc
diff --git a/src/elf_fixup.h b/src/compiler/elf_fixup.h
similarity index 100%
rename from src/elf_fixup.h
rename to src/compiler/elf_fixup.h
diff --git a/src/elf_stripper.cc b/src/compiler/elf_stripper.cc
similarity index 100%
rename from src/elf_stripper.cc
rename to src/compiler/elf_stripper.cc
diff --git a/src/elf_stripper.h b/src/compiler/elf_stripper.h
similarity index 100%
rename from src/elf_stripper.h
rename to src/compiler/elf_stripper.h
diff --git a/src/elf_writer.cc b/src/compiler/elf_writer.cc
similarity index 100%
rename from src/elf_writer.cc
rename to src/compiler/elf_writer.cc
diff --git a/src/elf_writer.h b/src/compiler/elf_writer.h
similarity index 100%
rename from src/elf_writer.h
rename to src/compiler/elf_writer.h
diff --git a/src/elf_writer_mclinker.cc b/src/compiler/elf_writer_mclinker.cc
similarity index 100%
rename from src/elf_writer_mclinker.cc
rename to src/compiler/elf_writer_mclinker.cc
diff --git a/src/elf_writer_mclinker.h b/src/compiler/elf_writer_mclinker.h
similarity index 100%
rename from src/elf_writer_mclinker.h
rename to src/compiler/elf_writer_mclinker.h
diff --git a/src/elf_writer_quick.cc b/src/compiler/elf_writer_quick.cc
similarity index 100%
rename from src/elf_writer_quick.cc
rename to src/compiler/elf_writer_quick.cc
diff --git a/src/elf_writer_quick.h b/src/compiler/elf_writer_quick.h
similarity index 100%
rename from src/elf_writer_quick.h
rename to src/compiler/elf_writer_quick.h
diff --git a/src/elf_writer_test.cc b/src/compiler/elf_writer_test.cc
similarity index 100%
rename from src/elf_writer_test.cc
rename to src/compiler/elf_writer_test.cc
diff --git a/src/image_writer.cc b/src/compiler/image_writer.cc
similarity index 99%
rename from src/image_writer.cc
rename to src/compiler/image_writer.cc
index f0b49be..8b84e12 100644
--- a/src/image_writer.cc
+++ b/src/compiler/image_writer.cc
@@ -25,6 +25,7 @@
#include "class_linker.h"
#include "compiled_method.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/elf_writer.h"
#include "dex_file-inl.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/accounting/heap_bitmap.h"
@@ -115,7 +116,7 @@
Thread::Current()->TransitionFromSuspendedToRunnable();
size_t oat_loaded_size = 0;
size_t oat_data_offset = 0;
- compiler_driver_.GetOatElfInformation(oat_file.get(), oat_loaded_size, oat_data_offset);
+ ElfWriter::GetOatElfInformation(oat_file.get(), oat_loaded_size, oat_data_offset);
CalculateNewObjectOffsets(oat_loaded_size, oat_data_offset);
CopyAndFixupObjects();
PatchOatCodeAndMethods();
diff --git a/src/image_writer.h b/src/compiler/image_writer.h
similarity index 100%
rename from src/image_writer.h
rename to src/compiler/image_writer.h
diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc
index 2795d05..cd8158d 100644
--- a/src/compiler/jni/portable/jni_compiler.cc
+++ b/src/compiler/jni/portable/jni_compiler.cc
@@ -24,7 +24,7 @@
#include "compiler/llvm/compiler_llvm.h"
#include "compiler/llvm/ir_builder.h"
#include "compiler/llvm/llvm_compilation_unit.h"
-#include "compiler/llvm/runtime_support_func.h"
+#include "compiler/llvm/runtime_support_llvm_func.h"
#include "compiler/llvm/utils_llvm.h"
#include "dex_file-inl.h"
#include "mirror/abstract_method.h"
diff --git a/src/compiler/llvm/compiler_llvm.cc b/src/compiler/llvm/compiler_llvm.cc
index dfd0e32..3af6687 100644
--- a/src/compiler/llvm/compiler_llvm.cc
+++ b/src/compiler/llvm/compiler_llvm.cc
@@ -152,8 +152,8 @@
cunit->Materialize();
- CompilerDriver::MethodReference mref(dex_compilation_unit->GetDexFile(),
- dex_compilation_unit->GetDexMethodIndex());
+ MethodReference mref(dex_compilation_unit->GetDexFile(),
+ dex_compilation_unit->GetDexMethodIndex());
return new CompiledMethod(compiler_driver_->GetInstructionSet(),
cunit->GetElfObject(),
*verifier::MethodVerifier::GetDexGcMap(mref),
diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
index bdf9aca..4702b37 100644
--- a/src/compiler/llvm/gbc_expander.cc
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -19,6 +19,7 @@
#include "dex_file-inl.h"
#include "intrinsic_helper.h"
#include "ir_builder.h"
+#include "method_reference.h"
#include "mirror/abstract_method.h"
#include "mirror/array.h"
#include "mirror/string.h"
@@ -776,8 +777,8 @@
art::InvokeType invoke_type =
static_cast<art::InvokeType>(LV2UInt(call_inst.getArgOperand(0)));
bool is_static = (invoke_type == art::kStatic);
- art::CompilerDriver::MethodReference target_method(dex_compilation_unit_->GetDexFile(),
- LV2UInt(call_inst.getArgOperand(1)));
+ art::MethodReference target_method(dex_compilation_unit_->GetDexFile(),
+ LV2UInt(call_inst.getArgOperand(1)));
// Load *this* actual parameter
llvm::Value* this_addr = (!is_static) ? call_inst.getArgOperand(3) : NULL;
diff --git a/src/compiler/llvm/ir_builder.h b/src/compiler/llvm/ir_builder.h
index 9d78fe6..eb88fca 100644
--- a/src/compiler/llvm/ir_builder.h
+++ b/src/compiler/llvm/ir_builder.h
@@ -22,7 +22,7 @@
#include "intrinsic_helper.h"
#include "md_builder.h"
#include "runtime_support_builder.h"
-#include "runtime_support_func.h"
+#include "runtime_support_llvm_func.h"
#include <llvm/IR/Constants.h>
#include <llvm/IR/DerivedTypes.h>
diff --git a/src/compiler/llvm/llvm_compilation_unit.h b/src/compiler/llvm/llvm_compilation_unit.h
index 857d924..a5d4e11 100644
--- a/src/compiler/llvm/llvm_compilation_unit.h
+++ b/src/compiler/llvm/llvm_compilation_unit.h
@@ -25,7 +25,7 @@
#include "instruction_set.h"
#include "compiler/driver/dex_compilation_unit.h"
#include "runtime_support_builder.h"
-#include "runtime_support_func.h"
+#include "runtime_support_llvm_func.h"
#include "safe_map.h"
#include <UniquePtr.h>
diff --git a/src/compiler/llvm/runtime_support_builder.cc b/src/compiler/llvm/runtime_support_builder.cc
index 2be2ddf..28405f6 100644
--- a/src/compiler/llvm/runtime_support_builder.cc
+++ b/src/compiler/llvm/runtime_support_builder.cc
@@ -48,7 +48,7 @@
runtime_support_func_decls_[runtime_support::ID] = fn; \
} while (0);
-#include "runtime_support_func_list.h"
+#include "runtime_support_llvm_func_list.h"
RUNTIME_SUPPORT_FUNC_LIST(GET_RUNTIME_SUPPORT_FUNC_DECL)
#undef RUNTIME_SUPPORT_FUNC_LIST
#undef GET_RUNTIME_SUPPORT_FUNC_DECL
diff --git a/src/compiler/llvm/runtime_support_builder.h b/src/compiler/llvm/runtime_support_builder.h
index 04d72b8..267b406 100644
--- a/src/compiler/llvm/runtime_support_builder.h
+++ b/src/compiler/llvm/runtime_support_builder.h
@@ -19,7 +19,7 @@
#include "backend_types.h"
#include "base/logging.h"
-#include "runtime_support_func.h"
+#include "runtime_support_llvm_func.h"
#include <stdint.h>
diff --git a/src/compiler/llvm/runtime_support_func.h b/src/compiler/llvm/runtime_support_llvm_func.h
similarity index 95%
rename from src/compiler/llvm/runtime_support_func.h
rename to src/compiler/llvm/runtime_support_llvm_func.h
index 6dfa961..ac6f3b8 100644
--- a/src/compiler/llvm/runtime_support_func.h
+++ b/src/compiler/llvm/runtime_support_llvm_func.h
@@ -23,7 +23,7 @@
enum RuntimeId {
#define DEFINE_RUNTIME_SUPPORT_FUNC_ID(ID, NAME) ID,
-#include "runtime_support_func_list.h"
+#include "runtime_support_llvm_func_list.h"
RUNTIME_SUPPORT_FUNC_LIST(DEFINE_RUNTIME_SUPPORT_FUNC_ID)
#undef RUNTIME_SUPPORT_FUNC_LIST
#undef DEFINE_RUNTIME_SUPPORT_FUNC_ID
diff --git a/src/oat_writer.cc b/src/compiler/oat_writer.cc
similarity index 98%
rename from src/oat_writer.cc
rename to src/compiler/oat_writer.cc
index 1d249d6..0bfa4ec 100644
--- a/src/oat_writer.cc
+++ b/src/compiler/oat_writer.cc
@@ -161,7 +161,7 @@
num_methods = num_direct_methods + num_virtual_methods;
}
- CompilerDriver::ClassReference class_ref = CompilerDriver::ClassReference(dex_file, class_def_index);
+ ClassReference class_ref(dex_file, class_def_index);
CompiledClass* compiled_class = compiler_driver_->GetCompiledClass(class_ref);
mirror::Class::Status status;
if (compiled_class != NULL) {
@@ -303,7 +303,7 @@
#endif
CompiledMethod* compiled_method =
- compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(dex_file, method_idx));
+ compiler_driver_->GetCompiledMethod(MethodReference(dex_file, method_idx));
if (compiled_method != NULL) {
#if defined(ART_USE_PORTABLE_COMPILER)
compiled_method->AddOatdataOffsetToCompliledCodeOffset(
@@ -366,7 +366,7 @@
#if !defined(NDEBUG)
// We expect GC maps except when the class hasn't been verified or the method is native
- CompilerDriver::ClassReference class_ref = CompilerDriver::ClassReference(dex_file, class_def_index);
+ ClassReference class_ref(dex_file, class_def_index);
CompiledClass* compiled_class = compiler_driver_->GetCompiledClass(class_ref);
mirror::Class::Status status;
if (compiled_class != NULL) {
@@ -670,7 +670,7 @@
size_t class_def_method_index, bool is_static,
uint32_t method_idx, const DexFile& dex_file) {
const CompiledMethod* compiled_method =
- compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(&dex_file, method_idx));
+ compiler_driver_->GetCompiledMethod(MethodReference(&dex_file, method_idx));
OatMethodOffsets method_offsets =
oat_classes_[oat_class_index]->method_offsets_[class_def_method_index];
diff --git a/src/oat_writer.h b/src/compiler/oat_writer.h
similarity index 100%
rename from src/oat_writer.h
rename to src/compiler/oat_writer.h
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index 6397f40..6c5ba52 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -30,17 +30,19 @@
#include "base/unix_file/fd_file.h"
#include "class_linker.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/elf_fixup.h"
+#include "compiler/elf_stripper.h"
+#include "compiler/image_writer.h"
+#include "compiler/oat_writer.h"
#include "dex_file-inl.h"
#include "gc/space/image_space.h"
#include "gc/space/space-inl.h"
-#include "image_writer.h"
#include "leb128.h"
#include "mirror/abstract_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "mirror/object-inl.h"
#include "mirror/object_array-inl.h"
-#include "oat_writer.h"
#include "object_utils.h"
#include "os.h"
#include "runtime.h"
@@ -325,7 +327,7 @@
PLOG(ERROR) << "Failed to open ELF file: " << oat_filename;
return false;
}
- if (!compiler.FixupElf(oat_file.get(), oat_data_begin)) {
+ if (!ElfFixup::Fixup(oat_file.get(), oat_data_begin)) {
LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath();
return false;
}
@@ -1044,7 +1046,7 @@
// Strip unneeded sections for target
off_t seek_actual = lseek(oat_file->Fd(), 0, SEEK_SET);
CHECK_EQ(0, seek_actual);
- compiler->StripElf(oat_file.get());
+ ElfStripper::Strip(oat_file.get());
// We wrote the oat file successfully, and want to keep it.
LOG(INFO) << "Oat file written successfully (stripped): " << oat_location;
diff --git a/src/image_test.cc b/src/image_test.cc
index 9f86a1a..9ab1d74 100644
--- a/src/image_test.cc
+++ b/src/image_test.cc
@@ -18,11 +18,12 @@
#include <vector>
#include "common_test.h"
-#include "image.h"
-#include "image_writer.h"
-#include "oat_writer.h"
-#include "signal_catcher.h"
+#include "compiler/elf_fixup.h"
+#include "compiler/image_writer.h"
+#include "compiler/oat_writer.h"
#include "gc/space/image_space.h"
+#include "image.h"
+#include "signal_catcher.h"
#include "UniquePtr.h"
#include "utils.h"
#include "vector_output_stream.h"
@@ -72,7 +73,7 @@
bool success_image = writer.Write(tmp_image.GetFilename(), requested_image_base,
tmp_oat->GetPath(), tmp_oat->GetPath());
ASSERT_TRUE(success_image);
- bool success_fixup = compiler_driver_->FixupElf(tmp_oat.get(), writer.GetOatDataBegin());
+ bool success_fixup = ElfFixup::Fixup(tmp_oat.get(), writer.GetOatDataBegin());
ASSERT_TRUE(success_fixup);
}
diff --git a/src/method_reference.h b/src/method_reference.h
new file mode 100644
index 0000000..ff8bf31
--- /dev/null
+++ b/src/method_reference.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_METHOD_REFERENCE_H_
+#define ART_SRC_METHOD_REFERENCE_H_
+
+namespace art {
+
+class DexFile;
+
+// A class is uniquely located by its DexFile and the class_defs_ table index into that DexFile
+typedef std::pair<const DexFile*, uint32_t> ClassReference;
+
+// A method is uniquely located by its DexFile and the method_ids_ table index into that DexFile
+struct MethodReference {
+ MethodReference(const DexFile* file, uint32_t index) : dex_file(file), dex_method_index(index) {
+ }
+ const DexFile* dex_file;
+ uint32_t dex_method_index;
+};
+
+struct MethodReferenceComparator {
+ bool operator()(MethodReference mr1, MethodReference mr2) const {
+ if (mr1.dex_file == mr2.dex_file) {
+ return mr1.dex_method_index < mr2.dex_method_index;
+ } else {
+ return mr1.dex_file < mr2.dex_file;
+ }
+ }
+};
+
+} // namespace art
+
+#endif // ART_SRC_METHOD_REFERENCE_H_
diff --git a/src/oat_test.cc b/src/oat_test.cc
index 29e2891..f41a7ba 100644
--- a/src/oat_test.cc
+++ b/src/oat_test.cc
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+#include "compiler/oat_writer.h"
#include "mirror/abstract_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object_array-inl.h"
#include "mirror/object-inl.h"
#include "oat_file.h"
-#include "oat_writer.h"
#include "vector_output_stream.h"
#include "common_test.h"
@@ -33,8 +33,8 @@
const DexFile* dex_file)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
const CompiledMethod* compiled_method =
- compiler_driver_->GetCompiledMethod(CompilerDriver::MethodReference(dex_file,
- method->GetDexMethodIndex()));
+ compiler_driver_->GetCompiledMethod(MethodReference(dex_file,
+ method->GetDexMethodIndex()));
if (compiled_method == NULL) {
EXPECT_TRUE(oat_method.GetCode() == NULL) << PrettyMethod(method) << " "
diff --git a/src/runtime.h b/src/runtime.h
index 0b893a3..fc0ce83 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -134,9 +134,11 @@
return is_concurrent_gc_enabled_;
}
+#ifdef ART_SEA_IR_MODE
bool IsSeaIRMode() const {
return sea_ir_mode_;
}
+#endif
void SetSeaIRMode(bool sea_ir_mode) {
sea_ir_mode_ = sea_ir_mode;
diff --git a/src/compiler/llvm/runtime_support_llvm.cc b/src/runtime_support_llvm.cc
similarity index 99%
rename from src/compiler/llvm/runtime_support_llvm.cc
rename to src/runtime_support_llvm.cc
index bff13f9..cbdefe8 100644
--- a/src/compiler/llvm/runtime_support_llvm.cc
+++ b/src/runtime_support_llvm.cc
@@ -33,11 +33,10 @@
#include "object_utils.h"
#include "reflection.h"
#include "runtime_support.h"
-#include "runtime_support_func_list.h"
+#include "runtime_support_llvm_func_list.h"
#include "scoped_thread_state_change.h"
#include "thread.h"
#include "thread_list.h"
-#include "utils_llvm.h"
#include "verifier/dex_gc_map.h"
#include "verifier/method_verifier.h"
#include "well_known_classes.h"
diff --git a/src/compiler/llvm/runtime_support_llvm.h b/src/runtime_support_llvm.h
similarity index 100%
rename from src/compiler/llvm/runtime_support_llvm.h
rename to src/runtime_support_llvm.h
diff --git a/src/compiler/llvm/runtime_support_func_list.h b/src/runtime_support_llvm_func_list.h
similarity index 100%
rename from src/compiler/llvm/runtime_support_func_list.h
rename to src/runtime_support_llvm_func_list.h
diff --git a/src/verifier/method_verifier.cc b/src/verifier/method_verifier.cc
index 74a79e0..31aec47 100644
--- a/src/verifier/method_verifier.cc
+++ b/src/verifier/method_verifier.cc
@@ -22,7 +22,6 @@
#include "base/mutex-inl.h"
#include "base/stringpiece.h"
#include "class_linker.h"
-#include "compiler/driver/compiler_driver.h"
#include "dex_file-inl.h"
#include "dex_instruction-inl.h"
#include "dex_instruction_visitor.h"
@@ -426,7 +425,7 @@
// marked as rejected to prevent it from being compiled.
case VERIFY_ERROR_BAD_CLASS_HARD: {
if (Runtime::Current()->IsCompiler()) {
- CompilerDriver::ClassReference ref(dex_file_, class_def_idx_);
+ ClassReference ref(dex_file_, class_def_idx_);
AddRejectedClass(ref);
}
have_pending_hard_failure_ = true;
@@ -1001,9 +1000,6 @@
return false;
}
- CompilerDriver::MethodReference ref(dex_file_, dex_method_idx_);
-
-
/* Generate a register map and add it to the method. */
UniquePtr<const std::vector<uint8_t> > map(GenerateGcMap());
if (map.get() == NULL) {
@@ -1013,6 +1009,7 @@
if (kIsDebugBuild) {
VerifyGcMap(*map);
}
+ MethodReference ref(dex_file_, dex_method_idx_);
const std::vector<uint8_t>* dex_gc_map = CreateLengthPrefixedDexGcMap(*(map.get()));
verifier::MethodVerifier::SetDexGcMap(ref, *dex_gc_map);
@@ -3816,7 +3813,7 @@
if (pc_to_concrete_method_map.get() == NULL) {
pc_to_concrete_method_map.reset(new PcToConcreteMethodMap());
}
- CompilerDriver::MethodReference concrete_ref(
+ MethodReference concrete_ref(
concrete_method->GetDeclaringClass()->GetDexCache()->GetDexFile(),
concrete_method->GetDexMethodIndex());
pc_to_concrete_method_map->Put(dex_pc, concrete_ref);
@@ -3914,8 +3911,7 @@
}
}
-void MethodVerifier::SetDexGcMap(CompilerDriver::MethodReference ref,
- const std::vector<uint8_t>& gc_map) {
+void MethodVerifier::SetDexGcMap(MethodReference ref, const std::vector<uint8_t>& gc_map) {
{
WriterMutexLock mu(Thread::Current(), *dex_gc_maps_lock_);
DexGcMapTable::iterator it = dex_gc_maps_->find(ref);
@@ -3929,8 +3925,7 @@
}
-void MethodVerifier::SetSafeCastMap(CompilerDriver::MethodReference ref,
- const MethodSafeCastSet* cast_set) {
+void MethodVerifier::SetSafeCastMap(MethodReference ref, const MethodSafeCastSet* cast_set) {
MutexLock mu(Thread::Current(), *safecast_map_lock_);
SafeCastMap::iterator it = safecast_map_->find(ref);
if (it != safecast_map_->end()) {
@@ -3942,7 +3937,7 @@
CHECK(safecast_map_->find(ref) != safecast_map_->end());
}
-bool MethodVerifier::IsSafeCast(CompilerDriver::MethodReference ref, uint32_t pc) {
+bool MethodVerifier::IsSafeCast(MethodReference ref, uint32_t pc) {
MutexLock mu(Thread::Current(), *safecast_map_lock_);
SafeCastMap::const_iterator it = safecast_map_->find(ref);
if (it == safecast_map_->end()) {
@@ -3954,7 +3949,7 @@
return cast_it != it->second->end();
}
-const std::vector<uint8_t>* MethodVerifier::GetDexGcMap(CompilerDriver::MethodReference ref) {
+const std::vector<uint8_t>* MethodVerifier::GetDexGcMap(MethodReference ref) {
ReaderMutexLock mu(Thread::Current(), *dex_gc_maps_lock_);
DexGcMapTable::const_iterator it = dex_gc_maps_->find(ref);
if (it == dex_gc_maps_->end()) {
@@ -3965,7 +3960,7 @@
return it->second;
}
-void MethodVerifier::SetDevirtMap(CompilerDriver::MethodReference ref,
+void MethodVerifier::SetDevirtMap(MethodReference ref,
const PcToConcreteMethodMap* devirt_map) {
WriterMutexLock mu(Thread::Current(), *devirt_maps_lock_);
DevirtualizationMapTable::iterator it = devirt_maps_->find(ref);
@@ -3978,7 +3973,7 @@
CHECK(devirt_maps_->find(ref) != devirt_maps_->end());
}
-const CompilerDriver::MethodReference* MethodVerifier::GetDevirtMap(const CompilerDriver::MethodReference& ref,
+const MethodReference* MethodVerifier::GetDevirtMap(const MethodReference& ref,
uint32_t dex_pc) {
ReaderMutexLock mu(Thread::Current(), *devirt_maps_lock_);
DevirtualizationMapTable::const_iterator it = devirt_maps_->find(ref);
@@ -4110,7 +4105,7 @@
verifier::RegTypeCache::ShutDown();
}
-void MethodVerifier::AddRejectedClass(CompilerDriver::ClassReference ref) {
+void MethodVerifier::AddRejectedClass(ClassReference ref) {
{
MutexLock mu(Thread::Current(), *rejected_classes_lock_);
rejected_classes_->insert(ref);
@@ -4118,7 +4113,7 @@
CHECK(IsClassRejected(ref));
}
-bool MethodVerifier::IsClassRejected(CompilerDriver::ClassReference ref) {
+bool MethodVerifier::IsClassRejected(ClassReference ref) {
MutexLock mu(Thread::Current(), *rejected_classes_lock_);
return (rejected_classes_->find(ref) != rejected_classes_->end());
}
diff --git a/src/verifier/method_verifier.h b/src/verifier/method_verifier.h
index e90f9d9..ac0de9e 100644
--- a/src/verifier/method_verifier.h
+++ b/src/verifier/method_verifier.h
@@ -23,10 +23,11 @@
#include "base/casts.h"
#include "base/macros.h"
#include "base/stl_util.h"
-#include "compiler/driver/compiler_driver.h"
+#include "class_reference.h"
#include "dex_file.h"
#include "dex_instruction.h"
#include "instruction_flags.h"
+#include "method_reference.h"
#include "mirror/object.h"
#include "reg_type.h"
#include "reg_type_cache-inl.h"
@@ -184,17 +185,15 @@
// information
void Dump(std::ostream& os) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- static const std::vector<uint8_t>* GetDexGcMap(CompilerDriver::MethodReference ref)
+ static const std::vector<uint8_t>* GetDexGcMap(MethodReference ref)
LOCKS_EXCLUDED(dex_gc_maps_lock_);
- static const CompilerDriver::MethodReference* GetDevirtMap(const CompilerDriver::MethodReference& ref,
- uint32_t dex_pc)
+ static const MethodReference* GetDevirtMap(const MethodReference& ref, uint32_t dex_pc)
LOCKS_EXCLUDED(devirt_maps_lock_);
// Returns true if the cast can statically be verified to be redundant
// by using the check-cast elision peephole optimization in the verifier
- static bool IsSafeCast(CompilerDriver::MethodReference ref, uint32_t pc)
- LOCKS_EXCLUDED(safecast_map_lock_);
+ static bool IsSafeCast(MethodReference ref, uint32_t pc) LOCKS_EXCLUDED(safecast_map_lock_);
// Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding
// to the locks held at 'dex_pc' in method 'm'.
@@ -217,7 +216,7 @@
static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static void Shutdown();
- static bool IsClassRejected(CompilerDriver::ClassReference ref)
+ static bool IsClassRejected(ClassReference ref)
LOCKS_EXCLUDED(rejected_classes_lock_);
bool CanLoadClasses() const {
@@ -622,42 +621,42 @@
InstructionFlags* CurrentInsnFlags();
// All the GC maps that the verifier has created
- typedef SafeMap<const CompilerDriver::MethodReference, const std::vector<uint8_t>*,
- CompilerDriver::MethodReferenceComparator> DexGcMapTable;
+ typedef SafeMap<const MethodReference, const std::vector<uint8_t>*,
+ MethodReferenceComparator> DexGcMapTable;
static ReaderWriterMutex* dex_gc_maps_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
static DexGcMapTable* dex_gc_maps_ GUARDED_BY(dex_gc_maps_lock_);
- static void SetDexGcMap(CompilerDriver::MethodReference ref, const std::vector<uint8_t>& dex_gc_map)
+ static void SetDexGcMap(MethodReference ref, const std::vector<uint8_t>& dex_gc_map)
LOCKS_EXCLUDED(dex_gc_maps_lock_);
// Cast elision types.
typedef std::set<uint32_t> MethodSafeCastSet;
- typedef SafeMap<const CompilerDriver::MethodReference, const MethodSafeCastSet*,
- CompilerDriver::MethodReferenceComparator> SafeCastMap;
+ typedef SafeMap<const MethodReference, const MethodSafeCastSet*,
+ MethodReferenceComparator> SafeCastMap;
MethodVerifier::MethodSafeCastSet* GenerateSafeCastSet()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- static void SetSafeCastMap(CompilerDriver::MethodReference ref, const MethodSafeCastSet* mscs);
+ static void SetSafeCastMap(MethodReference ref, const MethodSafeCastSet* mscs);
LOCKS_EXCLUDED(safecast_map_lock_);
static Mutex* safecast_map_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
static SafeCastMap* safecast_map_ GUARDED_BY(safecast_map_lock_);
// Devirtualization map.
- typedef SafeMap<const uint32_t, CompilerDriver::MethodReference> PcToConcreteMethodMap;
- typedef SafeMap<const CompilerDriver::MethodReference, const PcToConcreteMethodMap*,
- CompilerDriver::MethodReferenceComparator> DevirtualizationMapTable;
+ typedef SafeMap<const uint32_t, MethodReference> PcToConcreteMethodMap;
+ typedef SafeMap<const MethodReference, const PcToConcreteMethodMap*,
+ MethodReferenceComparator> DevirtualizationMapTable;
MethodVerifier::PcToConcreteMethodMap* GenerateDevirtMap()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static ReaderWriterMutex* devirt_maps_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
static DevirtualizationMapTable* devirt_maps_ GUARDED_BY(devirt_maps_lock_);
- static void SetDevirtMap(CompilerDriver::MethodReference ref,
+ static void SetDevirtMap(MethodReference ref,
const PcToConcreteMethodMap* pc_method_map)
LOCKS_EXCLUDED(devirt_maps_lock_);
- typedef std::set<CompilerDriver::ClassReference> RejectedClassesTable;
+ typedef std::set<ClassReference> RejectedClassesTable;
static Mutex* rejected_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
static RejectedClassesTable* rejected_classes_;
- static void AddRejectedClass(CompilerDriver::ClassReference ref)
+ static void AddRejectedClass(ClassReference ref)
LOCKS_EXCLUDED(rejected_classes_lock_);
RegTypeCache reg_types_;