diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-10-14 15:01:24 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-10-14 15:43:21 -0700 |
commit | 6e88ef6b604a7a945a466784580c42e6554c1289 (patch) | |
tree | 1e296564787b51514cf2eca5b732647c1a82912e /compiler | |
parent | 58e51f38e2304a08aa9ec380383e0b3614f96a96 (diff) | |
download | android_art-6e88ef6b604a7a945a466784580c42e6554c1289.tar.gz android_art-6e88ef6b604a7a945a466784580c42e6554c1289.tar.bz2 android_art-6e88ef6b604a7a945a466784580c42e6554c1289.zip |
Change MemMap::maps_ to not be global variable
Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.
Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/common_compiler_test.cc | 1 | ||||
-rw-r--r-- | compiler/image_test.cc | 20 |
2 files changed, 13 insertions, 8 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index e3eb9e9915..d1d47fb361 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -397,6 +397,7 @@ void CommonCompilerTest::ReserveImageSpace() { // Reserve where the image will be loaded up front so that other parts of test set up don't // accidentally end up colliding with the fixed memory address when we need to load the image. std::string error_msg; + MemMap::Init(); image_reservation_.reset(MemMap::MapAnonymous("image reservation", reinterpret_cast<uint8_t*>(ART_BASE_ADDRESS), (size_t)100 * 1024 * 1024, // 100MB diff --git a/compiler/image_test.cc b/compiler/image_test.cc index cf4259f790..d5d487f03c 100644 --- a/compiler/image_test.cc +++ b/compiler/image_test.cc @@ -63,7 +63,7 @@ TEST_F(ImageTest, WriteRead) { ScratchFile oat_file(OS::CreateEmptyFile(oat_filename.c_str())); const uintptr_t requested_image_base = ART_BASE_ADDRESS; - ImageWriter writer(*compiler_driver_, requested_image_base); + std::unique_ptr<ImageWriter> writer(new ImageWriter(*compiler_driver_, requested_image_base)); { { jobject class_loader = NULL; @@ -83,8 +83,8 @@ TEST_F(ImageTest, WriteRead) { t.NewTiming("WriteElf"); SafeMap<std::string, std::string> key_value_store; OatWriter oat_writer(class_linker->GetBootClassPath(), 0, 0, 0, compiler_driver_.get(), - &writer, &timings, &key_value_store); - bool success = writer.PrepareImageAddressSpace() && + writer.get(), &timings, &key_value_store); + bool success = writer->PrepareImageAddressSpace() && compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, class_linker->GetBootClassPath(), @@ -99,9 +99,9 @@ TEST_F(ImageTest, WriteRead) { { bool success_image = - writer.Write(image_file.GetFilename(), dup_oat->GetPath(), dup_oat->GetPath()); + writer->Write(image_file.GetFilename(), dup_oat->GetPath(), dup_oat->GetPath()); ASSERT_TRUE(success_image); - bool success_fixup = ElfWriter::Fixup(dup_oat.get(), writer.GetOatDataBegin()); + bool success_fixup = ElfWriter::Fixup(dup_oat.get(), writer->GetOatDataBegin()); ASSERT_TRUE(success_fixup); } @@ -130,14 +130,18 @@ TEST_F(ImageTest, WriteRead) { compiler_driver_.reset(); // Tear down old runtime before making a new one, clearing out misc state. + + // Remove the reservation of the memory for use to load the image. + // Need to do this before we reset the runtime. + UnreserveImageSpace(); + writer.reset(nullptr); + runtime_.reset(); java_lang_dex_file_ = NULL; + MemMap::Init(); std::unique_ptr<const DexFile> dex(LoadExpectSingleDexFile(GetLibCoreDexFileName().c_str())); - // Remove the reservation of the memory for use to load the image. - UnreserveImageSpace(); - RuntimeOptions options; std::string image("-Ximage:"); image.append(image_location.GetFilename()); |