From 77a46ab1b8d13f35b11a7bd08459752912dca1bf Mon Sep 17 00:00:00 2001 From: Hermes Junior Date: Tue, 12 Nov 2024 18:38:35 +0100 Subject: [PATCH] LibJS: Correctly return cached value for global var bindings When the cached value was not an accessor, it was simply ignored. This is the value we really want, so we can just return it. Shows up to 5x improvements on some benchmarks, and 1.4x in general js-benchmarks. --- Libraries/LibJS/Bytecode/Interpreter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index f3b71c5f967..bbf67490750 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1118,6 +1118,7 @@ inline ThrowCompletionOr get_global(Interpreter& interpreter, IdentifierT auto value = binding_object.get_direct(cache.property_offset.value()); if (value.is_accessor()) return TRY(call(vm, value.as_accessor().getter(), js_undefined())); + return value; } // OPTIMIZATION: For global lexical bindings, if the global declarative environment hasn't changed,