|
|
|
|
|
by acimim_ha
820 days ago
|
|
I don't really see why: public class TestJIT {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
payload();
}
}
public static int payload(int a, int b) {
return a + b;
}
}
shouldn't be optimized into a 'no-op'. The end-effect is the same. |
|
In this case it doesn't happen because to see that the entire operation is dead requires the compiler to inline payload into main, but he says he disabled inlining for that method specifically so it wouldn't happen. Recall that the goal is to see the assembly for a block of code in isolation, not demo what the JVM can do when given free reign.