[cleanup] Remove VirtualMemory::TakeControl

Use the existing move assignment operator instead.

R=ulan@chromium.org

Bug: v8:9183
Change-Id: Id7a4427da2bbf92d2954faba06e24afe64cb9818
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1594729
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61236}
This commit is contained in:
Clemens Hammacher 2019-05-06 12:05:37 +02:00 committed by Commit Bot
parent 4d5969b2a8
commit b327a91705
4 changed files with 9 additions and 17 deletions

View File

@ -283,12 +283,5 @@ void VirtualMemory::Free() {
RoundUp(region.size(), page_allocator->AllocatePageSize())));
}
void VirtualMemory::TakeControl(VirtualMemory* from) {
DCHECK(!IsReserved());
page_allocator_ = from->page_allocator_;
region_ = from->region_;
from->Reset();
}
} // namespace internal
} // namespace v8

View File

@ -186,11 +186,14 @@ class V8_EXPORT_PRIVATE VirtualMemory final {
~VirtualMemory();
// Move constructor.
VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { TakeControl(&other); }
VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { *this = std::move(other); }
// Move assignment operator.
VirtualMemory& operator=(VirtualMemory&& other) V8_NOEXCEPT {
TakeControl(&other);
DCHECK(!IsReserved());
page_allocator_ = other.page_allocator_;
region_ = other.region_;
other.Reset();
return *this;
}
@ -235,10 +238,6 @@ class V8_EXPORT_PRIVATE VirtualMemory final {
// Frees all memory.
void Free();
// Assign control of the reserved region to a different VirtualMemory object.
// The old object is no longer functional (IsReserved() returns false).
void TakeControl(VirtualMemory* from);
bool InVM(Address address, size_t size) {
return region_.contains(address, size);
}

View File

@ -207,7 +207,7 @@ void MemoryAllocator::InitializeCodePageAllocator(
NewEvent("CodeRange", reinterpret_cast<void*>(reservation.address()),
requested));
heap_reservation_.TakeControl(&reservation);
heap_reservation_ = std::move(reservation);
code_page_allocator_instance_ = base::make_unique<base::BoundedPageAllocator>(
page_allocator, aligned_base, size,
static_cast<size_t>(MemoryChunk::kAlignment));
@ -457,7 +457,7 @@ Address MemoryAllocator::AllocateAlignedMemory(
return kNullAddress;
}
controller->TakeControl(&reservation);
*controller = std::move(reservation);
return base;
}
@ -942,7 +942,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
// linear allocation area.
if ((base + chunk_size) == 0u) {
CHECK(!last_chunk_.IsReserved());
last_chunk_.TakeControl(&reservation);
last_chunk_ = std::move(reservation);
UncommitMemory(&last_chunk_);
size_ -= chunk_size;
if (executable == EXECUTABLE) {

View File

@ -78,7 +78,7 @@ void StoreBuffer::SetUp() {
}
current_ = 0;
top_ = start_[current_];
virtual_memory_.TakeControl(&reservation);
virtual_memory_ = std::move(reservation);
}
void StoreBuffer::TearDown() {