RFR: 8350896: Integer/Long.compress gets wrong type from CompressBitsNode::Value [v15]
Jatin Bhateja
jbhateja at openjdk.org
Wed Jul 23 02:00:05 UTC 2025
On Tue, 22 Jul 2025 14:32:57 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> I am not sure about JDK 25 approval for these changes.
>>
>> Can you do simple fix for JDK 25 as @merykitty suggested: "I suggest removing all the logic and simply returning the bottom type" ? Will it be the same complexity? Will it affect performance (and how much)?
>
> @vnkozlov Given that this is an old issue already affecting JDK 19, maybe we should just defer to JDK 26 for now and then backport to JDK 25u only once the fix is stable?
> > Hi @TobiHartmann, Can you please re-verify the latest version of patch and approve if all tests are green.
>
> Sure, I'll re-run testing. How did you find the issue that you fixed in the latest commit?
Hi @TobiHartmann , On a re-review I found this incompatibility between code and comments, its not a correctness issue but trying to constrain the result value range further :-)
Hi @vnkozlov ,
On performance front, I see 500x improvement with and without patch for following micro.
<img width="1087" height="154" alt="{C9168262-BEFD-43FE-A2DF-E935FA312A41}" src="https://github.com/user-attachments/assets/a130d9f6-2d42-406d-92b0-458e754445d7" />
<img width="940" height="119" alt="{60D7988B-3DBC-4C84-AC13-68E858360045}" src="https://github.com/user-attachments/assets/ea3529cd-1691-45de-b8f7-6ae5052df663" />
public class test_compress {
public static int micro(int src, int mask) {
src = Math.max(0, Math.min(5, src));
int cond = Integer.compress(src, mask);
if (cond < 0) {
throw new AssertionError("Unexpected control path");
}
return cond;
}
public static void main(String [] args) {
int res = 0;
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
res = micro(i, i);
}
long t1 = System.currentTimeMillis();
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
res = micro(i, i);
}
long t2 = System.currentTimeMillis();
System.out.println("[time] " + (t2-t1) + " ms [res] " + res);
}
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23947#issuecomment-3105371975
More information about the hotspot-compiler-dev
mailing list