= Benchmark @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(3) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Benchmark) public class UnsafeSingleDoubleBench { static final Unsafe U; static { try { Field f = Unsafe.class.getDeclaredField("theUnsafe"); f.setAccessible(true); U = (Unsafe) f.get(null); } catch (Throwable t) { throw new IllegalStateException(t); } } long addr; long getAddr; Object reallyNull; @Setup public void setup() { addr = U.allocateMemory(100); getAddr = addr + 8; reallyNull = null; } @TearDown public void tearDown() { U.freeMemory(addr); } @Benchmark public int single() { return U.getInt(getAddr); } @Benchmark public int double_constant() { return U.getInt(null, getAddr); } @Benchmark public int double_nonConstant() { return U.getInt(reallyNull, getAddr); } } == C2: Benchmark Mode Cnt Score Error Units UnsafeSingleDoubleBench.get_double_constant avgt 15 2.002 ± 0.063 ns/op UnsafeSingleDoubleBench.get_double_nonConstant avgt 15 2.243 ± 0.011 ns/op UnsafeSingleDoubleBench.get_single avgt 15 2.004 ± 0.081 ns/op UnsafeSingleDoubleBench.put_double_constant avgt 15 0.438 ± 0.001 ns/op UnsafeSingleDoubleBench.put_double_nonConstant avgt 15 0.644 ± 0.038 ns/op UnsafeSingleDoubleBench.put_single avgt 15 0.445 ± 0.020 ns/op === Generated access code: get_single: 0x00007fd0bfe8fac9: mov (%r10),%edx get_double_constant: 0x00007fd0bfe8fac9: mov (%r10),%edx get_double_nonConstant: 0x00007f0e082a4fe2: mov %r8,%r11 0x00007f0e082a4fe5: shl $0x3,%r11 0x00007f0e082a4fe9: mov (%r11,%r10,1),%edx put_single: 0x00007ff6e1151b80: movl $0x2a,(%r10) put_double_constant: 0x00007f28e5367980: movl $0x2a,(%r10) put_double_nonConstant: 0x00007f4c11367284: mov 0xc(%r8),%r11d 0x00007f4c1136728c: shl $0x3,%r11 0x00007f4c11367290: movl $0x2a,(%r11,%r10,1) In other words, as long as the "object" argument is a constant "null", we are fine with C2. == C1: Benchmark Mode Cnt Score Error Units UnsafeSingleDoubleBench.get_double_constant avgt 15 2.458 ± 0.012 ns/op UnsafeSingleDoubleBench.get_double_nonConstant avgt 15 2.521 ± 0.055 ns/op UnsafeSingleDoubleBench.get_single avgt 15 2.370 ± 0.011 ns/op UnsafeSingleDoubleBench.put_double_constant avgt 15 0.569 ± 0.002 ns/op UnsafeSingleDoubleBench.put_double_nonConstant avgt 15 0.667 ± 0.001 ns/op UnsafeSingleDoubleBench.put_single avgt 15 0.502 ± 0.007 ns/op === Generated access code: get_single: 0x00007fb0e1e96d13: mov (%rsi),%esi get_double_constant: 0x00007f9e79e87d13: movabs $0x0,%rbx 0x00007f9e79e87d1d: mov (%rbx,%rsi,1),%esi get_double_nonConstant: 0x00007f29c1e94d8f: mov 0xc(%r8),%esi 0x00007f29c1e94d93: shl $0x3,%rsi 0x00007f29c1e94d9b: mov (%rsi,%rbx,1),%esi put_single: 0x00007f93b5e90964: mov $0x2a,%ebx 0x00007f93b5e90969: mov %ebx,(%rdi) put_double_constant: 0x00007f39bde8efe4: movabs $0x0,%rbx 0x00007f39bde8efee: mov $0x2a,%eax 0x00007f39bde8eff3: mov %eax,(%rbx,%rdi,1) put_double_nonConstant: 0x00007fd9f1e8e060: mov 0xc(%r8),%edi 0x00007fd9f1e8e064: shl $0x3,%rdi 0x00007fd9f1e8e06c: mov $0x2a,%eax 0x00007fd9f1e8e071: mov %eax,(%rdi,%rbx,1) double_nonConstant cases are not optimized, like in C2 case; but double_constant case might use a better code generation.