Skip to content

Commit

Permalink
Add CRIU helper VM.isJVMInSingleThreadedMode()
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Feng <fengj@ca.ibm.com>
  • Loading branch information
JasonFengJ9 committed Dec 14, 2022
1 parent ec0f0d7 commit 30d8cd2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
8 changes: 7 additions & 1 deletion jcl/src/java.base/share/classes/com/ibm/oti/vm/VM.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*[INCLUDE-IF Sidecar16]*/
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/

package com.ibm.oti.vm;
/*******************************************************************************
Expand Down Expand Up @@ -577,4 +577,10 @@ public static int markCurrentThreadAsSystem()
*/
public static native long getJ9ConstantPoolFromJ9Class(long j9clazz);

/**
* Queries whether the JVM is running in single threaded mode.
*
* @return true if JVM is in single threaded mode, false otherwise
*/
public static native boolean isJVMInSingleThreadedMode();
}
19 changes: 18 additions & 1 deletion runtime/jcl/common/com_ibm_oti_vm_VM.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2021 IBM Corp. and others
* Copyright (c) 1998, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -173,3 +173,20 @@ Java_com_ibm_oti_vm_VM_getJ9ConstantPoolFromJ9Class(JNIEnv *env, jclass unused,
*/
return (jlong)(UDATA)clazz->ramConstantPool;
}

/**
* Queries whether the JVM is running in single threaded mode.
*
* @return JNI_TRUE if JVM is in single threaded mode, JNI_FALSE otherwise
*/
jboolean JNICALL
Java_com_ibm_oti_vm_VM_isJVMInSingleThreadedMode(JNIEnv *env, jclass unused)
{
jboolean result = JNI_FALSE;
#if defined(J9VM_OPT_CRIU_SUPPORT)
if (J9_IS_SINGLE_THREAD_MODE(((J9VMThread*)env)->javaVM)) {
result = JNI_TRUE;
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
return result;
}
1 change: 1 addition & 0 deletions runtime/jcl/exports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ omr_add_exports(jclse
Java_com_ibm_oti_vm_VM_markCurrentThreadAsSystemImpl
Java_com_ibm_oti_vm_VM_setCommonData
Java_com_ibm_oti_vm_VM_getJ9ConstantPoolFromJ9Class
Java_com_ibm_oti_vm_VM_isJVMInSingleThreadedMode
Java_com_ibm_rmi_io_IIOPInputStream_00024LUDCLStackWalkOptimizer_LUDCLMarkFrame
Java_com_ibm_rmi_io_IIOPInputStream_00024LUDCLStackWalkOptimizer_LUDCLUnmarkFrameImpl
Java_com_ibm_virtualization_management_internal_GuestOS_retrieveMemoryUsageImpl
Expand Down
3 changes: 2 additions & 1 deletion runtime/jcl/uma/se7_exports.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2007, 2021 IBM Corp. and others
Copyright (c) 2007, 2022 IBM Corp. and others
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -74,4 +74,5 @@
<export name="Java_com_ibm_java_lang_management_internal_ThreadMXBeanImpl_findNativeThreadIDImpl" />
<export name="Java_com_ibm_oti_vm_VM_markCurrentThreadAsSystemImpl" />
<export name="Java_com_ibm_oti_vm_VM_getJ9ConstantPoolFromJ9Class" />
<export name="Java_com_ibm_oti_vm_VM_isJVMInSingleThreadedMode" />
</exports>
7 changes: 7 additions & 0 deletions runtime/oti/jclprots.h
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,13 @@ Java_com_ibm_oti_vm_VM_markCurrentThreadAsSystemImpl(JNIEnv *env);
*/
jlong JNICALL
Java_com_ibm_oti_vm_VM_getJ9ConstantPoolFromJ9Class(JNIEnv *env, jclass unused, jlong j9clazz);
/**
* Queries whether the JVM is running in single threaded mode.
*
* @return JNI_TRUE if JVM is in single threaded mode, JNI_FALSE otherwise
*/
jboolean JNICALL
Java_com_ibm_oti_vm_VM_isJVMInSingleThreadedMode(JNIEnv *env, jclass unused);

#if JAVA_SPEC_VERSION >= 16
jboolean JNICALL
Expand Down

0 comments on commit 30d8cd2

Please sign in to comment.