Extend value stack for all locals at once.
This commit is contained in:
parent
ad254790a4
commit
0cf0d7500d
|
@ -1290,9 +1290,7 @@ impl FunctionContext {
|
||||||
|
|
||||||
let num_locals = locals.iter().map(|l| l.count() as usize).sum();
|
let num_locals = locals.iter().map(|l| l.count() as usize).sum();
|
||||||
|
|
||||||
for _ in 0..num_locals {
|
value_stack.extend(num_locals)?;
|
||||||
value_stack.push(Default::default())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.is_initialized = true;
|
self.is_initialized = true;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1438,6 +1436,18 @@ impl ValueStack {
|
||||||
Ok(())
|
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]
|
#[inline]
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.sp
|
self.sp
|
||||||
|
|
Loading…
Reference in New Issue