mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibJS/Bytecode: Split SetVariable into four separate instructions
Instead of SetVariable having 2x2 modes for variable/lexical and initialize/set, those 4 modes are now separate instructions, which makes each instruction much less branchy.
This commit is contained in:
parent
640f195a70
commit
b7c04f999a
Notes:
sideshowbarker
2024-07-17 03:51:15 +09:00
Author: https://github.com/awesomekling
Commit: b7c04f999a
Pull-request: https://github.com/SerenityOS/serenity/pull/24324
8 changed files with 203 additions and 96 deletions
|
@ -399,29 +399,6 @@ inline ThrowCompletionOr<Value> typeof_variable(VM& vm, DeprecatedFlyString cons
|
|||
return PrimitiveString::create(vm, value.typeof());
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> set_variable(
|
||||
VM& vm,
|
||||
DeprecatedFlyString const& name,
|
||||
Value value,
|
||||
Op::EnvironmentMode mode,
|
||||
Op::SetVariable::InitializationMode initialization_mode,
|
||||
EnvironmentCoordinate& cache)
|
||||
{
|
||||
auto environment = mode == Op::EnvironmentMode::Lexical ? vm.running_execution_context().lexical_environment : vm.running_execution_context().variable_environment;
|
||||
auto reference = TRY(vm.resolve_binding(name, environment));
|
||||
if (reference.environment_coordinate().has_value())
|
||||
cache = reference.environment_coordinate().value();
|
||||
switch (initialization_mode) {
|
||||
case Op::SetVariable::InitializationMode::Initialize:
|
||||
TRY(reference.initialize_referenced_binding(vm, value));
|
||||
break;
|
||||
case Op::SetVariable::InitializationMode::Set:
|
||||
TRY(reference.put_value(vm, value));
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
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