Follow up on [JDK-7018422] - JavaAgent code always interpreted during initialization phase
Serguei Spitsyn
serguei.spitsyn at oracle.com
Thu Jan 28 02:01:09 UTC 2021
Hi Nhat,
What kind of work besides simple initialization does your Java agent's premain method?
Is it possible to postpone some part of it until the VM is fully initialized?
Also, why do you think the premain method is going to be compiled after the Jit Compiler initialization order is changed?
Thanks,
Serguei
On 1/27/21, 16:52, "hotspot-dev on behalf of Nhat Nguyen" <hotspot-dev-retn at openjdk.java.net on behalf of honguye at microsoft.com> wrote:
Hi,
I'm writing this email to follow up on JDK-7018422 [1] on jdk8u, where the JavaAgent code
is always interpreted during the initialization phase on jdk8.
For background, one of our tools is currently making use of a JavaAgent whose performance
is important. As part of a performance investigation, I discovered that the CompilerBroker is
not initialized by the time the premain method runs, therefore all compilation requests for
the JavaAgent are discarded.
Fortunately, I found JDK-7018422 which describes the exact issue that we are experiencing.
However, the ticket was closed as "Not an issue" because the initialization order is changed
with the introduction of the module system.
So I would like to ask the mailing list for opinions on whether a fix for this issue can be
considered for jdk8u. I have also attached a prototype fix [2] and would appreciate any
suggestions and comments as well.
[1]: https://bugs.openjdk.java.net/browse/JDK-7018422
[2]:
---
hotspot/src/share/vm/runtime/thread.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index 330593acb3..3918f989cc 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -3634,11 +3634,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
create_vm_init_libraries();
}
- // Notify JVMTI agents that VM initialization is complete - nop if no agents.
- JvmtiExport::post_vm_initialized();
-
- JFR_ONLY(Jfr::on_vm_start();)
-
if (CleanChunkPoolAsync) {
Chunk::start_chunk_pool_cleaner_task();
}
@@ -3648,6 +3643,11 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
CompileBroker::compilation_init();
#endif
+ // Notify JVMTI agents that VM initialization is complete - nop if no agents.
+ JvmtiExport::post_vm_initialized();
+
+ JFR_ONLY(Jfr::on_vm_start();)
+
if (EnableInvokeDynamic) {
// Pre-initialize some JSR292 core classes to avoid deadlock during class loading.
// It is done after compilers are initialized, because otherwise compilations of
--
More information about the hotspot-dev
mailing list