Skip to content

Simplify Expr.arithmetic#1661

Merged
fubuloubu merged 6 commits into
vyperlang:masterfrom
charles-cooper:fix_strictify
Nov 11, 2019
Merged

Simplify Expr.arithmetic#1661
fubuloubu merged 6 commits into
vyperlang:masterfrom
charles-cooper:fix_strictify

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Oct 26, 2019

What I did

  • Fix Unreasonable runtime for contract with complex invalid loop range #1658
  • Always precompute both sides into an LLL reference (pre_alloc for call
    no longer needed), so generally more gas efficient if the arguments
    are more than ~2 ops
  • Remove a jumpi for mul uint256
  • Simplify type calculation / pos calculation
  • Use clamps instead of seq-assert where it's clearer
  • Use similar styles for similar output (e.g. mul uint256 looks like mul
    int128)

How I did it

Use references to break the exponential behavior in #1658

How to verify it

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@charles-cooper
Copy link
Copy Markdown
Member Author

and of course that breaks constant folding.

@jacqueswww
Copy link
Copy Markdown
Contributor

jacqueswww commented Oct 28, 2019

@charles-cooper it's not breaking constant folding, you just have to fix the test to extract the constant value differently now that the LLL output has changed (which makes sens IMO) ;)

the safe add now generates different code, so just look for the return
statement.
- Always precompute both sides into an LLL reference (pre_alloc for call
    no longer needed), so generally more gas efficient if the arguments
    are more than ~2 ops
- Remove a jumpi for mul uint256
- Simplify type calculation / pos calculation
- Use clamps instead of seq-assert where it's clearer
- Use similar styles for similar output (e.g. mul uint256 looks like mul
    int128)
@charles-cooper charles-cooper changed the title WIP use references for adding Simplify Expr.arithmetic Oct 31, 2019
adhere to pylint's draconian whitespace rules
Copy link
Copy Markdown
Contributor

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Looks cleaner, let's fix the TODOs or at least have a discussion about them

Comment thread vyper/parser/expr.py
Comment thread vyper/parser/expr.py Outdated
Copy link
Copy Markdown
Contributor

@jacqueswww jacqueswww left a comment

Choose a reason for hiding this comment

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

Looks good @charles-cooper just add the missing overflow case (or remove the comment) - and I believe we can merge this :)

@fubuloubu fubuloubu merged commit e7e26e4 into vyperlang:master Nov 11, 2019
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.

Unreasonable runtime for contract with complex invalid loop range

3 participants