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

Box optional-typed references to non-optional values #1542

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

turbolent
Copy link
Member

Description

While investigating #1539 I noticed that #1303 was not properly handling the case of taking a reference where the value is non-optional and the borrowed type is optional. In that case the result must be boxed properly.

Also, add interpreter tests for all cases of taking references to optionals.


  • 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

@codecov-commenter
Copy link

Codecov Report

Merging #1542 (968d955) into master (c63336c) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1542      +/-   ##
==========================================
- Coverage   74.69%   74.69%   -0.01%     
==========================================
  Files         289      289              
  Lines       55625    55640      +15     
==========================================
+ Hits        41549    41560      +11     
- Misses      12581    12585       +4     
  Partials     1495     1495              
Flag Coverage Δ
unittests 74.69% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
runtime/interpreter/interpreter_expression.go 84.24% <100.00%> (+0.33%) ⬆️
runtime/sema/simple_type.go 92.30% <0.00%> (-3.85%) ⬇️
runtime/interpreter/storage.go 71.42% <0.00%> (-1.37%) ⬇️

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 c63336c...968d955. Read the comment docs.

@github-actions
Copy link

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit c63336c
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
RuntimeResourceDictionaryValues-215.9ms ± 6%15.6ms ± 3%~(p=0.295 n=7+6)
RuntimeFungibleTokenTransfer-21.47ms ±24%1.37ms ±33%~(p=0.456 n=7+7)
ParseDeploy/byte_array-222.4ms ± 9%22.4ms ± 9%~(p=0.902 n=7+7)
ParseDeploy/decode_hex-21.42ms ± 6%1.41ms ± 6%~(p=0.710 n=7+7)
ParseFungibleToken-2219µs ± 5%219µs ± 5%~(p=0.710 n=7+7)
ParseArray-214.4ms ± 6%14.5ms ± 6%~(p=0.456 n=7+7)
ParseInfix-29.48µs ± 6%9.58µs ± 7%~(p=0.620 n=7+7)
QualifiedIdentifierCreation/One_level-23.23ns ± 6%3.23ns ± 7%~(p=0.973 n=7+7)
QualifiedIdentifierCreation/Three_levels-2168ns ± 6%170ns ± 9%~(p=0.966 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2167µs ± 5%165µs ± 4%~(p=0.731 n=7+6)
ContractInterfaceFungibleToken-247.3µs ± 6%46.8µs ± 5%~(p=0.620 n=7+7)
InterpretRecursionFib-23.11ms ± 1%3.11ms ± 3%~(p=0.628 n=6+7)
NewInterpreter/new_interpreter-21.30µs ± 4%1.31µs ± 4%~(p=0.535 n=7+7)
NewInterpreter/new_sub-interpreter-22.52µs ± 5%2.49µs ± 4%~(p=0.710 n=7+7)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%~(p=0.073 n=7+7)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.365 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.192 n=7+7)
InterpretRecursionFib-21.26MB ± 0%1.26MB ± 0%~(p=0.988 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.073 n=7+7)
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
InterpretRecursionFib-226.2k ± 0%26.2k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-240.0 ± 0%40.0 ± 0%~(all equal)
 

@turbolent turbolent merged commit f8c8b1b into master Apr 5, 2022
@turbolent turbolent deleted the bastian/fix-optional-references branch April 5, 2022 15:24
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.

3 participants