Skip to content

Commit 1ea5134

Browse files
committed
use proper byte sizes for ValueStack setup
This roughly shrinks initial allocation size under default config by 8.
1 parent 60df4ba commit 1ea5134

File tree

1 file changed

+5
-0
lines changed
  • crates/wasmi/src/engine/executor/handler

1 file changed

+5
-0
lines changed

crates/wasmi/src/engine/executor/handler/state.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ pub struct ValueStack {
380380

381381
impl ValueStack {
382382
fn new(min_height: usize, max_height: usize) -> Self {
383+
// We need to convert from `size_of<Cell>`` to `size_of<u8>`:
384+
debug_assert!(min_height <= max_height);
385+
let sizeof_cell = mem::size_of::<UntypedVal>();
386+
let min_height = min_height / sizeof_cell;
387+
let max_height = max_height / sizeof_cell;
383388
let cells = Vec::with_capacity(min_height);
384389
Self { cells, max_height }
385390
}

0 commit comments

Comments
 (0)