Extend value stack for all locals at once.

This commit is contained in:
Adam Reichold 2019-10-11 16:33:37 +02:00
parent ad254790a4
commit 0cf0d7500d
1 changed files with 13 additions and 3 deletions

View File

@ -1290,9 +1290,7 @@ impl FunctionContext {
let num_locals = locals.iter().map(|l| l.count() as usize).sum();
for _ in 0..num_locals {
value_stack.push(Default::default())?;
}
value_stack.extend(num_locals)?;
self.is_initialized = true;
Ok(())
@ -1438,6 +1436,18 @@ impl ValueStack {
Ok(())
}
fn extend(&mut self, len: usize) -> Result<(), TrapKind> {
let cells = self
.buf
.get_mut(self.sp..self.sp + len)
.ok_or_else(|| TrapKind::StackOverflow)?;
for cell in cells {
*cell = Default::default();
}
self.sp += len;
Ok(())
}
#[inline]
fn len(&self) -> usize {
self.sp