storing directly the result in R0 instead of storing into a temporary R1 that is discarded right after.
In the case of the ternary operator, only the last ADD is patched, not the first one.
Fix: I added a lastjmp information which point to the further position in PC where a JMP lands. This optimization should not happen at the beginning of a new string of code starting from the target of a JMP.
Fix #396
Details:
The Berry parser does simple optimization in the following pattern:
The raw bytecode generated is:
but the optimizer saves the
MOVE
:storing directly the result in R0 instead of storing into a temporary R1 that is discarded right after.
In the case of the ternary operator, only the last
ADD
is patched, not the first one.Fix: I added a
lastjmp
information which point to the further position in PC where a JMP lands. This optimization should not happen at the beginning of a new string of code starting from the target of a JMP.