MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / initialize

Method initialize

src/j9Ext.cpp:24–60  ·  view source on GitHub ↗

Look for OpenJ9-specific JVM TI extension

Source from the content-addressed store, hash-verified

22
23// Look for OpenJ9-specific JVM TI extension
24bool J9Ext::initialize(jvmtiEnv* jvmti, const void* j9thread_self) {
25 _jvmti = jvmti;
26 _j9thread_self = (void* (*)())j9thread_self;
27
28 jint ext_count;
29 jvmtiExtensionFunctionInfo* ext_functions;
30 if (jvmti->GetExtensionFunctions(&ext_count, &ext_functions) == 0) {
31 for (int i = 0; i < ext_count; i++) {
32 if (strcmp(ext_functions[i].id, "com.ibm.GetOSThreadID") == 0) {
33 _GetOSThreadID = ext_functions[i].func;
34 } else if (strcmp(ext_functions[i].id, "com.ibm.GetJ9vmThread") == 0) {
35 _GetJ9vmThread = ext_functions[i].func;
36 } else if (strcmp(ext_functions[i].id, "com.ibm.GetStackTraceExtended") == 0) {
37 _GetStackTraceExtended = ext_functions[i].func;
38 } else if (strcmp(ext_functions[i].id, "com.ibm.GetAllStackTracesExtended") == 0) {
39 _GetAllStackTracesExtended = ext_functions[i].func;
40 }
41 }
42 jvmti->Deallocate((unsigned char*)ext_functions);
43 }
44
45 jvmtiExtensionEventInfo* ext_events;
46 if (jvmti->GetExtensionEvents(&ext_count, &ext_events) == 0) {
47 for (int i = 0; i < ext_count; i++) {
48 if (strcmp(ext_events[i].id, "com.ibm.InstrumentableObjectAlloc") == 0) {
49 InstrumentableObjectAlloc_id = ext_events[i].extension_event_index;
50 // If we don't set a callback now, we won't be able to enable it later in runtime
51 jvmti->SetExtensionEventCallback(InstrumentableObjectAlloc_id, (jvmtiExtensionEvent)J9ObjectSampler::JavaObjectAlloc);
52 jvmti->SetExtensionEventCallback(InstrumentableObjectAlloc_id, NULL);
53 break;
54 }
55 }
56 jvmti->Deallocate((unsigned char*)ext_events);
57 }
58
59 return _GetOSThreadID != NULL && _GetStackTraceExtended != NULL && _GetAllStackTracesExtended != NULL;
60}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected