Once an Opcode class is available, as documented in the PureReflectionIII
article, it becomes possible to decode opcodes with pure reflection and
build a bytecode verifier.
Who wants to build a bytecode verifier?
With an opcode class available in C++ for decaf, the size of each opcode is
known by the frame. It is possible to pass specific bytes to each opcode
subroutine. Each opcode method can have formal parameters based on the
operands expected. Instead of allowing each opcode method to access pc, the
calling method (the one with the big switch statement) can increment pc
(once) based on the size of the opcode and its operands. The evaluation of
opcodes is removed from opcode methods.
When a current frame is installed in the Opcode class (in C++) and the
address of each opcode method is added to the table, it is possible to use
an instance of the Opcode class to invoke the opcode method. It optimizes
the code almost to the level of machine code. A list of opcodes can be
exchanged (once) for an array of instances of the Opcode class. The
"interpreter" invokes the opcodes through the array, like this:
Opcode[] list = get_opcode_from_method();
int iMax = list.length;
for ( int i = 0; i < iMax; i++ ) {
list.invoke();
}
_______________________________________________
Kernel maillist - [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel