remove unnessesary argument from start_execution

This commit is contained in:
Andrew Dirksen 2018-11-20 10:30:56 -08:00
parent 6f9b0a2b96
commit 844fd0c5c9
3 changed files with 7 additions and 8 deletions

View File

@ -138,7 +138,7 @@ impl FuncInstance {
check_function_args(func.signature(), &args)?; check_function_args(func.signature(), &args)?;
match *func.as_internal() { match *func.as_internal() {
FuncInstanceInternal::Internal { .. } => { FuncInstanceInternal::Internal { .. } => {
interpreter.start_execution(externals, func, args, func.signature().return_type()) interpreter.start_execution(externals, func, args)
} }
FuncInstanceInternal::Host { FuncInstanceInternal::Host {
ref host_func_index, .. ref host_func_index, ..
@ -268,14 +268,13 @@ impl FuncInvocation {
externals: &'externals mut E, externals: &'externals mut E,
func: &FuncRef, func: &FuncRef,
args: &[RuntimeValue], args: &[RuntimeValue],
return_type: Option<ValueType>,
) -> Result<Option<RuntimeValue>, ResumableError> { ) -> Result<Option<RuntimeValue>, ResumableError> {
match self.kind { match self.kind {
FuncInvocationKind::Internal(ref mut interpreter) => { FuncInvocationKind::Internal(ref mut interpreter) => {
if interpreter.state() != &InterpreterState::Initialized { if interpreter.state() != &InterpreterState::Initialized {
return Err(ResumableError::AlreadyStarted); return Err(ResumableError::AlreadyStarted);
} }
Ok(interpreter.start_execution(externals, func, args, return_type)?) Ok(interpreter.start_execution(externals, func, args)?)
} }
FuncInvocationKind::Host { FuncInvocationKind::Host {
ref mut finished, ref mut finished,

View File

@ -204,10 +204,7 @@ impl Interpreter {
externals: &mut E, externals: &mut E,
func: &FuncRef, func: &FuncRef,
args: &[RuntimeValue], args: &[RuntimeValue],
return_type: Option<ValueType>,
) -> Result<Option<RuntimeValue>, Trap> { ) -> Result<Option<RuntimeValue>, Trap> {
debug_assert_eq!(func.signature().return_type(), return_type);
// Ensure that the VM has not been executed. This is checked in `FuncInvocation::start_execution`. // Ensure that the VM has not been executed. This is checked in `FuncInvocation::start_execution`.
assert!(self.state == InterpreterState::Initialized); assert!(self.state == InterpreterState::Initialized);
@ -224,7 +221,10 @@ impl Interpreter {
self.state = InterpreterState::Started; self.state = InterpreterState::Started;
self.run_interpreter_loop(externals)?; self.run_interpreter_loop(externals)?;
let opt_return_value = return_type.map(|vt| self.value_stack.pop().with_type(vt)); let opt_return_value = func
.signature()
.return_type()
.map(|vt| self.value_stack.pop().with_type(vt));
// Ensure that stack is empty after the execution. This is guaranteed by the validation properties. // Ensure that stack is empty after the execution. This is guaranteed by the validation properties.
assert!(self.value_stack.len() == 0); assert!(self.value_stack.len() == 0);

View File

@ -267,7 +267,7 @@ fn resume_call_host_func() {
let return_type = func_instance.signature().return_type(); let return_type = func_instance.signature().return_type();
let mut invocation = FuncInstance::invoke_resumable(&func_instance); let mut invocation = FuncInstance::invoke_resumable(&func_instance);
let result = invocation.start_execution(&mut env, func_instance, &[], return_type); let result = invocation.start_execution(&mut env, func_instance, &[]);
match result { match result {
Err(ResumableError::Trap(_)) => {} Err(ResumableError::Trap(_)) => {}
_ => panic!(), _ => panic!(),