In case of JIT VM second version will be much faster because we omit argument array creation and may perform addition using native instructions.
Even if method bytecodes contain the first version we still may perform an optimization because method graph is available during JIT compilation phase. All we need to do is to seek for SendMessage instructions that have matching selector literal and replace it with corresponding SendBinary. MarkArguments should be eliminated too.
Binary operators such as
+
or*
may be endoded in two ways.Consider the following method:
One way is to encode it using standard message passing:
Other way is to use
SendBinary
opcode:In case of JIT VM second version will be much faster because we omit argument array creation and may perform addition using native instructions.
Even if method bytecodes contain the first version we still may perform an optimization because method graph is available during JIT compilation phase. All we need to do is to seek for
SendMessage
instructions that have matching selector literal and replace it with correspondingSendBinary
.MarkArguments
should be eliminated too.