next up previous contents
Next: 3 P-Code File Format Up: HAFTA Overlord P-Code Definition Previous: 1 Introduction   Contents

Subsections

2 Virtual Machine

The p-code executes in a fairly simple RPN stack-based virtual machine.

Data constructs are stored inline with the opcodes. When a data construct is encountered, it is simply pushed onto the stack. As the opcodes are encountered they pop their arguments from the stack, do whatever calculations they're expected to do, and push their results back on the stack (if appropriate).

Other elements include the Nebuloid Dictionaries, and the P-Code Segment Table.

2.1 The Stack

It's just a stack. Nothing to see here, move along.

2.2 The Nebuloid Dictionaries

The nebuloid dictionaries map nebuloid names to nebuloid instances and their respective modules. They also contain the pid associated with the current dictionary.

There are two kinds of nebuloid dictionaries, the global dictionary (only one), and the local dictionaries (many). The global dictionary is always active and is searched after the local dictionary, of which only one may be active at any given time.

Local nebuloid dictionaries are selected using the context construct (ie: %foo ).

Nebuloids are added and removed from the dictionaries using the inst and dinst opcodes. They are accessed using the get and set opcodes.

The pid is accessed using the getpid and setpid opcodes.

2.3 The P-Code Segment Table

The P-Code Segment Table is a fairly standard jump table used for accessing various p-code segments.

2.4 The Alarm Stack

As alarm opcodes are encountered, alarm elements are inserted into the alarm stack in the order in which they will be triggered.

When an alarm is triggered, the associated element is removed from the alarm stack and executed.

2.5 The Sigusr Stacks

As signal opcodes are encountered, signal elements are appended to the end of either the sigusr1 or sigusr2 signal stacks.

When a signal is triggered, the contents of the respective signal stack are popped in order and executed.

While a signal stack is being cleared, new signal elements are appended to a temporary stack which is swapped onto the signal stack only after the signal stack has been cleared and reset.


next up previous contents
Next: 3 P-Code File Format Up: HAFTA Overlord P-Code Definition Previous: 1 Introduction   Contents
2003-01-03