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

Calculate array index offsets at compile time #2187

Merged

Conversation

iamdefinitelyahuman
Copy link
Contributor

What I did

When accessing an array in memory, calculate the offset during compile-time instead of runtime.

How I did it

In parser_utils, I added a private method _make_array_index_setter that generates different LLL if the target value is in memory and the offset is fixed. I also avoid the use of with where possible, so no values are needlessly placed on the stack.

How to verify it

Run the tests. I didn't add any new cases, but this behavior is well tested within the existing suite.

Cute Animal Picture

image

@codecov-io
Copy link

Codecov Report

Merging #2187 into master will decrease coverage by 0.79%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2187      +/-   ##
==========================================
- Coverage   85.36%   84.57%   -0.80%     
==========================================
  Files          79       83       +4     
  Lines        8250     8446     +196     
  Branches     2010     2040      +30     
==========================================
+ Hits         7043     7143     +100     
- Misses        709      802      +93     
- Partials      498      501       +3     
Impacted Files Coverage Δ
vyper/parser/parser_utils.py 81.31% <100.00%> (+0.76%) ⬆️
vyper/context/types/value/numeric.py 78.04% <0.00%> (-6.10%) ⬇️
vyper/functions/functions.py 84.40% <0.00%> (-5.34%) ⬇️
vyper/parser/expr.py 72.74% <0.00%> (-4.81%) ⬇️
vyper/ast/nodes.py 92.30% <0.00%> (-1.54%) ⬇️
vyper/opcodes.py 100.00% <0.00%> (ø)
vyper/exceptions.py 93.51% <0.00%> (ø)
vyper/__main__.py 0.00% <0.00%> (ø)
vyper/typing.py 100.00% <0.00%> (ø)

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 ce85d7d...2c4cb08. Read the comment docs.

@fubuloubu fubuloubu merged commit b1fbdcd into vyperlang:master Oct 10, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the optimize-make-setter branch December 4, 2020 10:33
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