mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
LibJS: Make async functions & generators faster with helper types
Instead of returning internal generator results as ordinary JS::Objects with properties, we now use GeneratorResult and CompletionCell which both inherit from Cell directly and allow efficient access to state. 1.59x speedup on JetStream3/lazy-collections.js :^)
This commit is contained in:
parent
1022566bff
commit
a0bb31f7a0
Notes:
github-actions[bot]
2025-04-01 00:31:35 +00:00
Author: https://github.com/awesomekling
Commit: a0bb31f7a0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4161
12 changed files with 259 additions and 93 deletions
|
@ -962,6 +962,58 @@ private:
|
|||
u32 m_cache_index { 0 };
|
||||
};
|
||||
|
||||
class GetCompletionFields final : public Instruction {
|
||||
public:
|
||||
GetCompletionFields(Operand type_dst, Operand value_dst, Operand completion)
|
||||
: Instruction(Type::GetCompletionFields)
|
||||
, m_type_dst(type_dst)
|
||||
, m_value_dst(value_dst)
|
||||
, m_completion(completion)
|
||||
{
|
||||
}
|
||||
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
||||
void visit_operands_impl(Function<void(Operand&)> visitor)
|
||||
{
|
||||
visitor(m_type_dst);
|
||||
visitor(m_value_dst);
|
||||
visitor(m_completion);
|
||||
}
|
||||
|
||||
Operand type_dst() const { return m_type_dst; }
|
||||
Operand value_dst() const { return m_value_dst; }
|
||||
Operand completion() const { return m_completion; }
|
||||
|
||||
private:
|
||||
Operand m_type_dst;
|
||||
Operand m_value_dst;
|
||||
Operand m_completion;
|
||||
};
|
||||
|
||||
class SetCompletionType final : public Instruction {
|
||||
public:
|
||||
SetCompletionType(Operand completion, Completion::Type type)
|
||||
: Instruction(Type::SetCompletionType)
|
||||
, m_completion(completion)
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
void execute_impl(Bytecode::Interpreter&) const;
|
||||
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
|
||||
void visit_operands_impl(Function<void(Operand&)> visitor)
|
||||
{
|
||||
visitor(m_completion);
|
||||
}
|
||||
|
||||
Operand completion() const { return m_completion; }
|
||||
|
||||
private:
|
||||
Operand m_completion;
|
||||
Completion::Type m_type;
|
||||
};
|
||||
|
||||
class GetByIdWithThis final : public Instruction {
|
||||
public:
|
||||
GetByIdWithThis(Operand dst, Operand base, IdentifierTableIndex property, Operand this_value, u32 cache_index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue