summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2018-03-02 19:38:56 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-03-02 19:38:56 +0000
commita2d18b7072158af6b1fb9260bbf4f5510c3def1d (patch)
tree0a85cb327c62a904ce6cd86913e80164e2d00aac
parent398daffb3e216ff7d552e50f47f93523409bca6e (diff)
parent6e74abb66162d2399c97594a2a0ed82f0f09b238 (diff)
Merge "ART: Restrict ImageSpace space check to first image"
-rw-r--r--runtime/gc/space/image_space.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 9ae1f45511..366eb535f4 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1531,15 +1531,20 @@ std::unique_ptr<ImageSpace> ImageSpace::CreateBootImage(const char* image_locati
&has_cache,
&cache_filename);
- if (is_zygote && dalvik_cache_exists) {
+ bool dex2oat_enabled = Runtime::Current()->IsImageDex2OatEnabled();
+
+ if (is_zygote && dalvik_cache_exists && !secondary_image) {
+ // Extra checks for the zygote. These only apply when loading the first image, explained below.
DCHECK(!dalvik_cache.empty());
std::string local_error_msg;
// All secondary images are verified when the primary image is verified.
- bool verified = secondary_image || VerifyImage(image_location,
- dalvik_cache.c_str(),
- image_isa,
- &local_error_msg);
- if (!(verified && CheckSpace(dalvik_cache, &local_error_msg))) {
+ bool verified = VerifyImage(image_location, dalvik_cache.c_str(), image_isa, &local_error_msg);
+ // If we prune for space at a secondary image, we may end up in a crash loop with the _exit
+ // path.
+ bool check_space = CheckSpace(dalvik_cache, &local_error_msg);
+ if (!verified || !check_space) {
+ // Note: it is important to only prune for space on the primary image, or we will hit the
+ // restart path.
LOG(WARNING) << local_error_msg << " Preemptively pruning the dalvik cache.";
PruneDalvikCache(image_isa);
@@ -1554,6 +1559,10 @@ std::unique_ptr<ImageSpace> ImageSpace::CreateBootImage(const char* image_locati
&has_cache,
&cache_filename);
}
+ if (!check_space) {
+ // Disable compilation/patching - we do not want to fill up the space again.
+ dex2oat_enabled = false;
+ }
}
// Collect all the errors.
@@ -1620,7 +1629,7 @@ std::unique_ptr<ImageSpace> ImageSpace::CreateBootImage(const char* image_locati
// secondary image.
if (found_image && has_system && relocate) {
std::string local_error_msg;
- if (!Runtime::Current()->IsImageDex2OatEnabled()) {
+ if (!dex2oat_enabled) {
local_error_msg = "Patching disabled.";
} else if (secondary_image) {
// We really want a working image. Prune and restart.
@@ -1652,7 +1661,7 @@ std::unique_ptr<ImageSpace> ImageSpace::CreateBootImage(const char* image_locati
// cache. This step fails if this is a secondary image.
if (!has_system) {
std::string local_error_msg;
- if (!Runtime::Current()->IsImageDex2OatEnabled()) {
+ if (!dex2oat_enabled) {
local_error_msg = "Image compilation disabled.";
} else if (secondary_image) {
local_error_msg = "Cannot compile a secondary image.";