dup2_x1 0x5d
Duplicates the top two slots and inserts them three slots down.
- Opcode
0x5d(93)- Family
- Stack manipulation
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value3, value2, value1 → …, value2, value1, value3, value2, value1- Can throw
- nothing at run time (beyond linking errors)
What it does
The two-slot version of dup_x1: duplicates the top two slots (usually one long or double) and puts the copy beneath the next value. javac uses it when assigning a long or double to an instance field is used as a value.
How often javac uses it
In JDK 25.0.5's java.base module, dup2_x1 appears 34 times in 30 of its 7,391 classes: <0.01% of all instructions, the 175th most common of 194 opcodes in use. Some of the methods that use it: java.lang.ThreadBuilders$BaseThreadBuilder.nextThreadName, java.util.concurrent.atomic.DoubleAccumulator.<init>, java.util.concurrent.atomic.LongAccumulator.<init>, java.util.concurrent.CompletableFuture$Signaller.isReleasable.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; dup2_x1 is highlighted.
long assignLongField(long v) in Tour, compiled by javac 25Related 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_x1 (Java SE 25).