Skip to content

Commit 21feef3

Browse files
committed
8348239: SA does not know about DeoptimizeObjectsALotThread
Reviewed-by: kevinw, dlong, dholmes, lmesnik
1 parent 8cc1304 commit 21feef3

File tree

6 files changed

+72
-25
lines changed

6 files changed

+72
-25
lines changed

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -773,20 +773,6 @@ void CompileBroker::compilation_init(JavaThread* THREAD) {
773773
}
774774

775775
#if defined(ASSERT) && COMPILER2_OR_JVMCI
776-
// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to
777-
// the running java application. Configured with vm options DeoptimizeObjectsALot*.
778-
class DeoptimizeObjectsALotThread : public JavaThread {
779-
780-
static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS);
781-
void deoptimize_objects_alot_loop_single();
782-
void deoptimize_objects_alot_loop_all();
783-
784-
public:
785-
DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { }
786-
787-
bool is_hidden_from_external_view() const { return true; }
788-
};
789-
790776
// Entry for DeoptimizeObjectsALotThread. The threads are started in
791777
// CompileBroker::init_compiler_threads() iff DeoptimizeObjectsALot is enabled
792778
void DeoptimizeObjectsALotThread::deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS) {

src/hotspot/share/compiler/compileBroker.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,22 @@
3939

4040
class nmethod;
4141

42+
#if defined(ASSERT) && COMPILER2_OR_JVMCI
43+
// Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to
44+
// the running java application. Configured with vm options DeoptimizeObjectsALot*.
45+
class DeoptimizeObjectsALotThread : public JavaThread {
46+
47+
static void deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS);
48+
void deoptimize_objects_alot_loop_single();
49+
void deoptimize_objects_alot_loop_all();
50+
51+
public:
52+
DeoptimizeObjectsALotThread() : JavaThread(&deopt_objs_alot_thread_entry) { }
53+
54+
bool is_hidden_from_external_view() const { return true; }
55+
};
56+
#endif
57+
4258
// CompilerCounters
4359
//
4460
// Per Compiler Performance Counters.

src/hotspot/share/runtime/vmStructs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,8 @@
12611261
declare_type(CompilerThread, JavaThread) \
12621262
declare_type(StringDedupThread, JavaThread) \
12631263
declare_type(AttachListenerThread, JavaThread) \
1264+
DEBUG_ONLY(COMPILER2_OR_JVMCI_PRESENT( \
1265+
declare_type(DeoptimizeObjectsALotThread, JavaThread))) \
12641266
declare_toplevel_type(OSThread) \
12651267
declare_toplevel_type(JavaFrameAnchor) \
12661268
\
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
package sun.jvm.hotspot.runtime;
26+
27+
import java.io.*;
28+
29+
import sun.jvm.hotspot.debugger.Address;
30+
31+
public class DeoptimizeObjectsALotThread extends JavaThread {
32+
33+
public DeoptimizeObjectsALotThread (Address addr) {
34+
super(addr);
35+
}
36+
37+
public boolean isJavaThread() { return false; }
38+
public boolean isHiddenFromExternalView() { return true; }
39+
40+
public boolean isDeoptimizeObjectsALotThread() { return true; }
41+
42+
}

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -89,6 +89,7 @@ public long allocatedBytes() {
8989
public boolean isServiceThread() { return false; }
9090
public boolean isMonitorDeflationThread() { return false; }
9191
public boolean isAttachListenerThread() { return false; }
92+
public boolean isDeoptimizeObjectsALotThread() { return false; }
9293

9394
/** Memory operations */
9495
public void oopsDo(AddressVisitor oopVisitor) {

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -155,19 +155,19 @@ private static synchronized void initialize(TypeDataBase db) {
155155
virtualConstructor.addMapping("NotificationThread", NotificationThread.class);
156156
virtualConstructor.addMapping("StringDedupThread", StringDedupThread.class);
157157
virtualConstructor.addMapping("AttachListenerThread", AttachListenerThread.class);
158+
virtualConstructor.addMapping("DeoptimizeObjectsALotThread", DeoptimizeObjectsALotThread.class);
158159
}
159160

160161
public Threads() {
161162
_list = VMObjectFactory.newObject(ThreadsList.class, threadListField.getValue());
162163
}
163164

164-
/** NOTE: this returns objects of type JavaThread, CompilerThread,
165-
JvmtiAgentThread, NotificationThread, MonitorDeflationThread,
166-
StringDedupThread, AttachListenerThread and ServiceThread.
167-
The latter seven subclasses of the former. Most operations
168-
(fetching the top frame, etc.) are only allowed to be performed on
169-
a "pure" JavaThread. For this reason, {@link
170-
sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been
165+
/** NOTE: this returns objects of type JavaThread or one if its subclasses:
166+
CompilerThread, JvmtiAgentThread, NotificationThread, MonitorDeflationThread,
167+
StringDedupThread, AttachListenerThread, DeoptimizeObjectsALotThread and
168+
ServiceThread. Most operations (fetching the top frame, etc.) are only
169+
allowed to be performed on a "pure" JavaThread. For this reason,
170+
{@link sun.jvm.hotspot.runtime.JavaThread#isJavaThread} has been
171171
changed from the definition in the VM (which returns true for
172172
all of these thread types) to return true for JavaThreads and
173173
false for the seven subclasses. FIXME: should reconsider the
@@ -195,7 +195,7 @@ public JavaThread createJavaThreadWrapper(Address threadAddr) {
195195
} catch (Exception e) {
196196
throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr +
197197
" (expected type JavaThread, CompilerThread, MonitorDeflationThread, AttachListenerThread," +
198-
" StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e);
198+
" DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e);
199199
}
200200
}
201201

0 commit comments

Comments
 (0)