How harbour/core works
“virtual machine” scope
• The “vm” directory (src/vm) contains the core files that implement execution.
• These include files for array and object management (arrays.c, arrayshb.c), instruction execution (eval.c, evalhb.c), control flow (break.c, proc.c), memory allocation (dlmalloc.c, memvars.c), class handling (classes.c), and system routines (initexit.c, initsymb.c, thread.c, task.c).
• Although the compiler is separate (in the src/compiler folder), the output of compilation – the intermediate bytecode – is executed by the VM. Note that the virtual machine is one of the central runtime “engines” of Harbour.
Main components of the VM
• Instruction Execution Loop:
– Represent the core interpreter cycle. Include “fetch,” “decode” and “execute” stages.
– Show how the compiled Harbour bytecode, generated by the compiler, is sent into the VM.
– Files such as eval.c and evalhb.c are key here.
• Memory Management & Data Storage:
– Include components for the heap and allocation, e.g., files like dlmalloc.c.
– Show “Memory Blocks,” “Dynamic variables management” (memvars, memvclip) and symbol table handling (initsymb).
• Object and Class System:
– Highlight the submodule that handles classes and objects (classes.c, possibly parts in vm related to built-in methods).
• Execution Control & Flow:
– Represent break/loop control and task scheduling. Files such as break.c, task.c, and thread.c provide support here.
• Runtime Built-in Functions and API Layer:
• Debugging and Exception (Tracing/Error) Facilities:
• External Interfaces:
– Optionally illustrate how the VM interacts with the rest of the runtime ecosystem (for example, linking to native libraries through dynamic linking routines and communicating with the OS).
Architectural Patterns and Technologies
• That the VM design uses a “fetch–decode–execute” cycle pattern typical in interpreters.
• A note on “garbage collection / memory management” if applicable (Harbour combines manual memory tracking with auto-managed variables).
• That the VM is multi-threaded by connecting the “Thread and Task Manager” into the execution control.