
JVM Code Generation 181
Notice that our method prevents unnecessary branches to branches. For example, consider
the slightly more complicated condition in
if ( a > b && b > c && c > 5) {
c = a;
}
else {
c = b;
}
The JVM code produced for this targets the same exit on false, for each of the && opera-
tions:
0: iload_1
1: iload_2
2: if_icmple 18
5: iload_2
6: iload_3
7: if_icmple 18
10: iload_3
11: iconst_5
12: if_icmple 18
15: iinc 1, -1
18: ...
Branches to branches are avoided even when generating code for a deeply nested and com-
plex Boolean expression because we pass the target through nested recursive calls to this
special version of codegen().
The implementation ...