OSDN Git Service

ART: Skip image visitor in OatWriter for VerifyAtRuntime
authorAndreas Gampe <agampe@google.com>
Thu, 17 Sep 2015 00:12:55 +0000 (17:12 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 17 Sep 2015 21:02:50 +0000 (14:02 -0700)
There's no use running the visitor, and it will force-resolve all
methods. Avoid the overhead. Reduces boot image compile time in
verify-at-runtime mode from 1.25s to 1s (on the host, in -j4 mode).

Bug: 24103765
Change-Id: Icdc3be628fed0c9bda01cf5f24fe377f23c571a9

compiler/oat_writer.cc

index 4ddd457..c96b171 100644 (file)
@@ -1123,7 +1123,11 @@ size_t OatWriter::InitOatCodeDexFiles(size_t offset) {
     } while (false)
 
   VISIT(InitCodeMethodVisitor);
-  if (compiler_driver_->IsImage()) {
+  // InitImageMethodVisitor visits all methods, resolves them (failing if one cannot be resolved,
+  // which is a bad sign for a working boot image), and then install entrypoints.
+  // In case of VerifyAtRuntime, there won't be code, and we do not want to resolve the methods
+  // (this has been skipped in the driver for performance).
+  if (compiler_driver_->IsImage() && !compiler_driver_->GetCompilerOptions().VerifyAtRuntime()) {
     VISIT(InitImageMethodVisitor);
   }