Skip to content

Instruction set

exotic edited this page Feb 2, 2024 · 1 revision

Core instructions

The JVM being well... a VM has bytecode which for simplicity I'll just call instructions. Let's go over a few of the most important ones.

Opcode Type Purpose Frequency
iload General Loads a local variable of type primitive integer that was previously stored onto the stack. High
istore General Stores a primitive integer value into a local variable that can later be loaded onto the stack using it's index. High
goto Flow Jumps to a specified label. Medium
ifeq,ne Flow Jumps to a specified label based on a condition. Medium
dup General Duplicates the latest stack element. Medium
pop General Pops the latest stack element off the stack. High
ireturn General Returns an integer primitive from a method. High
iadd Arithmetic Adds the latest 2 integer primitive type stack elements together and pushes the result. Low
isub Arithmetic Subtracts the latest 2 integer primitive type stack elements and pushes the result. Low
ixor Bitwise Performs an exclusive OR operation on the 2 latest integer primitive type stack elements. Medium
invokestatic Invocation Invokes a static method from a class. High
invokevirtual Invocation Invokes a method from a class using an instance of said class. High
Clone this wiki locally