Commit b61e85a3 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Revisit maximum jump table distance

This changes a '<' to a '<=' and adds a comment to explain why it is
safe to use a jump table where the maximum distance is exactly
{kMaxCodeSpaceSize}.

R=jkummerow@chromium.org

Bug: chromium:1151364
Change-Id: Id4971a2e9095fa99df48367ab09af4adbfadffaf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2552906Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71337}
parent 6ded810b
......@@ -1473,7 +1473,11 @@ NativeModule::JumpTablesRef NativeModule::FindJumpTablesForRegion(
size_t max_distance = std::max(
code_region.end() > table_start ? code_region.end() - table_start : 0,
table_end > code_region.begin() ? table_end - code_region.begin() : 0);
return max_distance < WasmCodeAllocator::kMaxCodeSpaceSize;
// We can allow a max_distance that is equal to kMaxCodeSpaceSize, because
// every call or jump will target an address *within* the region, but never
// exactly the end of the region. So all occuring offsets are actually
// smaller than max_distance.
return max_distance <= WasmCodeAllocator::kMaxCodeSpaceSize;
};
// Fast path: Try to use {main_jump_table_} and {main_far_jump_table_}.
......
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