From 6ff9931dde832de135fe9e3f5e972a1388aa3853 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 10 Nov 2022 20:59:44 +0100 Subject: [PATCH] LibJS: Make Identifier::execute() actually use the lookup cache If we have cached environment coordinates for an Identifier, we have to call to_reference() to actually make use of them. :^) --- Userland/Libraries/LibJS/AST.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 012d369053..b4763f6a61 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -2543,7 +2543,8 @@ Completion Identifier::execute(Interpreter& interpreter) const auto& vm = interpreter.vm(); // 1. Return ? ResolveBinding(StringValue of Identifier). - auto reference = TRY(vm.resolve_binding(m_string)); + // OPTIMIZATION: We call Identifier::to_reference() here, which acts as a caching layer around ResolveBinding. + auto reference = TRY(to_reference(interpreter)); // NOTE: The spec wants us to return the reference directly; this is not possible with ASTNode::execute() (short of letting it return a variant). // So, instead of calling GetValue at the call site, we do it here.