mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibJS: Add SetGlobal bytecode instruction for cached global writes
Before this change, setting a global would end up as SetLexicalBinding. That instruction always failed to cache the access if the global was a property of the global object. 1.14x speedup on Octane/earley-boyer.js 2.04x speedup on MicroBench/for-of.js Note that MicroBench/for-of.js was more of a "set global" benchmark before this. After this change, it's actually a for..of benchmark. :^)
This commit is contained in:
parent
de6df6f403
commit
ad7c1e147f
Notes:
github-actions[bot]
2025-05-03 23:59:49 +00:00
Author: https://github.com/awesomekling
Commit: ad7c1e147f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4586
4 changed files with 134 additions and 1 deletions
|
@ -861,6 +861,34 @@ private:
|
|||
u32 m_cache_index { 0 };
|
||||
};
|
||||
|
||||
class SetGlobal final : public Instruction {
|
||||
public:
|
||||
SetGlobal(IdentifierTableIndex identifier, Operand src, u32 cache_index)
|
||||
: Instruction(Type::SetGlobal)
|
||||
, m_src(src)
|
||||
, m_identifier(identifier)
|
||||
, m_cache_index(cache_index)
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
||||
|
||||
Operand src() const { return m_src; }
|
||||
IdentifierTableIndex identifier() const { return m_identifier; }
|
||||
u32 cache_index() const { return m_cache_index; }
|
||||
|
||||
void visit_operands_impl(Function<void(Operand&)> visitor)
|
||||
{
|
||||
visitor(m_src);
|
||||
}
|
||||
|
||||
private:
|
||||
Operand m_src;
|
||||
IdentifierTableIndex m_identifier;
|
||||
u32 m_cache_index { 0 };
|
||||
};
|
||||
|
||||
class DeleteVariable final : public Instruction {
|
||||
public:
|
||||
explicit DeleteVariable(Operand dst, IdentifierTableIndex identifier)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue