-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjvmSupport.h
More file actions
75 lines (58 loc) · 2.51 KB
/
Copy pathjvmSupport.h
File metadata and controls
75 lines (58 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright 2026, Datadog, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _JVMSUPPORT_H
#define _JVMSUPPORT_H
#include "mutex.h"
#include "stackFrame.h"
#include "stackWalker.h"
// Stack recovery techniques used to workaround AsyncGetCallTrace flaws.
// Can be disabled with 'safemode' option.
enum StackRecovery {
UNKNOWN_JAVA = (1 << 0),
POP_STUB = (1 << 1),
POP_METHOD = (1 << 2),
LAST_JAVA_PC = (1 << 4),
GC_TRACES = (1 << 5),
PROBE_SP = 0x100,
};
class HotspotSupport;
class JVMSupport {
enum JMethodIDLoadStats {
No_loaded, // Has not yet executed any profiling command, no jmethodIDs are loaded
Partial_loaded, // Partially loaded, see HotspotSupport::shouldPreloadJmethodIDs()
Fully_loaded // All jmethodIDs are loaded
};
friend class HotspotSupport;
static Mutex _initialization_lock;
static volatile JMethodIDLoadStats jmethodID_load_state;
// Call JVM AsyncGetCallTrace implementation
static inline void jvmAsyncGetCallTrace(ASGCT_CallTrace *frames, int max_depth, void* ucontext);
static int asyncGetCallTrace(ASGCT_CallFrame *frames, int max_depth, void* ucontext);
// J9 and Zing shared implementation, load jmethodIDs of the method unconditionally.
static bool loadMethodIDsImpl(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass);
static JMethodIDLoadStats getLoadState();
static void setLoadState(JMethodIDLoadStats state);
static bool isInitialized();
public:
// Initialize JVM support - check JVM related resources are available.
// Return false if any critical resource is not available, which should
// result in disabling profiling.
static bool initialize();
// Initializing JVM support
static void initExecution(Arguments& args, jvmtiEnv* jvmti, JNIEnv* jni);
static int walkJavaStack(StackWalkRequest& request);
static inline bool canUnwind(const StackFrame& frame, const void*& pc);
static inline bool isJitCode(const void* pc);
// Live heap usage of the JIT runtime-stubs code cache. HotSpot-only; 0 on
// other VMs (J9/Zing), which have no such cache.
static inline long long runtimeStubsMemoryUsage();
static void loadAllMethodIDsIfNeeded(jvmtiEnv *jvmti, JNIEnv *jni);
static bool loadMethodIDsIfNeeded(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass);
// Resolve method pointer to jmethodID
static inline jmethodID resolve(const void* method);
// If a class is hidden class
static inline bool isHidden(jint modifiers);
};
#endif // _JVMSUPPORT_H