21
21
*******************************************************************************/
22
22
23
23
#include < string.h>
24
- #include "jni.h"
25
24
#include " jcl.h"
26
25
#include " jclglob.h"
27
26
#include " jclprots.h"
28
- #include "jcl_internal.h"
27
+ #include " jni.h"
28
+ #include " omrlinkedlist.h"
29
29
#include " util_api.h"
30
+ #include " VMHelpers.hpp"
30
31
31
- /* private static native byte[][] getVMArgsImpl(); */
32
+ extern " C " {
32
33
34
+ /* private static native byte[][] getVMArgsImpl(); */
33
35
jobjectArray JNICALL
34
36
Java_com_ibm_oti_vm_VM_getVMArgsImpl (JNIEnv *env, jobject recv)
35
37
{
@@ -53,9 +55,9 @@ Java_com_ibm_oti_vm_VM_getVMArgsImpl(JNIEnv *env, jobject recv)
53
55
54
56
/* Create the result array and fill it in, including only options that begin with "-" */
55
57
56
- byteArrayClass = ( * env ) -> FindClass (env , "[B" );
58
+ byteArrayClass = env->FindClass (" [B" );
57
59
if (NULL != byteArrayClass) {
58
- result = ( * env ) -> NewObjectArray (env , resultSize , byteArrayClass , NULL );
60
+ result = env->NewObjectArray (resultSize, byteArrayClass, NULL );
59
61
if (NULL != result) {
60
62
jint writeIndex = 0 ;
61
63
@@ -64,15 +66,15 @@ Java_com_ibm_oti_vm_VM_getVMArgsImpl(JNIEnv *env, jobject recv)
64
66
65
67
if (' -' == optionString[0 ]) {
66
68
jint optionLength = (jint) strlen (optionString);
67
- jbyteArray option = ( * env ) -> NewByteArray (env , optionLength );
69
+ jbyteArray option = env->NewByteArray (optionLength);
68
70
69
71
if (NULL == option) {
70
72
/* Don't use break here to avoid triggering the assertion below */
71
73
return NULL ;
72
74
}
73
- ( * env ) -> SetByteArrayRegion (env , option , 0 , optionLength , (jbyte * )optionString );
74
- ( * env ) -> SetObjectArrayElement (env , result , writeIndex , option );
75
- ( * env ) -> DeleteLocalRef (env , option );
75
+ env->SetByteArrayRegion (option, 0 , optionLength, (jbyte*)optionString);
76
+ env->SetObjectArrayElement (result, writeIndex, option);
77
+ env->DeleteLocalRef (option);
76
78
writeIndex += 1 ;
77
79
}
78
80
}
@@ -190,3 +192,30 @@ Java_com_ibm_oti_vm_VM_isJVMInSingleThreadedMode(JNIEnv *env, jclass unused)
190
192
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
191
193
return result;
192
194
}
195
+
196
+ #if defined(J9VM_OPT_JFR)
197
+ void JNICALL
198
+ Java_com_ibm_oti_vm_VM_triggerExecutionSample (JNIEnv *env, jclass unused) {
199
+ J9VMThread *currentThread = (J9VMThread *)env;
200
+ J9JavaVM *vm = currentThread->javaVM ;
201
+ J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions ;
202
+
203
+ vmFuncs->internalEnterVMFromJNI (currentThread);
204
+ vmFuncs->acquireExclusiveVMAccess (currentThread);
205
+
206
+ J9VMThread *walkThread = J9_LINKED_LIST_START_DO (vm->mainThread );
207
+ while (NULL != walkThread) {
208
+ if (VM_VMHelpers::threadCanRunJavaCode (walkThread)
209
+ && (currentThread != walkThread)
210
+ ) {
211
+ vmFuncs->jfrExecutionSample (currentThread, walkThread);
212
+ }
213
+ walkThread = J9_LINKED_LIST_NEXT_DO (vm->mainThread , walkThread);
214
+ }
215
+
216
+ vmFuncs->releaseExclusiveVMAccess (currentThread);
217
+ vmFuncs->internalExitVMToJNI (currentThread);
218
+ }
219
+ #endif /* defined(J9VM_OPT_JFR) */
220
+
221
+ } /* extern "C" */
0 commit comments