Closed Bug 1827420 Opened 3 years ago Closed 3 years ago

Optimize AutoSetNewObjectMetadata

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox114 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

(Whiteboard: [sp3])

Attachments

(2 files)

AutoSetNewObjectMetadata often shows up in profiles. We can make this quite a lot faster for the common case when there's no active metadata builder.

I have some patches for this that improve the micro-benchmark below from ~405 ms to ~345 ms.

function f() {
    var obj = {};
    var res;
    var t = new Date;
    for (var i = 0; i < 10_000_000; i++) {
        res = Object.getOwnPropertyNames(obj);
    }
    print(new Date - t);
    return res;
}
f();

If we're not using JSCLASS_DELAY_METADATA_BUILDER, we won't set pending metadata
so AutoSetNewObjectMetadata will be a no-op.

Also adds an assertion to catch these.

Inline more code and add realm->hasAllocationMetadataBuilder() checks in a
few places.

Removes the prevState_ field beacuse it was always ImmediateMetadata. We now
assert this in the constructor.

This makes a getOwnPropertyNames micro-benchmark about 15% faster.

Depends on D175136

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f3ea7807cf5c part 1 - Remove some unnecessary AutoSetNewObjectMetadata uses. r=jonco https://hg.mozilla.org/integration/autoland/rev/8872eb50a6b1 part 2 - Optimize AutoSetNewObjectMetadata. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: