Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asserts for checking expected number of inputs/outputs #547

Merged
merged 4 commits into from
Sep 29, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Sep 23, 2020

No description provided.

@chfast chfast requested review from gumb0 and axic September 23, 2020 08:31

return stack.size() != 0 ? ExecutionResult{stack.pop()} : Void;
return !func_type.outputs.empty() ? ExecutionResult{stack.pop()} : Void;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use func_type, the stack.size() is only used in asserts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get, why is it better?

It looks you could do assertions like

assert(args.size() == instance.module.get_function_type(func_idx).inputs.size());
assert(stack.size() == instance.module.get_function_type(func_idx).inputs.outputs.size());

and then avoid another variable declaration in outer scope and get_function_type() call.

I kind of liked the fact that execute doesn't need to access called function type, because all type stuff is handled at validation...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right here.

It looks we don't need information about number of outputs. But we will probably need the information about number of arguments. In the end to bootstrap execution we need:

  • number of arguments,
  • number of locals,
  • max stack height.

@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #547 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #547   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files          59       59           
  Lines        8932     8948   +16     
=======================================
+ Hits         8811     8827   +16     
  Misses        121      121           

@chfast chfast marked this pull request as draft September 23, 2020 08:43
@chfast chfast marked this pull request as ready for review September 23, 2020 09:10
@chfast chfast force-pushed the check_inputs_and_outputs branch 2 times, most recently from 18a67f3 to 7208c06 Compare September 29, 2020 10:25
@chfast chfast merged commit da544ab into master Sep 29, 2020
@chfast chfast deleted the check_inputs_and_outputs branch September 29, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants