diff options
author | 2018-08-16 16:12:49 +0100 | |
---|---|---|
committer | 2018-08-21 13:51:00 +0100 | |
commit | c34bebf39410f5571d3d5813157b61f274d435c3 (patch) | |
tree | 73909d3b34a2908e9de44cc60c4a2ff74eabefd7 /compiler | |
parent | f345404c725330914b8313d2c1af17226c5b92ca (diff) |
Remove unnecessary indirection from MemMap.
Avoid plain MemMap pointers being passed around by changing
the MemMap to moveable and return MemMap objects by value.
Previously we could have a valid zero-size MemMap but this
is now forbidden.
MemMap::RemapAtEnd() is changed to avoid the explicit call
to munmap(); mmap() with MAP_FIXED automatically removes
old mappings for overlapping regions.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: m test-art-target-gtest
Test: testrunner.py --target --optimizing
Change-Id: I12bd453c26a396edc20eb141bfd4dad20923f170
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/common_compiler_test.cc | 20 | ||||
-rw-r--r-- | compiler/common_compiler_test.h | 2 | ||||
-rw-r--r-- | compiler/utils/swap_space.cc | 1 |
3 files changed, 12 insertions, 11 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index 87197becf9..2f017662e2 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -221,7 +221,7 @@ void CommonCompilerTest::TearDown() { callbacks_.reset(); verification_results_.reset(); compiler_options_.reset(); - image_reservation_.reset(); + image_reservation_.Reset(); CommonRuntimeTest::TearDown(); } @@ -323,18 +323,18 @@ void CommonCompilerTest::ReserveImageSpace() { // 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)120 * 1024 * 1024, // 120MB - PROT_NONE, - false /* no need for 4gb flag with fixed mmap*/, - false /* not reusing existing reservation */, - &error_msg)); - CHECK(image_reservation_.get() != nullptr) << error_msg; + image_reservation_ = MemMap::MapAnonymous("image reservation", + reinterpret_cast<uint8_t*>(ART_BASE_ADDRESS), + (size_t)120 * 1024 * 1024, // 120MB + PROT_NONE, + false /* no need for 4gb flag with fixed mmap */, + false /* not reusing existing reservation */, + &error_msg); + CHECK(image_reservation_.IsValid()) << error_msg; } void CommonCompilerTest::UnreserveImageSpace() { - image_reservation_.reset(); + image_reservation_.Reset(); } void CommonCompilerTest::SetDexFilesForOatFile(const std::vector<const DexFile*>& dex_files) { diff --git a/compiler/common_compiler_test.h b/compiler/common_compiler_test.h index db38110400..366489c58f 100644 --- a/compiler/common_compiler_test.h +++ b/compiler/common_compiler_test.h @@ -115,7 +115,7 @@ class CommonCompilerTest : public CommonRuntimeTest { std::unique_ptr<CompilerDriver> compiler_driver_; private: - std::unique_ptr<MemMap> image_reservation_; + MemMap image_reservation_; // Chunks must not move their storage after being created - use the node-based std::list. std::list<std::vector<uint8_t>> header_code_and_maps_chunks_; diff --git a/compiler/utils/swap_space.cc b/compiler/utils/swap_space.cc index 1f9ad4242d..dee83d1c71 100644 --- a/compiler/utils/swap_space.cc +++ b/compiler/utils/swap_space.cc @@ -141,6 +141,7 @@ void* SwapSpace::Alloc(size_t size) { it->size -= size; } else { // Changing in place would break the std::set<> ordering, we need to remove and insert. + // TODO: When C++17 becomes available, use std::map<>::extract(), modify, insert. free_by_size_.erase(it); free_by_size_.insert(new_value); } |