Skip to content

Conversation

@merykitty
Copy link
Member

@merykitty merykitty commented Nov 15, 2025

Hi,

This PR splits ciObjArrayKlass into ciRefArrayKlass and ciFlatArrayKlass, aligns the hierarchy with the corresponding types of the VM.

I also had to fix GraphKit::cast_to_flat_array, currently it incorrectly assumes that the cast is to an exact type, splitting into cast_to_flat_array and cast_to_flat_array_exact seems to make it clearer.

Please kindly review, thanks a lot.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JDK-8370880: [lworld] Split ciObjArrayKlass into ciRefArrayKlass and ciFlatArrayKlass (Enhancement - P2)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1739/head:pull/1739
$ git checkout pull/1739

Update a local copy of the PR:
$ git checkout pull/1739
$ git pull https://git.openjdk.org/valhalla.git pull/1739/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1739

View PR using the GUI difftool:
$ git pr show -t 1739

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1739.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 15, 2025

👋 Welcome back qamai! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 15, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 15, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 15, 2025

Webrevs

@merykitty
Copy link
Member Author

There are still a lot of refactoring to be done regarding moving elements from ciArrayKlass to ciObjArrayKlass since now it is the new common ancestor of all arrays of objects.

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this, Quan-Anh! Testing looks good except for this:

compiler/valhalla/inlinetypes/TestArrayNullMarkers.java#AVF-nAVF
-XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-DoEscapeAnalysis -XX:+AlwaysIncrementalInline

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/workspace/open/src/hotspot/share/ci/ciMetadata.hpp:105), pid=418142, tid=418159
#  assert(is_flat_array_klass()) failed: bad cast
#
# JRE version: Java(TM) SE Runtime Environment (26.0) (fastdebug build 26-jep401ea2-2025-11-17-0811237.tobias.hartmann.valhalla2)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 26-jep401ea2-2025-11-17-0811237.tobias.hartmann.valhalla2, mixed mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x1ca876a]  TypeAryPtr::flat_layout_helper() const+0x7a

Current CompileTask:
C2:2887  380 % !b        compiler.valhalla.inlinetypes.TestArrayNullMarkers::main @ 698 (2967 bytes)

Stack: [0x00007f5639cfe000,0x00007f5639dfe000],  sp=0x00007f5639df8240,  free space=1000k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1ca876a]  TypeAryPtr::flat_layout_helper() const+0x7a  (ciMetadata.hpp:105)
V  [libjvm.so+0x102a8a9]  GraphKit::get_layout_helper(Node*, int&)+0x299  (graphKit.cpp:4100)
V  [libjvm.so+0x102cd43]  GraphKit::new_array(Node*, Node*, int, Node**, bool, Node*)+0x43  (graphKit.cpp:4345)
V  [libjvm.so+0x158b712]  LibraryCallKit::inline_newArray(bool, bool)+0x242  (library_call.cpp:4904)
V  [libjvm.so+0x15b2c6a]  LibraryIntrinsic::generate(JVMState*)+0x22a  (library_call.cpp:130)
V  [libjvm.so+0xdbc50f]  Parse::do_call()+0xebf  (doCall.cpp:771)
V  [libjvm.so+0x18fee88]  Parse::do_one_bytecode()+0x4c8  (parse2.cpp:3526)
V  [libjvm.so+0x18e6007]  Parse::do_one_block()+0x357  (parse1.cpp:1703)
V  [libjvm.so+0x18e7300]  Parse::do_all_blocks()+0x130  (parse1.cpp:760)
V  [libjvm.so+0x18eae81]  Parse::Parse(JVMState*, ciMethod*, float)+0xea1  (parse1.cpp:664)
V  [libjvm.so+0x9e1975]  ParseGenerator::generate(JVMState*)+0x135  (callGenerator.cpp:99)
V  [libjvm.so+0x9e6ba3]  CallGenerator::do_late_inline_helper()+0xa03  (callGenerator.cpp:751)
V  [libjvm.so+0xbdc968]  Compile::inline_incrementally_one()+0x1b8  (compile.cpp:2614)
V  [libjvm.so+0xbde0ab]  Compile::inline_incrementally(PhaseIterGVN&)+0x38b  (compile.cpp:2707)
V  [libjvm.so+0xbe0c9e]  Compile::Optimize()+0x47e  (compile.cpp:2843)
V  [libjvm.so+0xbe45c5]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1da5  (compile.cpp:879)
V  [libjvm.so+0x9de490]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x4e0  (c2compiler.cpp:149)
V  [libjvm.so+0xbf3e20]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x780  (compileBroker.cpp:2345)
V  [libjvm.so+0xbf5680]  CompileBroker::compiler_thread_loop()+0x530  (compileBroker.cpp:1989)
V  [libjvm.so+0x118d15b]  JavaThread::thread_main_inner()+0x13b  (javaThread.cpp:772)
V  [libjvm.so+0x1c68ee6]  Thread::call_run()+0xb6  (thread.cpp:243)
V  [libjvm.so+0x1893bc8]  thread_native_entry(Thread*)+0x128  (os_linux.cpp:883)

@merykitty
Copy link
Member Author

merykitty commented Nov 17, 2025

Thanks for your testing. Unfortunately, the issue cuts pretty deep. We have multiple potential inconsistencies when dealing with _klass such as when trying to obtain a flat TypeAryPtr from a non-flat TypeAryPtr. I think it can be addressed as follow-up issues. To fix the immediate crash, I choose to fix a particular issue, that is we can only compute the _klass if we have klass_is_exact.

@merykitty
Copy link
Member Author

Too bad it seems pretty hard to walk on the thin line right now. I think it is better to tighten the type system around arrays first.

@merykitty merykitty marked this pull request as draft November 17, 2025 16:34
@openjdk openjdk bot removed the rfr Pull request is ready for review label Nov 17, 2025
@TobiHartmann
Copy link
Member

Right, I think so too, the latest version hits more issues :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants