diff options
author | Andreas Gampe <agampe@google.com> | 2014-07-26 09:07:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-07-23 17:53:27 +0000 |
commit | ff9d95d58ea9c36d26b96f52c9a7ac4bf92fed2d (patch) | |
tree | 11bec4ba51478046c7ab7b1ca2b2f45c21463622 /runtime | |
parent | 3bcac48f23094fa0f46315a080ec47fc368fd4c2 (diff) | |
parent | cf4bf386ef3f527825c70e01130b9276da4f786a (diff) | |
download | art-ff9d95d58ea9c36d26b96f52c9a7ac4bf92fed2d.zip art-ff9d95d58ea9c36d26b96f52c9a7ac4bf92fed2d.tar.gz art-ff9d95d58ea9c36d26b96f52c9a7ac4bf92fed2d.tar.bz2 |
Merge "Tweaks to patchoat and other related things."
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/gc/space/image_space.cc | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 7a3cbf3..883e1c1f 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -45,6 +45,26 @@ ImageSpace::ImageSpace(const std::string& image_filename, const char* image_loca live_bitmap_.reset(live_bitmap); } +static int32_t ChooseRelocationOffsetDelta(int32_t min_delta, int32_t max_delta) { + CHECK_ALIGNED(min_delta, kPageSize); + CHECK_ALIGNED(max_delta, kPageSize); + CHECK_LT(min_delta, max_delta); + + std::default_random_engine generator; + generator.seed(NanoTime() * getpid()); + std::uniform_int_distribution<int32_t> distribution(min_delta, max_delta); + int32_t r = distribution(generator); + if (r % 2 == 0) { + r = RoundUp(r, kPageSize); + } else { + r = RoundDown(r, kPageSize); + } + CHECK_LE(min_delta, r); + CHECK_GE(max_delta, r); + CHECK_ALIGNED(r, kPageSize); + return r; +} + static bool GenerateImage(const std::string& image_filename, std::string* error_msg) { const std::string boot_class_path_string(Runtime::Current()->GetBootClassPathString()); std::vector<std::string> boot_class_path; @@ -75,7 +95,11 @@ static bool GenerateImage(const std::string& image_filename, std::string* error_ Runtime::Current()->AddCurrentRuntimeFeaturesAsDex2OatArguments(&arg_vector); - arg_vector.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS)); + int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA, + ART_BASE_ADDRESS_MAX_DELTA); + LOG(INFO) << "Using an offset of 0x" << std::hex << base_offset << " from default " + << "art base address of 0x" << std::hex << ART_BASE_ADDRESS; + arg_vector.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS + base_offset)); if (kIsTargetBuild) { arg_vector.push_back("--image-classes-zip=/system/framework/framework.jar"); @@ -145,26 +169,6 @@ static bool ReadSpecificImageHeader(const char* filename, ImageHeader* image_hea return true; } -static int32_t ChooseRelocationOffsetDelta(int32_t min_delta, int32_t max_delta) { - CHECK_ALIGNED(min_delta, kPageSize); - CHECK_ALIGNED(max_delta, kPageSize); - CHECK_LT(min_delta, max_delta); - - std::default_random_engine generator; - generator.seed(NanoTime() * getpid()); - std::uniform_int_distribution<int32_t> distribution(min_delta, max_delta); - int32_t r = distribution(generator); - if (r % 2 == 0) { - r = RoundUp(r, kPageSize); - } else { - r = RoundDown(r, kPageSize); - } - CHECK_LE(min_delta, r); - CHECK_GE(max_delta, r); - CHECK_ALIGNED(r, kPageSize); - return r; -} - bool ImageSpace::RelocateImage(const char* image_location, const char* dest_filename, InstructionSet isa, std::string* error_msg) { std::string patchoat(Runtime::Current()->GetPatchoatExecutable()); @@ -376,13 +380,6 @@ ImageSpace* ImageSpace::Create(const char* image_location, CHECK(dalvik_cache_exists) << "No place to put generated image."; CHECK(GenerateImage(cache_filename, &error_msg)) << "Failed to generate image '" << cache_filename << "': " << error_msg; - // TODO Should I relocate this image? Sure - if (relocate) { - if (!RelocateImage(cache_filename.c_str(), cache_filename.c_str(), image_isa, &error_msg)) { - LOG(FATAL) << "Failed to relocate newly created image " << cache_filename.c_str(); - return nullptr; - } - } { // Note that we must not use the file descriptor associated with // ScopedFlock::GetFile to Init the image file. We want the file |