Closed Bug 1914005 Opened 1 year ago Closed 10 months ago

Optimize call_indirect for table64

Categories

(Core :: JavaScript: WebAssembly, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
143 Branch
Tracking Status
firefox143 --- fixed

People

(Reporter: rhunt, Assigned: bvisness)

References

Details

Attachments

(2 files, 1 obsolete file)

All table64 operations in JIT code put index parameters through a clamping operation to turn them UINT32_MAX if they are outside the 32-bit range. This let us keep our bounds checks the same. It works because our maximum table length at runtime is much less than UINT32_MAX. Most table operations are also not that performance sensitive at this time.

However, this extra overhead could be significant for call_indirect. We should measure and possibly optimize.

We should try to do this sometime soon, now that we're shipping memory64.

Assignee: nobody → bvisness

We currently do bounds checks for call_indirect at the masm level, and
always as 32-bit. This is not ideal now that we have table64, since it
forces us to clamp our address and length values down to 32 bits.

This patch removes the bounds check from masm and the corresponding
optimization logic from lowering. Instead, it moves the optimization
logic into MIR and LIR. Specifically:

  • If the index is constant and less than the table's min size, the
    bounds check is eliminated. (To be done in follow-up patch.)
  • If the table has a fixed length, a constant is emitted instead of a
    load, and we will compare against an immediate instead of a register
    or memory operand.
  • If the bounds check limit is an MWasmLoadInstance (as it is for
    tables), then the load will be emitted at use as a memory operand to
    the bounds check instead of a load to a register.
Attachment #9494469 - Attachment description: WIP: Bug 1914005: Move bounds checks out of call_indirect. → Bug 1914005: Move bounds checks out of call_indirect. r=rhunt

This extends our existing WasmBCE pass to work for tables, and also
multiple memories.

It seems like the phi path is actually not used. We can remove the code
to avoid future maintenance and bugs.

Attachment #9497428 - Attachment description: WIP: Bug 1914005: Implement WasmBCE for tables. → Bug 1914005: Implement WasmBCE for tables. r=rhunt
Attachment #9498438 - Attachment is obsolete: true
See Also: → 1625891
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 143 Branch
QA Whiteboard: [qa-triage-done-c144/b143]
Duplicate of this bug: 1860806
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: