Hi,

It turns out this issue has been fixed by @marc-chevalier. However, after 
thinking about this issue, I find that the pattern we use 
`cast_to_exactness(false)->as_instance_type()` to obtain the `Type` of an oop 
that subtypes a klass pointer is flawed. This is because in the `Type` lattice, 
`cast_to_exactness` works in the `ciType` dimension, while we also need to 
handle the `_refined_type` dimension when trying to perform that action.

To be specific, in this issue, we have a klass pointer of unrefined arrays that 
subtype `Object[]`, `cast_to_exactness` finds that this `TypeKlassPtr` is 
already inexact, and return it as is. This is problematic, because there is no 
instance for an unrefined array klass, and `as_instance_type` is confused. 
@marc-chevalier solves the issue by walking around this issue, and assume when 
the klass pointer is unrefined, we really mean obtaining the instance that 
subtypes the pointer, not just those with the same type.

This PR does not actually solve the issue, I just refactored it, so the use 
sites work in a more rigourous manner, we can fix the implementation after 
Valhalla being merged.

Testing:

- [ ] tier1-4,valhalla-comp-stress

Please take a look and leave your reviews, thanks a lot.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - Refactor cast_to_exactness(false)->as_instance_type()

Changes: https://git.openjdk.org/valhalla/pull/2598/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2598&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8386160
  Stats: 45 lines in 10 files changed: 13 ins; 1 del; 31 mod
  Patch: https://git.openjdk.org/valhalla/pull/2598.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2598/head:pull/2598

PR: https://git.openjdk.org/valhalla/pull/2598

Reply via email to