-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Our VM code compiler can compiles to instructions to save a bit of memory, but further optimizations can be applied to make VM an attractive option for calling eval() repeatedly.
Our VM implementation is based on stack machine, so it should be easy to optimize arithmetic operations for constants. Something like this:
Original code for 12.5 + (23.5 * 18):
push 12.5
push 23.5
push 18
multiply
add
Optimized code (first pass):
push 12.5
push 423 // push 23.5; push 18; multiply
add
Optimized code (second pass):
push 435.5
Optimized code (third pass):
push 435.5
Because nothing is changed in the code in this pass, no further optimization will be applied.
Metadata
Metadata
Assignees
Labels
No labels