[lworld] RFR: 8372824: [lworld] C2 hits "Unexpected argument type" assertion with --enable-preview [v4]

Quan Anh Mai qamai at openjdk.org
Wed Jan 21 15:43:31 UTC 2026


> Since I overrode `MyValue1::equals` in #1929 , `TestIntrinsics` has failed with `-XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0`. The failed test is this one:
> 
>     // Value class array creation via reflection
>     @Test
>     public void test51(int len) {
>         Object[] va = (Object[])Array.newInstance(MyValue1.class, len);
>         for (int i = 0; i < len; ++i) {
>             Asserts.assertEQ(va[i], null);
>         }
>     }
> 
> During parsing, `Array::newInstance` is not inlined, so `va` is of type `Object[]` and `va[i]` is of type `Object`. `Asserts.assertEQ` calls `va[i].equals(null)` which resolves to a `CallJavaDynamic` with its receiver of type `Object`, which is passed in as an oop. During incremental inline, It is revealed that `va` is a `MyValue1[]` and `va[i]` is of type `MyValue1`. This allows the devirtualization of `va[i]::equals`. Since this is a method call on a value object, the calling convention changes, which leads to the assert because the input is an oop.
> 
> I relaxed the assert a little bit to allow changing of the calling convention due to devirtualization.
> 
> Please take a look and leave your review, thansk a lot.

Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:

  assert that we are during devirtualization of calls

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

Changes:
  - all: https://git.openjdk.org/valhalla/pull/1935/files
  - new: https://git.openjdk.org/valhalla/pull/1935/files/147fa71e..f3f230f6

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=valhalla&pr=1935&range=03
 - incr: https://webrevs.openjdk.org/?repo=valhalla&pr=1935&range=02-03

  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/valhalla/pull/1935.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1935/head:pull/1935

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


More information about the valhalla-dev mailing list