Rename OatCompilationUnit to Dex.. move to compiler.
Some other clean-up to make fields const and private.
Change-Id: Icad66e2969385ab1f4125162bcbf8d5fa92d3ed5
diff --git a/src/compiler/dex/compiler_ir.h b/src/compiler/dex/compiler_ir.h
index 04dee77..76e838c 100644
--- a/src/compiler/dex/compiler_ir.h
+++ b/src/compiler/dex/compiler_ir.h
@@ -20,8 +20,8 @@
#include <vector>
#include "dex_instruction.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
#include "compiler_utility.h"
-#include "oat_compilation_unit.h"
#include "safe_map.h"
#include "compiler_llvm/ir_builder.h"
#include "compiler_llvm/intrinsic_helper.h"
diff --git a/src/compiler/dex/dataflow.cc b/src/compiler/dex/dataflow.cc
index 0fa9ab1..ac3116e 100644
--- a/src/compiler/dex/dataflow.cc
+++ b/src/compiler/dex/dataflow.cc
@@ -2491,7 +2491,7 @@
LOG(WARNING) << "Unexpected invoke op: " << opcode;
return false;
}
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
+ DexCompilationUnit m_unit(cu->class_loader, cu->class_linker,
*cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx,
cu->access_flags);
diff --git a/src/compiler/dex/quick/arm/call_arm.cc b/src/compiler/dex/quick/arm/call_arm.cc
index 09e8f3f..d3a3a7c 100644
--- a/src/compiler/dex/quick/arm/call_arm.cc
+++ b/src/compiler/dex/quick/arm/call_arm.cc
@@ -21,7 +21,6 @@
#include "compiler/dex/quick/codegen_util.h"
#include "compiler/dex/quick/ralloc_util.h"
#include "oat/runtime/oat_support_entrypoints.h"
-#include "oat_compilation_unit.h"
namespace art {
diff --git a/src/compiler/dex/quick/arm/int_arm.cc b/src/compiler/dex/quick/arm/int_arm.cc
index 0018d44..ed65636 100644
--- a/src/compiler/dex/quick/arm/int_arm.cc
+++ b/src/compiler/dex/quick/arm/int_arm.cc
@@ -21,7 +21,6 @@
#include "compiler/dex/quick/codegen_util.h"
#include "compiler/dex/quick/ralloc_util.h"
#include "oat/runtime/oat_support_entrypoints.h"
-#include "oat_compilation_unit.h"
namespace art {
diff --git a/src/compiler/dex/quick/codegen_util.cc b/src/compiler/dex/quick/codegen_util.cc
index a7ca77a..5f8f6ef 100644
--- a/src/compiler/dex/quick/codegen_util.cc
+++ b/src/compiler/dex/quick/codegen_util.cc
@@ -54,7 +54,7 @@
bool FastInstance(CompilationUnit* cu, uint32_t field_idx,
int& field_offset, bool& is_volatile, bool is_put)
{
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
+ DexCompilationUnit m_unit(cu->class_loader, cu->class_linker,
*cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx,
cu->access_flags);
diff --git a/src/compiler/dex/quick/gen_common.cc b/src/compiler/dex/quick/gen_common.cc
index e3791ce..f14d6cf 100644
--- a/src/compiler/dex/quick/gen_common.cc
+++ b/src/compiler/dex/quick/gen_common.cc
@@ -354,7 +354,7 @@
bool is_volatile;
bool is_referrers_class;
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker, *cu->dex_file, cu->code_item,
+ DexCompilationUnit m_unit(cu->class_loader, cu->class_linker, *cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx, cu->access_flags);
bool fast_path =
@@ -446,7 +446,7 @@
bool is_volatile;
bool is_referrers_class;
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
+ DexCompilationUnit m_unit(cu->class_loader, cu->class_linker,
*cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx,
cu->access_flags);
diff --git a/src/compiler/dex/quick/gen_invoke.cc b/src/compiler/dex/quick/gen_invoke.cc
index 3fe797c..2c01c19 100644
--- a/src/compiler/dex/quick/gen_invoke.cc
+++ b/src/compiler/dex/quick/gen_invoke.cc
@@ -1335,7 +1335,7 @@
// Explicit register usage
LockCallTemps(cu);
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
+ DexCompilationUnit m_unit(cu->class_loader, cu->class_linker,
*cu->dex_file, cu->code_item,
cu->class_def_idx, cu->method_idx,
cu->access_flags);
diff --git a/src/compiler/driver/compiler_driver.cc b/src/compiler/driver/compiler_driver.cc
index f22aaa5..a28ba18 100644
--- a/src/compiler/driver/compiler_driver.cc
+++ b/src/compiler/driver/compiler_driver.cc
@@ -24,8 +24,8 @@
#include "base/stl_util.h"
#include "base/timing_logger.h"
#include "class_linker.h"
+#include "dex_compilation_unit.h"
#include "jni_internal.h"
-#include "oat_compilation_unit.h"
#include "oat_file.h"
#include "oat/runtime/stub.h"
#include "object_utils.h"
@@ -671,37 +671,37 @@
}
static mirror::Class* ComputeCompilingMethodsClass(ScopedObjectAccess& soa,
- OatCompilationUnit* mUnit)
+ const DexCompilationUnit* mUnit)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::DexCache* dex_cache = mUnit->class_linker_->FindDexCache(*mUnit->dex_file_);
- mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->class_loader_);
- const DexFile::MethodId& referrer_method_id = mUnit->dex_file_->GetMethodId(mUnit->method_idx_);
- return mUnit->class_linker_->ResolveType(*mUnit->dex_file_, referrer_method_id.class_idx_,
- dex_cache, class_loader);
+ mirror::DexCache* dex_cache = mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile());
+ mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader());
+ const DexFile::MethodId& referrer_method_id = mUnit->GetDexFile()->GetMethodId(mUnit->GetDexMethodIndex());
+ return mUnit->GetClassLinker()->ResolveType(*mUnit->GetDexFile(), referrer_method_id.class_idx_,
+ dex_cache, class_loader);
}
static mirror::Field* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAccess& soa,
- OatCompilationUnit* mUnit,
+ const DexCompilationUnit* mUnit,
uint32_t field_idx)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::DexCache* dex_cache = mUnit->class_linker_->FindDexCache(*mUnit->dex_file_);
- mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->class_loader_);
- return mUnit->class_linker_->ResolveField(*mUnit->dex_file_, field_idx, dex_cache,
- class_loader, false);
+ mirror::DexCache* dex_cache = mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile());
+ mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader());
+ return mUnit->GetClassLinker()->ResolveField(*mUnit->GetDexFile(), field_idx, dex_cache,
+ class_loader, false);
}
static mirror::AbstractMethod* ComputeMethodReferencedFromCompilingMethod(ScopedObjectAccess& soa,
- OatCompilationUnit* mUnit,
+ const DexCompilationUnit* mUnit,
uint32_t method_idx,
InvokeType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::DexCache* dex_cache = mUnit->class_linker_->FindDexCache(*mUnit->dex_file_);
- mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->class_loader_);
- return mUnit->class_linker_->ResolveMethod(*mUnit->dex_file_, method_idx, dex_cache,
- class_loader, NULL, type);
+ mirror::DexCache* dex_cache = mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile());
+ mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader());
+ return mUnit->GetClassLinker()->ResolveMethod(*mUnit->GetDexFile(), method_idx, dex_cache,
+ class_loader, NULL, type);
}
-bool CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, OatCompilationUnit* mUnit,
+bool CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit,
int& field_offset, bool& is_volatile, bool is_put) {
ScopedObjectAccess soa(Thread::Current());
// Conservative defaults.
@@ -721,7 +721,7 @@
// protected field being made public by a sub-class. Resort to the dex file to determine
// the correct class for the access check.
const DexFile& dex_file = *referrer_class->GetDexCache()->GetDexFile();
- mirror::Class* dex_fields_class = mUnit->class_linker_->ResolveType(dex_file,
+ mirror::Class* dex_fields_class = mUnit->GetClassLinker()->ResolveType(dex_file,
dex_file.GetFieldId(field_idx).class_idx_,
referrer_class);
access_ok = referrer_class->CanAccess(dex_fields_class) &&
@@ -746,7 +746,7 @@
return false; // Incomplete knowledge needs slow path.
}
-bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, OatCompilationUnit* mUnit,
+bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit,
int& field_offset, int& ssb_index,
bool& is_referrers_class, bool& is_volatile,
bool is_put) {
@@ -779,9 +779,9 @@
// used to identify the SSB.
const DexFile& dex_file = *referrer_class->GetDexCache()->GetDexFile();
mirror::Class* dex_fields_class =
- mUnit->class_linker_->ResolveType(dex_file,
- dex_file.GetFieldId(field_idx).class_idx_,
- referrer_class);
+ mUnit->GetClassLinker()->ResolveType(dex_file,
+ dex_file.GetFieldId(field_idx).class_idx_,
+ referrer_class);
access_ok = referrer_class->CanAccess(dex_fields_class) &&
referrer_class->CanAccessMember(dex_fields_class,
resolved_field->GetAccessFlags());
@@ -792,7 +792,7 @@
// in its static storage base (which may fail if it doesn't have a slot for it)
// TODO: for images we can elide the static storage base null check
// if we know there's a non-null entry in the image
- mirror::DexCache* dex_cache = mUnit->class_linker_->FindDexCache(*mUnit->dex_file_);
+ mirror::DexCache* dex_cache = mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile());
if (fields_class->GetDexCache() == dex_cache) {
// common case where the dex cache of both the referrer and the field are the same,
// no need to search the dex file
@@ -806,13 +806,13 @@
// of the class mentioned in the dex file and there is no dex cache entry.
std::string descriptor(FieldHelper(resolved_field).GetDeclaringClassDescriptor());
const DexFile::StringId* string_id =
- mUnit->dex_file_->FindStringId(descriptor);
+ mUnit->GetDexFile()->FindStringId(descriptor);
if (string_id != NULL) {
const DexFile::TypeId* type_id =
- mUnit->dex_file_->FindTypeId(mUnit->dex_file_->GetIndexForStringId(*string_id));
+ mUnit->GetDexFile()->FindTypeId(mUnit->GetDexFile()->GetIndexForStringId(*string_id));
if (type_id != NULL) {
// medium path, needs check of static storage base being initialized
- ssb_index = mUnit->dex_file_->GetIndexForTypeId(*type_id);
+ ssb_index = mUnit->GetDexFile()->GetIndexForTypeId(*type_id);
field_offset = resolved_field->GetOffset().Int32Value();
is_volatile = resolved_field->IsVolatile();
stats_->ResolvedStaticField();
@@ -882,7 +882,7 @@
}
}
-bool CompilerDriver::ComputeInvokeInfo(uint32_t method_idx, OatCompilationUnit* mUnit,
+bool CompilerDriver::ComputeInvokeInfo(uint32_t method_idx, const DexCompilationUnit* mUnit,
InvokeType& type, int& vtable_idx, uintptr_t& direct_code,
uintptr_t& direct_method) {
ScopedObjectAccess soa(Thread::Current());
@@ -907,9 +907,9 @@
// check.
const DexFile& dex_file = *referrer_class->GetDexCache()->GetDexFile();
methods_class =
- mUnit->class_linker_->ResolveType(dex_file,
- dex_file.GetMethodId(method_idx).class_idx_,
- referrer_class);
+ mUnit->GetClassLinker()->ResolveType(dex_file,
+ dex_file.GetMethodId(method_idx).class_idx_,
+ referrer_class);
}
if (referrer_class->CanAccess(methods_class) &&
referrer_class->CanAccessMember(methods_class, resolved_method->GetAccessFlags())) {
diff --git a/src/compiler/driver/compiler_driver.h b/src/compiler/driver/compiler_driver.h
index 7026a60..49bc473 100644
--- a/src/compiler/driver/compiler_driver.h
+++ b/src/compiler/driver/compiler_driver.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_SRC_COMPILER_H_
-#define ART_SRC_COMPILER_H_
+#ifndef ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_
+#define ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_
#include <set>
#include <string>
@@ -36,7 +36,7 @@
class AOTCompilationStats;
class ParallelCompilationManager;
-class OatCompilationUnit;
+class DexCompilationUnit;
class TimingLogger;
enum CompilerBackend {
@@ -151,20 +151,20 @@
LOCKS_EXCLUDED(Locks::mutator_lock_);
// Can we fast path instance field access? Computes field's offset and volatility.
- bool ComputeInstanceFieldInfo(uint32_t field_idx, OatCompilationUnit* mUnit,
+ bool ComputeInstanceFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit,
int& field_offset, bool& is_volatile, bool is_put)
LOCKS_EXCLUDED(Locks::mutator_lock_);
// Can we fastpath static field access? Computes field's offset, volatility and whether the
// field is within the referrer (which can avoid checking class initialization).
- bool ComputeStaticFieldInfo(uint32_t field_idx, OatCompilationUnit* mUnit,
+ bool ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit,
int& field_offset, int& ssb_index,
bool& is_referrers_class, bool& is_volatile, bool is_put)
LOCKS_EXCLUDED(Locks::mutator_lock_);
// Can we fastpath a interface, super class or virtual method call? Computes method's vtable
// index.
- bool ComputeInvokeInfo(uint32_t method_idx, OatCompilationUnit* mUnit, InvokeType& type,
+ bool ComputeInvokeInfo(uint32_t method_idx, const DexCompilationUnit* mUnit, InvokeType& type,
int& vtable_idx, uintptr_t& direct_code, uintptr_t& direct_method)
LOCKS_EXCLUDED(Locks::mutator_lock_);
@@ -419,4 +419,4 @@
} // namespace art
-#endif // ART_SRC_COMPILER_H_
+#endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_
diff --git a/src/oat_compilation_unit.h b/src/compiler/driver/dex_compilation_unit.h
similarity index 74%
rename from src/oat_compilation_unit.h
rename to src/compiler/driver/dex_compilation_unit.h
index 7eac322..6a0218d 100644
--- a/src/oat_compilation_unit.h
+++ b/src/compiler/driver/dex_compilation_unit.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_SRC_OAT_COMPILATION_UNIT_H_
-#define ART_SRC_OAT_COMPILATION_UNIT_H_
+#ifndef ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_
+#define ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_
#include "dex_file.h"
@@ -29,22 +29,16 @@
class ClassLinker;
class DexFile;
-class OatCompilationUnit {
+class DexCompilationUnit {
public:
- OatCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file,
+ DexCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file,
const DexFile::CodeItem* code_item, uint32_t class_def_idx,
uint32_t method_idx, uint32_t access_flags)
: class_loader_(class_loader), class_linker_(class_linker), dex_file_(&dex_file),
- code_item_(code_item), class_def_idx_(class_def_idx), method_idx_(method_idx),
+ code_item_(code_item), class_def_idx_(class_def_idx), dex_method_idx_(method_idx),
access_flags_(access_flags) {
}
- OatCompilationUnit* GetCallee(uint32_t callee_method_idx,
- uint32_t callee_access_flags) {
- return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, NULL,
- 0, callee_method_idx, callee_access_flags);
- }
-
jobject GetClassLoader() const {
return class_loader_;
}
@@ -62,7 +56,7 @@
}
uint32_t GetDexMethodIndex() const {
- return method_idx_;
+ return dex_method_idx_;
}
const DexFile::CodeItem* GetCodeItem() const {
@@ -70,31 +64,43 @@
}
const char* GetShorty() const {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
+ const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
return dex_file_->GetMethodShorty(method_id);
}
const char* GetShorty(uint32_t* shorty_len) const {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
+ const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
return dex_file_->GetMethodShorty(method_id, shorty_len);
}
+ uint32_t GetAccessFlags() const {
+ return access_flags_;
+ }
+
+ bool IsNative() const {
+ return ((access_flags_ & kAccNative) != 0);
+ }
+
bool IsStatic() const {
return ((access_flags_ & kAccStatic) != 0);
}
- public:
- jobject class_loader_;
+ bool IsSynchronized() const {
+ return ((access_flags_ & kAccSynchronized) != 0);
+ }
+
+ private:
+ const jobject class_loader_;
ClassLinker* const class_linker_;
const DexFile* const dex_file_;
const DexFile::CodeItem* const code_item_;
const uint32_t class_def_idx_;
- const uint32_t method_idx_;
+ const uint32_t dex_method_idx_;
const uint32_t access_flags_;
};
} // namespace art
-#endif // ART_SRC_OAT_COMPILATION_UNIT_H_
+#endif // ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_
diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc
index 840cd77..a0f4dc8 100644
--- a/src/compiler/jni/portable/jni_compiler.cc
+++ b/src/compiler/jni/portable/jni_compiler.cc
@@ -20,13 +20,13 @@
#include "class_linker.h"
#include "compiled_method.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
#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/utils_llvm.h"
#include "mirror/abstract_method.h"
-#include "oat_compilation_unit.h"
#include "runtime.h"
#include "stack.h"
#include "thread.h"
@@ -44,25 +44,24 @@
JniCompiler::JniCompiler(LlvmCompilationUnit* cunit,
const CompilerDriver& driver,
- OatCompilationUnit* oat_compilation_unit)
+ const DexCompilationUnit* dex_compilation_unit)
: cunit_(cunit), driver_(&driver), module_(cunit_->GetModule()),
context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()),
- oat_compilation_unit_(oat_compilation_unit),
- access_flags_(oat_compilation_unit->access_flags_),
- method_idx_(oat_compilation_unit->method_idx_),
- dex_file_(oat_compilation_unit->dex_file_),
+ dex_compilation_unit_(dex_compilation_unit),
func_(NULL), elf_func_idx_(0) {
// Check: Ensure that JNI compiler will only get "native" method
- CHECK((access_flags_ & kAccNative) != 0);
+ CHECK(dex_compilation_unit->IsNative());
}
CompiledMethod* JniCompiler::Compile() {
- const bool is_static = (access_flags_ & kAccStatic) != 0;
- const bool is_synchronized = (access_flags_ & kAccSynchronized) != 0;
- DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx_);
- char const return_shorty = dex_file_->GetMethodShorty(method_id)[0];
+ const bool is_static = dex_compilation_unit_->IsStatic();
+ const bool is_synchronized = dex_compilation_unit_->IsSynchronized();
+ const DexFile* dex_file = dex_compilation_unit_->GetDexFile();
+ DexFile::MethodId const& method_id =
+ dex_file->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
+ char const return_shorty = dex_file->GetMethodShorty(method_id)[0];
llvm::Value* this_object_or_class_object;
CreateFunction();
@@ -128,7 +127,8 @@
llvm::Value* code_addr =
irb_.LoadFromObjectOffset(method_object_addr,
mirror::AbstractMethod::NativeMethodOffset().Int32Value(),
- GetFunctionType(method_idx_, is_static, true)->getPointerTo(),
+ GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(),
+ is_static, true)->getPointerTo(),
kTBAARuntimeInfo);
// Load actual parameters
@@ -241,11 +241,11 @@
// LLVM function name
std::string func_name(ElfFuncName(cunit_->GetIndex()));
- const bool is_static = (access_flags_ & kAccStatic) != 0;
+ const bool is_static = dex_compilation_unit_->IsStatic();
// Get function type
llvm::FunctionType* func_type =
- GetFunctionType(method_idx_, is_static, false);
+ GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(), is_static, false);
// Create function
func_ = llvm::Function::Create(func_type, llvm::Function::ExternalLinkage,
@@ -262,10 +262,8 @@
llvm::FunctionType* JniCompiler::GetFunctionType(uint32_t method_idx,
bool is_static, bool is_native_function) {
// Get method signature
- DexFile::MethodId const& method_id = dex_file_->GetMethodId(method_idx);
-
uint32_t shorty_size;
- const char* shorty = dex_file_->GetMethodShorty(method_id, &shorty_size);
+ const char* shorty = dex_compilation_unit_->GetShorty(&shorty_size);
CHECK_GE(shorty_size, 1u);
// Get return type
diff --git a/src/compiler/jni/portable/jni_compiler.h b/src/compiler/jni/portable/jni_compiler.h
index 071229c..3125f0f 100644
--- a/src/compiler/jni/portable/jni_compiler.h
+++ b/src/compiler/jni/portable/jni_compiler.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_
-#define ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_
+#ifndef ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
+#define ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
#include <stdint.h>
@@ -24,7 +24,7 @@
class CompiledMethod;
class CompilerDriver;
class DexFile;
- class OatCompilationUnit;
+ class DexCompilationUnit;
namespace mirror {
class AbstractMethod;
class ClassLoader;
@@ -53,7 +53,7 @@
public:
JniCompiler(LlvmCompilationUnit* cunit,
const CompilerDriver& driver,
- OatCompilationUnit* oat_compilation_unit);
+ const DexCompilationUnit* dex_compilation_unit);
CompiledMethod* Compile();
@@ -71,19 +71,15 @@
llvm::LLVMContext* context_;
IRBuilder& irb_;
- OatCompilationUnit* oat_compilation_unit_;
-
- uint32_t access_flags_;
- uint32_t method_idx_;
- const DexFile* dex_file_;
+ const DexCompilationUnit* const dex_compilation_unit_;
llvm::Function* func_;
uint16_t elf_func_idx_;
};
-} // namespace compiler_llvm
-} // namespace art
+} // namespace compiler_llvm
+} // namespace art
-#endif // ART_SRC_COMPILER_LLVM_JNI_COMPILER_H_
+#endif // ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 45f9931..3030dce 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -21,10 +21,10 @@
#include "class_linker.h"
#include "compiled_method.h"
#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
#include "ir_builder.h"
#include "compiler/jni/portable/jni_compiler.h"
#include "llvm_compilation_unit.h"
-#include "oat_compilation_unit.h"
#include "oat_file.h"
#include "stub_compiler.h"
#include "utils_llvm.h"
@@ -133,31 +133,31 @@
CompiledMethod* CompilerLLVM::
-CompileDexMethod(OatCompilationUnit* oat_compilation_unit, InvokeType invoke_type) {
+CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_type) {
UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
- std::string methodName(PrettyMethod(oat_compilation_unit->GetDexMethodIndex(),
- *oat_compilation_unit->GetDexFile()));
+ std::string methodName(PrettyMethod(dex_compilation_unit->GetDexMethodIndex(),
+ *dex_compilation_unit->GetDexFile()));
// TODO: consolidate ArtCompileMethods
CompileOneMethod(*compiler_driver_,
kPortable,
- oat_compilation_unit->GetCodeItem(),
- oat_compilation_unit->access_flags_,
+ dex_compilation_unit->GetCodeItem(),
+ dex_compilation_unit->GetAccessFlags(),
invoke_type,
- oat_compilation_unit->GetClassDefIndex(),
- oat_compilation_unit->GetDexMethodIndex(),
- oat_compilation_unit->GetClassLoader(),
- *oat_compilation_unit->GetDexFile(),
+ dex_compilation_unit->GetClassDefIndex(),
+ dex_compilation_unit->GetDexMethodIndex(),
+ dex_compilation_unit->GetClassLoader(),
+ *dex_compilation_unit->GetDexFile(),
cunit->GetQuickContext()
);
cunit->SetCompiler(compiler_driver_);
- cunit->SetOatCompilationUnit(oat_compilation_unit);
+ cunit->SetDexCompilationUnit(dex_compilation_unit);
cunit->Materialize();
- CompilerDriver::MethodReference mref(oat_compilation_unit->GetDexFile(),
- oat_compilation_unit->GetDexMethodIndex());
+ CompilerDriver::MethodReference mref(dex_compilation_unit->GetDexFile(),
+ dex_compilation_unit->GetDexMethodIndex());
return new CompiledMethod(compiler_driver_->GetInstructionSet(),
cunit->GetCompiledCode(),
*verifier::MethodVerifier::GetDexGcMap(mref));
@@ -165,11 +165,11 @@
CompiledMethod* CompilerLLVM::
-CompileNativeMethod(OatCompilationUnit* oat_compilation_unit) {
+CompileNativeMethod(DexCompilationUnit* dex_compilation_unit) {
UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
UniquePtr<JniCompiler> jni_compiler(
- new JniCompiler(cunit.get(), *compiler_driver_, oat_compilation_unit));
+ new JniCompiler(cunit.get(), *compiler_driver_, dex_compilation_unit));
return jni_compiler->Compile();
}
@@ -235,11 +235,11 @@
UNUSED(class_def_idx); // TODO: this is used with Compiler::RequiresConstructorBarrier.
art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
- art::OatCompilationUnit oat_compilation_unit(
+ art::DexCompilationUnit dex_compilation_unit(
class_loader, class_linker, dex_file, code_item,
class_def_idx, method_idx, access_flags);
art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
- art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&oat_compilation_unit, invoke_type);
+ art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type);
return result;
}
@@ -248,12 +248,12 @@
const art::DexFile& dex_file) {
art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
- art::OatCompilationUnit oat_compilation_unit(
+ art::DexCompilationUnit dex_compilation_unit(
NULL, class_linker, dex_file, NULL,
0, method_idx, access_flags);
art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
- art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&oat_compilation_unit);
+ art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&dex_compilation_unit);
return result;
}
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 0995a55..0470f29 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -34,7 +34,7 @@
class CompiledInvokeStub;
class CompiledMethod;
class CompilerDriver;
- class OatCompilationUnit;
+ class DexCompilationUnit;
namespace mirror {
class AbstractMethod;
class ClassLoader;
@@ -76,12 +76,12 @@
bitcode_filename_ = filename;
}
- CompiledMethod* CompileDexMethod(OatCompilationUnit* oat_compilation_unit,
+ CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
InvokeType invoke_type);
- CompiledMethod* CompileGBCMethod(OatCompilationUnit* oat_compilation_unit, std::string* func);
+ CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
- CompiledMethod* CompileNativeMethod(OatCompilationUnit* oat_compilation_unit);
+ CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty);
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler_llvm/gbc_expander.cc
index f0d3830..16d71af 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler_llvm/gbc_expander.cc
@@ -15,11 +15,11 @@
*/
#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
#include "intrinsic_helper.h"
#include "ir_builder.h"
#include "mirror/abstract_method.h"
#include "mirror/array.h"
-#include "oat_compilation_unit.h"
#include "thread.h"
#include "utils_llvm.h"
#include "verifier/method_verifier.h"
@@ -65,7 +65,7 @@
private:
art::CompilerDriver* const driver_;
- art::OatCompilationUnit* oat_compilation_unit_;
+ const art::DexCompilationUnit* const dex_compilation_unit_;
llvm::Function* func_;
@@ -326,12 +326,12 @@
static char ID;
GBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
- art::CompilerDriver* compiler, art::OatCompilationUnit* oat_compilation_unit)
+ art::CompilerDriver* compiler, art::DexCompilationUnit* dex_compilation_unit)
: llvm::FunctionPass(ID), intrinsic_helper_(intrinsic_helper), irb_(irb),
context_(irb.getContext()), rtb_(irb.Runtime()),
shadow_frame_(NULL), old_shadow_frame_(NULL),
driver_(compiler),
- oat_compilation_unit_(oat_compilation_unit),
+ dex_compilation_unit_(dex_compilation_unit),
func_(NULL), current_bb_(NULL), basic_block_unwind_(NULL), changed_(false) {}
bool runOnFunction(llvm::Function& func);
@@ -360,8 +360,8 @@
func_ = &func;
changed_ = false; // Assume unchanged
- basic_blocks_.resize(oat_compilation_unit_->code_item_->insns_size_in_code_units_);
- basic_block_landing_pads_.resize(oat_compilation_unit_->code_item_->tries_size_, NULL);
+ basic_blocks_.resize(dex_compilation_unit_->GetCodeItem()->insns_size_in_code_units_);
+ basic_block_landing_pads_.resize(dex_compilation_unit_->GetCodeItem()->tries_size_, NULL);
basic_block_unwind_ = NULL;
for (llvm::Function::iterator bb_iter = func_->begin(), bb_end = func_->end();
bb_iter != bb_end;
@@ -1393,7 +1393,7 @@
int field_offset;
bool is_volatile;
bool is_fast_path = driver_->ComputeInstanceFieldInfo(
- field_idx, oat_compilation_unit_, field_offset, is_volatile, false);
+ field_idx, dex_compilation_unit_, field_offset, is_volatile, false);
if (!is_fast_path) {
llvm::Function* runtime_func;
@@ -1453,7 +1453,7 @@
int field_offset;
bool is_volatile;
bool is_fast_path = driver_->ComputeInstanceFieldInfo(
- field_idx, oat_compilation_unit_, field_offset, is_volatile, true);
+ field_idx, dex_compilation_unit_, field_offset, is_volatile, true);
if (!is_fast_path) {
llvm::Function* runtime_func;
@@ -1509,8 +1509,8 @@
llvm::Value* GBCExpanderPass::EmitLoadConstantClass(uint32_t dex_pc,
uint32_t type_idx) {
- if (!driver_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
- *oat_compilation_unit_->dex_file_, type_idx)) {
+ if (!driver_->CanAccessTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+ *dex_compilation_unit_->GetDexFile(), type_idx)) {
llvm::Value* type_idx_value = irb_.getInt32(type_idx);
llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
@@ -1536,7 +1536,7 @@
llvm::Value* type_object_addr = irb_.CreateLoad(type_field_addr, kTBAARuntimeInfo);
- if (driver_->CanAssumeTypeIsPresentInDexCache(*oat_compilation_unit_->dex_file_, type_idx)) {
+ if (driver_->CanAssumeTypeIsPresentInDexCache(*dex_compilation_unit_->GetDexFile(), type_idx)) {
return type_object_addr;
}
@@ -1653,7 +1653,7 @@
bool is_volatile;
bool is_fast_path = driver_->ComputeStaticFieldInfo(
- field_idx, oat_compilation_unit_, field_offset, ssb_index,
+ field_idx, dex_compilation_unit_, field_offset, ssb_index,
is_referrers_class, is_volatile, false);
llvm::Value* static_field_value;
@@ -1735,7 +1735,7 @@
bool is_volatile;
bool is_fast_path = driver_->ComputeStaticFieldInfo(
- field_idx, oat_compilation_unit_, field_offset, ssb_index,
+ field_idx, dex_compilation_unit_, field_offset, ssb_index,
is_referrers_class, is_volatile, true);
if (!is_fast_path) {
@@ -1814,8 +1814,8 @@
llvm::Value* string_addr = irb_.CreateLoad(string_field_addr, kTBAARuntimeInfo);
- if (!driver_->CanAssumeStringIsPresentInDexCache(*oat_compilation_unit_->dex_file_,
- string_idx)) {
+ if (!driver_->CanAssumeStringIsPresentInDexCache(*dex_compilation_unit_->GetDexFile(),
+ string_idx)) {
llvm::BasicBlock* block_str_exist =
CreateBasicBlockWithDexPC(dex_pc, "str_exist");
@@ -2037,9 +2037,9 @@
uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
llvm::Function* runtime_func;
- if (driver_->CanAccessInstantiableTypeWithoutChecks(oat_compilation_unit_->method_idx_,
- *oat_compilation_unit_->dex_file_,
- type_idx)) {
+ if (driver_->CanAccessInstantiableTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+ *dex_compilation_unit_->GetDexFile(),
+ type_idx)) {
runtime_func = irb_.GetRuntime(runtime_support::AllocObject);
} else {
runtime_func = irb_.GetRuntime(runtime_support::AllocObjectWithAccessCheck);
@@ -2073,7 +2073,7 @@
uintptr_t direct_code = 0;
uintptr_t direct_method = 0;
bool is_fast_path = driver_->
- ComputeInvokeInfo(callee_method_idx, oat_compilation_unit_,
+ ComputeInvokeInfo(callee_method_idx, dex_compilation_unit_,
invoke_type, vtable_idx, direct_code, direct_method);
// Load *this* actual parameter
@@ -2199,7 +2199,7 @@
// Check for the element type
uint32_t type_desc_len = 0;
const char* type_desc =
- oat_compilation_unit_->dex_file_->StringByTypeIdx(type_idx, &type_desc_len);
+ dex_compilation_unit_->GetDexFile()->StringByTypeIdx(type_idx, &type_desc_len);
DCHECK_GE(type_desc_len, 2u); // should be guaranteed by verifier
DCHECK_EQ(type_desc[0], '['); // should be guaranteed by verifier
@@ -2253,7 +2253,7 @@
const art::Instruction::ArrayDataPayload* payload =
reinterpret_cast<const art::Instruction::ArrayDataPayload*>(
- oat_compilation_unit_->code_item_->insns_ + payload_offset);
+ dex_compilation_unit_->GetCodeItem()->insns_ + payload_offset);
if (payload->element_count == 0) {
// When the number of the elements in the payload is zero, we don't have
@@ -2289,8 +2289,8 @@
llvm::Function* runtime_func;
bool skip_access_check =
- driver_->CanAccessTypeWithoutChecks(oat_compilation_unit_->method_idx_,
- *oat_compilation_unit_->dex_file_, type_idx);
+ driver_->CanAccessTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+ *dex_compilation_unit_->GetDexFile(), type_idx);
if (is_filled_new_array) {
@@ -2508,10 +2508,10 @@
bool is_static) {
// Get method signature
art::DexFile::MethodId const& method_id =
- oat_compilation_unit_->dex_file_->GetMethodId(method_idx);
+ dex_compilation_unit_->GetDexFile()->GetMethodId(method_idx);
uint32_t shorty_size;
- const char* shorty = oat_compilation_unit_->dex_file_->GetMethodShorty(method_id, &shorty_size);
+ const char* shorty = dex_compilation_unit_->GetDexFile()->GetMethodShorty(method_id, &shorty_size);
CHECK_GE(shorty_size, 1u);
// Get argument type
@@ -2544,20 +2544,20 @@
}
llvm::BasicBlock* GBCExpanderPass::GetBasicBlock(uint32_t dex_pc) {
- DCHECK(dex_pc < oat_compilation_unit_->code_item_->insns_size_in_code_units_);
+ DCHECK(dex_pc < dex_compilation_unit_->GetCodeItem()->insns_size_in_code_units_);
CHECK(basic_blocks_[dex_pc] != NULL);
return basic_blocks_[dex_pc];
}
int32_t GBCExpanderPass::GetTryItemOffset(uint32_t dex_pc) {
int32_t min = 0;
- int32_t max = oat_compilation_unit_->code_item_->tries_size_ - 1;
+ int32_t max = dex_compilation_unit_->GetCodeItem()->tries_size_ - 1;
while (min <= max) {
int32_t mid = min + (max - min) / 2;
- const art::DexFile::TryItem* ti = art::DexFile::GetTryItems(*oat_compilation_unit_->code_item_,
- mid);
+ const art::DexFile::TryItem* ti =
+ art::DexFile::GetTryItems(*dex_compilation_unit_->GetCodeItem(), mid);
uint32_t start = ti->start_addr_;
uint32_t end = start + ti->insn_count_;
@@ -2592,7 +2592,7 @@
}
// Get try item from code item
- const art::DexFile::TryItem* ti = art::DexFile::GetTryItems(*oat_compilation_unit_->code_item_,
+ const art::DexFile::TryItem* ti = art::DexFile::GetTryItems(*dex_compilation_unit_->GetCodeItem(),
ti_offset);
std::string lpadname;
@@ -2622,7 +2622,7 @@
irb_.CreateSwitch(catch_handler_index_value, GetUnwindBasicBlock());
// Cases with matched catch block
- art::CatchHandlerIterator iter(*oat_compilation_unit_->code_item_, ti->start_addr_);
+ art::CatchHandlerIterator iter(*dex_compilation_unit_->GetCodeItem(), ti->start_addr_);
for (uint32_t c = 0; iter.HasNext(); iter.Next(), ++c) {
sw->addCase(irb_.getInt32(c), GetBasicBlock(iter.GetHandlerAddress()));
@@ -2656,7 +2656,7 @@
Expand_PopShadowFrame();
// Emit the code to return default value (zero) for the given return type.
- char ret_shorty = oat_compilation_unit_->GetShorty()[0];
+ char ret_shorty = dex_compilation_unit_->GetShorty()[0];
ret_shorty = art::RemapShorty(ret_shorty);
if (ret_shorty == 'V') {
irb_.CreateRetVoid();
@@ -3634,8 +3634,8 @@
llvm::FunctionPass*
CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
- CompilerDriver* driver, OatCompilationUnit* oat_compilation_unit) {
- return new GBCExpanderPass(intrinsic_helper, irb, driver, oat_compilation_unit);
+ CompilerDriver* driver, DexCompilationUnit* dex_compilation_unit) {
+ return new GBCExpanderPass(intrinsic_helper, irb, driver, dex_compilation_unit);
}
} // namespace compiler_llvm
diff --git a/src/compiler_llvm/llvm_compilation_unit.cc b/src/compiler_llvm/llvm_compilation_unit.cc
index 3f13c18..d240bac 100644
--- a/src/compiler_llvm/llvm_compilation_unit.cc
+++ b/src/compiler_llvm/llvm_compilation_unit.cc
@@ -82,16 +82,15 @@
llvm::FunctionPass*
CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
- CompilerDriver* compiler, OatCompilationUnit* oat_compilation_unit);
+ CompilerDriver* compiler, DexCompilationUnit* dex_compilation_unit);
llvm::Module* makeLLVMModuleContents(llvm::Module* module);
-LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm,
- size_t cunit_idx)
-: compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
+LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm, size_t cunit_idx)
+ : compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
driver_ = NULL;
- oat_compilation_unit_ = NULL;
+ dex_compilation_unit_ = NULL;
llvm_info_.reset(new LLVMInfo());
context_.reset(llvm_info_->GetLLVMContext());
module_ = llvm_info_->GetLLVMModule();
@@ -214,11 +213,11 @@
// If we don't need write the bitcode to file, add the AddSuspendCheckToLoopLatchPass to the
// regular FunctionPass.
fpm.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
- driver_, oat_compilation_unit_));
+ driver_, dex_compilation_unit_));
} else {
llvm::FunctionPassManager fpm2(module_);
fpm2.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
- driver_, oat_compilation_unit_));
+ driver_, dex_compilation_unit_));
fpm2.doInitialization();
for (llvm::Module::iterator F = module_->begin(), E = module_->end();
F != E; ++F) {
diff --git a/src/compiler_llvm/llvm_compilation_unit.h b/src/compiler_llvm/llvm_compilation_unit.h
index 801bbef..acdeb58 100644
--- a/src/compiler_llvm/llvm_compilation_unit.h
+++ b/src/compiler_llvm/llvm_compilation_unit.h
@@ -23,7 +23,7 @@
#include "compiler/driver/compiler_driver.h"
#include "globals.h"
#include "instruction_set.h"
-#include "oat_compilation_unit.h"
+#include "compiler/driver/dex_compilation_unit.h"
#include "runtime_support_builder.h"
#include "runtime_support_func.h"
#include "safe_map.h"
@@ -81,8 +81,8 @@
void SetCompiler(CompilerDriver* driver) {
driver_ = driver;
}
- void SetOatCompilationUnit(OatCompilationUnit* oat_compilation_unit) {
- oat_compilation_unit_ = oat_compilation_unit;
+ void SetDexCompilationUnit(DexCompilationUnit* dex_compilation_unit) {
+ dex_compilation_unit_ = dex_compilation_unit;
}
bool Materialize();
@@ -110,7 +110,7 @@
UniquePtr<IntrinsicHelper> intrinsic_helper_;
UniquePtr<LLVMInfo> llvm_info_;
CompilerDriver* driver_;
- OatCompilationUnit* oat_compilation_unit_;
+ DexCompilationUnit* dex_compilation_unit_;
std::string bitcode_filename_;