diff options
-rw-r--r-- | src/heap.cc | 2 | ||||
-rw-r--r-- | src/image_test.cc | 24 | ||||
-rw-r--r-- | src/mem_map.cc | 3 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/heap.cc b/src/heap.cc index 1cdc9c9..fa84e49 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -222,7 +222,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max uintptr_t reserve_end = RoundUp(reinterpret_cast<uintptr_t>(oat_end_addr), kPageSize); oat_file_map_.reset(MemMap::MapAnonymous("oat file reserve", reinterpret_cast<byte*>(reserve_begin), - reserve_end - reserve_begin, PROT_READ)); + reserve_end - reserve_begin, PROT_NONE)); if (oat_end_addr > requested_begin) { requested_begin = reinterpret_cast<byte*>(RoundUp(reinterpret_cast<uintptr_t>(oat_end_addr), diff --git a/src/image_test.cc b/src/image_test.cc index a250b13..dc81587 100644 --- a/src/image_test.cc +++ b/src/image_test.cc @@ -23,11 +23,24 @@ #include "oat_writer.h" #include "signal_catcher.h" #include "gc/space.h" +#include "UniquePtr.h" #include "utils.h" namespace art { -class ImageTest : public CommonTest {}; +class ImageTest : public CommonTest { + + protected: + virtual void SetUp() { + // 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. + image_reservation_.reset(MemMap::MapAnonymous("Image reservation", (byte*)ART_BASE_ADDRESS, + (size_t)100 * 1024 *1024, // 100MB + PROT_NONE)); + CommonTest::SetUp(); + } + UniquePtr<MemMap> image_reservation_; +}; TEST_F(ImageTest, WriteRead) { ScratchFile tmp_oat; @@ -74,15 +87,18 @@ TEST_F(ImageTest, WriteRead) { } // Need to delete the compiler since it has worker threads which are attached to runtime. - delete compiler_.release(); + compiler_.reset(); - // tear down old runtime before making a new one, clearing out misc state - delete runtime_.release(); + // Tear down old runtime before making a new one, clearing out misc state. + runtime_.reset(); java_lang_dex_file_ = NULL; UniquePtr<const DexFile> dex(DexFile::Open(GetLibCoreDexFileName(), GetLibCoreDexFileName())); ASSERT_TRUE(dex.get() != NULL); + // Remove the reservation of the memory for use to load the image. + image_reservation_.reset(); + Runtime::Options options; std::string image("-Ximage:"); image.append(tmp_image.GetFilename()); diff --git a/src/mem_map.cc b/src/mem_map.cc index 800f274..a2ddf3c 100644 --- a/src/mem_map.cc +++ b/src/mem_map.cc @@ -42,7 +42,7 @@ static std::ostream& operator<<(std::ostream& os, map_info_t* rhs) { return os; } -void CheckMapRequest(byte* addr, size_t byte_count) { +static void CheckMapRequest(byte* addr, size_t byte_count) { if (addr == NULL) { return; } @@ -69,7 +69,6 @@ static void CheckMapRequest(byte*, size_t) { } MemMap* MemMap::MapAnonymous(const char* name, byte* addr, size_t byte_count, int prot) { CHECK_NE(0U, byte_count); - CHECK_NE(0, prot); size_t page_aligned_byte_count = RoundUp(byte_count, kPageSize); CheckMapRequest(addr, page_aligned_byte_count); |