εVM
An embeddable Compiler and Micro Virtual Machine
EVM is a high-performance, lightweight virtual machine platform optimized for embedding directly into diverse applications. With EVM, developers can integrate portable logic that runs within video games or low-spec embedded systems, sandbox user-generated content, or automate tasks. Its versatility making it suitable for everything from teaching systems programming to real-time applications on resource constrained architectures–delivering impressive performance even on hardware as modest as an ATmega328 or a 386 in real mode.
Familiar yet Minimal Environment
EVM's strength lies in its simplicity and compatibility. It includes a straightforward recursive-descent C compiler that enables developers to virtualize existing code seamlessly or write new code without needing to learn a custom language. The compiler produces a minimal bytecode optimized around universal processor instructions–a "lowest common denominator" design that keeps the virtual machine lean and fast. Most instructions translate nearly one-to-one with the underlying hardware, with only a few requiring multiple steps, allowing EVM to perform closer to the level of native code without the bulk of heavy JIT (Just-in-Time) compilers.
Program listing for "PRIME.C" which can be run both natively and through EVM.
char isPrime(int n)
{
int i;
if (n <= 1) {
return 0;
}
i = 2;
while (i < n) {
if (n % i == 0) {
return 0;
}
++i;
}
return 1;
}
On a scale from AST-traversing interpreters (low speed) to JIT compilers (native speed), EVM falls somewhere prior to JIT in performance. Its structure provides native code sequence threading and macro-instructions, offering developers a balance between speed and memory efficiency, with the VM core requiring under a kilobyte of memory without the C compiler.
Key Features
EVM is engineered with features that provide robust control, efficiency, and sandboxing across applications:
-
Interrupts (Events): EVM supports rapid, event-driven responses essential in dynamic applications. For instance, game developers can use interrupts to handle scenarios like enemy-projectile collisions or user menu interactions with minimal latency. Parameters can be passed to interrupts much like function calls, while also enabling clear and flexible inter-VM communication.
-
Cycle Limits: To maintain overall application performance, EVM allows developers to set cycle limits per VM instance. This prevents any single instance from consuming excess resources, ensuring smooth frame rates and responsive UI even under heavy load.
-
Memory Protection: EVM offers memory sandboxing at the addressing level, allowing VMs to operate within defined memory blocks. This protects the host's memory space from unintended or undesired modifications, reducing debugging time and increasing overall stability.
-
Threads & Coroutines: Developers can create lightweight, parallelized instances of the same virtual machine that share memory but maintain independent stacks. Depending on scheduling, these instances can function as threads or coroutines, offering flexibility for applications that need concurrent operations without the overhead of host threads.
εVM in action!
EVM is an ideal choice for developers looking to add powerful, efficient logic engines to their applications without sacrificing speed or memory. Whether you're developing resource-constrained embedded software, fast-paced game mechanics, or interactive applications, EVM brings performance and portability to a range of use cases such as:
- Particle Simulator (Projectile Spawning and Behavior)
- Quadrant Zero Sample Game (Enemy AI)
Download Evaluation Sample (Win2K+/ReactOS): [TSetup.zip].
Free for personal, non-commercial use.