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

Fix invoke: drop args after the call #573

Merged
merged 2 commits into from
Oct 5, 2020
Merged

Fix invoke: drop args after the call #573

merged 2 commits into from
Oct 5, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Oct 5, 2020

This fixes logical error in invoke_function() implementation. The call arguments are now dropped from the stack after the call returns.

Performance difference is not significant.

fizzy/execute/blake2b/512_bytes_rounds_1_mean                     -0.0056         -0.0056            77            77            77            77
fizzy/execute/blake2b/512_bytes_rounds_16_mean                    -0.0105         -0.0105          1173          1160          1173          1160
fizzy/execute/ecpairing/onepoint_mean                             +0.0026         +0.0026        389544        390546        389548        390550
fizzy/execute/keccak256/512_bytes_rounds_1_mean                   +0.0067         +0.0067            93            94            93            94
fizzy/execute/keccak256/512_bytes_rounds_16_mean                  +0.0066         +0.0066          1348          1357          1348          1357
fizzy/execute/memset/256_bytes_mean                               -0.0056         -0.0056             6             6             6             6
fizzy/execute/memset/60000_bytes_mean                             -0.0113         -0.0113          1393          1377          1393          1377
fizzy/execute/mul256_opt0/input1_mean                             -0.0191         -0.0191            25            25            25            25
fizzy/execute/ramanujan_pi/33_runs_mean                           -0.0490         -0.0490           122           116           122           116
fizzy/execute/sha1/512_bytes_rounds_1_mean                        -0.0117         -0.0117            84            83            84            83
fizzy/execute/sha1/512_bytes_rounds_16_mean                       -0.0125         -0.0125          1176          1161          1176          1161
fizzy/execute/sha256/512_bytes_rounds_1_mean                      +0.0075         +0.0075            85            85            85            85
fizzy/execute/sha256/512_bytes_rounds_16_mean                     +0.0082         +0.0082          1172          1182          1172          1182
fizzy/execute/taylor_pi/pi_1000000_runs_mean                      -0.0002         -0.0002         40039         40029         40039         40029
fizzy/execute/micro/eli_interpreter/exec105_mean                  +0.0091         +0.0091             4             4             4             4
fizzy/execute/micro/factorial/20_mean                             -0.0099         -0.0099             1             1             1             1
fizzy/execute/micro/fibonacci/24_mean                             -0.0052         -0.0052          4952          4926          4952          4926
fizzy/execute/micro/host_adler32/1_mean                           +0.0052         +0.0052             0             0             0             0
fizzy/execute/micro/host_adler32/1000_mean                        -0.0040         -0.0040            29            29            29            29
fizzy/execute/micro/spinner/1_mean                                +0.0133         +0.0133             0             0             0             0
fizzy/execute/micro/spinner/1000_mean                             +0.0406         +0.0406             9             9             9             9

@chfast chfast requested review from axic and gumb0 October 5, 2020 08:29

const auto ret = func(instance, call_args, depth + 1);
// Bubble up traps
if (ret.trapped)
return false;

stack.drop(num_args);
Copy link
Member

Choose a reason for hiding this comment

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

If we want to be pedantic, shouldn't this happen before the trap?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. Trap terminates this execution, so we can keep stack unchanged.

@gumb0
Copy link
Collaborator

gumb0 commented Oct 5, 2020

Are tests possible for this?

@chfast
Copy link
Collaborator Author

chfast commented Oct 5, 2020

Are tests possible for this?

No, because stack.drop() only moves the top pointer, the arguments are still valid for the call. No functional change here.

@gumb0
Copy link
Collaborator

gumb0 commented Oct 5, 2020

How about the test to check that args remain on stack in case of trap, if want this to be intended behaviour?

@chfast
Copy link
Collaborator Author

chfast commented Oct 5, 2020

Stack is not accessible from outside.

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #573 into master will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #573   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files          62       62           
  Lines        9062     9062           
=======================================
  Hits         8903     8903           
  Misses        159      159           

@axic axic merged commit 3ec1b4d into master Oct 5, 2020
@axic axic deleted the fix_invoke branch October 5, 2020 12:05
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