1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibJS: Add modification counter in DeclarativeEnvironment

This counter is incremented whenever a mutating operation occurs
within the environment's set of bindings.

It is going to be used by GetGlobal instruction to correctly invalidate
cache when global declarative environment is mutated.
This commit is contained in:
Aliaksandr Kalenik 2023-07-12 14:30:51 +02:00 committed by Andreas Kling
parent b0a533dbc0
commit a27c4cf63c
2 changed files with 10 additions and 0 deletions

View file

@ -77,6 +77,8 @@ ThrowCompletionOr<void> DeclarativeEnvironment::create_mutable_binding(VM&, Depr
.initialized = false,
});
++m_environment_serial_number;
// 3. Return unused.
return {};
}
@ -97,6 +99,8 @@ ThrowCompletionOr<void> DeclarativeEnvironment::create_immutable_binding(VM&, De
.initialized = false,
});
++m_environment_serial_number;
// 3. Return unused.
return {};
}
@ -217,6 +221,8 @@ ThrowCompletionOr<bool> DeclarativeEnvironment::delete_binding(VM&, DeprecatedFl
// NOTE: We keep the entries in m_bindings to avoid disturbing indices.
binding_and_index->binding() = {};
++m_environment_serial_number;
// 4. Return true.
return true;
}