Closed Bug 1457125 Opened 5 years ago Closed 5 years ago

Use interpreter fast path for calls also for calls to non-constructors

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
Noticed this while investigating bug 1449950 in the debugger on Windows.

The interpreter has an inline-call path that's guarded by:

    /* Don't bother trying to fast-path calls to scripted non-constructors. */
    if (!isFunction || !maybeFun->isInterpreted() || !maybeFun->isConstructor() ||
        (!construct && maybeFun->isClassConstructor()))

We were not using this path for calls to some self-hosted function because isConstructor() returns false, but we only care about that if we're actually constructing.
Attachment #8971207 - Flags: review?(tcampbell)
Note that bug 667824 added this "Don't bother trying to fast-path calls to scripted non-constructors." comment, but back then I think the only non-constructor function was probably Function.prototype -- nowadays we have a lot more of them.
FWIW this improves the micro-benchmark below from 210 ms to 151 ms with --no-baseline

function f() {
    var g = () => 1;
    var t = new Date;
    for (var i = 0; i < 1000000; i++)
        g();
    print(new Date - t);
}
f();
Comment on attachment 8971207 [details] [diff] [review]
Patch

Review of attachment 8971207 [details] [diff] [review]:
-----------------------------------------------------------------

Good find. This is going to move a huge amount of normal calls to the "fast-path". Probably worth getting some talos/AWFY results before landing, especially if aiming for FF61.

While you are here, do you mind changing the definition of |construct| to use |IsConstructorCallPC|?
Attachment #8971207 - Flags: review?(tcampbell) → review+
Ah, I was missing that functions by default are constructors, even if code doesn't use them as constructors. This looks reasonable then. :)
Pushed by jandemooij@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/314f5e5e4502
Use interpreter fast path for calls also for calls to non-constructors. r=tcampbell
https://hg.mozilla.org/mozilla-central/rev/314f5e5e4502
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.