next up previous contents
Next: Descriptors Up: The Instruction Set Previous: Method Instructions

Miscellaneous Instructions

 

Besides instructions for synchronization, there is also an instruction that can be used to modify the behaviour of another instruction so that it can operate on a local variable with a wide index. This instruction has two formats: The first format takes as its operands the opcode of one of the instructions iload, fload, lload, dload, aload, istore, fstore, lstore, dstore, astore or ret and the bytes indexbyte1 and indexbyte2 to construct the wide index from.

The second format takes as its operands the iinc instruction, the bytes indexbyte1 and indexbyte2 to construct the wide index from of the local variable that has to be incremented, and the bytes constbyte1 and constbyte2 to construct a signed 16-bit constant to increment the local variable with.

The effect of the wide instruction is that these instructions can now access a local variable with a wide index and, in case of the second format, the local variable can be incremented with a larger constant.

Another instruction is the athrow instruction, used to throw exceptions. It requires the reference to the object which is an exception to be on top of the operand stack. This objectref is popped from the operand stack and is then thrown by searching if the current frame can catch the exception. If it can, the operand stack is cleared, objectref is pushed back on the operand stack and execution continues with the first instruction of the code that handles the exception. If the current frame does not contain a catch clause, that frame is popped, the frame of the invoker is reinstated, and the objectref is rethrown.

Because exceptions are objects, they can have parameters, which differs from exceptions in a programming language such as Ada where this is not possible. This means exceptions in Java can contain information just as objects can contain information.



next up previous contents
Next: Descriptors Up: The Instruction Set Previous: Method Instructions



mark@bottom.xs4all.nl