Closed Bug 1401577 Opened 2 years ago Closed 2 years ago

Optimize object flag accessors on native objects

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
While looking at the profile in bug 1398578 I noticed NativeSetProperty calls obj->watched() -> JSObject::hasAllFlags -> JSObject::maybeShape -> JSObject::is<js::ShapedObject>().

This is slower than necessary: we check for native/proxy/TypedObject even though NativeSetProperty is called with a NativeObject argument.

The patch fixes this and some related issues:

* NativeObject now shadows hasAllFlags, watched, nonProxyIsExtensible. These are faster than the methods on JSObject.

* I moved isIndexed, setHadElementsAccess/hadElementsAccess, setNewScriptCleared/wasNewScriptCleared from JSObject to NativeObject. These methods are only relevant for native objects and can now call the faster NativeObject::hasAllFlags.

* For consistency, I added NativeObject::hasInterestingSymbol and used that instead of calling hasAllFlags directly.
Attachment #8910311 - Flags: review?(andrebargull)
Comment on attachment 8910311 [details] [diff] [review]
Patch

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

Looks reasonable.

::: js/src/vm/NativeObject.h
@@ +758,5 @@
> +    // Mark an object as having its 'new' script information cleared.
> +    bool wasNewScriptCleared() const {
> +        return hasAllFlags(js::BaseShape::NEW_SCRIPT_CLEARED);
> +    }
> +    static bool setNewScriptCleared(JSContext* cx, JS::HandleObject obj) {

HandleNativeObject instead of HandleObject
Attachment #8910311 - Flags: review?(andrebargull) → review+
Pushed by jandemooij@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e3835d35a46e
Optimize object flag accessors on native objects. r=anba
This improved object-assign-es6 by a few %:

https://arewefastyet.com/#machine=29&view=single&suite=six-speed&subtest=object-assign-es6

We're now very close to JSC. We really need to kill watch/unwatch and there's a bit more stuff to optimize on the NativeSetProperty path.
https://hg.mozilla.org/mozilla-central/rev/e3835d35a46e
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.