dstore 0x39

Pops a double into local variable (operand).

Opcode
0x39 (57)
Family
Stores
Operands
  • 1 byte: local variable index
Length
2 bytes
Operand stack
…, value (double) → …
Can throw
nothing at run time (beyond linking errors)

What it does

Pops a double into the local variable named by its operand. It is a long or double, so it takes two slots: local variables n and n+1, and two stack slots.

Slots 0 to 3 have one-byte forms (dstore_0 to dstore_3); javac uses this form for slots 4 to 255, and wide for slots above 255.

How often javac uses it

In JDK 25.0.5's java.base module, dstore appears 491 times in 53 of its 7,391 classes: 0.03% of all instructions, the 122nd most common of 194 opcodes in use. Some of the methods that use it: java.io.StreamTokenizer.nextToken, java.lang.classfile.AnnotationValue.of, java.lang.FdLibm$Acos.compute, java.lang.FdLibm$Asin.compute.

Examples

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

static double doubles(double a, double b) in Tour, compiled by javac 25
… 2 instructions before
31double x = a + b - a * b;
3dload_0 // a
4dload_2 // b
7dstore 4// x
32x = x / b % 7;
9dload 4// x
11dload_2 // b
12ddiv
13ldc2_w #14// 7
16drem
17dstore 4// x
… 7 instructions after

Open in the viewer

static double area(Shapes$Shape s) in Shapes, compiled by javac 25
… 37 instructions before
11case Rect(double w, double h) -> w * h;
96checkcast #37// Shapes$Rect
99astore 5
101aload 5
103invokevirtual #39// Shapes$Rect.w() : double
106dstore 10
108dload 10
110dstore 12
113ifeq 142
116dload 10
118dstore 6// w
… 26 instructions after

Open in the viewer

Related instructions

dload Pushes the double in local variable (operand).dstore_0 Pops a double into local variable 0.wide Makes the next instruction take a two-byte local index (and a two-byte iinc constant).

Specification: JVMS §6.5, dstore (Java SE 25).