Commit b327a917 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[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/+/1594729Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61236}
parent 4d5969b2
...@@ -283,12 +283,5 @@ void VirtualMemory::Free() { ...@@ -283,12 +283,5 @@ void VirtualMemory::Free() {
RoundUp(region.size(), page_allocator->AllocatePageSize()))); 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 internal
} // namespace v8 } // namespace v8
...@@ -186,11 +186,14 @@ class V8_EXPORT_PRIVATE VirtualMemory final { ...@@ -186,11 +186,14 @@ class V8_EXPORT_PRIVATE VirtualMemory final {
~VirtualMemory(); ~VirtualMemory();
// Move constructor. // Move constructor.
VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { TakeControl(&other); } VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { *this = std::move(other); }
// Move assignment operator. // Move assignment operator.
VirtualMemory& operator=(VirtualMemory&& other) V8_NOEXCEPT { VirtualMemory& operator=(VirtualMemory&& other) V8_NOEXCEPT {
TakeControl(&other); DCHECK(!IsReserved());
page_allocator_ = other.page_allocator_;
region_ = other.region_;
other.Reset();
return *this; return *this;
} }
...@@ -235,10 +238,6 @@ class V8_EXPORT_PRIVATE VirtualMemory final { ...@@ -235,10 +238,6 @@ class V8_EXPORT_PRIVATE VirtualMemory final {
// Frees all memory. // Frees all memory.
void Free(); 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) { bool InVM(Address address, size_t size) {
return region_.contains(address, size); return region_.contains(address, size);
} }
......
...@@ -207,7 +207,7 @@ void MemoryAllocator::InitializeCodePageAllocator( ...@@ -207,7 +207,7 @@ void MemoryAllocator::InitializeCodePageAllocator(
NewEvent("CodeRange", reinterpret_cast<void*>(reservation.address()), NewEvent("CodeRange", reinterpret_cast<void*>(reservation.address()),
requested)); requested));
heap_reservation_.TakeControl(&reservation); heap_reservation_ = std::move(reservation);
code_page_allocator_instance_ = base::make_unique<base::BoundedPageAllocator>( code_page_allocator_instance_ = base::make_unique<base::BoundedPageAllocator>(
page_allocator, aligned_base, size, page_allocator, aligned_base, size,
static_cast<size_t>(MemoryChunk::kAlignment)); static_cast<size_t>(MemoryChunk::kAlignment));
...@@ -457,7 +457,7 @@ Address MemoryAllocator::AllocateAlignedMemory( ...@@ -457,7 +457,7 @@ Address MemoryAllocator::AllocateAlignedMemory(
return kNullAddress; return kNullAddress;
} }
controller->TakeControl(&reservation); *controller = std::move(reservation);
return base; return base;
} }
...@@ -942,7 +942,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size, ...@@ -942,7 +942,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
// linear allocation area. // linear allocation area.
if ((base + chunk_size) == 0u) { if ((base + chunk_size) == 0u) {
CHECK(!last_chunk_.IsReserved()); CHECK(!last_chunk_.IsReserved());
last_chunk_.TakeControl(&reservation); last_chunk_ = std::move(reservation);
UncommitMemory(&last_chunk_); UncommitMemory(&last_chunk_);
size_ -= chunk_size; size_ -= chunk_size;
if (executable == EXECUTABLE) { if (executable == EXECUTABLE) {
......
...@@ -78,7 +78,7 @@ void StoreBuffer::SetUp() { ...@@ -78,7 +78,7 @@ void StoreBuffer::SetUp() {
} }
current_ = 0; current_ = 0;
top_ = start_[current_]; top_ = start_[current_];
virtual_memory_.TakeControl(&reservation); virtual_memory_ = std::move(reservation);
} }
void StoreBuffer::TearDown() { void StoreBuffer::TearDown() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment