Inline across dex files for compiler options' non-BCP methods

We are now able to inline across dexfiles for the dexfiles present
in compiler options' dex_files_for_oat_file_.

Note that the dex files in the Class Loader Context are not included
in this implementation since they will not have an OatDexFile.

Bug: 154012332
Test: ART tests

Change-Id: I7704217d936afecb66fc952c10529bb1030d6981
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 17957d8..e996512 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1703,24 +1703,35 @@
 
 static bool CanEncodeInlinedMethodInStackMap(const DexFile& outer_dex_file,
                                              ArtMethod* callee,
+                                             const CodeGenerator* codegen,
                                              bool* out_needs_bss_check)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   if (!Runtime::Current()->IsAotCompiler()) {
     // JIT can always encode methods in stack maps.
     return true;
   }
-  if (IsSameDexFile(outer_dex_file, *callee->GetDexFile())) {
+  const DexFile* dex_file = callee->GetDexFile();
+  if (IsSameDexFile(outer_dex_file, *dex_file)) {
     return true;
   }
 
-  // Inline across dexfiles if the callee's DexFile is in the bootclasspath.
+  // Inline across dexfiles if the callee's DexFile is:
+  // 1) in the bootclasspath, or
   if (callee->GetDeclaringClass()->GetClassLoader() == nullptr) {
     *out_needs_bss_check = true;
     return true;
   }
 
-  // TODO(ngeoffray): Support more AOT cases for inlining:
-  // - methods in multidex
+  // 2) is a non-BCP dexfile with an OatDexFile.
+  const std::vector<const DexFile*>& dex_files =
+      codegen->GetCompilerOptions().GetDexFilesForOatFile();
+  if (std::find(dex_files.begin(), dex_files.end(), dex_file) != dex_files.end()) {
+    *out_needs_bss_check = true;
+    return true;
+  }
+
+  // TODO(solanes): Support more AOT cases for inlining:
+  // - methods in class loader context's DexFiles
   return false;
 }
 
@@ -1834,7 +1845,7 @@
       total_number_of_dex_registers_ > kMaximumNumberOfCumulatedDexRegisters;
   bool needs_bss_check = false;
   const bool can_encode_in_stack_map = CanEncodeInlinedMethodInStackMap(
-      *outer_compilation_unit_.GetDexFile(), resolved_method, &needs_bss_check);
+      *outer_compilation_unit_.GetDexFile(), resolved_method, codegen_, &needs_bss_check);
   size_t number_of_instructions = 0;
   // Skip the entry block, it does not contain instructions that prevent inlining.
   for (HBasicBlock* block : callee_graph->GetReversePostOrderSkipEntryBlock()) {