[lworld] Integrated: 8375441: [lworld] C2: assert(is_instance()) failed: bad cast
Marc Chevalier
mchevalier at openjdk.org
Mon Feb 16 08:29:53 UTC 2026
On Fri, 16 Jan 2026 13:31:16 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:
> 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
This pull request has now been integrated.
Changeset: 81acb627
Author: Marc Chevalier <mchevalier at openjdk.org>
URL: https://git.openjdk.org/valhalla/commit/81acb627f3471bb8b2a9281461cb0697b0df45fd
Stats: 334 lines in 14 files changed: 212 ins; 74 del; 48 mod
8375441: [lworld] C2: assert(is_instance()) failed: bad cast
Reviewed-by: qamai, thartmann
-------------
PR: https://git.openjdk.org/valhalla/pull/1923
More information about the valhalla-dev
mailing list