Closed Bug 921813 Opened 6 years ago Closed 4 years ago

Arrow functions: Remove "this" binding when "this" not observable in the body.

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED DUPLICATE of bug 989204

People

(Reporter: mano, Unassigned)

Details

Attachments

(2 files)

Attached file scratchpad.js
Try the attached script in Scratchpad. I see a constant 10%+ difference (but I'm not sure it actually scales).
I can confirm the speed difference. However, there are quite a few other constructs in the test that we don't yet fully optimize (i.e., array comprehensions and generators).

I created a version that calculates the same results in a very different way, getting rid of everything but a single list.filter call in the functions under test. This version has a speed difference of 2-3%, when run in the shell.
Note that
  x => set.has(x)

is literally equivalent to:
  function (x) { set.has(x) }.bind(this)

and not:
  function (x) { set.has(x) }

We should optimize the arrow functions when "this" is not observable in the body of arrow function.
Summary: Arrow functions performance issue → Arrow functions: Remove "this" binding when "this" not observable in the body.
Is this still valid? I get a difference of less than 1% between the two on the second testcase.
This has been fixed yes.

http://www.jandemooij.nl/blog/2014/04/11/fast-arrow-functions-in-firefox-31/
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 989204
You need to log in before you can comment on or make changes to this bug.