Hi Andy! This all looks pretty exciting! Being able to get rid of all repeated ‘local-{ref,set}’ instructions sounds compelling. And it does seem to bring us one step closer to native code.
Presumably the tricky part will be the register allocator, right? Looking at the ‘countdown’ example, I wonder how much could be achieved in the stack VM by using well-chosen super-instructions: 0 (assert-nargs-ee/locals 17) 2 (br :L186) ;; -> 30 6 (local-ref 1) 8 (make-int8:0) 9 (ee?) 10 (local-set 2) ;; 12 (local-ref 2) ;; → use ‘local-set* 2’, which doesn’t pop 14 (br-if-not :L187) ;; -> 21 18 (local-ref 2) 20 (return) 21 (local-ref 1) ;; 23 (sub1) ;; → use ‘local-sub1 1’ 24 (local-set 1) ;; 26 (br :L188) ;; -> 6 30 (local-ref 0) ;; 32 (local-set 1) ;; → use ‘local-mov 0 1’ 34 (br :L188) ;; -> 6 This would amount to making some of the instructions like those of a register VM, but it could be done incrementally. Anyway, this is inspiring, and promising! Thanks, Ludo’.