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

[wasm] Use unprotected loads for known in-bound accesses

For memory accesses that are statically known to be in bounds, avoid the
out-of-line code for the trap handler. This makes trap handler metadata
smaller, reduces code size (by avoiding OOL code), and enables more
optimizations at later phases, because unprotected memory loads can be
reordered and reused.

Drive-by: Use {GetMemoryAccessKind} consistently.

R=ahaas@chromium.org

Bug: v8:11802
Change-Id: Ia824d3355a95f446a796c5b06f69ecaa1500709b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2912585Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74776}
parent 9fe26a86
This diff is collapsed.
......@@ -216,6 +216,16 @@ class WasmGraphBuilder {
kWithNullCheck = true,
kWithoutNullCheck = false
};
enum BoundsCheckResult {
// Statically OOB.
kOutOfBounds,
// Dynamically checked (using 1-2 conditional branches).
kDynamicallyChecked,
// OOB handled via the trap handler.
kTrapHandler,
// Statically known to be in bounds.
kInBounds
};
V8_EXPORT_PRIVATE WasmGraphBuilder(
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
......@@ -523,9 +533,14 @@ class WasmGraphBuilder {
// offset fits in a platform-dependent uintptr_t.
Node* MemBuffer(uintptr_t offset);
// BoundsCheckMem receives a uint32 {index} node and returns a ptrsize index.
Node* BoundsCheckMem(uint8_t access_size, Node* index, uint64_t offset,
wasm::WasmCodePosition, EnforceBoundsCheck);
// BoundsCheckMem receives a 32/64-bit index (depending on
// WasmModule::is_memory64) and returns a ptrsize index and information about
// the kind of bounds check performed (or why none was needed).
std::pair<Node*, BoundsCheckResult> BoundsCheckMem(uint8_t access_size,
Node* index,
uint64_t offset,
wasm::WasmCodePosition,
EnforceBoundsCheck);
Node* CheckBoundsAndAlignment(int8_t access_size, Node* index,
uint64_t offset, wasm::WasmCodePosition);
......
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