Open jurgenvinju opened 4 years ago
As you know I have good experience writing peephole optimizers directly in Rascal. One could give that a try.
I know. Unfortunately I have not made an intermediate step between flybytes asts and the ASM library on the way to bytecode. The reason is performance of the compiler. I think the disassembled example made you think otherwise. Got ya! 😇
On the way back I did use the above data type for bytecode instructions, because I really needed list matching for the decompiler and because some people only need a disassembler.
So we would have to implement the peephole optimizer against the ASM library.
If you look at what we generate for the FuncFactorial demo:
You see the consecutive
ILOAD(0), ILOAD(0)
which is much faster asILOAD(0), DUP
. A simple peephole optimizer in the back-end, written as a ASM visitor wrapper could do the trick.