| Digital Zone | Solutions | Company | Portfolio | Contacts |
| Realité | Josephine | iDesk! | Gardemarine | Z-Cash | RoomTeem | Phantom Operating System |
|
Operations → Copyright © 2009 Dmitry Zavalishin, Contacts: Dmitry Zavalishin dz@dz.ru, +7 (916) 690 3208 Digital Zone, Moscow, Russia +7 (499) 973-23-80 |
OperationsHere are virtual machine instructions described on assembler (phantasm) language level. (Phantasm is not used anymore for system development, but is good to describe bytecode structure.) Strange stuff
No operation. This operation does completely nothing.
Prints string argument (if any), and top values of integer and object stack. Integer argument (mode) is one byte and upper bit is used internally, so don’t pass anything > 0x7F or < 0 – will be stripped. Bit 0 (& 0x01) of mode byte turns on debug instruction printing. Flow control
Unconditional jump.
Decrement top of int stack. If top of int stack is not zero — jump to label. NB! This operation does not pop integer stack!
While-style loop operator. Jump if top of int stack is zero. NB! This operation does pop integer stack!
Top of int stack (popped) is diminished by shift (signed), divided by divisor (unsigned) and is used as offset into the jump address table. If result is out of bounds, operator falls through, else jumps to selected address.
Top of object stack is popped and pushed on caller’s stack. If stack is empty null object is pushed to caller. All the exception catchers pushed in this call are discarded.
Pops numberOfArgs arguments from object stack, than pops object to call method for. Calls selected method passing given number of args. Top of integer stack of called method will have number of arguments passed. After the return exactly one object (possibly null) will be on the object stack.
Executes this (and only this!) object’s embedded method. NB – it is not possible to execute sys for other object than this because it will render its specialness visible from outside. Nothing can be guaranteed about sys. As for now all of them return something, but it is not enforced by interpreter. Though, for normal operation sys must return some object. It is possible to pass parameters to sys on int stack and receive some return there as well, which is differs from call, which passes data on object stack only. That is so because sys does not create a call frame and thus all the current stack data is available to its code. Generally, sys is used as the only content of internal class methods. Stack manipulations
Duplicate stack top – either object or int.
Delete stack top.
Copy object displacement steps down from top of object stack on top of it. Pull 0 is equal to dup. NB! Deprecated!
Load object reference from this object slot (field), push to top of stack.
Pop object reference, store to selected slot (field) of this object.
Load object from given position of object stack, push to top of stack.
Pop object, store to selected position of object stack. These two are for local variables access.
Top of stack is class object, initializers follow. New object of that class will be constructed, new object slots will be filled with n_objects objects from stack. NB!! This operation must be available to objects of classes that permit it explicitly. Corresponding checks must be added. NB!! It is better to kill it at all.
Will store on stack all of the fields of top stack object. Number of objects will be pushed to integer stack. NB!! This operation must be available to objects of classes that permit it explicitly. Corresponding checks must be added. NB!! It is better to kill it at all.
Create a new object of given (stack top) class. It does not call any constructor.
Create a copy of top stack object. Same class, same slot values.
Pop and compare two objects on object stack. If they are the same, push non-zero on integer stack, else push zero.
Pop and compare two objects on object stack. If they are the same, push zero on integer stack, else push non-zero.
Pop object. If it is a null, push non-zero on integer stack, else push zero. Exceptions
Top of stack contains class object. Exceptions of that class will be catched here and control will be passed to a label if such exception is thrown. Thrown object will be on stack top in this case. In general no other assumptions about stack state can be done.
Last pushed catcher will be deleted.
Object on top of stack is thrown down. If stack is empty - will throw special system-wide object (null?), if already on top of call stack - will kill current thread in a bad way. Constants
Push constant on stack top. Special shortcuts for 0 and 1 exist. Strings are Unicode UTF-8. MUST BE PLAIN 2-BYTE UNICODE? Summoning
Puts this object reference on stack.
Puts current thread object reference on stack.
Put null object on stack.
Push corresponding class object on stack. Integer stack operations
These operations can be used to move data between integer and object stacks.
(Not implemented!) Load object from this object slot, push to top of integer stack.
(Not implemented!) Pop value from integer stack, store to selected slot of this object.
Addition and multiplication.
Integer subtraction and division.
Bit wise operations on integer stack top.
logical operations on integer stack top. Not yet described codesNone at the moment. Stuff to implementint 64 bit It is possible that all integers and pointers will be 64 bit in phantom in a near future because persistent memory has to be as large as common hard disks are, and gigabytes are not of interest now, we need terabytes to be addressable. float 32 bit (24+8) |