Closed Bug 1671635 Opened 4 years ago Closed 4 years ago

Warp: try-catch + OSR phi unboxing can result in performance issues

Categories

(Core :: JavaScript Engine: JIT, task, P2)

task

Tracking

()

RESOLVED DUPLICATE of bug 1673497

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

I was running some old perf tests and noticed this issue on the test in bug 604905.

Because Ion/Warp don't compile catch-blocks, we risk bailing out a few times and then being stuck in Baseline (due to bailoutExpected) if some variable is assigned a different type in the catch-block. A simple fix is to not specialize OSR phis if there's a try-catch, similar to some other backend optimizations we disable when try-catch is present, but ideally we'd have a more targeted fix..

Here's a micro-benchmark for this where we're much slower than we should be:

function f() {
  var x;
  try {
    doesNotExist();
  } catch (e) {
    x = {x: 1};
  }
  var t = dateNow();
  var res = 0;
  for (var i = 0; i < 100_000_000; i++) {
    res += x.x;
  }
  print(dateNow() - t);
  print(res);
}
f();

This is fixed in bug 1673497 by disabling OSR phi specialization if an OSR phi guard fails, which allows us to fall back to a Value phi in this case. The speedup for this microbenchmark is about 10x.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.