Next: 13 QScheme libraries
Up: QScheme Documentation
Previous: 11 Internal representation of
  Contents
Subsections
The virtual machine consists of a set of registers and a stack. See table 7
Table 7:
Virtual Machine registers
Register |
Description |
ip |
the instruction pointer |
sp |
the stack pointer |
TOS |
the top of stack register. You can consider TOS as a cache. |
cont |
the pointer to the current continuation frame. |
env |
the pointer to the current dynamic environment |
|
The stack is used both at compile-time and at run-time.
At compilation time, QScheme uses the stack as temporary workspace to generate
code. This is done to limit the number of cells created and as consequence the
number of GCs (garbage collections).
At run time, QScheme uses the stack to store function arguments, runtime environment,
catches and partial continuations.
The default stack size is 32000 pointers.. This default can be changed on the
command line.
Presently, stack overflow and underflow conditions are not caught during execution,
to avoid the related execution overhead and raise the performance of the VM
- speed matters.
The virtual machine is in the file vm2.c file.
The internal opcodes are stored in the table symbols local to the function
scm_vm() in the file vm2.c .
A pointer to this table is provided during initialization of the virtual machine.
Things to know
- during the sweep phase, all accessible cells have the gc mark bit set. Because
I don't want to mask to obtain the true type, you will have to cope with the
fact that the primitive testing the type will be fooled. (the scm_display
function is anyway GC-proof (for debugging))
- the nargs field in the code header is the number of arguments expected including
the optional argument. This means that nargs is the number of argument slots
a function will receive.
Next: 13 QScheme libraries
Up: QScheme Documentation
Previous: 11 Internal representation of
  Contents
Daniel Crettol
2000-06-12