mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:17:44 +00:00
LibJS/JIT: Add fast path for GetById of Array.length
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) :^)
This commit is contained in:
parent
e41f0d9dec
commit
b532dedc91
3 changed files with 65 additions and 0 deletions
|
@ -64,6 +64,7 @@ NonnullGCPtr<Array> Array::create_from(Realm& realm, Vector<Value> const& elemen
|
|||
Array::Array(Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
m_has_magical_length_property = true;
|
||||
}
|
||||
|
||||
// 10.4.2.4 ArraySetLength ( A, Desc ), https://tc39.es/ecma262/#sec-arraysetlength
|
||||
|
|
|
@ -221,6 +221,8 @@ public:
|
|||
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); }
|
||||
|
||||
protected:
|
||||
enum class GlobalObjectTag { Tag };
|
||||
enum class ConstructWithoutPrototypeTag { Tag };
|
||||
|
@ -238,6 +240,8 @@ protected:
|
|||
// [[ParameterMap]]
|
||||
bool m_has_parameter_map { false };
|
||||
|
||||
bool m_has_magical_length_property { false };
|
||||
|
||||
private:
|
||||
void set_shape(Shape& shape) { m_shape = &shape; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue