瀏覽代碼

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.
Hermes Junior 7 月之前
父節點
當前提交
77a46ab1b8
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      Libraries/LibJS/Bytecode/Interpreter.cpp

+ 1 - 0
Libraries/LibJS/Bytecode/Interpreter.cpp

@@ -1118,6 +1118,7 @@ inline ThrowCompletionOr<Value> get_global(Interpreter& interpreter, IdentifierT
             auto value = binding_object.get_direct(cache.property_offset.value());
             auto value = binding_object.get_direct(cache.property_offset.value());
             if (value.is_accessor())
             if (value.is_accessor())
                 return TRY(call(vm, value.as_accessor().getter(), js_undefined()));
                 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,
         // OPTIMIZATION: For global lexical bindings, if the global declarative environment hasn't changed,