From 889aefb68be7995b92d37ad0436a7a8d952e3788 Mon Sep 17 00:00:00 2001 From: Rahil Shah Date: Thu, 25 Nov 2021 15:42:48 -0500 Subject: [PATCH] Add JNI Call to set ForceUsePreexistence Add a JNI method which can be used to set ForceUsePreexistence JIT options for DebugAgent. Signed-off-by: Rahil Shah --- .../java.base/share/classes/com/ibm/jit/JITHelpers.java | 2 ++ jcl/src/java.base/share/classes/module-info.java.extra | 1 + runtime/compiler/control/DebugAgent.cpp | 6 ++++++ runtime/compiler/control/DebugAgent.hpp | 3 +++ runtime/compiler/control/rossa.cpp | 1 + runtime/jcl/common/jithelpers.c | 8 ++++++++ runtime/jcl/exports.cmake | 1 + runtime/jcl/uma/jithelpers_jni_exports.xml | 1 + runtime/oti/j9nonbuilder.h | 1 + runtime/oti/jclprots.h | 1 + 10 files changed, 25 insertions(+) diff --git a/jcl/src/java.base/share/classes/com/ibm/jit/JITHelpers.java b/jcl/src/java.base/share/classes/com/ibm/jit/JITHelpers.java index 76e2945c09..1d385d9c1c 100644 --- a/jcl/src/java.base/share/classes/com/ibm/jit/JITHelpers.java +++ b/jcl/src/java.base/share/classes/com/ibm/jit/JITHelpers.java @@ -1178,6 +1178,8 @@ public int getInitialLockword(int flags, int reservedCounter, int cancelCounter) public static native void dispatchVirtual(); + public static native void setForceUsePreexistence(); + private native static final void debugAgentRun(MethodAccessor ma, Object obj, Object[] args); public static Object invoke(MethodAccessor ma, Object obj, Object[] args) throws InvocationTargetException { diff --git a/jcl/src/java.base/share/classes/module-info.java.extra b/jcl/src/java.base/share/classes/module-info.java.extra index fa76e14609..54a0c3dbd9 100644 --- a/jcl/src/java.base/share/classes/module-info.java.extra +++ b/jcl/src/java.base/share/classes/module-info.java.extra @@ -37,6 +37,7 @@ exports com.ibm.oti.util to java.management, jdk.attach, jdk.jcmd, jdk.managemen exports openj9.internal.tools.attach.target to jdk.attach, jdk.jcmd, jdk.management; exports openj9.management.internal to java.management, openj9.jvm; exports openj9.internal.management to java.management; +exports com.ibm.jit; exports jdk.internal.org.objectweb.asm to openj9.dtfj, openj9.dtfjview; // Following allows dtfj/dtfjview modules invoke module addReads & addExports programmatically via reflection APIs exports jdk.internal.module to openj9.dtfj, openj9.dtfjview; diff --git a/runtime/compiler/control/DebugAgent.cpp b/runtime/compiler/control/DebugAgent.cpp index 37a56ff3d8..8fe89d91bf 100644 --- a/runtime/compiler/control/DebugAgent.cpp +++ b/runtime/compiler/control/DebugAgent.cpp @@ -35,6 +35,12 @@ #include #include +void +debugAgentSetForceUsePreexistence(J9VMThread* vmThread) + { + TR::Options::getCmdLineOptions()->setOption(TR_ForceUsePreexistence); + } + BOOLEAN debugAgentStart(J9VMThread* vmThread) { diff --git a/runtime/compiler/control/DebugAgent.hpp b/runtime/compiler/control/DebugAgent.hpp index 23ddc116a5..3a2410c3dd 100644 --- a/runtime/compiler/control/DebugAgent.hpp +++ b/runtime/compiler/control/DebugAgent.hpp @@ -27,6 +27,9 @@ #include "j9nonbuilder.h" #include "jni.h" +extern J9_CFUNC void +debugAgentSetForceUsePreexistence(J9VMThread* vmThread); + extern J9_CFUNC BOOLEAN debugAgentStart(J9VMThread* vmThread); diff --git a/runtime/compiler/control/rossa.cpp b/runtime/compiler/control/rossa.cpp index d459883db7..bd5d49324a 100644 --- a/runtime/compiler/control/rossa.cpp +++ b/runtime/compiler/control/rossa.cpp @@ -1820,6 +1820,7 @@ onLoadInternal( jitConfig->debugAgentRevertToInterpreter = debugAgentRevertToInterpreter; jitConfig->debugAgentRecompile = debugAgentRecompile; jitConfig->debugAgentEnd = debugAgentEnd; + jitConfig->debugAgentSetForceUsePreexistence = debugAgentSetForceUsePreexistence; jitConfig->printAOTHeaderProcessorFeatures = printAOTHeaderProcessorFeatures; diff --git a/runtime/jcl/common/jithelpers.c b/runtime/jcl/common/jithelpers.c index c22ab5860d..6375c15392 100644 --- a/runtime/jcl/common/jithelpers.c +++ b/runtime/jcl/common/jithelpers.c @@ -462,6 +462,14 @@ Java_com_ibm_jit_JITHelpers_getClassFlagsFromJ9Class32(JNIEnv *env, jobject rcv, #endif +void JNICALL +Java_com_ibm_jit_JITHelpers_setForceUsePreexistence(JNIEnv* env, jclass ignored) +{ + J9VMThread *vmThread = (J9VMThread *)env; + J9JITConfig *jitConfig = vmThread->javaVM->jitConfig; + jitConfig->debugAgentSetForceUsePreexistence(vmThread); +} + void JNICALL Java_com_ibm_jit_JITHelpers_debugAgentRun(JNIEnv *env, jclass ignored, jobject ma, jobject obj, jobjectArray args) { diff --git a/runtime/jcl/exports.cmake b/runtime/jcl/exports.cmake index 10108e336d..f76cab6550 100644 --- a/runtime/jcl/exports.cmake +++ b/runtime/jcl/exports.cmake @@ -143,6 +143,7 @@ omr_add_exports(jclse Java_com_ibm_jit_JITHelpers_objectHeaderHasBeenHashedInClass Java_com_ibm_jit_JITHelpers_objectHeaderHasBeenMovedInClass Java_com_ibm_jit_JITHelpers_debugAgentRun + Java_com_ibm_jit_JITHelpers_setForceUsePreexistence Java_com_ibm_jvm_Dump_HeapDumpImpl Java_com_ibm_jvm_Dump_JavaDumpImpl Java_com_ibm_jvm_Dump_SnapDumpImpl diff --git a/runtime/jcl/uma/jithelpers_jni_exports.xml b/runtime/jcl/uma/jithelpers_jni_exports.xml index 8ebb42a206..38ff24390c 100644 --- a/runtime/jcl/uma/jithelpers_jni_exports.xml +++ b/runtime/jcl/uma/jithelpers_jni_exports.xml @@ -126,4 +126,5 @@ + diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 7945c406de..84a744288b 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -4037,6 +4037,7 @@ typedef struct J9JITConfig { BOOLEAN (*debugAgentRevertToInterpreter)(struct J9VMThread *vmThread, J9JITExceptionTable *jitMethod); BOOLEAN (*debugAgentRecompile)(struct J9VMThread *vmThread, J9JITExceptionTable *jitMethod, IDATA lastOptIndex, IDATA lastOptSubIndex, BOOLEAN enableTracing); BOOLEAN (*debugAgentEnd)(struct J9VMThread *vmThread); + void (*debugAgentSetForceUsePreexistence)(struct J9VMThread *vmThread); #if defined(J9VM_OPT_JITSERVER) int32_t (*startJITServer)(struct J9JITConfig *jitConfig); int32_t (*waitJITServerTermination)(struct J9JITConfig *jitConfig); diff --git a/runtime/oti/jclprots.h b/runtime/oti/jclprots.h index a90342877b..db2585d51d 100644 --- a/runtime/oti/jclprots.h +++ b/runtime/oti/jclprots.h @@ -856,6 +856,7 @@ jint JNICALL Java_com_ibm_jit_JITHelpers_getModifiersFromRomClass32(JNIEnv *env, jint JNICALL Java_com_ibm_jit_JITHelpers_getClassFlagsFromJ9Class32(JNIEnv *env, jobject rcv, jint j9clazz); #endif /* J9VM_ENV_DATA64 */ void JNICALL Java_com_ibm_jit_JITHelpers_debugAgentRun(JNIEnv *env, jclass ignored, jobject ma, jobject obj, jobjectArray args); +void JNICALL Java_com_ibm_jit_JITHelpers_setForceUsePreexistence(JNIEnv *env,jclass ignored); /* crypto.c */ jboolean JNICALL Java_com_ibm_jit_Crypto_isAESSupportedByHardware(JNIEnv *env, jobject ignored);