Skip to content

Commit

Permalink
8348239: SA does not know about DeoptimizeObjectsALotThread
Browse files Browse the repository at this point in the history
Reviewed-by: kevinw, dlong, dholmes, lmesnik
  • Loading branch information
plummercj committed Jan 27, 2025
1 parent 8cc1304 commit 21feef3
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 25 deletions.
14 changes: 0 additions & 14 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 17 additions & 1 deletion src/hotspot/share/compiler/compileBroker.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
\
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }

}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down

1 comment on commit 21feef3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.