bootstrap.rst 4.1 KB

  1. Bootstrap
  2. =========
  3. The Modelverse bootstrap procedure compiles the core library into an intitial Modelverse State image.
  4. This is a "bootable" configuration, meaning that as soon as this is passed on to the MvS, the MvS starts execution of the code stored in the bootstrap files.
  5. All information related to the bootstrap files, and the core library, which is an essential part of it, can be found in the *bootstrap/* folder.
  6. Initial Code
  7. ------------
  8. The core library consists of some files, which are merged together during compilation.
  9. This split is primarily done to allow for partial compilation.
  10. Most files are just a part of the core library, and are not discussed in detail.
  11. Initially, the file *main.alc* is found to have a *main* function, at which all tasks start execution.
  12. The contents of these bootstrap files is not discussed here, as this could in theory be anything.
  13. Note that, upon compilation of the bootstrap code, an additional *merged.alm* file is created, which is a merged version of all the code into a single file.
  14. Initial Models
  15. --------------
  16. The bootstrap folder also contains several model files, which follow a marginally different syntax.
  17. Instead of being only the definition of the model, these files additionally contain an import and export statement, referring to locations in the Modelverse.
  18. These models are not compiled to model constructors, as normally the case, but are translated to Action Language code to incrementally create the model.
  19. This generated action language is merged with the *metamodels.alt* file, which is executed upon startup of the Modelverse.
  20. Note that these initial models cannot contain action language, as the action language constructors are not fully loaded yet upon initialization of the models.
  21. If action language is desired, this should be added afterwards in the Modelverse.
  22. Bootstrap Procedure
  23. -------------------
  24. To generate the bootstrap file, the script *scripts/* does the necessary steps.
  25. In essence, the models are first compiled to action language, and all the action language is merged together into a single bootstrap file: *bootstrap.m.gz*.
  26. Additionally, *bootstrap/* adds some linking code to define all the primitives and make all of them available at the correct location within the Modelverse.
  27. Linking is also performed between the different fragments of code, as it effectively becomes a single whole.
  28. This file is gzipped, as otherwise it would become rather large: it is a complete dump of the MvS.
  29. With this bootstrap state of the MvS, the Modelverse can now start up and have all the state that is required.
  30. Note that the MvS does not write out its state changes to the file again, as this would likely become a performance bottleneck.
  31. Altering the Bootstrap File
  32. ---------------------------
  33. While users can update the files in the bootstrap folder directly, changes to these files require recompilation of the bootstrap file, after which the Modelverse has to be restarted.
  34. As all tasks are also stored within the MvS, overwriting the MvS indiscriminately would erase running tasks.
  35. Instead, the Modelverse allows users to modify the code of the bootstrap directly by overloading.
  36. While all users can manually define and execute functions that overwrite the meaning of some built-in functions, one specific model is loaded at the start of each task.
  37. This code model has to be stored in the modelverse at *models/core_library*.
  38. While this was intended to serve as a means of overwriting the bootstrap functions, any possible function can be added here.
  39. To upload the initial bootstrap file, thereby making it possible to be updated completely later on, users can execute the *scripts/* script.
  40. This script uploads the complete bootstrap as a single action language model, which then represents the functions to be executed.
  41. Note that by default the bootstrap action language code is not visible, even though this is present in the Modelverse.
  42. This was done for performance reasons: the original bootstrap code is only typed by conformance bottom for performance reasons, and adding all typing information might be wasteful.
  43. Nonetheless, if users require this functionality, the option exists.