[lworld] RFR: 8309650: [lworld] Fix mismatch inline type issue during method calls

Tobias Hartmann thartmann at openjdk.org
Wed Jun 14 07:41:23 UTC 2023


On Fri, 9 Jun 2023 08:31:29 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:

> JVM crashes with following assertion failure when running the new added
>  test case (i.e. `compiler/valhalla/inlinetypes/TestCastMismatch.java`):
> 
> 
> A fatal error has been detected by the Java Runtime Environment:
> 
>  Internal Error (/mnt/local/code/valhalla/src/hotspot/share/opto/graphKit.cpp:3414), pid=1533674, tid=1533690
>  assert(stopped() || !toop->is_inlinetypeptr() || obj->is_InlineType()) failed: should have been scalarized
> 
>  Problematic frame:
>  V [[libjvm.so](http://libjvm.so/)+0xd2c070] GraphKit::gen_checkcast(Node*, Node*, Node**, bool)+0x46c
> 
> 
> The failure happens when compiler knows the type of the `checkcast`
>  input is a value/primitive class, while the input node is not an
>  `InlineTypeNode`. Note that `InlineTypeNode` is use to represent each
>  value/primitive class instance.
> 
> In the test case, the input of cast is a method call. And from the
>  method declaration, the return type of this method is an abstract class
>  whose concrete subclass is a value class. From the method signature,
>  the compiler knows the return type is not a value class. Hence, when
>  it handles the return result of this method call, no `InlineTypeNode`
>  is generated. But when compiler handles the `checkcast` bytecode, it
>  checks the speculative type of the input, which is actually the concrete
>  class of the instance. In this case, it is the value class. So compiler
>  expects the input node is an `InlineTypeNode`.
> 
> To fix this issue, the compiler has to use the consistent type system
>  for different routines. This patch changes to use the speculative
>  type of the method call as well when handling the call's return result.
>  With this change, an `InlineTypeNode` is generated for this case after
>  the call, and the assertion pass.
> 
> Verified with `hotspot::hotspot_all, jdk::tier1,tier2,tier3, langtool::tier1`

All testing passed.

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

PR Comment: https://git.openjdk.org/valhalla/pull/860#issuecomment-1590645334


More information about the valhalla-dev mailing list