Clear the wasm operand stack at the end of a function.

This preserves an invariant that the stack is empty between function
body translations.
This commit is contained in:
Dan Gohman
2017-11-01 11:25:22 -07:00
parent 09b1bdc108
commit aa724846f6

View File

@@ -215,6 +215,10 @@ fn parse_function_body<FE: FuncEnvironment + ?Sized>(
builder.ins().return_(&state.stack); builder.ins().return_(&state.stack);
} }
// Discard any remaining values on the stack. Either we just returned them,
// or the end of the function is unreachable.
state.stack.clear();
debug_assert!(reader.eof()); debug_assert!(reader.eof());
Ok(()) Ok(())