mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 08:52:54 +00:00
LibJS/JIT: Add fastpath for set variable
This commit is contained in:
parent
b3cbe0fdb9
commit
84eecbb10e
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/feliwir 🔰
Commit: 84eecbb10e
Pull-request: https://github.com/SerenityOS/serenity/pull/21955
8 changed files with 148 additions and 12 deletions
|
@ -264,10 +264,13 @@ ThrowCompletionOr<void> set_variable(
|
|||
DeprecatedFlyString const& name,
|
||||
Value value,
|
||||
Op::EnvironmentMode mode,
|
||||
Op::SetVariable::InitializationMode initialization_mode)
|
||||
Op::SetVariable::InitializationMode initialization_mode,
|
||||
EnvironmentVariableCache& 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();
|
||||
switch (initialization_mode) {
|
||||
case Op::SetVariable::InitializationMode::Initialize:
|
||||
TRY(reference.initialize_referenced_binding(vm, value));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue