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/compiler/driver/dex_compilation_unit.h b/src/compiler/driver/dex_compilation_unit.h
new file mode 100644
index 0000000..6a0218d
--- /dev/null
+++ b/src/compiler/driver/dex_compilation_unit.h
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#ifndef ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_
+#define ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_
+
+#include "dex_file.h"
+
+#include <stdint.h>
+
+namespace art {
+namespace mirror {
+class ClassLoader;
+class DexCache;
+}  // namespace mirror
+class ClassLinker;
+class DexFile;
+
+class DexCompilationUnit {
+ public:
+  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), dex_method_idx_(method_idx),
+        access_flags_(access_flags) {
+  }
+
+  jobject GetClassLoader() const {
+    return class_loader_;
+  }
+
+  ClassLinker* GetClassLinker() const {
+    return class_linker_;
+  }
+
+  const DexFile* GetDexFile() const {
+    return dex_file_;
+  }
+
+  uint32_t GetClassDefIndex() const {
+    return class_def_idx_;
+  }
+
+  uint32_t GetDexMethodIndex() const {
+    return dex_method_idx_;
+  }
+
+  const DexFile::CodeItem* GetCodeItem() const {
+    return code_item_;
+  }
+
+  const char* GetShorty() const {
+    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(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);
+  }
+
+  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 dex_method_idx_;
+  const uint32_t access_flags_;
+};
+
+} // namespace art
+
+#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_