Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibJS/JIT: Fast paths for object==object and Array.length #21910

Merged
merged 2 commits into from Nov 12, 2023

Conversation

awesomekling
Copy link
Member

Combined, these yield a strong ~2.7x speed-up on Kraken/ai-astar.js :^)

There are more fast paths to be added here, just starting with this
one since it's heavy on Kraken/ai-astar.js :^)
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 12, 2023
dotnetCarpenter

This comment was marked as duplicate.

@@ -221,6 +221,8 @@ class Object : public Cell {
static FlatPtr may_interfere_with_indexed_property_access_offset() { return OFFSET_OF(Object, m_may_interfere_with_indexed_property_access); }
static FlatPtr indexed_properties_offset() { return OFFSET_OF(Object, m_indexed_properties); }

static FlatPtr has_magical_length_property_offset() { return OFFSET_OF(Object, m_has_magical_length_property); }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might belong as a youtube comment, but I was thinking that since you're adding a magic property to Array, why not call it isArray, instead of has_magical_length_property_offset? Then you also have a clear fast path for Array.isArray() (ES5).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem safe if the value is a Proxy object 🤔

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh yes. I wrote my comment wrong. I actually meant the m_has_magical_length_property = true; property in the Array constructor. Sorry for the confusion.

Array.length is magical (since it has to reflect the number of elements
in the object's property storage).

We now handle it specially in jitted code, giving us a massive speed-up
on Kraken/ai-astar.js (and probably many other things as well) :^)
@awesomekling awesomekling merged commit b532ded into SerenityOS:master Nov 12, 2023
7 of 12 checks passed
@awesomekling awesomekling deleted the ai-astar-go-brr branch November 12, 2023 18:57
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants