Unified · Split
| @@ -5,11 +5,33 @@ The DisVM project is a re-implementation of the [Dis virtual machine specificati · 4 unmodified lines | |||
| 5 | 5 | ||
| 6 | This project's intent is to take the Java approach and provide an implementation of the Dis virtual machine that is separate from any OS, including the Inferno OS. The project is written in C++ - using only the standard library where possible - and is intended to support compilation on any platform that has a conforming [C++ 11](https://en.wikipedia.org/wiki/C%2B%2B11) compiler. At present various modules written in Limbo (even the official Limbo compiler) have been verified to run successfully using this implementation. Some precompiled byte-code modules (`.dis` extension) have been provided in the [Downloads](https://bitbucket.org/linuxuser27/disvm/downloads) section. | 6 | This project's intent is to take the Java approach and provide an implementation of the Dis virtual machine that is separate from any OS, including the Inferno OS. The project is written in C++ - using only the standard library where possible - and is intended to support compilation on any platform that has a conforming [C++ 11](https://en.wikipedia.org/wiki/C%2B%2B11) compiler. At present various modules written in Limbo (even the official Limbo compiler) have been verified to run successfully using this implementation. Some precompiled byte-code modules (`.dis` extension) have been provided in the [Downloads](https://bitbucket.org/linuxuser27/disvm/downloads) section. |
| 7 | 7 | ||
| 8 | Notes: | 8 | Current Implementation Notes: |
| 9 | 9 | ||
| 10 | * Only parts of the built-in [`Sys`](http://www.vitanuova.com/inferno/man/2/sys-0intro.html) and [`Math`](http://www.vitanuova.com/inferno/man/2/math-0intro.html) modules have been written | 10 | * Only parts of the built-in [`Sys`](http://www.vitanuova.com/inferno/man/2/sys-0intro.html) and [`Math`](http://www.vitanuova.com/inferno/man/2/math-0intro.html) modules have been written |
| 11 | * The `disvm-exec` project does not support the original [`Command`](http://www.vitanuova.com/inferno/man/2/command.html) entry module since the official [`Draw`](http://www.vitanuova.com/inferno/man/2/draw-0intro.html) module is not currently supported. Instead the entry point is defined by `limbo/Exec.m`. | 11 | * The `disvm-exec` project does not support the original [`Command`](http://www.vitanuova.com/inferno/man/2/command.html) entry module since the official [`Draw`](http://www.vitanuova.com/inferno/man/2/draw-0intro.html) module is not currently supported. Instead the entry point is defined by `limbo/Exec.m`. |
| 12 | 12 | ||
| 13 | # Components | ||
| 14 | |||
| 15 | This section contains implementation details on DisVM components. | ||
| 16 | |||
| 17 | ### Garbage Collection - `src/vm/garbage_collector.cpp` | ||
| 18 | |||
| 19 | The Dis virtual machine specification described a hybrid garbage collection mechanism that utilized reference counting and a [concurrent mark-and-sweep algorithm](http://doc.cat-v.org/inferno/concurrent_gc/). The purpose of the hybrid approach was to mitigate cases where reference counting fails (e.g. cyclic references). The algorithm in this project fully implements reference counting, but at present has a naïve synchronous mark-and-sweep implementation. | ||
| 20 | |||
| 21 | It has been observed during usage of the Limbo compiler running in DisVM, that the mark-and-sweep implementation has a 20 - 25 % performance impact. This is clearly unacceptable for a modern virtual machine implementation, but was written to satisfy the current needs of the virtual machine as a learning tool. Even though the current mark-and-sweep implementation has poor performance characteristics, the original reason for it was cyclical references, so if data structures are written so these types of references don't or can't exist, reference counting will suffice. The option to disable the mark-and-sweep garbage collector is exposed as a flag on the `disvm-exec` program or if consumed directly - during instantiation of the VM. | ||
| 22 | |||
| 23 | This component can also be replaced with a custom implementation if the DisVM is consumed as a library. | ||
| 24 | |||
| 25 | ### Scheduler - `src/vm/scheduler.cpp` | ||
| 26 | |||
| 27 | The DisVM default scheduler supports utilization of 1 to 4 system threads, which is useful if parallelism is desired at runtime. The current default is for the scheduler to use 1 system thread, but this can be altered from the `disvm-exec` command line or programmatically. | ||
| 28 | |||
| 29 | Like the garbage collector, this component can also be replaced with a custom implementation. | ||
| 30 | |||
| 31 | ### Just-In-Time compilation | ||
| 32 | |||
| 33 | There is currently no support for the JIT compilation described in the Dis virtual machine specification. | ||
| 34 | |||
| 13 | # Build instructions | 35 | # Build instructions |
| 14 | 36 | ||
| 15 | Requirements | 37 | Requirements |
| @@ -31,12 +53,12 @@ Python and gyp are only needed for build file generation. · 15 unmodified lines | |||
| 31 | 53 | ||
| 32 | The source tree is as follows: | 54 | The source tree is as follows: |
| 33 | 55 | ||
| 34 | - `limbo/` - Source code written in Limbo for testing the VM | 56 | - `limbo/` - Source code written in Limbo for testing DisVM |
| 35 | - `compiler/` - Copied and slightly modified source code for the official Limbo compiler | 57 | - `compiler/` - Copied and slightly modified source code for the official Limbo compiler |
| 36 | - `src/` | 58 | - `src/` |
| 37 | - `asm/` - Library for manipulating byte code | 59 | - `asm/` - Library for manipulating byte code |
| 38 | - `include/` - Global include files | 60 | - `include/` - Global include files |
| 39 | - `exec/` - Hosting binary for VM (includes debugger) | 61 | - `exec/` - Hosting binary for DisVM (includes debugger) |
| 40 | - `vm/` - DisVM as a static library | 62 | - `vm/` - DisVM as a static library |
| 41 | 63 | ||
| 42 | 64 | ||