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

compiler: clean up stack on branch statements #731

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Mar 6, 2020

When return or break statement is encountered inside
a for/range/switch statement, top stack items can be auxilliary.
They need to be cleaned up before returning from the function.

Related to #683 .
The only unfixed test RN is a function call used as a statement.

@codecov
Copy link

codecov bot commented Mar 6, 2020

Codecov Report

Merging #731 into master will increase coverage by 0.05%.
The diff coverage is 90.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #731      +/-   ##
==========================================
+ Coverage   66.68%   66.73%   +0.05%     
==========================================
  Files         136      136              
  Lines       12269    12299      +30     
==========================================
+ Hits         8181     8208      +27     
- Misses       3692     3695       +3     
  Partials      396      396              
Impacted Files Coverage Δ
pkg/compiler/codegen.go 87.77% <90.32%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f1e8f6...2a1402f. Read the comment docs.

@@ -834,6 +858,32 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
return c
}

func (c *codegen) pushLabel(name string, size int) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we name these in some other fashion? We have newLabel, setLabel, generateLabel, getLabelOffset already and if you're to add pushLabel, dropLabel that work with a different structure and have some different semantics, I think it'll be a mess. Something around branching and stack?

Copy link
Contributor Author

@fyrchik fyrchik Mar 10, 2020

Choose a reason for hiding this comment

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

Renamed to (push/drop)StackLabel.

When `return` or `break` statement is encountered inside
a for/range/switch statement, top stack items can be auxilliary.
They need to be cleaned up before returning from the function.
@roman-khimov roman-khimov merged commit 19f55e7 into master Mar 10, 2020
@roman-khimov roman-khimov deleted the feature/cleanstack branch March 10, 2020 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Go smart contract compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants