How pharo-project/pharo-vm works
Main Components Identification
• VM Core: Represent the heart of the virtual machine (illustrated by the “extracted/vm” and “src” directories). This part includes the bytecode interpreter and the core execution loop.
• JIT Compiler: Show a separate module for the baseline JIT compiler that translates bytecode (using IR templates and abstract interpretation).
• FFI Subsystem: Represent a module wrapping the libFFI-based interface along with its support for non-blocking (worker-thread based) FFI calls. Files under “ffi” provide evidence of this component.
• Plugin Mechanism: Indicate a plug-in architecture supporting various functionalities (e.g., BitBlt, JPEG, Socket, Locale, etc.). These plugins can be shown as additional modules interacting with the core VM.
• Platform-Specific/OS Abstraction Layers: Include components (like in “src/win”, “src/unix”, “include/pharovm/”) that enable support across different operating systems. Also note Docker files and platform-specific CMake modules (found under the “cmake” directory) for build and deployment.
• Build & Configuration Infrastructure: Although not run-time components, it is beneficial to indicate the dependency relationships with the build system (CMake, Jenkins, and Docker configurations).
Relationships and Interactions
• GC as a concurrent (or interleaved) subsystem that interacts with the VM core by managing memory allocation, as well as an independent scanning mechanism.
• How FFI calls are invoked from the VM (perhaps initiated through bytecode primitives) and then handed off to the FFI subsystem, which in turn may use worker threads to execute external functions.
Architectural Patterns and Design Principles
• Layered Architecture: At the lowest level, you have platform-specific and build environment modules; above that sits the VM core with the interpreter and associated subsystems; then come the dynamic JIT and GC components, with plugins on the periphery, integrated at runtime.
• Modularity/Plug-in Interface: The clear separation of plugins (in multiple directories such as “extracted/plugins” and “plugins”) suggests a design that encourages extensibility.
• Separation of Concerns: Different directories and file groups control build configurations (CMake, Docker), platform-specific code, and actual VM operational code.