Skip to content

Optimise Bind-Pop-PushB bytecode sequences #15

@rmhsilva

Description

@rmhsilva

In many cases, the following bytecode is generated by the naïve compiler:

....
 |   10 | BIND     x
 |   11 | POP
 |   12 | PUSHB    x
...

The last two instructions cancel each other out, and can be deleted entirely. This is a great simple optimisation to add!

Background reading: https://teal-book.condense9.com/vm/source-to-success-compilation.html#compile

Brief implementation thoughts:

  • in compiler.py...
  • create a function called optimise_bytecode for this and future optimisations
  • create this optimisation in remove_redundant_bytecode or something
  • call optimise_bytecode from CompileTopLevel.make_function

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions