Closed Bug 1431772 Opened 7 years ago Closed 4 years ago

Ion: Function.prototype.call is faster than a plain call

Categories

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

enhancement

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox59 --- affected

People

(Reporter: bbouvier, Unassigned)

Details

The following micro benchmark shows that Function.prototype.call may be faster than a plain call. It outputs the following, when run with --ion-inlining=off --no-threads: callknown time: 3437.96044921875 function.prototype.call time: 3203.791259765625 Is it because no `this` value is passed to the callee in the case of F.p.call? In any case, it seems the results should be more similar than this (since this is unused in the callee). The strangest thing is that iongraph shows that the final LIR graphs are the same (in particular both calls end up being compiled to a LCallKnown), so I wonder if compilation somehow just kicks in faster with F.p.call. var INNER_ITERATIONS = 100000; var ITERATIONS = 10000; function run(name, func) { let sum = 0; for (var i = ITERATIONS; i --> 0;) { t = dateNow(); func(); sum += dateNow() - t; } console.log(name, 'time: ', sum); } function jsAdd(x, y) { return (x|0) + (y|0) | 0; } function testJSCallKnown() { for (var i = 0; i < INNER_ITERATIONS; i++) { jsAdd(i, i +1); } } function testJSFunctionCall() { for (var i = 0; i < INNER_ITERATIONS; i++) { jsAdd.call(null, i, i +1); } } run('callknown', testJSCallKnown); run('function.prototype.call', testJSFunctionCall);
Priority: -- → P3

No longer reproducible -> Resolving as WFM.

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