1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibJS/Bytecode: Cache object own property accesses

The instructions GetById and GetByIdWithThis now remember the last-seen
Shape, and if we see the same object again, we reuse the property offset
from last time without doing a new lookup.

This allows us to use Object::get_direct(), bypassing the entire lookup
machinery and saving lots of time.

~23% speed-up on Kraken/ai-astar.js :^)
This commit is contained in:
Andreas Kling 2023-07-08 17:43:26 +02:00
parent 52cd671163
commit de8e4b1853
8 changed files with 76 additions and 26 deletions

View file

@ -564,9 +564,10 @@ private:
class GetById final : public Instruction {
public:
explicit GetById(IdentifierTableIndex property)
GetById(IdentifierTableIndex property, u32 cache_index)
: Instruction(Type::GetById)
, m_property(property)
, m_cache_index(cache_index)
{
}
@ -577,14 +578,16 @@ public:
private:
IdentifierTableIndex m_property;
u32 m_cache_index { 0 };
};
class GetByIdWithThis final : public Instruction {
public:
GetByIdWithThis(IdentifierTableIndex property, Register this_value)
GetByIdWithThis(IdentifierTableIndex property, Register this_value, u32 cache_index)
: Instruction(Type::GetByIdWithThis)
, m_property(property)
, m_this_value(this_value)
, m_cache_index(cache_index)
{
}
@ -600,6 +603,7 @@ public:
private:
IdentifierTableIndex m_property;
Register m_this_value;
u32 m_cache_index { 0 };
};
class GetPrivateById final : public Instruction {