summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-02-22 13:35:44 -0800
committer Mathieu Chartier <mathieuc@google.com> 2017-02-22 14:55:25 -0800
commit97ab5e3b79d1cf6034d3a2a1c6e6b2176d4e2af5 (patch)
treebbba74bf351ebf2863bda16d8fb46c2ca43f9c67
parentfc5d8c28e5265634aeeb2f255dc8d5747e2919ee (diff)
Check for null profile in ShouldCompileBasedOnProfile
It may be null if speed-profile is passed to dex2oat without a profile. In this case, compile nothing. Test: mm test-art-host-gtest-dex2oat_test -j32 Bug: 35665292 Bug: 35420088 Change-Id: I2da3258492d1f6b86bba6b4bb5a86d378f0a9227
-rw-r--r--compiler/driver/compiler_driver.cc5
-rw-r--r--dex2oat/dex2oat_test.cc6
2 files changed, 11 insertions, 0 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 52ffa55342..7e91453741 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1054,11 +1054,16 @@ bool CompilerDriver::IsMethodToCompile(const MethodReference& method_ref) const
}
bool CompilerDriver::ShouldCompileBasedOnProfile(const MethodReference& method_ref) const {
+ // Profile compilation info may be null if no profile is passed.
if (!CompilerFilter::DependsOnProfile(compiler_options_->GetCompilerFilter())) {
// Use the compiler filter instead of the presence of profile_compilation_info_ since
// we may want to have full speed compilation along with profile based layout optimizations.
return true;
}
+ // If we are using a profile filter but do not have a profile compilation info, compile nothing.
+ if (profile_compilation_info_ == nullptr) {
+ return false;
+ }
bool result = profile_compilation_info_->ContainsMethod(method_ref);
if (kDebugProfileGuidedCompilation) {
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 6881f75c75..2c0b125fb7 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -554,6 +554,12 @@ TEST_F(Dex2oatVeryLargeTest, UseVeryLarge) {
RunTest(CompilerFilter::kSpeed, true, { "--very-large-app-threshold=100" });
}
+// Regressin test for b/35665292.
+TEST_F(Dex2oatVeryLargeTest, SpeedProfileNoProfile) {
+ // Test that dex2oat doesn't crash with speed-profile but no input profile.
+ RunTest(CompilerFilter::kSpeedProfile, false);
+}
+
class Dex2oatLayoutTest : public Dex2oatTest {
protected:
void CheckFilter(CompilerFilter::Filter input ATTRIBUTE_UNUSED,