Skip to content

Conversation

@adinn
Copy link
Contributor

@adinn adinn commented Aug 13, 2024

Store the throw_exception and jfr stub code as blobs in class SharedRuntime, move the generation code to the the arch-specific generator classes and update client code to access them from their new location.


Progress

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

Issue

  • JDK-8337987: Relocate jfr and throw_exception stubs from StubGenerator to SharedRuntime (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20566

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20566.diff

Webrev

Link to Webrev Comment

@adinn adinn marked this pull request as ready for review August 13, 2024 11:36
@bridgekeeper
Copy link

bridgekeeper bot commented Aug 13, 2024

👋 Welcome back adinn! A progress list of the required criteria for merging this PR into master 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 Aug 13, 2024

@adinn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8337987: Relocate jfr and throw_exception stubs from StubGenerator to SharedRuntime

Reviewed-by: fyang, kvn, yzheng

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 3 new commits pushed to the master branch:

  • 15b20cb: 8337886: java/awt/Frame/MaximizeUndecoratedTest.java fails in OEL due to a slight color difference
  • 56a007d: 8338488: Add screen capture for failure case
  • 2f7ba78: 8335150: Test LogGeneratedClassesTest.java fails on rpmbuild mock enviroment

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Aug 13, 2024

@adinn The following labels will be automatically applied to this pull request:

  • graal
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review labels Aug 13, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 13, 2024

Webrevs

@adinn
Copy link
Contributor Author

adinn commented Aug 13, 2024

/label runtime

@adinn adinn marked this pull request as draft August 13, 2024 12:38
@openjdk openjdk bot removed the rfr Pull request is ready for review label Aug 13, 2024
@openjdk
Copy link

openjdk bot commented Aug 13, 2024

@adinn
The label runtime is not a valid label.
These labels are valid:

  • graal
  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@adinn
Copy link
Contributor Author

adinn commented Aug 13, 2024

/label hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 13, 2024
@openjdk
Copy link

openjdk bot commented Aug 13, 2024

@adinn
The hotspot-runtime label was successfully added.

@adinn adinn marked this pull request as ready for review August 13, 2024 17:26
@adinn adinn marked this pull request as draft August 13, 2024 17:26
@adinn adinn marked this pull request as ready for review August 13, 2024 17:30
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 13, 2024
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Please, add description to PR

Comment on lines 4133 to 3917
// Build this early so it's available for the interpreter
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception",
CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
StubRoutines::_throw_delayed_StackOverflowError_entry = generate_throw_exception("delayed StackOverflowError throw_exception",
CAST_FROM_FN_PTR(address, SharedRuntime::throw_delayed_StackOverflowError));
CAST_FROM_FN_PTR(address, SharedRuntime::throw_delayed_StackOverflowError));
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seems correct. And I see linux-x86 (32 bits) corresponding build failure in GHA.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, that was an accidental paste while editing the code. Should be fixed now.

@RealFYang
Copy link
Member

Hi Andrew, I find that we need following add-on change for riscv:

diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
index dc89e489b24..bed24e442e8 100644
--- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
+++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
@@ -66,6 +66,12 @@

 #define __ masm->

+#ifdef PRODUCT
+#define BLOCK_COMMENT(str) /* nothing */
+#else
+#define BLOCK_COMMENT(str) __ block_comment(str)
+#endif
+
 const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size;

 class RegisterSaver {
@@ -2742,7 +2748,7 @@ static void jfr_epilogue(MacroAssembler* masm) {
 // For c2: c_rarg0 is junk, call to runtime to write a checkpoint.
 // It returns a jobject handle to the event writer.
 // The handle is dereferenced and the return value is the event writer oop.
-static RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
+RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
   enum layout {
     fp_off,
     fp_off2,
@@ -2780,7 +2786,7 @@ static RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() {
 }

 // For c2: call to return a leased buffer.
-static RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
+RuntimeStub* SharedRuntime::generate_jfr_return_lease() {
   enum layout {
     fp_off,
     fp_off2,

@adinn
Copy link
Contributor Author

adinn commented Aug 14, 2024

Hi @RealFYang

Hi Andrew, I find that we need following add-on change for riscv:

Thanks for checking. Should be fixed by the latest push.

\
static_field(StubRoutines, _verify_oop_count, jint) \
\
static_field(StubRoutines, _throw_delayed_StackOverflowError_entry, address) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the following symbol exporting

diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
index 8fdb96a3038..0e96cea6596 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
@@ -50,6 +50,7 @@ class CompilerToVM {
     static address SharedRuntime_deopt_blob_unpack_with_exception_in_tls;
     static address SharedRuntime_deopt_blob_uncommon_trap;
     static address SharedRuntime_polling_page_return_handler;
+    static address SharedRuntime_throw_delayed_StackOverflowError_blob;
 
     static address nmethod_entry_barrier;
     static int thread_disarmed_guard_value_offset;
diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
index 2116133e56e..27031bf55fe 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
@@ -68,6 +68,7 @@ address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack;
 address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack_with_exception_in_tls;
 address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap;
 address CompilerToVM::Data::SharedRuntime_polling_page_return_handler;
+address CompilerToVM::Data::SharedRuntime_throw_delayed_StackOverflowError_blob;
 
 address CompilerToVM::Data::nmethod_entry_barrier;
 int CompilerToVM::Data::thread_disarmed_guard_value_offset;
@@ -158,6 +159,7 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
   SharedRuntime_deopt_blob_unpack_with_exception_in_tls = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
   SharedRuntime_deopt_blob_uncommon_trap = SharedRuntime::deopt_blob()->uncommon_trap();
   SharedRuntime_polling_page_return_handler = SharedRuntime::polling_page_return_handler_blob()->entry_point();
+  SharedRuntime_throw_delayed_StackOverflowError_blob = SharedRuntime::throw_delayed_StackOverflowError_entry();
 
   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
   if (bs_nm != nullptr) {
diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
index 130f1032e65..e0c56ccabee 100644
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
@@ -68,6 +68,8 @@
   static_field(CompilerToVM::Data,             SharedRuntime_deopt_blob_uncommon_trap, address)                                      \
   static_field(CompilerToVM::Data,             SharedRuntime_polling_page_return_handler,                                            \
                                                                                        address)                                      \
+  static_field(CompilerToVM::Data,             SharedRuntime_throw_delayed_StackOverflowError_blob,                                  \
+                                                                                       address)                                      \
                                                                                                                                      \
   static_field(CompilerToVM::Data,             nmethod_entry_barrier, address)                                                       \
   static_field(CompilerToVM::Data,             thread_disarmed_guard_value_offset, int)                                              \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @mur47x111. Thanks for looking at this PR.

I deleted the static field declaration from vmStructs_jvmci.cpp because I found no other mention of throw_delayed_StackOverflowError_entry under src/hotspot/share/jvmci. So, I assumed it was not being used by any JVMCI clients.

I am happy to push a patch with your proposed changes. However, I just wanted to check whether you are sure you want to use the name SharedRuntime_throw_delayed_StackOverflowError_blob in the new declarations of the CompilerToVM field.

I am asking because I when I moved the exception stubs from StubGenerator to SharedRuntime I also made a change in the way the stubs are named, stored and accessed.

The original field StubGenerator::SharedRuntime_throw_delayed_StackOverflowError_entry stored the entry point for the throw routine and was of type address. The getter method that returns the entry address simply returns the field value.

The relocated field SharedRuntime::_throw_delayed_StackOverflowError_blob stores a pointer to a RuntimeBlob, the one that contains the throw routine. That is why the field name ends with _blob not _entry. The entry address is not stored directly in class SharedRuntime. In the new code the getter method computes the address by calling the blob's entry_point() method.

So, your patch is seems to be mixing up things by using the name SharedRuntime_throw_delayed_StackOverflowError_blob for the CompilerToVM field but declaring it with type address. Would it make more sense to use the name SharedRuntime_throw_delayed_StackOverflowError_entry for this field?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, SharedRuntime_throw_delayed_StackOverflowError_entry is better. Thanks for the explanation!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I pushed a version of your patch modified to use that name.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Update is good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 15, 2024
Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

Copy link
Contributor

@mur47x111 mur47x111 left a comment

Choose a reason for hiding this comment

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

JVMCI changes look good to me. Thanks!

@adinn
Copy link
Contributor Author

adinn commented Aug 17, 2024

@vnkozlov @RealFYang @mur47x111
Thank you for the reviews!

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 17, 2024
@adinn
Copy link
Contributor Author

adinn commented Aug 19, 2024

@vnkozlov @RealFYang Could one of you please re-review. I had to merge with master to allow for a one-line include file change in sharedRuntime.cpp.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 19, 2024
@adinn
Copy link
Contributor Author

adinn commented Aug 19, 2024

@RealFYang Thanks!

@adinn
Copy link
Contributor Author

adinn commented Aug 19, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Aug 19, 2024

Going to push as commit f0374a0.
Since your change was applied there have been 3 commits pushed to the master branch:

  • 15b20cb: 8337886: java/awt/Frame/MaximizeUndecoratedTest.java fails in OEL due to a slight color difference
  • 56a007d: 8338488: Add screen capture for failure case
  • 2f7ba78: 8335150: Test LogGeneratedClassesTest.java fails on rpmbuild mock enviroment

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 19, 2024
@openjdk openjdk bot closed this Aug 19, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 19, 2024
@openjdk
Copy link

openjdk bot commented Aug 19, 2024

@adinn Pushed as commit f0374a0.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@shqking
Copy link
Contributor

shqking commented Sep 20, 2024

Hi @adinn , I encountered Client build failure on AArch64 after this commit. Could you help take a look at it when you have spare time? Thanks.

Here shows the configuration

====================================================
The existing configuration has been successfully updated in
/tmp/test123/build-release
using configure arguments '--with-debug-level=release --with-version-opt=git-fe80618bf3f --with-jvm-variants=client'.

Configuration summary:
* Name:           /tmp/test123/build-release
* Debug level:    release
* HS debug level: product
* JVM variants:   client
* JVM features:   client: 'cds compiler1 epsilongc g1gc jfr jni-check jvmti management parallelgc serialgc services shenandoahgc vm-structs zgc' 
* OpenJDK target: OS: linux, CPU architecture: aarch64, address length: 64
* Version string: 24-internal-git-fe80618bf3f (24-internal)
* Source date:    1726841146 (2024-09-20T14:05:46Z)

Tools summary:
* Boot JDK:       openjdk version "22.0.2" 2024-07-16 OpenJDK Runtime Environment (build 22.0.2+9-70) OpenJDK 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing) (at /usr/lib/jvm/jdk-22.0.2)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version 13.2.0 (at /usr/bin/gcc)
* C++ Compiler:   Version 13.2.0 (at /usr/bin/g++)

Build performance summary:
* Build jobs:     72
* Memory limit:   587068 MB

And here shows the error msg:

=== Output from failing command(s) repeated here ===
* For target hotspot_variant-client_libjvm_objs_sharedRuntime_aarch64.o:
/tmp/test123/jdk-src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp: In static member function ‘static RuntimeStub* SharedRuntime::generate_throw_exception(const char*, address)’:
/tmp/test123/jdk-src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp:2809:3: error: ‘TraceTime’ was not declared in this scope; did you mean ‘traceid’?
 2809 |   TraceTime timer(timer_msg, TRACETIME_LOG(Info, startuptime));
      |   ^~~~~~~~~
      |   traceid

* All command lines available in /tmp/test123/build-release/make-support/failure-logs.
=== End of repeated output ===

@adinn
Copy link
Contributor Author

adinn commented Sep 24, 2024

@shqking Thanks for reporting this problem. I reproduced the same failure on aarch64 and have noticed that the problem also arises on arm. File sharedRuntime_aarch64.cpp needs to include the header that declares class TraceTime as does sharedRuntime_arm.cpp.

I raised JDK-8340793 and will push a patch to fix it.

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

Labels

graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants