Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: runtime/vm/virtual_memory.cc

Issue 644453003: Simplify VirtualMemory by removing unused ReserveAligned method. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/virtual_memory.cc
===================================================================
--- runtime/vm/virtual_memory.cc (revision 41000)
+++ runtime/vm/virtual_memory.cc (working copy)
@@ -15,34 +15,15 @@
}
-VirtualMemory* VirtualMemory::ReserveAligned(intptr_t size,
- intptr_t alignment) {
- ASSERT((size & (PageSize() - 1)) == 0);
- ASSERT(Utils::IsPowerOfTwo(alignment));
- ASSERT(alignment >= PageSize());
- VirtualMemory* result = VirtualMemory::Reserve(size + alignment);
- if (result == NULL) {
- FATAL("Out of memory.\n");
- }
- uword start = result->start();
- uword real_start = (start + alignment - 1) & ~(alignment - 1);
- result->Truncate(real_start, size);
- return result;
-}
-
-
-void VirtualMemory::Truncate(uword new_start, intptr_t new_size) {
- ASSERT(new_start >= start());
+void VirtualMemory::Truncate(intptr_t new_size, bool try_unmap) {
ASSERT((new_size & (PageSize() - 1)) == 0);
- if (new_start > start()) {
- uword split = new_start - start();
- ASSERT((split & (PageSize() - 1)) == 0);
- FreeSubSegment(address(), split);
- region_.Subregion(region_, split, size() - split);
- }
ASSERT(new_size <= size());
- FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
- size() - new_size);
+ if (try_unmap &&
+ (reserved_size_ == size()) && /* Don't create holes in reservation. */
+ FreeSubSegment(reinterpret_cast<void*>(start() + new_size),
+ size() - new_size)) {
+ reserved_size_ = new_size;
+ }
region_.Subregion(region_, 0, new_size);
}

Powered by Google App Engine
This is Rietveld 408576698