Skip to content

Commit 325bdf1

Browse files
committed
fix performance regression
1 parent a4052c2 commit 325bdf1

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

crates/wasmi/src/engine/executor.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
763763
.and_then(|memory| memory.get_mut(..n))
764764
.ok_or(TrapCode::MemoryOutOfBounds)?;
765765
memory.fill(byte);
766-
this.try_next_instr()
766+
Ok(())
767767
},
768-
)
768+
)?;
769+
self.try_next_instr()
769770
}
770771

771772
fn visit_memory_copy(&mut self) -> Result<(), TrapCode> {
@@ -786,9 +787,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
786787
.and_then(|memory| memory.get(..n))
787788
.ok_or(TrapCode::MemoryOutOfBounds)?;
788789
data.copy_within(src_offset..src_offset.wrapping_add(n), dst_offset);
789-
this.try_next_instr()
790+
Ok(())
790791
},
791-
)
792+
)?;
793+
self.try_next_instr()
792794
}
793795

794796
fn visit_memory_init(&mut self, segment: DataSegmentIdx) -> Result<(), TrapCode> {
@@ -812,9 +814,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
812814
.and_then(|data| data.get(..n))
813815
.ok_or(TrapCode::MemoryOutOfBounds)?;
814816
memory.copy_from_slice(data);
815-
this.try_next_instr()
817+
Ok(())
816818
},
817-
)
819+
)?;
820+
self.try_next_instr()
818821
}
819822

820823
fn visit_data_drop(&mut self, segment_index: DataSegmentIdx) {
@@ -866,9 +869,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
866869
this.ctx
867870
.resolve_table_mut(&table)
868871
.fill_untyped(dst, val, len)?;
869-
this.try_next_instr()
872+
Ok(())
870873
},
871-
)
874+
)?;
875+
self.try_next_instr()
872876
}
873877

874878
fn visit_table_get(&mut self, table_index: TableIdx) -> Result<(), TrapCode> {
@@ -915,9 +919,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
915919
let (dst, src) = this.ctx.resolve_table_pair_mut(&dst, &src);
916920
TableEntity::copy(dst, dst_index, src, src_index, len)?;
917921
}
918-
this.try_next_instr()
922+
Ok(())
919923
},
920-
)
924+
)?;
925+
self.try_next_instr()
921926
}
922927

923928
fn visit_table_init(
@@ -941,9 +946,10 @@ impl<'ctx, 'engine, 'func> Executor<'ctx, 'engine, 'func> {
941946
.get_func(func_index)
942947
.unwrap_or_else(|| panic!("missing function at index {func_index}"))
943948
})?;
944-
this.try_next_instr()
949+
Ok(())
945950
},
946-
)
951+
)?;
952+
self.try_next_instr()
947953
}
948954

949955
fn visit_element_drop(&mut self, segment_index: ElementSegmentIdx) {

0 commit comments

Comments
 (0)