On Thu, 27 Jun 2024 11:14:30 GMT, Shaojin Wen <d...@openjdk.org> wrote:
> Currently, the java.util.Formatter$Conversion::isValid method is implemented > based on switch, which cannot be inlined because codeSize > 325. This problem > can be avoided by implementing it with ImmutableBitSetPredicate. > > use `-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining` to see the master > branch: > > @ 109 java.util.Formatter$Conversion::isValid (358 bytes) failed to > inline: hot method too big > > > current version > > @ 109 java.util.Formatter$Conversion::isValid (10 bytes) inline (hot) > @ 4 > jdk.internal.util.ImmutableBitSetPredicate$SmallImmutableBitSetPredicate::test > (50 bytes) inline (hot) @cl4es This is a scenario optimized using ImmutableBitSetPredicate Execute the following command, we can see that the `java.util.Formatter$Conversion.isValid` method generates a tableswitch of size 85. This large tableswitch makes the code size 358 bytes. Can C2 be optimized to use `jdk.internal.util.ImmutableBitSetPredicate$SmallImmutableBitSetPredicate`? javap -c java.util.Formatter.Conversion * byte codes of `Conversion.isValid` static boolean isValid(char); Code: 0: iload_0 1: tableswitch { // 37 to 120 37: 352 38: 356 39: 356 40: 356 41: 356 42: 356 43: 356 44: 356 45: 356 46: 356 47: 356 48: 356 49: 356 50: 356 51: 356 52: 356 53: 356 54: 356 55: 356 56: 356 57: 356 58: 356 59: 356 60: 356 61: 356 62: 356 63: 356 64: 356 65: 352 66: 352 67: 352 68: 356 69: 352 70: 356 71: 352 72: 352 73: 356 74: 356 75: 356 76: 356 77: 356 78: 356 79: 356 80: 356 81: 356 82: 356 83: 352 84: 356 85: 356 86: 356 87: 356 88: 352 89: 356 90: 356 91: 356 92: 356 93: 356 94: 356 95: 356 96: 356 97: 352 98: 352 99: 352 100: 352 101: 352 102: 352 103: 352 104: 352 105: 356 106: 356 107: 356 108: 356 109: 356 110: 352 111: 352 112: 356 113: 356 114: 356 115: 352 116: 356 117: 356 118: 356 119: 356 120: 352 default: 356 } 352: iconst_1 353: goto 357 356: iconst_0 357: ireturn ------------- PR Comment: https://git.openjdk.org/jdk/pull/19926#issuecomment-2194416329 PR Comment: https://git.openjdk.org/jdk/pull/19926#issuecomment-2194470276