Open Bug 1966536 Opened 1 year ago Updated 1 year ago

Optimize try note searching

Categories

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

enhancement

Tracking

()

People

(Reporter: rhunt, Unassigned)

References

(Blocks 1 open bug)

Details

When an exception is thrown, we must look up a try note using a pc to find the nearest enclosing try_table to jump to. The try notes are ranges that are all sorted in a list by their end offset [1]. This makes it so that to find the nearest enclosing try note, we can do a linear search and stop at the first match. For large modules this can be really time consuming.

Here are some ideas for making this faster:

  1. Use a binary search to find a match, then back up to find the first match
  2. Adopt some fancy interval data structure
  3. Switch try note from being a 'range of code addresses' to being a 'single code address'. This is actually how Ion handles try notes by generating a single one for every call site within a try block. Baseline is the only one to use the nesting feature properly. Once we have this, we can use a hash table for lookups. If we do this, we should probably put some effort into minimizing the size of try note, or making it a sparse addition to the CallSites class.

[1] https://searchfox.org/mozilla-central/rev/bd4d1cd1ca3037e6dc8d4081a4303824880b1b45/js/src/wasm/WasmCodegenTypes.h#1468
[2] https://searchfox.org/mozilla-central/source/js/src/wasm/WasmCode.cpp#1043-1046

You need to log in before you can comment on or make changes to this bug.