Use class def index from java.lang.Class.

Bug: 10244719
Depends on:
https://googleplex-android-review.git.corp.google.com/362363
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h
index 26d0923..6607562 100644
--- a/compiler/dex/compiler_ir.h
+++ b/compiler/dex/compiler_ir.h
@@ -77,7 +77,7 @@
   ClassLinker* class_linker;           // Linker to resolve fields and methods.
   const DexFile* dex_file;             // DexFile containing the method being compiled.
   jobject class_loader;                // compiling method's class loader.
-  uint32_t class_def_idx;              // compiling method's defining class definition index.
+  uint16_t class_def_idx;              // compiling method's defining class definition index.
   uint32_t method_idx;                 // compiling method's index into method_ids of DexFile.
   const DexFile::CodeItem* code_item;  // compiling method's DexFile code_item.
   uint32_t access_flags;               // compiling method's access flags.
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index ffd7905..abafbc5 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -280,7 +280,7 @@
 
 extern "C" void 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,
+                  uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
                   const art::DexFile& dex_file,
                   art::DexToDexCompilationLevel dex_to_dex_compilation_level) {
   if (dex_to_dex_compilation_level != art::kDontDexToDexCompile) {
diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc
index 2303649..fefcab9 100644
--- a/compiler/dex/frontend.cc
+++ b/compiler/dex/frontend.cc
@@ -110,7 +110,7 @@
                                      const CompilerBackend compiler_backend,
                                      const DexFile::CodeItem* code_item,
                                      uint32_t access_flags, InvokeType invoke_type,
-                                     uint32_t class_def_idx, uint32_t method_idx,
+                                     uint16_t class_def_idx, uint32_t method_idx,
                                      jobject class_loader, const DexFile& dex_file
 #if defined(ART_USE_PORTABLE_COMPILER)
                                      , llvm::LlvmCompilationUnit* llvm_compilation_unit
@@ -273,7 +273,7 @@
                                  const DexFile::CodeItem* code_item,
                                  uint32_t access_flags,
                                  InvokeType invoke_type,
-                                 uint32_t class_def_idx,
+                                 uint16_t class_def_idx,
                                  uint32_t method_idx,
                                  jobject class_loader,
                                  const DexFile& dex_file,
@@ -292,7 +292,7 @@
     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,
+                          uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
                           const art::DexFile& dex_file) {
   // TODO: check method fingerprint here to determine appropriate backend type.  Until then, use build default
   art::CompilerBackend backend = compiler.GetCompilerBackend();
diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h
index bafa468..6c33d10 100644
--- a/compiler/dex/frontend.h
+++ b/compiler/dex/frontend.h
@@ -117,7 +117,7 @@
                                                  const art::DexFile::CodeItem* code_item,
                                                  uint32_t access_flags,
                                                  art::InvokeType invoke_type,
-                                                 uint32_t class_dex_idx,
+                                                 uint16_t class_def_idx,
                                                  uint32_t method_idx,
                                                  jobject class_loader,
                                                  const art::DexFile& dex_file);
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index c72283e..c234298 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -504,7 +504,7 @@
 
 /* Parse a Dex method and insert it into the MIRGraph at the current insert point. */
 void MIRGraph::InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
-                           InvokeType invoke_type, uint32_t class_def_idx,
+                           InvokeType invoke_type, uint16_t class_def_idx,
                            uint32_t method_idx, jobject class_loader, const DexFile& dex_file) {
   current_code_item_ = code_item;
   method_stack_.push_back(std::make_pair(current_method_, current_offset_));
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index 0244dae..9d4ab98 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -357,7 +357,7 @@
    * actually the index of the method in the m_units_ array).
    */
   void InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
-                    InvokeType invoke_type, uint32_t class_def_idx,
+                    InvokeType invoke_type, uint16_t class_def_idx,
                     uint32_t method_idx, jobject class_loader, const DexFile& dex_file);
 
   /* Find existing block */
diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc
index f13ab2d..4ce752f 100644
--- a/compiler/dex/quick/codegen_util.cc
+++ b/compiler/dex/quick/codegen_util.cc
@@ -385,11 +385,12 @@
   while (data_lir != NULL) {
     uint32_t target = data_lir->operands[0];
     cu_->compiler_driver->AddCodePatch(cu_->dex_file,
-                                      cu_->method_idx,
-                                      cu_->invoke_type,
-                                      target,
-                                      static_cast<InvokeType>(data_lir->operands[1]),
-                                      code_buffer_.size());
+                                       cu_->class_def_idx,
+                                       cu_->method_idx,
+                                       cu_->invoke_type,
+                                       target,
+                                       static_cast<InvokeType>(data_lir->operands[1]),
+                                       code_buffer_.size());
     const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target);
     // unique based on target to ensure code deduplication works
     uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);
@@ -400,11 +401,12 @@
   while (data_lir != NULL) {
     uint32_t target = data_lir->operands[0];
     cu_->compiler_driver->AddMethodPatch(cu_->dex_file,
-                                        cu_->method_idx,
-                                        cu_->invoke_type,
-                                        target,
-                                        static_cast<InvokeType>(data_lir->operands[1]),
-                                        code_buffer_.size());
+                                         cu_->class_def_idx,
+                                         cu_->method_idx,
+                                         cu_->invoke_type,
+                                         target,
+                                         static_cast<InvokeType>(data_lir->operands[1]),
+                                         code_buffer_.size());
     const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target);
     // unique based on target to ensure code deduplication works
     uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 8d521de..658370f 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -293,7 +293,7 @@
                                                  const art::DexFile::CodeItem* code_item,
                                                  uint32_t access_flags,
                                                  art::InvokeType invoke_type,
-                                                 uint32_t class_def_idx,
+                                                 uint16_t class_def_idx,
                                                  uint32_t method_idx,
                                                  jobject class_loader,
                                                  const art::DexFile& dex_file);
@@ -301,7 +301,7 @@
                                                       const art::DexFile::CodeItem* code_item,
                                                       uint32_t access_flags,
                                                       art::InvokeType invoke_type,
-                                                      uint32_t class_def_idx,
+                                                      uint16_t class_def_idx,
                                                       uint32_t method_idx,
                                                       jobject class_loader,
                                                       const art::DexFile& dex_file);
@@ -310,7 +310,7 @@
                                               const art::DexFile::CodeItem* code_item,
                                               uint32_t access_flags,
                                               art::InvokeType invoke_type,
-                                              uint32_t class_def_idx,
+                                              uint16_t class_def_idx,
                                               uint32_t method_idx,
                                               jobject class_loader,
                                               const art::DexFile& dex_file);
@@ -319,7 +319,7 @@
                                                    const art::DexFile::CodeItem* code_item,
                                                    uint32_t access_flags,
                                                    art::InvokeType invoke_type,
-                                                   uint32_t class_def_idx,
+                                                   uint16_t class_def_idx,
                                                    uint32_t method_idx,
                                                    jobject class_loader,
                                                    const art::DexFile& dex_file);
@@ -540,7 +540,7 @@
   Thread* self = Thread::Current();
   jobject jclass_loader;
   const DexFile* dex_file;
-  uint32_t class_def_idx;
+  uint16_t class_def_idx;
   {
     ScopedObjectAccessUnchecked soa(self);
     ScopedLocalRef<jobject>
@@ -1304,13 +1304,15 @@
 
 
 void CompilerDriver::AddCodePatch(const DexFile* dex_file,
-                            uint32_t referrer_method_idx,
-                            InvokeType referrer_invoke_type,
-                            uint32_t target_method_idx,
-                            InvokeType target_invoke_type,
-                            size_t literal_offset) {
+                                  uint16_t referrer_class_def_idx,
+                                  uint32_t referrer_method_idx,
+                                  InvokeType referrer_invoke_type,
+                                  uint32_t target_method_idx,
+                                  InvokeType target_invoke_type,
+                                  size_t literal_offset) {
   MutexLock mu(Thread::Current(), compiled_methods_lock_);
   code_to_patch_.push_back(new PatchInformation(dex_file,
+                                                referrer_class_def_idx,
                                                 referrer_method_idx,
                                                 referrer_invoke_type,
                                                 target_method_idx,
@@ -1318,13 +1320,15 @@
                                                 literal_offset));
 }
 void CompilerDriver::AddMethodPatch(const DexFile* dex_file,
-                              uint32_t referrer_method_idx,
-                              InvokeType referrer_invoke_type,
-                              uint32_t target_method_idx,
-                              InvokeType target_invoke_type,
-                              size_t literal_offset) {
+                                    uint16_t referrer_class_def_idx,
+                                    uint32_t referrer_method_idx,
+                                    InvokeType referrer_invoke_type,
+                                    uint32_t target_method_idx,
+                                    InvokeType target_invoke_type,
+                                    size_t literal_offset) {
   MutexLock mu(Thread::Current(), compiled_methods_lock_);
   methods_to_patch_.push_back(new PatchInformation(dex_file,
+                                                   referrer_class_def_idx,
                                                    referrer_method_idx,
                                                    referrer_invoke_type,
                                                    target_method_idx,
@@ -1625,10 +1629,12 @@
      */
     mirror::DexCache* dex_cache =  manager->GetClassLinker()->FindDexCache(*manager->GetDexFile());
     std::string error_msg;
-    if (verifier::MethodVerifier::VerifyClass(manager->GetDexFile(),
+    const DexFile* dex_file = manager->GetDexFile();
+    const DexFile::ClassDef* class_def = &dex_file->GetClassDef(class_def_index);
+    if (verifier::MethodVerifier::VerifyClass(dex_file,
                                               dex_cache,
                                               soa.Decode<mirror::ClassLoader*>(manager->GetClassLoader()),
-                                              class_def_index, error_msg, true) ==
+                                              class_def, true, &error_msg) ==
                                                   verifier::MethodVerifier::kHardFailure) {
       const DexFile::ClassDef& class_def = manager->GetDexFile()->GetClassDef(class_def_index);
       LOG(ERROR) << "Verification failed on class "
@@ -2137,7 +2143,8 @@
       }
       // If successfully initialized place in SSB array.
       if (klass->IsInitialized()) {
-        klass->GetDexCache()->GetInitializedStaticStorage()->Set(klass->GetDexTypeIndex(), klass);
+        int32_t ssb_index = klass->GetDexTypeIndex();
+        klass->GetDexCache()->GetInitializedStaticStorage()->Set(ssb_index, klass);
       }
     }
     // Record the final class status if necessary.
@@ -2264,7 +2271,7 @@
 }
 
 void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
-                                   InvokeType invoke_type, uint32_t class_def_idx,
+                                   InvokeType invoke_type, uint16_t class_def_idx,
                                    uint32_t method_idx, jobject class_loader,
                                    const DexFile& dex_file,
                                    DexToDexCompilationLevel dex_to_dex_compilation_level) {
@@ -2387,13 +2394,13 @@
 
 
 void CompilerDriver::AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
-                                             size_t class_def_index) {
+                                                   uint16_t class_def_index) {
   WriterMutexLock mu(self, freezing_constructor_lock_);
   freezing_constructor_classes_.insert(ClassReference(dex_file, class_def_index));
 }
 
 bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
-                                          size_t class_def_index) {
+                                                uint16_t class_def_index) {
   ReaderMutexLock mu(self, freezing_constructor_lock_);
   return freezing_constructor_classes_.count(ClassReference(dex_file, class_def_index)) != 0;
 }
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index b4ec0c1..66c9cbf 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -145,8 +145,9 @@
   CompiledMethod* GetCompiledMethod(MethodReference ref) const
       LOCKS_EXCLUDED(compiled_methods_lock_);
 
-  void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index);
-  bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index);
+  void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
+                                     uint16_t class_def_index);
+  bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, uint16_t class_def_index);
 
   // Callbacks from compiler to see what runtime checks must be generated.
 
@@ -192,6 +193,7 @@
 
   // Record patch information for later fix up.
   void AddCodePatch(const DexFile* dex_file,
+                    uint16_t referrer_class_def_idx,
                     uint32_t referrer_method_idx,
                     InvokeType referrer_invoke_type,
                     uint32_t target_method_idx,
@@ -199,6 +201,7 @@
                     size_t literal_offset)
       LOCKS_EXCLUDED(compiled_methods_lock_);
   void AddMethodPatch(const DexFile* dex_file,
+                      uint16_t referrer_class_def_idx,
                       uint32_t referrer_method_idx,
                       InvokeType referrer_invoke_type,
                       uint32_t target_method_idx,
@@ -249,6 +252,9 @@
     const DexFile& GetDexFile() const {
       return *dex_file_;
     }
+    uint16_t GetReferrerClassDefIdx() const {
+      return referrer_class_def_idx_;
+    }
     uint32_t GetReferrerMethodIdx() const {
       return referrer_method_idx_;
     }
@@ -267,12 +273,14 @@
 
    private:
     PatchInformation(const DexFile* dex_file,
+                     uint16_t referrer_class_def_idx,
                      uint32_t referrer_method_idx,
                      InvokeType referrer_invoke_type,
                      uint32_t target_method_idx,
                      InvokeType target_invoke_type,
                      size_t literal_offset)
       : dex_file_(dex_file),
+        referrer_class_def_idx_(referrer_class_def_idx),
         referrer_method_idx_(referrer_method_idx),
         referrer_invoke_type_(referrer_invoke_type),
         target_method_idx_(target_method_idx),
@@ -281,12 +289,13 @@
       CHECK(dex_file_ != NULL);
     }
 
-    const DexFile* dex_file_;
-    uint32_t referrer_method_idx_;
-    InvokeType referrer_invoke_type_;
-    uint32_t target_method_idx_;
-    InvokeType target_invoke_type_;
-    size_t literal_offset_;
+    const DexFile* const dex_file_;
+    const uint16_t referrer_class_def_idx_;
+    const uint32_t referrer_method_idx_;
+    const InvokeType referrer_invoke_type_;
+    const uint32_t target_method_idx_;
+    const InvokeType target_invoke_type_;
+    const size_t literal_offset_;
 
     friend class CompilerDriver;
     DISALLOW_COPY_AND_ASSIGN(PatchInformation);
@@ -358,7 +367,7 @@
                       ThreadPool& thread_pool, base::TimingLogger& timings)
       LOCKS_EXCLUDED(Locks::mutator_lock_);
   void CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
-                     InvokeType invoke_type, uint32_t class_def_idx, uint32_t method_idx,
+                     InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx,
                      jobject class_loader, const DexFile& dex_file,
                      DexToDexCompilationLevel dex_to_dex_compilation_level)
       LOCKS_EXCLUDED(compiled_methods_lock_);
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index eb8941b..c441d09 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -39,7 +39,7 @@
                                        ClassLinker* class_linker,
                                        const DexFile& dex_file,
                                        const DexFile::CodeItem* code_item,
-                                       uint32_t class_def_idx,
+                                       uint16_t class_def_idx,
                                        uint32_t method_idx,
                                        uint32_t access_flags)
     : cu_(cu),
diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h
index 465139b..3df50ff 100644
--- a/compiler/driver/dex_compilation_unit.h
+++ b/compiler/driver/dex_compilation_unit.h
@@ -36,7 +36,7 @@
 
   DexCompilationUnit(CompilationUnit* cu, 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);
+                     uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags);
 
   CompilationUnit* GetCompilationUnit() const {
     return cu_;
@@ -54,7 +54,7 @@
     return dex_file_;
   }
 
-  uint32_t GetClassDefIndex() const {
+  uint16_t GetClassDefIndex() const {
     return class_def_idx_;
   }
 
@@ -108,7 +108,7 @@
   const DexFile* const dex_file_;
 
   const DexFile::CodeItem* const code_item_;
-  const uint32_t class_def_idx_;
+  const uint16_t class_def_idx_;
   const uint32_t dex_method_idx_;
   const uint32_t access_flags_;
 
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index d1859e6..f82c6fb 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -699,6 +699,7 @@
 void ImageWriter::SetPatchLocation(const CompilerDriver::PatchInformation* patch, uint32_t value) {
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   const void* oat_code = class_linker->GetOatCodeFor(patch->GetDexFile(),
+                                                     patch->GetReferrerClassDefIdx(),
                                                      patch->GetReferrerMethodIdx());
   OatHeader& oat_header = const_cast<OatHeader&>(oat_file_->GetOatHeader());
   // TODO: make this Thumb2 specific
diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc
index 0df3c47..d59afd4 100644
--- a/compiler/llvm/compiler_llvm.cc
+++ b/compiler/llvm/compiler_llvm.cc
@@ -40,7 +40,7 @@
                       const CompilerBackend compilerBackend,
                       const DexFile::CodeItem* code_item,
                       uint32_t access_flags, InvokeType invoke_type,
-                      uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
+                      uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
                       const DexFile& dex_file,
                       llvm::LlvmCompilationUnit* llvm_info);
 }
@@ -203,7 +203,7 @@
                                                  const art::DexFile::CodeItem* code_item,
                                                  uint32_t access_flags,
                                                  art::InvokeType invoke_type,
-                                                 uint32_t class_def_idx,
+                                                 uint16_t class_def_idx,
                                                  uint32_t method_idx,
                                                  jobject class_loader,
                                                  const art::DexFile& dex_file) {
diff --git a/compiler/sea_ir/frontend.cc b/compiler/sea_ir/frontend.cc
index 93f6f25..3512911 100644
--- a/compiler/sea_ir/frontend.cc
+++ b/compiler/sea_ir/frontend.cc
@@ -41,7 +41,7 @@
                                      const CompilerBackend compiler_backend,
                                      const DexFile::CodeItem* code_item,
                                      uint32_t method_access_flags, InvokeType invoke_type,
-                                     uint32_t class_def_idx, uint32_t method_idx,
+                                     uint16_t class_def_idx, uint32_t method_idx,
                                      jobject class_loader, const DexFile& dex_file
 #if defined(ART_USE_PORTABLE_COMPILER)
                                      , llvm::LlvmCompilationUnit* llvm_compilation_unit
@@ -69,7 +69,7 @@
                                  const DexFile::CodeItem* code_item,
                                  uint32_t method_access_flags,
                                  InvokeType invoke_type,
-                                 uint32_t class_def_idx,
+                                 uint16_t class_def_idx,
                                  uint32_t method_idx,
                                  jobject class_loader,
                                  const DexFile& dex_file,
@@ -86,7 +86,7 @@
     SeaIrCompileMethod(art::CompilerDriver& compiler,
                           const art::DexFile::CodeItem* code_item,
                           uint32_t method_access_flags, art::InvokeType invoke_type,
-                          uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
+                          uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
                           const art::DexFile& dex_file) {
   // TODO: Check method fingerprint here to determine appropriate backend type.
   //       Until then, use build default
diff --git a/compiler/sea_ir/ir/sea.cc b/compiler/sea_ir/ir/sea.cc
index 5ccaba6..0734b21 100644
--- a/compiler/sea_ir/ir/sea.cc
+++ b/compiler/sea_ir/ir/sea.cc
@@ -191,7 +191,7 @@
 }
 
 void SeaGraph::BuildMethodSeaGraph(const art::DexFile::CodeItem* code_item,
-    const art::DexFile& dex_file, uint32_t class_def_idx,
+    const art::DexFile& dex_file, uint16_t class_def_idx,
     uint32_t method_idx, uint32_t method_access_flags) {
   code_item_ = code_item;
   class_def_idx_ = class_def_idx;
@@ -409,7 +409,7 @@
 
 CodeGenData* SeaGraph::CompileMethod(
     const std::string& function_name,
-    const art::DexFile::CodeItem* code_item, uint32_t class_def_idx,
+    const art::DexFile::CodeItem* code_item, uint16_t class_def_idx,
     uint32_t method_idx, uint32_t method_access_flags, const art::DexFile& dex_file) {
   // Two passes: Builds the intermediate structure (non-SSA) of the sea-ir for the function.
   BuildMethodSeaGraph(code_item, dex_file, class_def_idx, method_idx, method_access_flags);
diff --git a/compiler/sea_ir/ir/sea.h b/compiler/sea_ir/ir/sea.h
index 92c2043..26b16be 100644
--- a/compiler/sea_ir/ir/sea.h
+++ b/compiler/sea_ir/ir/sea.h
@@ -262,7 +262,7 @@
   static SeaGraph* GetGraph(const art::DexFile&);
 
   CodeGenData* CompileMethod(const std::string& function_name,
-      const art::DexFile::CodeItem* code_item, uint32_t class_def_idx,
+      const art::DexFile::CodeItem* code_item, uint16_t class_def_idx,
       uint32_t method_idx, uint32_t method_access_flags, const art::DexFile& dex_file);
   // Returns all regions corresponding to this SeaGraph.
   std::vector<Region*>* GetRegions() {
@@ -288,7 +288,7 @@
   }
 
   TypeInference* ti_;
-  uint32_t class_def_idx_;
+  uint16_t class_def_idx_;
   uint32_t method_idx_;
   uint32_t method_access_flags_;
 
@@ -311,7 +311,7 @@
   // Builds the non-SSA sea-ir representation of the function @code_item from @dex_file
   // with class id @class_def_idx and method id @method_idx.
   void BuildMethodSeaGraph(const art::DexFile::CodeItem* code_item,
-      const art::DexFile& dex_file, uint32_t class_def_idx,
+      const art::DexFile& dex_file, uint16_t class_def_idx,
       uint32_t method_idx, uint32_t method_access_flags);
   // Computes immediate dominators for each region.
   // Precondition: ComputeMethodSeaGraph()