dload 0x18

Pushes the double in local variable (operand).

Opcode
0x18 (24)
Family
Loads
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

Pushes the double in 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 (dload_0 to dload_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, dload appears 1,179 times in 77 of its 7,391 classes: 0.06% of all instructions, the 104th 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; dload is highlighted.

static int locals(int a, int b, int c, int d, long e, double f) in Tour, compiled by javac 25
123int g = a + b + c + d;
0iload_0 // a
1iload_1 // b
3iload_2 // c
5iload_3 // d
7istore 8// g
124return g + (int) e + (int) f;
9iload 8// g
11lload 4// e
13l2i
14iadd
15dload 6// f
17d2i
18iadd

Open in the viewer

static long mix(long a, int b, short c, byte d, double e, float f, char g, boolean h) in Numbers, compiled by javac 25
… 7 instructions before
30long r = a * b + c - d;
7iload 4// d
9i2l
10lsub
11lstore 10// r
31r ^= (long) (e * f);
13lload 10// r
15dload 5// e
17fload 7// f
19f2d
20dmul
21d2l
22lxor
23lstore 10// r
… 50 instructions after

Open in the viewer

Related instructions

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

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