mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +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:
parent
b0a533dbc0
commit
a27c4cf63c
2 changed files with 10 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
|
||||
void shrink_to_fit();
|
||||
|
||||
[[nodiscard]] u64 environment_serial_number() const { return m_environment_serial_number; }
|
||||
|
||||
private:
|
||||
ThrowCompletionOr<Value> get_binding_value_direct(VM&, Binding&, bool strict);
|
||||
ThrowCompletionOr<void> set_mutable_binding_direct(VM&, Binding&, Value, bool strict);
|
||||
|
@ -121,6 +123,8 @@ private:
|
|||
|
||||
Vector<Binding> m_bindings;
|
||||
Vector<DisposableResource> m_disposable_resource_stack;
|
||||
|
||||
u64 m_environment_serial_number { 0 };
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue