ART: Add dex::ProtoIndex

Test: m -j32 test-art-host
Change-Id: Ic2d2a7a43be1b8590b97cdf3729200b043ffc6a3
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index f573337..fb556f4 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -771,7 +771,7 @@
 
 void CodeGenerator::GenerateLoadMethodTypeRuntimeCall(HLoadMethodType* method_type) {
   LocationSummary* locations = method_type->GetLocations();
-  MoveConstant(locations->GetTemp(0), method_type->GetProtoIndex());
+  MoveConstant(locations->GetTemp(0), method_type->GetProtoIndex().index_);
   CheckEntrypointTypes<kQuickResolveMethodType, void*, uint32_t>();
   InvokeRuntime(kQuickResolveMethodType, method_type, method_type->GetDexPc());
 }
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 35a3945..0e20a65 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1055,7 +1055,7 @@
 bool HInstructionBuilder::BuildInvokePolymorphic(const Instruction& instruction ATTRIBUTE_UNUSED,
                                                  uint32_t dex_pc,
                                                  uint32_t method_idx,
-                                                 uint32_t proto_idx,
+                                                 dex::ProtoIndex proto_idx,
                                                  uint32_t number_of_vreg_arguments,
                                                  bool is_range,
                                                  uint32_t* args,
@@ -1896,17 +1896,17 @@
   }
 }
 
-void HInstructionBuilder::BuildLoadMethodHandle(uint16_t proto_idx, uint32_t dex_pc) {
+void HInstructionBuilder::BuildLoadMethodHandle(uint16_t method_handle_index, uint32_t dex_pc) {
   const DexFile& dex_file = *dex_compilation_unit_->GetDexFile();
-  HLoadMethodHandle* load_method_handle =
-      new (allocator_) HLoadMethodHandle(graph_->GetCurrentMethod(), proto_idx, dex_file, dex_pc);
+  HLoadMethodHandle* load_method_handle = new (allocator_) HLoadMethodHandle(
+      graph_->GetCurrentMethod(), method_handle_index, dex_file, dex_pc);
   AppendInstruction(load_method_handle);
 }
 
-void HInstructionBuilder::BuildLoadMethodType(uint16_t proto_idx, uint32_t dex_pc) {
+void HInstructionBuilder::BuildLoadMethodType(dex::ProtoIndex proto_index, uint32_t dex_pc) {
   const DexFile& dex_file = *dex_compilation_unit_->GetDexFile();
   HLoadMethodType* load_method_type =
-      new (allocator_) HLoadMethodType(graph_->GetCurrentMethod(), proto_idx, dex_file, dex_pc);
+      new (allocator_) HLoadMethodType(graph_->GetCurrentMethod(), proto_index, dex_file, dex_pc);
   AppendInstruction(load_method_type);
 }
 
@@ -2189,7 +2189,7 @@
 
     case Instruction::INVOKE_POLYMORPHIC: {
       uint16_t method_idx = instruction.VRegB_45cc();
-      uint16_t proto_idx = instruction.VRegH_45cc();
+      dex::ProtoIndex proto_idx(instruction.VRegH_45cc());
       uint32_t number_of_vreg_arguments = instruction.VRegA_45cc();
       uint32_t args[5];
       instruction.GetVarArgs(args);
@@ -2205,7 +2205,7 @@
 
     case Instruction::INVOKE_POLYMORPHIC_RANGE: {
       uint16_t method_idx = instruction.VRegB_4rcc();
-      uint16_t proto_idx = instruction.VRegH_4rcc();
+      dex::ProtoIndex proto_idx(instruction.VRegH_4rcc());
       uint32_t number_of_vreg_arguments = instruction.VRegA_4rcc();
       uint32_t register_index = instruction.VRegC_4rcc();
       return BuildInvokePolymorphic(instruction,
@@ -2949,7 +2949,7 @@
     }
 
     case Instruction::CONST_METHOD_TYPE: {
-      uint16_t proto_idx = instruction.VRegB_21c();
+      dex::ProtoIndex proto_idx(instruction.VRegB_21c());
       BuildLoadMethodType(proto_idx, dex_pc);
       UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
       break;
diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h
index 95ffa6b..9d886a8 100644
--- a/compiler/optimizing/instruction_builder.h
+++ b/compiler/optimizing/instruction_builder.h
@@ -178,7 +178,7 @@
   bool BuildInvokePolymorphic(const Instruction& instruction,
                               uint32_t dex_pc,
                               uint32_t method_idx,
-                              uint32_t proto_idx,
+                              dex::ProtoIndex proto_idx,
                               uint32_t number_of_vreg_arguments,
                               bool is_range,
                               uint32_t* args,
@@ -240,11 +240,11 @@
   bool LoadClassNeedsAccessCheck(Handle<mirror::Class> klass)
       REQUIRES_SHARED(Locks::mutator_lock_);
 
-  // Builds a `HLoadMethodHandle` loading the given `method_handle_idx`.
+  // Builds a `HLoadMethodHandle` loading the given `method_handle_index`.
   void BuildLoadMethodHandle(uint16_t method_handle_idx, uint32_t dex_pc);
 
-  // Builds a `HLoadMethodType` loading the given `proto_idx`.
-  void BuildLoadMethodType(uint16_t proto_idx, uint32_t dex_pc);
+  // Builds a `HLoadMethodType` loading the given `proto_index`.
+  void BuildLoadMethodType(dex::ProtoIndex proto_index, uint32_t dex_pc);
 
   // Returns the outer-most compiling method's class.
   ObjPtr<mirror::Class> GetOutermostCompilingClass() const;
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index a7c2d0b..e786502 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -6548,7 +6548,7 @@
 class HLoadMethodType FINAL : public HInstruction {
  public:
   HLoadMethodType(HCurrentMethod* current_method,
-                  uint16_t proto_idx,
+                  dex::ProtoIndex proto_index,
                   const DexFile& dex_file,
                   uint32_t dex_pc)
       : HInstruction(kLoadMethodType,
@@ -6556,7 +6556,7 @@
                      SideEffectsForArchRuntimeCalls(),
                      dex_pc),
         special_input_(HUserRecord<HInstruction*>(current_method)),
-        proto_idx_(proto_idx),
+        proto_index_(proto_index),
         dex_file_(dex_file) {
   }
 
@@ -6568,7 +6568,7 @@
 
   bool IsClonable() const OVERRIDE { return true; }
 
-  uint16_t GetProtoIndex() const { return proto_idx_; }
+  dex::ProtoIndex GetProtoIndex() const { return proto_index_; }
 
   const DexFile& GetDexFile() const { return dex_file_; }
 
@@ -6585,7 +6585,7 @@
   // The special input is the HCurrentMethod for kRuntimeCall.
   HUserRecord<HInstruction*> special_input_;
 
-  const uint16_t proto_idx_;
+  const dex::ProtoIndex proto_index_;
   const DexFile& dex_file_;
 };