[wasm] Avoid code modifications during code freeing
Code freeing can happen at any point in time where a GC might be triggered. Hence it's difficult to ensure that no other {CodeSpaceWriteScope} is already open at that point. The way these scope objects are implemented forbids multiple scopes for different modules though. To solve this, this CL just avoids the code zapping in {WasmCodeAllocator::FreeCode}, which is the only place that actually writes to the code space. Without this, we do not need the {CodeSpaceWriteScope} in {NativeModule::FreeCode} any more. R=jkummerow@chromium.org Bug: v8:11974 Change-Id: I1f01979e1eaea6c311c9ad568d605aabeef3bfc4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3081522 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#76174}
This commit is contained in:
parent
e82a3b1e79
commit
d38ea7d979
@ -822,13 +822,6 @@ void WasmCodeAllocator::FreeCode(base::Vector<WasmCode* const> codes) {
|
||||
DisjointAllocationPool freed_regions;
|
||||
size_t code_size = 0;
|
||||
for (WasmCode* code : codes) {
|
||||
// TODO(clemensb): If zapping is worth it, we need to unprotect the code
|
||||
// memory first.
|
||||
if (!protect_code_memory_) {
|
||||
ZapCode(code->instruction_start(), code->instructions().size());
|
||||
FlushInstructionCache(code->instruction_start(),
|
||||
code->instructions().size());
|
||||
}
|
||||
code_size += code->instructions().size();
|
||||
freed_regions.Merge(base::AddressRegion{code->instruction_start(),
|
||||
code->instructions().size()});
|
||||
@ -2356,10 +2349,6 @@ std::vector<int> NativeModule::FindFunctionsToRecompile(
|
||||
|
||||
void NativeModule::FreeCode(base::Vector<WasmCode* const> codes) {
|
||||
base::RecursiveMutexGuard guard(&allocation_mutex_);
|
||||
// Get writable permission already here (and not inside the loop in
|
||||
// {WasmCodeAllocator::FreeCode}), to avoid switching for each {code}
|
||||
// individually.
|
||||
CodeSpaceWriteScope code_space_write_scope(this);
|
||||
// Free the code space.
|
||||
code_allocator_.FreeCode(codes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user