LibJS/Bytecode: Give TypeofBinding instructions a lookup cache

These can use an EnvironmentCoordinate for caching, just like normal
binding lookups. Saves a bunch of time for repeated typeof checks.
This commit is contained in:
Andreas Kling 2024-06-14 13:57:51 +02:00 committed by Andreas Kling
commit 60a05ef414
Notes: sideshowbarker 2024-07-18 05:01:22 +09:00
3 changed files with 33 additions and 19 deletions

View file

@ -389,24 +389,6 @@ inline ThrowCompletionOr<void> throw_if_needed_for_call(Interpreter& interpreter
return {};
}
inline ThrowCompletionOr<Value> typeof_binding(VM& vm, DeprecatedFlyString const& string)
{
// 1. Let val be the result of evaluating UnaryExpression.
auto reference = TRY(vm.resolve_binding(string));
// 2. If val is a Reference Record, then
// a. If IsUnresolvableReference(val) is true, return "undefined".
if (reference.is_unresolvable())
return PrimitiveString::create(vm, "undefined"_string);
// 3. Set val to ? GetValue(val).
auto value = TRY(reference.get_value(vm));
// 4. NOTE: This step is replaced in section B.3.6.3.
// 5. Return a String according to Table 41.
return PrimitiveString::create(vm, value.typeof());
}
inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<IdentifierTableIndex> const& lhs_name, Optional<Operand> const& home_object)
{
Value value;