Revert^2 "Inline across dex files for bootclaspath's methods"

This reverts commit 8cb989f1019c4fa30845bf2deb5bc996ed4e8966, so we
are re-enabling commit d690f8ae8f8e2675bc52089a83ac18c749f8e6d2.

Reason for revert: Failing test was fixed here
https://android-review.googlesource.com/c/platform/art/+/1873567

Bug: 154012332
Test: ART tests
Change-Id: If159b29583e35abcfe753f30483f83990208b1b9
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index e52a3ce..964b48c 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -17,10 +17,14 @@
 #include "stack_map_stream.h"
 
 #include <memory>
+#include <vector>
 
 #include "art_method-inl.h"
 #include "base/stl_util.h"
+#include "class_linker.h"
+#include "dex/dex_file.h"
 #include "dex/dex_file_types.h"
+#include "optimizing/nodes.h"
 #include "optimizing/optimizing_compiler.h"
 #include "runtime.h"
 #include "scoped_thread_state_change-inl.h"
@@ -211,12 +215,26 @@
     entry[InlineInfo::kArtMethodHi] = High32Bits(reinterpret_cast<uintptr_t>(method));
     entry[InlineInfo::kArtMethodLo] = Low32Bits(reinterpret_cast<uintptr_t>(method));
   } else {
-    if (dex_pc != static_cast<uint32_t>(-1) && kIsDebugBuild) {
+    uint32_t bootclasspath_index = MethodInfo::kSameDexFile;
+    if (dex_pc != static_cast<uint32_t>(-1)) {
       ScopedObjectAccess soa(Thread::Current());
-      DCHECK(IsSameDexFile(*outer_dex_file, *method->GetDexFile()));
+      const DexFile* dex_file = method->GetDexFile();
+      if (method->GetDeclaringClass()->GetClassLoader() == nullptr) {
+        ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+        const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath();
+        auto it = std::find_if(
+            boot_class_path.begin(), boot_class_path.end(), [dex_file](const DexFile* df) {
+              return IsSameDexFile(*df, *dex_file);
+            });
+        DCHECK(it != boot_class_path.end());
+        bootclasspath_index = std::distance(boot_class_path.begin(), it);
+      } else {
+        DCHECK(IsSameDexFile(*outer_dex_file, *dex_file));
+      }
     }
     uint32_t dex_method_index = method->GetDexMethodIndex();
-    entry[InlineInfo::kMethodInfoIndex] = method_infos_.Dedup({dex_method_index});
+    entry[InlineInfo::kMethodInfoIndex] =
+        method_infos_.Dedup({dex_method_index, bootclasspath_index});
   }
   current_inline_infos_.push_back(entry);
 
@@ -232,7 +250,18 @@
       if (encode_art_method) {
         CHECK_EQ(inline_info.GetArtMethod(), method);
       } else {
-        CHECK_EQ(code_info.GetMethodIndexOf(inline_info), method->GetDexMethodIndex());
+        MethodInfo method_info = code_info.GetMethodInfoOf(inline_info);
+        CHECK_EQ(method_info.GetMethodIndex(), method->GetDexMethodIndex());
+        if (inline_info.GetDexPc() != static_cast<uint32_t>(-1)) {
+          ScopedObjectAccess soa(Thread::Current());
+          if (method->GetDeclaringClass()->GetClassLoader() == nullptr) {
+            ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+            const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath();
+            DCHECK_LT(method_info.GetDexFileIndex(), boot_class_path.size());
+            CHECK(IsSameDexFile(*boot_class_path[method_info.GetDexFileIndex()],
+                                *method->GetDexFile()));
+          }
+        }
       }
     });
   }