Closed Bug 1097890 Opened 10 years ago Closed 10 years ago

Inline JSOP_NEWOBJECT in baseline

Categories

(Core :: JavaScript Engine: JIT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
ES6 generators return a new object every time they yield and now that we can Baseline-compile generators (bug 1093573) this is a perf issue because Baseline currently always uses a VM call.

The attached patch inlines JSOP_NEWOBJECT in Baseline and this should also help "normal" object literals. For the generator micro-benchmark below I get:

before: 155 ms
after:   94 ms

function *g(n) { for (var i = 0; i < n; i++) { yield i; } }
function f() {
    var t = new Date();
    var it = g(1000000);
    for (var i=0; i<1000000; i++)
	it.next();
    print(new Date() - t);
}
f();
Attachment #8521587 - Flags: review?(bhackett1024)
Comment on attachment 8521587 [details] [diff] [review]
Patch

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

::: js/src/jit/BaselineCompiler.cpp
@@ +1746,5 @@
> +    // Try to do the allocation inline.
> +    Label done;
> +    if (type && !type->shouldPreTenure() &&
> +        !templateObject->hasDynamicSlots() &&
> +        !cx->compartment()->hasObjectMetadataCallback())

Maybe remove the metadata part of this test, since it isn't necessary for correctness and makes it not really obvious what's going on.  Optimizing things based on the presence/absence of the metadata callback is probably something we should avoid.
Attachment #8521587 - Flags: review?(bhackett1024) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/c39b72dd4d10

(In reply to Brian Hackett (:bhackett) from comment #1)
> Maybe remove the metadata part of this test, since it isn't necessary for
> correctness and makes it not really obvious what's going on.  Optimizing
> things based on the presence/absence of the metadata callback is probably
> something we should avoid.

Done.
https://hg.mozilla.org/mozilla-central/rev/c39b72dd4d10
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: