RFR: 8341136: Optimize StackMapGenerator::trimAndCompress

Shaojin Wen swen at openjdk.org
Sun Sep 29 02:33:44 UTC 2024


On Sat, 28 Sep 2024 17:15:43 GMT, Abdelhak Zaaim <duke at openjdk.org> wrote:

> We can improve performance by avoiding repeated array access in the loop. Instead of accessing types[i] multiple times, we cache it in a local variable. Here's the optimized version `for (int i = 0; i < count; i++) { Type current = types[i]; if (!current.isCategory2_2nd()) { if (compressed != i) { types[compressed] = current; } compressed++; } } ` This reduces overhead from multiple array lookups.

This will add one more store and one more load operation in the loop when there is no isCategory2_2nd. The classfile is optimized to be faster at startup and work better in interpreted mode or C1.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21227#issuecomment-2381076305


More information about the core-libs-dev mailing list