[erlang-questions] Small Erlang VM

Mikael Pettersson mikpe@REDACTED
Thu Jul 3 17:57:33 CEST 2008


Corrado Santoro writes:
 > Dear all,
 > 
 > I would like to have an erlang VM onto a small embedded system, that is 
 > an ARM7 machine, with 256K of flash and 64K or RAM. I have in mind 
 > something like the BEAM emulator and only a minimal subset of libraries 
 > and OTP system.

Forget about BEAM, for a system this small you need to design
the entire compiler/VM/interpreter from scratch for small space.
 
I assume the ARM7 has Thumb(-1) but not Thumb-2?

 > Could anyone have some suggestions or pointers for such an idea?

Off the top of my head:
- stack-based VM with implicit operands, easy to compile
  to and quite compact
- high-level VM instructions
- don't do excessive special-casing of simple instructions,
  that eats a lot of code space
- configurable set of BIFs and libraries
- maybe consider dropping some high-level language features,
  like live code upgrades
- if you're _really_ pressed for space, drop flonums
  (dropping bignums might be difficult if your implementation
  uses fixnums, but could save a lot of code space; for an
  embedded system you might be better off with a plain 32-bit
  integer type with overflow detection rather than sub-32-bit
  fixnums plus bignums, although the language wouldn't quite
  be Erlang)
- build the application into the VM, so you can store the compiled
  Erlang code in flash rather than RAM, leaving RAM used only for
  dynamically allocated data

Google. Look for ACM's PLDI and various functional programming
conference proceedings, and maybe ASPLOS as well. OOPSLA is a
load of crap nowadays, but older ones can have interesting
implementation papers. I've seen some papers on small Scheme
systems from Guy Feeley's students that be interesting.

For GC consider some mark-sweep variation with compaction,
as copying collectors use more address space.



More information about the erlang-questions mailing list