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 definite field initialization analysis #1424

Merged
merged 4 commits into from
Feb 16, 2022
Merged

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Feb 15, 2022

Closes #1405

Description

MaybeJumpedOrReturned (now MaybeReturned) was used only to determine whether a branch of the function has a 'return'. Marking it as true for jumps (break and continue statements) was going against the above assumption/usage.

Reverted the change of using that flag for both jumps and returns, and continue to use it for returns only.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@SupunS SupunS added the Bugfix label Feb 15, 2022
@SupunS SupunS requested a review from turbolent as a code owner February 15, 2022 23:54
@SupunS SupunS self-assigned this Feb 15, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2022

Codecov Report

Merging #1424 (8882bb8) into master (8129778) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1424      +/-   ##
==========================================
- Coverage   73.14%   73.12%   -0.02%     
==========================================
  Files         282      282              
  Lines       39067    39065       -2     
==========================================
- Hits        28574    28568       -6     
- Misses       9050     9052       +2     
- Partials     1443     1445       +2     
Flag Coverage Δ
unittests 73.12% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/sema/check_while.go 100.00% <ø> (ø)
runtime/sema/check_assignment.go 96.38% <100.00%> (ø)
runtime/sema/check_return_statement.go 100.00% <100.00%> (ø)
runtime/sema/checker.go 89.10% <100.00%> (-0.16%) ⬇️
runtime/sema/return_info.go 100.00% <100.00%> (ø)
runtime/sema/type.go 88.28% <0.00%> (-0.13%) ⬇️
runtime/sema/simple_type.go 96.42% <0.00%> (+3.57%) ⬆️

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 8129778...8882bb8. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 16, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 8129778
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeFungibleTokenTransfer-21.50ms ±21%1.47ms ±23%~(p=0.805 n=7+7)
RuntimeResourceDictionaryValues-217.0ms ± 6%17.0ms ± 6%~(p=0.902 n=7+7)
ParseArray-216.9ms ± 7%17.8ms ±11%~(p=0.209 n=7+7)
ParseInfix-29.93µs ± 4%10.17µs ± 5%~(p=0.165 n=7+7)
ParseDeploy/byte_array-227.3ms ± 7%28.8ms ±12%~(p=0.165 n=7+7)
ParseDeploy/decode_hex-21.42ms ± 2%1.43ms ± 6%~(p=0.628 n=6+7)
ParseFungibleToken-2220µs ± 5%225µs ± 6%~(p=0.234 n=6+7)
QualifiedIdentifierCreation/Three_levels-2167ns ± 4%173ns ± 9%~(p=0.128 n=7+7)
ContractInterfaceFungibleToken-248.0µs ± 4%47.5µs ± 4%~(p=0.731 n=7+6)
CheckContractInterfaceFungibleTokenConformance-2160µs ± 9%161µs ± 3%~(p=0.383 n=7+7)
NewInterpreter/new_interpreter-21.30µs ± 2%1.30µs ± 3%~(p=0.596 n=7+7)
NewInterpreter/new_sub-interpreter-22.59µs ± 9%2.58µs ± 6%~(p=0.805 n=7+7)
InterpretRecursionFib-22.80ms ± 7%2.82ms ± 6%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-23.19ns ± 5%2.78ns ± 4%−13.02%(p=0.001 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2289kB ± 0%289kB ± 0%~(p=0.913 n=7+6)
RuntimeResourceDictionaryValues-24.06MB ± 0%4.06MB ± 0%~(p=0.535 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.192 n=7+7)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(all equal)
NewInterpreter/new_interpreter-2768B ± 0%768B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.24kB ± 0%1.24kB ± 0%~(all equal)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=0.400 n=7+6)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.65k ± 0%4.65k ± 0%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.604 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
NewInterpreter/new_interpreter-212.0 ± 0%12.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-238.0 ± 0%38.0 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
 

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice work! 👏 Glad it was an easy fix, I couldn't quite see it 🙂

Co-authored-by: Bastian Müller <[email protected]>
@SupunS SupunS merged commit 6d77ca6 into master Feb 16, 2022
@SupunS SupunS deleted the supun/improve-flow-analysis branch February 16, 2022 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Definite initialization is too conservative
3 participants