ladd 0x61

Adds two longs on top of the stack; pushes the result.

Opcode
0x61 (97)
Family
Arithmetic and bitwise
Operands
none
Length
1 byte
Operand stack
…, value1 (long), value2 (long) → …, result (long)
Can throw
nothing at run time (beyond linking errors)

What it does

a + b on two longs: pops b, then a, and pushes the result.

Overflow wraps around silently, as in Java. Math.addExact is the version that throws.

How often javac uses it

In JDK 25.0.5's java.base module, ladd appears 7,549 times in 395 of its 7,391 classes: 0.39% of all instructions, the 50th most common of 194 opcodes in use. Some of the methods that use it: java.io.DataOutputStream.tooLongMsg, java.io.FileInputStream.transferTo, java.io.ObjectInputStream.readObject0, java.io.ObjectInputStream$PeekInputStream.peek.

Examples

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

static long staticLong() in Increments, compiled by javac 25
18return ++counter;
0getstatic #13// Increments.counter : long
6putstatic #13// Increments.counter : long

Open in the viewer

static long longs(long a, long b) in Tour, compiled by javac 25
17long x = a + b - a * b;
0lload_0 // a
1lload_2 // b
3lload_0 // a
4lload_2 // b
7lstore 4// x
18x = x / b % 7;
9lload 4// x
… 26 instructions after

Open in the viewer

Related instructions

iadd Adds two ints on top of the stack; pushes the result.fadd Adds two floats on top of the stack; pushes the result.dadd Adds two doubles on top of the stack; pushes the result.

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