From 5c803116e26ef40ad2a9c14d3411e21d149e0c9b Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 13 Apr 2018 17:28:34 -0700 Subject: ART: Add profile-compile-check support Add --check-profiled-methods, which verifies that all methods mentioned in a profile for a guided compilation are actually compiled instead of being punted. As outcome it may log or abort dex2oat. TODO: Extend dex2oat_test Bug: 76145463 Test: mmma art Test: m test-art-host Change-Id: I956113b55796d0666db9dbfd387105a7d27b0868 --- compiler/driver/compiler_driver.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 89ac308fed..408cde2c30 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -24,6 +24,7 @@ #include // For mallinfo #endif +#include "android-base/logging.h" #include "android-base/strings.h" #include "art_field-inl.h" @@ -609,6 +610,29 @@ static void CompileMethodQuick( class_loader, dex_file, dex_cache); + ProfileMethodsCheck check_type = + driver->GetCompilerOptions().CheckProfiledMethodsCompiled(); + if (UNLIKELY(check_type != ProfileMethodsCheck::kNone)) { + bool violation = driver->ShouldCompileBasedOnProfile(method_ref) && + (compiled_method == nullptr); + if (violation) { + std::ostringstream oss; + oss << "Failed to compile " + << method_ref.dex_file->PrettyMethod(method_ref.index) + << "[" << method_ref.dex_file->GetLocation() << "]" + << " as expected by profile"; + switch (check_type) { + case ProfileMethodsCheck::kNone: + break; + case ProfileMethodsCheck::kLog: + LOG(ERROR) << oss.str(); + break; + case ProfileMethodsCheck::kAbort: + LOG(FATAL_WITHOUT_ABORT) << oss.str(); + _exit(1); + } + } + } } if (compiled_method == nullptr && dex_to_dex_compilation_level != -- cgit v1.2.3-59-g8ed1b