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

LibJS: Don't track executing AST nodes in a Vector

Instead just link together the InterpreterNodeScopes in a linked list.
This was surprisingly hot on CanvasCycle.
This commit is contained in:
Andreas Kling 2021-03-21 17:38:42 +01:00
parent 46e61d208b
commit e0abfcb27d
4 changed files with 27 additions and 29 deletions

View file

@ -59,19 +59,20 @@ class InterpreterNodeScope {
public:
InterpreterNodeScope(Interpreter& interpreter, const ASTNode& node)
: m_interpreter(interpreter)
, m_node(node)
, m_chain_node { nullptr, node }
{
m_interpreter.enter_node(m_node);
m_interpreter.vm().call_frame().current_node = &node;
m_interpreter.push_ast_node(m_chain_node);
}
~InterpreterNodeScope()
{
m_interpreter.exit_node(m_node);
m_interpreter.pop_ast_node();
}
private:
Interpreter& m_interpreter;
const ASTNode& m_node;
ExecutingASTNodeChain m_chain_node;
};
String ASTNode::class_name() const
@ -2169,8 +2170,7 @@ void SequenceExpression::dump(int indent) const
Value SequenceExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
{
interpreter.enter_node(*this);
ScopeGuard exit_node { [&] { interpreter.exit_node(*this); } };
InterpreterNodeScope node_scope { interpreter, *this };
Value last_value;
for (auto& expression : m_expressions) {