Next: 13. QScheme libraries
Up: QScheme Documentation
Previous: 11. Internal representation of
  Contents
Subsections
The virtual machine consist 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 compile time, QScheme uses the stack as temporary workspace to generate code.
The goal of this is to limit the number of cells created and as consequence
the number of GCs.
At run time, QScheme uses the stack to store function argument, runtime environment,
catches and partial continuations.
The default stack size is 32000 pointers.. This default can be changed on the
command line.
Stack overflow and underflow condition is not tested during execution now, speed
matters.
The virtual machine is in the file vm2.c file.
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 sweep hook, all accessible cells have gc mark bit set. Because I don't
want to mask to obtain type, you will have to live with the fact that primitive
testing the type will be fooled. (the scm_display function is anyway
proof (for debugging))
- the nargs field in the code header is the number of arguments expected inclusive
the optional argument. This means that nargs is the number of argument slot
a function will receive.
Next: 13. QScheme libraries
Up: QScheme Documentation
Previous: 11. Internal representation of
  Contents
Daniel Crettol
1999-09-17