[lworld] RFR: 8375441: [lworld] C2: assert(is_instance()) failed: bad cast [v2]

Marc Chevalier mchevalier at openjdk.org
Tue Feb 3 08:09:31 UTC 2026


On Mon, 2 Feb 2026 16:36:07 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Marc Chevalier has updated the pull request incrementally with 10 additional commits since the last revision:
>> 
>>  - Details
>>  - exception handling
>>  - oops
>>  - Also cache correctly whole stable fields
>>  - fix comment
>>  - Remove debug
>>  - ShouldNotReachHere
>>  - explicit casts
>>  - Clean up
>>  - expand_constant
>
> src/hotspot/share/ci/ciInstanceKlass.cpp line 440:
> 
>> 438: }
>> 439: 
>> 440: int ciInstanceKlass::field_index_by_offset(int offset) {
> 
> Why is assert needs removing?

That allows to find the declared field containing a sub-field only for inline classes, for identity classes, an assert explodes somewhere deep inside. Indeed, for identity classes, this asserts that the offset is the offset of a declared field, regardless of the identitiness of the containing field.

I've seen the single other usage of this method is on inline classes, so it's not surprising this behavior was unnoticed. Also, the assert is running a code not very different from the implementation of this function. Overall, I wasn't convinced it's bringing a lot: the asserts on the results seems enough.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1923#discussion_r2757769840


More information about the valhalla-dev mailing list