diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index badcfeab2954e..6659ac90dd822 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -773,20 +773,6 @@ void CompileBroker::compilation_init(JavaThread* THREAD) { } #if defined(ASSERT) && COMPILER2_OR_JVMCI -// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to -// the running java application. Configured with vm options DeoptimizeObjectsALot*. -class DeoptimizeObjectsALotThread : public JavaThread { - - static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS); - void deoptimize_objects_alot_loop_single(); - void deoptimize_objects_alot_loop_all(); - -public: - DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { } - - bool is_hidden_from_external_view() const { return true; } -}; - // Entry for DeoptimizeObjectsALotThread. The threads are started in // CompileBroker::init_compiler_threads() iff DeoptimizeObjectsALot is enabled void DeoptimizeObjectsALotThread::deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS) { diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index f6067f75d32aa..ac62a20bc6ff2 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,22 @@ class nmethod; +#if defined(ASSERT) && COMPILER2_OR_JVMCI +// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to +// the running java application. Configured with vm options DeoptimizeObjectsALot*. +class DeoptimizeObjectsALotThread : public JavaThread { + + static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS); + void deoptimize_objects_alot_loop_single(); + void deoptimize_objects_alot_loop_all(); + +public: + DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { } + + bool is_hidden_from_external_view() const { return true; } +}; +#endif + // CompilerCounters // // Per Compiler Performance Counters. diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 37c4aebf58bfb..6613f30016109 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -1261,6 +1261,8 @@ declare_type(CompilerThread, JavaThread) \ declare_type(StringDedupThread, JavaThread) \ declare_type(AttachListenerThread, JavaThread) \ + DEBUG_ONLY(COMPILER2_OR_JVMCI_PRESENT( \ + declare_type(DeoptimizeObjectsALotThread, JavaThread))) \ declare_toplevel_type(OSThread) \ declare_toplevel_type(JavaFrameAnchor) \ \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java new file mode 100644 index 0000000000000..b79d43948a209 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeoptimizeObjectsALotThread.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.runtime; + +import java.io.*; + +import sun.jvm.hotspot.debugger.Address; + +public class DeoptimizeObjectsALotThread extends JavaThread { + + public DeoptimizeObjectsALotThread (Address addr) { + super(addr); + } + + public boolean isJavaThread() { return false; } + public boolean isHiddenFromExternalView() { return true; } + + public boolean isDeoptimizeObjectsALotThread() { return true; } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java index d9828b06e260c..f9f2f57892869 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,7 @@ public long allocatedBytes() { public boolean isServiceThread() { return false; } public boolean isMonitorDeflationThread() { return false; } public boolean isAttachListenerThread() { return false; } + public boolean isDeoptimizeObjectsALotThread() { return false; } /** Memory operations */ public void oopsDo(AddressVisitor oopVisitor) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index e2e0c98942557..f449fc317e1aa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,19 +155,19 @@ private static synchronized void initialize(TypeDataBase db) { virtualConstructor.addMapping("NotificationThread", NotificationThread.class); virtualConstructor.addMapping("StringDedupThread", StringDedupThread.class); virtualConstructor.addMapping("AttachListenerThread", AttachListenerThread.class); + virtualConstructor.addMapping("DeoptimizeObjectsALotThread", DeoptimizeObjectsALotThread.class); } public Threads() { _list = VMObjectFactory.newObject(ThreadsList.class, threadListField.getValue()); } - /** NOTE: this returns objects of type JavaThread, CompilerThread, - JvmtiAgentThread, NotificationThread, MonitorDeflationThread, - StringDedupThread, AttachListenerThread and ServiceThread. - The latter seven subclasses of the former. Most operations - (fetching the top frame, etc.) are only allowed to be performed on - a "pure" JavaThread. For this reason, {@link - sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been + /** NOTE: this returns objects of type JavaThread or one if its subclasses: + CompilerThread, JvmtiAgentThread, NotificationThread, MonitorDeflationThread, + StringDedupThread, AttachListenerThread, DeoptimizeObjectsALotThread and + ServiceThread. Most operations (fetching the top frame, etc.) are only + allowed to be performed on a "pure" JavaThread. For this reason, + {@link sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been changed from the definition in the VM (which returns true for all of these thread types) to return true for JavaThreads and false for the seven subclasses. FIXME: should reconsider the @@ -195,7 +195,7 @@ public JavaThread createJavaThreadWrapper(Address threadAddr) { } catch (Exception e) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + " (expected type JavaThread, CompilerThread, MonitorDeflationThread, AttachListenerThread," + - " StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e); + " DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e); } }