Skip to content

Commit

Permalink
Add missing resets for function translation allocations (#1034)
Browse files Browse the repository at this point in the history
* add missing reset for some translation allocations

* add missing docs
  • Loading branch information
Robbepop authored May 13, 2024
1 parent 3880d86 commit 9c7b899
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/wasmi/src/engine/bytecode/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ impl<T> Default for ProviderSliceStack<T> {
}

impl<T> ProviderSliceStack<T> {
/// Resets the [`ProviderSliceStack`] to allow for reuse.
pub fn reset(&mut self) {
self.ends.clear();
self.providers.clear();
}

/// Pushes a new [`Provider`] slice and returns its [`ProviderSliceRef`].
pub fn push<I>(&mut self, providers: I) -> Result<ProviderSliceRef, Error>
where
Expand Down
3 changes: 2 additions & 1 deletion crates/wasmi/src/engine/translator/control_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ pub struct ControlStack {
impl ControlStack {
/// Resets the [`ControlStack`] to allow for reuse.
pub fn reset(&mut self) {
self.frames.clear()
self.frames.clear();
self.else_providers.reset();
}

/// Returns `true` if `relative_depth` points to the first control flow frame.
Expand Down
1 change: 1 addition & 0 deletions crates/wasmi/src/engine/translator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl PreservedLocal {
}

impl TranslationBuffers {
/// Resets the [`TranslationBuffers`].
fn reset(&mut self) {
self.providers.clear();
self.br_table_targets.clear();
Expand Down
1 change: 1 addition & 0 deletions crates/wasmi/src/engine/translator/stack/register_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl RegisterAlloc {
self.next_dynamic = 0;
self.max_dynamic = 0;
self.min_preserve = Self::INITIAL_PRESERVATION_INDEX;
self.defrag_offset = 0;
}

/// Adjusts the [`RegisterAlloc`] for the popped [`TaggedProvider`] and returns a [`TypedProvider`].
Expand Down

0 comments on commit 9c7b899

Please sign in to comment.