Ahead-of-time Compiling & Boot-image
This issus is about supporting ahead-of-time compiling and building boot-images.
The Mu (including both the IR and the API) is designed for JIT compiling. Very little is specified about the ahead-of-time compiling scenario. However, real-world language VMs (such as the pypy.exe
, python.exe
or java.exe
executable images) are executable images and should be in the system-specific native image format (such as ELF). The image should contain the micro VM and the client. Preferably it should also contain AoT-compiled core libraries (such as built-in objec types, java.lang.Object
) and, in some cases (such as PyPy), the AoT-compiled interpreter and metacircular client.
This issue will discuss the following topics:
- Dynamic linking and loading (linking at start-up time by the system linker)
- Symbol resolution (determine the addresses of symbols (such as
write
))- This will revive an old idea: "load-time constants" (#47)
- Proposed load-time constants: `.const @Xxxx <@T> = EXTERN "write"
- Library dependencies (which
.so
should be loaded?)- Each ELF or Mach-O file can specify its library dependencies. But this part is extremely platform-specific.
- Could add a new top-level, but my hypothetical scenarios (1, 2) suggest external linkage should be specified in a separate linking step, like:
ld impl_supplied_entry_point.o bootimage.o -l external-lib -o executable
.
- Symbol resolution (determine the addresses of symbols (such as
- Possible extensions to the API to address boot-image building
- What should be in the boot image?
- This is very client-specific. It's determined by how the client is implemented, metacircular or not.
- How to determine what is in a boot image?
- Probably using a whitelist. The client can always record all necessary things.
- What should be in the boot image?
I will consider the following scenarios:
- VM with non-metacircular client (No active project. My obsolete js-mu was an example).
- AoT compiling Mu IR program into the boot image. (RPySOM interpreter as an RPython program)