Closed Bug 1809180 Opened 2 years ago Closed 2 years ago

Inline more array builtins with a callback argument

Categories

(Core :: JavaScript Engine, task)

task

Tracking

()

RESOLVED FIXED
110 Branch
Tracking Status
firefox110 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

We call SetIsInlinableLargeFunction for ArrayMap and ArrayForEach, but not for ArrayFilter and ArrayFind{Index,Last,LastIndex}. We should probably treat those the same way.

Flags: needinfo?(jdemooij)

This matches code in other builtins and shrinks the bytecode a little.

This matches map, some, forEach, etc.

Depends on D166639

Flags: needinfo?(jdemooij)

This micro-benchmark for Array.prototype.filter improves from ~312 ms to ~163 ms:

function f() {
  var arr = Array(100).fill(123);
  var res;
  var t = new Date;
  for (var i = 0; i < 100_000; i++) {
    res = arr.filter(x => x > 100).filter(x => x > 120).filter(x => x < 0);
  }
  print(new Date - t);
  return res;
}
f();

And this one for %TypedArray%.prototype.findIndex from ~193 ms to ~54 ms:

function f() {
  var ta = new Int32Array(100);
  ta[90] = 123;
  var res;
  var t = new Date;
  for (var i = 0; i < 100_000; i++) {
    res = ta.findIndex(x => x > 0) + ta.findIndex(x => x < 0) + ta.findIndex(x => x === 123);
  }
  print(new Date - t);
  return res;
}
f();
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/49832385a669 part 1 - Remove some unnecessary vars in self-hosted code. r=iain https://hg.mozilla.org/integration/autoland/rev/67187d488af1 part 2 - Mark {Typed}Array find/filter builtins as inlinable. r=iain
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: