Optimise if_true, if_false, and if
Similar to (most) Smalltalk VMs we should optimise sending if
, if_true
, and if_false
to objects if the implementations of those methods match the ones implemented by default for Object, Boolean, and Nil. This would remove the need for allocating blocks and dispatching method calls for the most common conditionals.
I experimented with this locally but the resulting code was a bit of a mess. It was also a compiler optimisation (coupled with a VM instruction to execute a CompiledCode directly), which was a bit tricky to implement. Having this in a JIT instead of the compiler would probably be better since the JIT would be able to optimise more (e.g. the compiler can't optimise sending if_true
to a dynamically typed object).