Commit 5cfa94bd authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Minor cleanup in code allocation

1) Avoid putting empty VirtualMemory objects in {owned_code_space_}.
2) After allocating more code space, the actual allocation in that space
   should also succeed. DCHECK that.
3) Remove pointless std::move.

R=ahaas@chromium.org

Bug: v8:8015
Change-Id: Ifda30d8279579ea290c6fa8e9c310f05a044b288
Reviewed-on: https://chromium-review.googlesource.com/1238721Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56156}
parent 333434d2
......@@ -661,15 +661,15 @@ Address NativeModule::AllocateForCode(size_t size) {
Address hint = owned_code_space_.empty() ? kNullAddress
: owned_code_space_.back().end();
owned_code_space_.emplace_back(
wasm_code_manager_->TryAllocate(size, reinterpret_cast<void*>(hint)));
VirtualMemory& new_mem = owned_code_space_.back();
VirtualMemory new_mem =
wasm_code_manager_->TryAllocate(size, reinterpret_cast<void*>(hint));
if (!new_mem.IsReserved()) return kNullAddress;
wasm_code_manager_->AssignRanges(new_mem.address(), new_mem.end(), this);
free_code_space_.Merge({new_mem.address(), new_mem.end()});
owned_code_space_.emplace_back(std::move(new_mem));
mem = free_code_space_.Allocate(size);
if (mem.is_empty()) return kNullAddress;
DCHECK(!mem.is_empty());
}
Address commit_start = RoundUp(mem.start, page_allocator->AllocatePageSize());
Address commit_end = RoundUp(mem.end, page_allocator->AllocatePageSize());
......@@ -711,7 +711,7 @@ Address NativeModule::AllocateForCode(size_t size) {
#endif
}
DCHECK(IsAligned(mem.start, kCodeAlignment));
allocated_code_space_.Merge(std::move(mem));
allocated_code_space_.Merge(mem);
TRACE_HEAP("Code alloc for %p: %" PRIuPTR ",+%zu\n", this, mem.start, size);
return mem.start;
}
......
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