mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
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:
parent
4302e07346
commit
60a05ef414
Notes:
sideshowbarker
2024-07-18 05:01:22 +09:00
Author: https://github.com/awesomekling
Commit: 60a05ef414
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/165
3 changed files with 33 additions and 19 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue