dup2_x2 0x5e

Duplicates the top two slots and inserts them four slots down.

Opcode
0x5e (94)
Family
Stack manipulation
Operands
none
Length
1 byte
Operand stack
…, value4, value3, value2, value1 → …, value2, value1, value4, value3, value2, value1
Can throw
nothing at run time (beyond linking errors)

What it does

The two-slot version of dup_x2: duplicates the top two slots and puts the copy beneath the next two. javac needs it only when a long or double array element assignment is used as a value, as in return a[i] = v; on a long[]. It is the rarest instruction javac emits: one use in all of java.base.

How often javac uses it

In JDK 25.0.5's java.base module, dup2_x2 appears 1 times in 1 of its 7,391 classes: <0.01% of all instructions, the 194th most common of 194 opcodes in use. Some of the methods that use it: java.lang.FdLibm$RemPio2.__ieee754_rem_pio2.

Example

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

static long assignLongElement(long[] a, long v) in Tour, compiled by javac 25
86return a[0] = v;
0aload_0 // a
2lload_1 // v

Open in the viewer

Related instructions

pop Discards the top stack slot.pop2 Discards the top two stack slots (or one long or double).dup Duplicates the top of the stack.

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