Closed Bug 921813 Opened 12 years ago Closed 10 years ago

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

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 989204

People

(Reporter: asaf, 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.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: