-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Conversation
There are more fast paths to be added here, just starting with this one since it's heavy on Kraken/ai-astar.js :^)
3bb698b
to
fd3e611
Compare
@@ -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); } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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) :^)
fd3e611
to
1e4b8e1
Compare
Combined, these yield a strong ~2.7x speed-up on Kraken/ai-astar.js :^)