https://github.com/tezos/optimal_stack
Compiler for stack manipulation in Michelson
https://github.com/tezos/optimal_stack
Last synced: 11 months ago
JSON representation
Compiler for stack manipulation in Michelson
- Host: GitHub
- URL: https://github.com/tezos/optimal_stack
- Owner: tezos
- Created: 2017-10-19T09:07:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-19T17:17:18.000Z (over 7 years ago)
- Last Synced: 2025-05-07T05:28:22.413Z (about 1 year ago)
- Language: OCaml
- Size: 4.88 KB
- Stars: 14
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# optimal_stack
I don't think the heap implementation is mine, but I don't remember
where it's from. Let me know if you find it so I can put the right license.
Compiler for stack manipulation in Michelson
A lot of operations in Michelson are stack manipulation operations that
decompose structures on the stack and recompose them. This is a compiler
that calculates the optimal sequence of stack operations to achieve
a given result using A\*.
This could be used as a light compilation pass for a JUMBLE macro
that would work like this:
JUMBLE (a,b):c:(d,(e,f)) => (a,f):(c,d)
Would turn a stack of the form on the left into a stack of the form
on the right. a,b,c,d,e,f are symbolic variables.
Currently, this compiler is quite slow because it attempts to find
the *optimal* solution. Here are ways in which it could be made practical
1. Instead of searching for an optimal solution among the graph
of all stack manipulations, start from a known admissible solution
and refine it using a set of rewriting rules.
2. Speed up the seach by
- introducing more theorems about minimal costs in order to improve the A\* heuristic
- adding pseudo-instructions with known costs in order to help guide the search