RFR: 8326692: JVMCI Local.endBci is off-by-one

Gilles Duboscq gdub at openjdk.org
Sat Mar 2 17:39:52 UTC 2024


On Sat, 2 Mar 2024 12:21:51 GMT, Guoxiong Li <gli at openjdk.org> wrote:

>> I don't see anything in [JVMS 4.7.13](https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.13) that says it cannot be 0. It basically means the LVT entry is useless (denotes a local that is never alive) but is otherwise harmless.
>> Maybe add this to the javadoc for `getEndBci()` to make the API user aware of this corner case:
>> 
>> If the value returned is less than {@link #getStartBCI}, this object denotes a local that is never live.
>
> The reason, which causes this problem, is that the `Local::endBci` includes itself instead of excluding it. But now, we can only fix the javadoc just as you suggested.
> 
>> If the value returned is less than {@link #getStartBCI}, this object denotes a local that is never live.
> 
> `a local variable` may be better to `a local` above.

I had checked the specs on that and came to the same conclusion.
I also think the current state is fine in that regards in terms of code since it just means that there is no bci where this local would be valid when checking both start and end bci.
Adding a note about that to the javadoc is a good idea. I'll do that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18087#discussion_r1510010422


More information about the hotspot-compiler-dev mailing list