Closed Bug 1888418 Opened 1 year ago Closed 1 month ago

Allow to inline Math.min/max when the initial array is large

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
firefox144 --- fixed

People

(Reporter: anba, Assigned: iain)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

CacheIR inlining for spread calls to Math.{min,max} is guarded by JIT_ARGS_LENGTH_MAX, but the actual compiled code works for any array length. We should investigate removing this restriction during CacheIR inlining, because the compiled code doesn't need that restriction.

Test case:

function f(...xss) {
  var N = 1_000_000;
  var r = 0;
  var t = performance.now();
  for (var i = 0; i < N; ++i) {
    var xs = xss[(i > (N / 2))|0];
    r += Math.max(...xs);
  }
  console.log(performance.now() - t, r);
}

// Fast when the initial array is small enough.
Function(`return ${f}`)()(
  Array(10).fill(0),
  Array(1000).fill(0),
);

// Slow when the initial array is too large.
Function(`return ${f}`)()(
  Array(1000).fill(0),
  Array(10).fill(0),
);
Blocks: sm-jits
Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → iireland
Status: NEW → ASSIGNED
Pushed by iireland@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ee015f2a0371 https://hg.mozilla.org/integration/autoland/rev/9633b8a44119 Allow spread call natives to be inlined with more than JIT_ARGS_LENGTH_MAX arguments r=anba
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 144 Branch
QA Whiteboard: [qa-triage-done-c145/b144]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: