fstore_2 0x45

Pops a float into local variable 2.

Opcode
0x45 (69)
Family
Stores
Operands
none
Length
1 byte
Operand stack
…, value (float) → …
Can throw
nothing at run time (beyond linking errors)
Spec name
fstore_<n>

What it does

Pops a float into local variable 2.

Slots 0 to 3 each have a one-byte instruction; the general fstore takes a one-byte slot number, and wide extends that to two bytes.

How often javac uses it

In JDK 25.0.5's java.base module, fstore_2 appears 6 times in 4 of its 7,391 classes: <0.01% of all instructions, the 190th most common of 194 opcodes in use. Some of the methods that use it: java.nio.DirectByteBuffer.getFloat, java.nio.DirectFloatBufferS.get, java.nio.DirectFloatBufferU.get, jdk.internal.util.random.RandomSupport.boundedNextFloat.

Example

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; fstore_2 is highlighted.

static float floats(float a, float b) in Tour, compiled by javac 25
… 2 instructions before
25float x = a + b - a * b;
3fload_0 // a
4fload_1 // b
7fstore_2 // x
26x = x / b % 7f;
8fload_2 // x
9fload_1 // b
10fdiv
11ldc #13// 7
13frem
14fstore_2 // x
… 9 instructions after

Open in the viewer

Related instructions

fload_2 Pushes the float in local variable 2.fstore Pops a float into local variable (operand).wide Makes the next instruction take a two-byte local index (and a two-byte iinc constant).

Specification: JVMS §6.5, fstore_<n> (Java SE 25).