OSDN Git Service

Only do some checks when compiling against the core image.
authorNicolas Geoffray <ngeoffray@google.com>
Thu, 25 Jun 2015 09:01:47 +0000 (10:01 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Thu, 25 Jun 2015 09:21:35 +0000 (10:21 +0100)
This will avoid false negatives when running dex2oatd on apks.

bug:21865473

Change-Id: Id8eacaefae0bcf07a2ada8aedd7951854cdb5c4f

compiler/optimizing/inliner.cc
compiler/optimizing/optimizing_compiler.cc
compiler/optimizing/optimizing_compiler.h

index 92ebf06..3efe7c7 100644 (file)
@@ -27,6 +27,7 @@
 #include "mirror/class_loader.h"
 #include "mirror/dex_cache.h"
 #include "nodes.h"
+#include "optimizing_compiler.h"
 #include "reference_type_propagation.h"
 #include "register_allocator.h"
 #include "ssa_phi_elimination.h"
@@ -64,14 +65,14 @@ void HInliner::Run() {
         // We use the original invoke type to ensure the resolution of the called method
         // works properly.
         if (!TryInline(call, call->GetDexMethodIndex())) {
-          if (kIsDebugBuild) {
+          if (kIsDebugBuild && IsCompilingWithCoreImage()) {
             std::string callee_name =
                 PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile());
             bool should_inline = callee_name.find("$inline$") != std::string::npos;
             CHECK(!should_inline) << "Could not inline " << callee_name;
           }
         } else {
-          if (kIsDebugBuild) {
+          if (kIsDebugBuild && IsCompilingWithCoreImage()) {
             std::string callee_name =
                 PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile());
             bool must_not_inline = callee_name.find("$noinline$") != std::string::npos;
index 1944ba6..1e51530 100644 (file)
@@ -614,7 +614,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite
   {
     PassScope scope(HGraphBuilder::kBuilderPassName, &pass_observer);
     if (!builder.BuildGraph(*code_item)) {
-      CHECK(!shouldCompile) << "Could not build graph in optimizing compiler";
+      DCHECK(!(IsCompilingWithCoreImage() && shouldCompile))
+          << "Could not build graph in optimizing compiler";
       pass_observer.SetGraphInBadState();
       return nullptr;
     }
@@ -705,4 +706,9 @@ Compiler* CreateOptimizingCompiler(CompilerDriver* driver) {
   return new OptimizingCompiler(driver);
 }
 
+bool IsCompilingWithCoreImage() {
+  const std::string& image = Runtime::Current()->GetImageLocation();
+  return EndsWith(image, "core.art") || EndsWith(image, "core-optimizing.art");
+}
+
 }  // namespace art
index d076fb5..0c89da1 100644 (file)
@@ -24,6 +24,11 @@ class CompilerDriver;
 
 Compiler* CreateOptimizingCompiler(CompilerDriver* driver);
 
+// Returns whether we are compiling against a "core" image, which
+// is an indicative we are running tests. The compiler will use that
+// information for checking invariants.
+bool IsCompilingWithCoreImage();
+
 }  // namespace art
 
 #endif  // ART_COMPILER_OPTIMIZING_OPTIMIZING_COMPILER_H_