Remove unused InvokeInfo from stack maps and the runtime.

Test: test-art-host-gtest
Change-Id: I5ce28973042f9241e72ceb52fc5db472ca571563
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index 074f249..0ebf4be 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -70,9 +70,6 @@
 
 namespace art {
 
-// If true, we record the static and direct invokes in the invoke infos.
-static constexpr bool kEnableDexLayoutOptimizations = false;
-
 // Return whether a location is consistent with a type.
 static bool CheckType(DataType::Type type, Location location) {
   if (location.IsFpuRegister()
@@ -1136,15 +1133,6 @@
                                        locations->GetStackMask(),
                                        kind);
   EmitEnvironment(environment, slow_path);
-  // Record invoke info, the common case for the trampoline is super and static invokes. Only
-  // record these to reduce oat file size.
-  if (kEnableDexLayoutOptimizations) {
-    if (instruction->IsInvokeStaticOrDirect()) {
-      HInvoke* const invoke = instruction->AsInvokeStaticOrDirect();
-      DCHECK(environment != nullptr);
-      stack_map_stream->AddInvoke(invoke->GetInvokeType(), invoke->GetDexMethodIndex());
-    }
-  }
   stack_map_stream->EndStackMapEntry();
 
   if (osr) {
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index 3e1a36d..a65fbcc 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -156,26 +156,6 @@
   }
 }
 
-void StackMapStream::AddInvoke(InvokeType invoke_type, uint32_t dex_method_index) {
-  uint32_t packed_native_pc = current_stack_map_[StackMap::kPackedNativePc];
-  size_t invoke_info_index = invoke_infos_.size();
-  BitTableBuilder<InvokeInfo>::Entry entry;
-  entry[InvokeInfo::kPackedNativePc] = packed_native_pc;
-  entry[InvokeInfo::kInvokeType] = invoke_type;
-  entry[InvokeInfo::kMethodInfoIndex] = method_infos_.Dedup({dex_method_index});
-  invoke_infos_.Add(entry);
-
-  if (kVerifyStackMaps) {
-    dchecks_.emplace_back([=](const CodeInfo& code_info) {
-      InvokeInfo invoke_info = code_info.GetInvokeInfo(invoke_info_index);
-      CHECK_EQ(invoke_info.GetNativePcOffset(instruction_set_),
-               StackMap::UnpackNativePc(packed_native_pc, instruction_set_));
-      CHECK_EQ(invoke_info.GetInvokeType(), invoke_type);
-      CHECK_EQ(method_infos_[invoke_info.GetMethodInfoIndex()][0], dex_method_index);
-    });
-  }
-}
-
 void StackMapStream::BeginInlineInfoEntry(ArtMethod* method,
                                           uint32_t dex_pc,
                                           uint32_t num_dex_registers,
@@ -333,7 +313,6 @@
   stack_maps_.Encode(out);
   register_masks_.Encode(out);
   stack_masks_.Encode(out);
-  invoke_infos_.Encode(out);
   inline_infos_.Encode(out);
   dex_register_masks_.Encode(out);
   dex_register_maps_.Encode(out);
diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h
index ed865b1..203c2cd 100644
--- a/compiler/optimizing/stack_map_stream.h
+++ b/compiler/optimizing/stack_map_stream.h
@@ -42,7 +42,6 @@
         stack_maps_(allocator),
         register_masks_(allocator),
         stack_masks_(allocator),
-        invoke_infos_(allocator),
         inline_infos_(allocator),
         dex_register_masks_(allocator),
         dex_register_maps_(allocator),
@@ -76,8 +75,6 @@
     current_dex_registers_.push_back(DexRegisterLocation(kind, value));
   }
 
-  void AddInvoke(InvokeType type, uint32_t dex_method_index);
-
   void BeginInlineInfoEntry(ArtMethod* method,
                             uint32_t dex_pc,
                             uint32_t num_dex_registers,
@@ -112,7 +109,6 @@
   BitTableBuilder<StackMap> stack_maps_;
   BitTableBuilder<RegisterMask> register_masks_;
   BitmapTableBuilder stack_masks_;
-  BitTableBuilder<InvokeInfo> invoke_infos_;
   BitTableBuilder<InlineInfo> inline_infos_;
   BitmapTableBuilder dex_register_masks_;
   BitTableBuilder<MaskInfo> dex_register_maps_;
diff --git a/compiler/optimizing/stack_map_test.cc b/compiler/optimizing/stack_map_test.cc
index 9ed90a4..42f9789 100644
--- a/compiler/optimizing/stack_map_test.cc
+++ b/compiler/optimizing/stack_map_test.cc
@@ -758,56 +758,4 @@
             stack_map2.GetStackMaskIndex());
 }
 
-TEST(StackMapTest, TestInvokeInfo) {
-  MallocArenaPool pool;
-  ArenaStack arena_stack(&pool);
-  ScopedArenaAllocator allocator(&arena_stack);
-  StackMapStream stream(&allocator, kRuntimeISA);
-  stream.BeginMethod(32, 0, 0, 0);
-
-  ArenaBitVector sp_mask(&allocator, 0, true);
-  sp_mask.SetBit(1);
-  stream.BeginStackMapEntry(0, 4 * kPcAlign, 0x3, &sp_mask);
-  stream.AddInvoke(kSuper, 1);
-  stream.EndStackMapEntry();
-  stream.BeginStackMapEntry(0, 8 * kPcAlign, 0x3, &sp_mask);
-  stream.AddInvoke(kStatic, 3);
-  stream.EndStackMapEntry();
-  stream.BeginStackMapEntry(0, 16 * kPcAlign, 0x3, &sp_mask);
-  stream.AddInvoke(kDirect, 65535);
-  stream.EndStackMapEntry();
-
-  stream.EndMethod();
-  const size_t code_info_size = stream.PrepareForFillIn();
-  MemoryRegion code_info_region(allocator.Alloc(code_info_size, kArenaAllocMisc), code_info_size);
-  stream.FillInCodeInfo(code_info_region);
-
-  const size_t method_info_size = stream.ComputeMethodInfoSize();
-  MemoryRegion method_info_region(allocator.Alloc(method_info_size, kArenaAllocMisc),
-                                  method_info_size);
-  stream.FillInMethodInfo(method_info_region);
-
-  CodeInfo code_info(code_info_region);
-  MethodInfo method_info(method_info_region.begin());
-  ASSERT_EQ(3u, code_info.GetNumberOfStackMaps());
-
-  InvokeInfo invoke1(code_info.GetInvokeInfoForNativePcOffset(4 * kPcAlign));
-  InvokeInfo invoke2(code_info.GetInvokeInfoForNativePcOffset(8 * kPcAlign));
-  InvokeInfo invoke3(code_info.GetInvokeInfoForNativePcOffset(16 * kPcAlign));
-  InvokeInfo invoke_invalid(code_info.GetInvokeInfoForNativePcOffset(12));
-  EXPECT_FALSE(invoke_invalid.IsValid());  // No entry for that index.
-  EXPECT_TRUE(invoke1.IsValid());
-  EXPECT_TRUE(invoke2.IsValid());
-  EXPECT_TRUE(invoke3.IsValid());
-  EXPECT_EQ(invoke1.GetInvokeType(), kSuper);
-  EXPECT_EQ(invoke1.GetMethodIndex(method_info), 1u);
-  EXPECT_EQ(invoke1.GetNativePcOffset(kRuntimeISA), 4u * kPcAlign);
-  EXPECT_EQ(invoke2.GetInvokeType(), kStatic);
-  EXPECT_EQ(invoke2.GetMethodIndex(method_info), 3u);
-  EXPECT_EQ(invoke2.GetNativePcOffset(kRuntimeISA), 8u * kPcAlign);
-  EXPECT_EQ(invoke3.GetInvokeType(), kDirect);
-  EXPECT_EQ(invoke3.GetMethodIndex(method_info), 65535u);
-  EXPECT_EQ(invoke3.GetNativePcOffset(kRuntimeISA), 16u * kPcAlign);
-}
-
 }  // namespace art
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 379292d..505e183 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -357,30 +357,6 @@
     }
   }
 
-  static bool GetInvokeType(ArtMethod** sp, InvokeType* invoke_type, uint32_t* dex_method_index)
-      REQUIRES_SHARED(Locks::mutator_lock_) {
-    DCHECK((*sp)->IsCalleeSaveMethod());
-    constexpr size_t callee_frame_size =
-        RuntimeCalleeSaveFrame::GetFrameSize(CalleeSaveType::kSaveRefsAndArgs);
-    ArtMethod** caller_sp = reinterpret_cast<ArtMethod**>(
-        reinterpret_cast<uintptr_t>(sp) + callee_frame_size);
-    uintptr_t outer_pc = QuickArgumentVisitor::GetCallingPc(sp);
-    const OatQuickMethodHeader* current_code = (*caller_sp)->GetOatQuickMethodHeader(outer_pc);
-    if (!current_code->IsOptimized()) {
-      return false;
-    }
-    uintptr_t outer_pc_offset = current_code->NativeQuickPcOffset(outer_pc);
-    CodeInfo code_info(current_code);
-    MethodInfo method_info = current_code->GetOptimizedMethodInfo();
-    InvokeInfo invoke(code_info.GetInvokeInfoForNativePcOffset(outer_pc_offset));
-    if (invoke.IsValid()) {
-      *invoke_type = static_cast<InvokeType>(invoke.GetInvokeType());
-      *dex_method_index = invoke.GetMethodIndex(method_info);
-      return true;
-    }
-    return false;
-  }
-
   // For the given quick ref and args quick frame, return the caller's PC.
   static uintptr_t GetCallingPc(ArtMethod** sp) REQUIRES_SHARED(Locks::mutator_lock_) {
     DCHECK((*sp)->IsCalleeSaveMethod());
@@ -1333,14 +1309,7 @@
     caller = QuickArgumentVisitor::GetCallingMethod(sp);
     called_method.dex_file = caller->GetDexFile();
 
-    InvokeType stack_map_invoke_type;
-    uint32_t stack_map_dex_method_idx;
-    const bool found_stack_map = QuickArgumentVisitor::GetInvokeType(sp,
-                                                                     &stack_map_invoke_type,
-                                                                     &stack_map_dex_method_idx);
-    // For debug builds, we make sure both of the paths are consistent by also looking at the dex
-    // code.
-    if (!found_stack_map || kIsDebugBuild) {
+    {
       uint32_t dex_pc = QuickArgumentVisitor::GetCallingDexPc(sp);
       CodeItemInstructionAccessor accessor(caller->DexInstructions());
       CHECK_LT(dex_pc, accessor.InsnsSizeInCodeUnits());
@@ -1394,23 +1363,8 @@
           UNREACHABLE();
       }
       called_method.index = (is_range) ? instr.VRegB_3rc() : instr.VRegB_35c();
-      // Check that the invoke matches what we expected, note that this path only happens for debug
-      // builds.
-      if (found_stack_map) {
-        DCHECK_EQ(stack_map_invoke_type, invoke_type);
-        if (invoke_type != kSuper) {
-          // Super may be sharpened.
-          DCHECK_EQ(stack_map_dex_method_idx, called_method.index)
-              << called_method.dex_file->PrettyMethod(stack_map_dex_method_idx) << " "
-              << called_method.PrettyMethod();
-        }
-      } else {
-        VLOG(dex) << "Accessed dex file for invoke " << invoke_type << " "
-                  << called_method.index;
-      }
-    } else {
-      invoke_type = stack_map_invoke_type;
-      called_method.index = stack_map_dex_method_idx;
+      VLOG(dex) << "Accessed dex file for invoke " << invoke_type << " "
+                << called_method.index;
     }
   } else {
     invoke_type = kStatic;
diff --git a/runtime/oat.h b/runtime/oat.h
index ef2a5d7..f8ec665 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,8 +32,8 @@
 class PACKED(4) OatHeader {
  public:
   static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
-  // Last oat version changed reason: Added AllocStringObject Quick Entrypoint.
-  static constexpr uint8_t kOatVersion[] = { '1', '5', '3', '\0' };
+  // Last oat version changed reason: Remove InvokeInfo from stack maps.
+  static constexpr uint8_t kOatVersion[] = { '1', '5', '4', '\0' };
 
   static constexpr const char* kImageLocationKey = "image-location";
   static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc
index 7e46eb7..9fa9d84 100644
--- a/runtime/stack_map.cc
+++ b/runtime/stack_map.cc
@@ -41,7 +41,6 @@
   stack_maps_.Decode(reader);
   register_masks_.Decode(reader);
   stack_masks_.Decode(reader);
-  invoke_infos_.Decode(reader);
   inline_infos_.Decode(reader);
   dex_register_masks_.Decode(reader);
   dex_register_maps_.Decode(reader);
@@ -155,7 +154,6 @@
   AddTableSizeStats<StackMap>("StackMaps", stack_maps_, stats);
   AddTableSizeStats<RegisterMask>("RegisterMasks", register_masks_, stats);
   AddTableSizeStats<MaskInfo>("StackMasks", stack_masks_, stats);
-  AddTableSizeStats<InvokeInfo>("InvokeInfos", invoke_infos_, stats);
   AddTableSizeStats<InlineInfo>("InlineInfos", inline_infos_, stats);
   AddTableSizeStats<MaskInfo>("DexRegisterMasks", dex_register_masks_, stats);
   AddTableSizeStats<DexRegisterMapInfo>("DexRegisterMaps", dex_register_maps_, stats);
@@ -224,7 +222,6 @@
   DumpTable<StackMap>(vios, "StackMaps", stack_maps_, verbose);
   DumpTable<RegisterMask>(vios, "RegisterMasks", register_masks_, verbose);
   DumpTable<MaskInfo>(vios, "StackMasks", stack_masks_, verbose, true /* is_mask */);
-  DumpTable<InvokeInfo>(vios, "InvokeInfos", invoke_infos_, verbose);
   DumpTable<InlineInfo>(vios, "InlineInfos", inline_infos_, verbose);
   DumpTable<MaskInfo>(vios, "DexRegisterMasks", dex_register_masks_, verbose, true /* is_mask */);
   DumpTable<DexRegisterMapInfo>(vios, "DexRegisterMaps", dex_register_maps_, verbose);
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 2f2053a..26b95b0 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -208,22 +208,6 @@
             const MethodInfo& method_info) const;
 };
 
-class InvokeInfo : public BitTableAccessor<3> {
- public:
-  BIT_TABLE_HEADER()
-  BIT_TABLE_COLUMN(0, PackedNativePc)
-  BIT_TABLE_COLUMN(1, InvokeType)
-  BIT_TABLE_COLUMN(2, MethodInfoIndex)
-
-  ALWAYS_INLINE uint32_t GetNativePcOffset(InstructionSet instruction_set) const {
-    return StackMap::UnpackNativePc(GetPackedNativePc(), instruction_set);
-  }
-
-  uint32_t GetMethodIndex(MethodInfo method_info) const {
-    return method_info.GetMethodIndex(GetMethodInfoIndex());
-  }
-};
-
 class MaskInfo : public BitTableAccessor<1> {
  public:
   BIT_TABLE_HEADER()
@@ -338,10 +322,6 @@
     return stack_maps_.NumRows();
   }
 
-  InvokeInfo GetInvokeInfo(size_t index) const {
-    return invoke_infos_.GetRow(index);
-  }
-
   ALWAYS_INLINE DexRegisterMap GetDexRegisterMapOf(StackMap stack_map) const {
     if (stack_map.HasDexRegisterMap()) {
       DexRegisterMap map(number_of_dex_registers_, DexRegisterLocation::Invalid());
@@ -413,15 +393,6 @@
 
   StackMap GetStackMapForNativePcOffset(uint32_t pc, InstructionSet isa = kRuntimeISA) const;
 
-  InvokeInfo GetInvokeInfoForNativePcOffset(uint32_t native_pc_offset) {
-    for (InvokeInfo item : invoke_infos_) {
-      if (item.GetNativePcOffset(kRuntimeISA) == native_pc_offset) {
-        return item;
-      }
-    }
-    return invoke_infos_.GetInvalidRow();
-  }
-
   // Dump this CodeInfo object on `vios`.
   // `code_offset` is the (absolute) native PC of the compiled method.
   void Dump(VariableIndentationOutputStream* vios,
@@ -459,7 +430,6 @@
   BitTable<StackMap> stack_maps_;
   BitTable<RegisterMask> register_masks_;
   BitTable<MaskInfo> stack_masks_;
-  BitTable<InvokeInfo> invoke_infos_;
   BitTable<InlineInfo> inline_infos_;
   BitTable<MaskInfo> dex_register_masks_;
   BitTable<DexRegisterMapInfo> dex_register_maps_;