[lworld] RFR: 8375441: [lworld] C2: assert(is_instance()) failed: bad cast [v5]
Marc Chevalier
mchevalier at openjdk.org
Mon Feb 16 08:11:27 UTC 2026
> Some code added by [JDK-8372700](https://bugs.openjdk.org/browse/JDK-8372700) can compute the constant value of a field of a (flatten) element in a flat array. We get a crash when the element of the array is known to be `null`, and so the field doesn't exist.
>
> So, let's just check in `ciConstant ciFlatArray::field_value(int index, ciField* field)` whether we get a null constant before interpreting it as a `ciInstance` and trying to retrieve a field from there. This should be enough since a `ciObject` is (directly) derived by `ciNullObject`, `ciInstance` and `ciArray`. Since we are looking up a value of a flat array, an element cannot be a `ciArray` (arrays have identities and can't be contained in a flat array). After looking up whether the flat array element is null, the `obj->as_instance()` cast acts as an assert, should we ever add another derived class from `ciObject`.
>
> In case of a null array element, `field_value` simply returns an invalid `ciConstant`.
>
> Tested with tier1,tier2,tier3,hs-precheckin-comp,hs-comp-stress,valhalla-comp-stress. Looks good.
>
> Thanks,
> Marc
Marc Chevalier has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 19 additional commits since the last revision:
- Merge remote-tracking branch 'origin/lworld' into JDK-8375441.review
- Merge remote-tracking branch 'origin/lworld' into JDK-8375441.review
- Unproblem-list
- Merge remote-tracking branch 'origin/lworld' into JDK-8375441.review
- More
- Addressing more comments
- Merge
- Some reviews
- Details
- exception handling
- ... and 9 more: https://git.openjdk.org/valhalla/compare/91aea67f...90f8677d
-------------
Changes:
- all: https://git.openjdk.org/valhalla/pull/1923/files
- new: https://git.openjdk.org/valhalla/pull/1923/files/f029b762..90f8677d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=valhalla&pr=1923&range=04
- incr: https://webrevs.openjdk.org/?repo=valhalla&pr=1923&range=03-04
Stats: 4128 lines in 133 files changed: 1088 ins; 2546 del; 494 mod
Patch: https://git.openjdk.org/valhalla/pull/1923.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1923/head:pull/1923
PR: https://git.openjdk.org/valhalla/pull/1923
More information about the valhalla-dev
mailing list