Beam implements a transform engine that transforms beam opcodes during the load phase, that way they can implement optimizations that are independent of the OTP version.
The problem is, it's a large perl script that generates a bunch of C arrays. The loader then uses that array as a series of simple instructions in state machine. The state machine part should be easy, for the generator, we might just fork the perl script to generate rust arrays. Or implement some form of a rust codegen.
Beam implements a transform engine that transforms beam opcodes during the load phase, that way they can implement optimizations that are independent of the OTP version.
https://github.com/erlang/otp/blob/master/erts/emulator/internal_doc/beam_makeops.md
The problem is, it's a large perl script that generates a bunch of C arrays. The loader then uses that array as a series of simple instructions in state machine. The state machine part should be easy, for the generator, we might just fork the perl script to generate rust arrays. Or implement some form of a rust codegen.
https://github.com/erlang/otp/blob/49eb25c80514b1e221cc516c423bbc45ba7cc107/erts/emulator/beam/beam_load.c#L5207
This is a time consuming issue, but will yield a lot of performance improvements (optimize bif calls, instruction combining, etc).