[lworld+vector] RFR: 8309777: [lworld+vector] Fix re-materialize crash for vector objects with un-vectorized multi-fields during deoptimization

Xiaohong Gong xgong at openjdk.org
Tue Jun 20 06:31:00 UTC 2023


Some vector API jtreg tests crash when running on hardwares that do
 not support the relative vector species.

Here is the log:


  A fatal error has been detected by the Java Runtime Environment:

  Internal Error (valhalla/src/hotspot/share/prims/vectorSupport.cpp:317), pid=2529357, tid=2529377
  assert(loc_type == Location::oop || loc_type == Location::narrowoop) failed: expected 'oop'(2) or 'narrowoop'(9) types location but got: 3

  JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-git-62ba7fc27)
  Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-git-62ba7fc27, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
  Problematic frame:
  V [[libjvm.so](http://libjvm.so/)+0x1aed828] VectorSupport::allocate_vector_payload(InstanceKlass*, int, BasicType, frame*, RegisterMap*, ObjectValue*, JavaThread*)+0x41


The root cause is `VectorSupport::allocate_vector_payload` assumes the
 `ScopeValue` which denotes the field value generated by C2 compiler
 is a vector or an oop. But after the vector's payload is changed to be
 the `MultiField` annotated field, the non-static fields of the vector
 class is changed to be a series of fields with the same primitive type.
 In C2 compiler, operations for such multi-fields can be vectorized only
 if the running hardware supports the vector operations for the specified
 vector size. For such cases, the field value generated by C2 is a vector.
 Otherwise, the fields are the scalarized primitive type values. Hence
 the re-materizalization for such vector objects should be handled just
 like other normal objects.

To make things right when re-materializing vector objects whose fields
 are not vectorized, two parts need to be modified:

1. In c2 compiler, pass the un-vectorized multi-fields on safepoint when
 scalaring an `InlineTypeNode`. To try to vectorize the multi-fields in
 compiler, only the multi-field base is added to the klass's non-static
 field list. And the other multi-fields are saved in a secondary field list
 of their multi-field base. So if the multi-fields are not vectorized, all
 the field members should be found out and passed to the safepoint.

2. During deoptimization, re-materialize the vector objects with different
 routines based on the `ScopeValue` types. That is, go to the `VectorSupport`
 routine to re-allocate the objects from a vector value, while go to the
 normal objects re-allocation path if the field value is not a vector.

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

Commit messages:
 - 8309777: [lworld+vector] Fix re-materialize crash for vector objects with un-vectorized multi-fields during deoptimization

Changes: https://git.openjdk.org/valhalla/pull/863/files
 Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=863&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8309777
  Stats: 98 lines in 5 files changed: 63 ins; 17 del; 18 mod
  Patch: https://git.openjdk.org/valhalla/pull/863.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/863/head:pull/863

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



More information about the valhalla-dev mailing list