pop2 0x58

Discards the top two stack slots (or one long or double).

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

What it does

Discards the top two slots: either two one-slot values, or one long or double. javac uses it to throw away an unused long or double result, as in Long.parseLong(s); as a statement.

How often javac uses it

In JDK 25.0.5's java.base module, pop2 appears 130 times in 42 of its 7,391 classes: <0.01% of all instructions, the 154th most common of 194 opcodes in use. Some of the methods that use it: java.nio.Bits.tryReserveMemory, java.nio.file.CopyMoveHelper.copyToForeignTarget, java.time.chrono.AbstractChronology.resolveProlepticMonth, java.time.chrono.Chronology.epochSecond.

Example

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

static void discard() in Tour, compiled by javac 25
90Long.parseLong("1");
0ldc #41// "1"
2invokestatic #43// Long.parseLong(String) : long
91Integer.parseInt("2");
6ldc #49// "2"
8invokestatic #51// Integer.parseInt(String) : int
11pop
92}

Open in the viewer

Related instructions

pop Discards the top stack slot.dup Duplicates the top of the stack.dup_x1 Duplicates the top value and inserts it two slots down.

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