Commit bc103e06 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Merge two mprotect calls into one

The two jump tables (near and far jump table) are usually allocated next
to each other, so we can switch permissions for both in a single system
call.
This removes one of the three to four remaining system calls in
deserialization.

R=jkummerow@chromium.org

Bug: v8:11974, chromium:1297999
Change-Id: I68d2bd1c2e68bea46ebac4e01906915ff5a1d3bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3472075Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79197}
parent 80326050
......@@ -1519,10 +1519,21 @@ void NativeModule::PatchJumpTableLocked(const CodeSpaceData& code_space_data,
DCHECK_NOT_NULL(code_space_data.jump_table);
DCHECK_NOT_NULL(code_space_data.far_jump_table);
code_allocator_.MakeWritable(
AddressRegionOf(code_space_data.jump_table->instructions()));
code_allocator_.MakeWritable(
AddressRegionOf(code_space_data.far_jump_table->instructions()));
// Jump tables are often allocated next to each other, so we can switch
// permissions on both at the same time.
if (code_space_data.jump_table->instructions().end() ==
code_space_data.far_jump_table->instructions().begin()) {
base::Vector<uint8_t> jump_tables_space = base::VectorOf(
code_space_data.jump_table->instructions().begin(),
code_space_data.jump_table->instructions().size() +
code_space_data.far_jump_table->instructions().size());
code_allocator_.MakeWritable(AddressRegionOf(jump_tables_space));
} else {
code_allocator_.MakeWritable(
AddressRegionOf(code_space_data.jump_table->instructions()));
code_allocator_.MakeWritable(
AddressRegionOf(code_space_data.far_jump_table->instructions()));
}
DCHECK_LT(slot_index, module_->num_declared_functions);
Address jump_table_slot =
......
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