Skip to content

Commit b36b74d

Browse files
committed
v9
1 parent 42ef245 commit b36b74d

7 files changed

Lines changed: 24 additions & 96 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright The async-profiler authors
3+
* Copyright 2026 Datadog, Inc
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef _HOTSPOT_HOTSPOTTHREADSTATE_H
8+
#define _HOTSPOT_HOTSPOTTHREADSTATE_H
9+
10+
#include "threadState.h"
11+
12+
ExecutionMode hotspotThreadExecutionMode();
13+
14+
#endif // _HOTSPOT_HOTSPOTTHREADSTATE_H

ddprof-lib/src/main/cpp/wallClock.cpp renamed to ddprof-lib/src/main/cpp/hotspot/wallClock.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/*
22
* Copyright The async-profiler authors
3-
* Copyright 2025, Datadog, Inc.
3+
* Copyright 2026, Datadog, Inc.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include "wallClock.h"
7+
#include "hotspot/wallClock.h"
8+
#include "hotspot/vmStructs.inline.h"
9+
810
#include "stackFrame.h"
911
#include "context.h"
1012
#include "debugSupport.h"
@@ -78,7 +80,7 @@ void WallClockASGCT::signalHandler(int signo, siginfo_t *siginfo, void *ucontext
7880
}
7981

8082
ExecutionEvent event;
81-
VMThread *vm_thread =(VMThread*) JVMThread::current();
83+
VMThread *vm_thread = VMThread::current();
8284
if (vm_thread != NULL && !vm_thread->isThreadAccessible()) {
8385
vm_thread = NULL;
8486
}

ddprof-lib/src/main/cpp/wallClock.h renamed to ddprof-lib/src/main/cpp/hotspot/wallClock.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
* Copyright The async-profiler authors
3-
* Copyright 2025, Datadog, Inc.
3+
* Copyright 2026, Datadog, Inc.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#ifndef _WALLCLOCK_H
8-
#define _WALLCLOCK_H
7+
#ifndef _HOTSPOT_WALLCLOCK_H
8+
#define _HOTSPOT_WALLCLOCK_H
99

1010
#include "engine.h"
1111
#include "os.h"
@@ -154,4 +154,4 @@ class WallClockASGCT : public BaseWallClock {
154154
}
155155
};
156156

157-
#endif // _WALLCLOCK_H
157+
#endif // _HOTSPOT_WALLCLOCK_H

ddprof-lib/src/main/cpp/javaApi.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "thread.h"
3030
#include "tsc.h"
3131
#include "vmEntry.h"
32-
#include "wallClock.h"
3332
#include <errno.h>
3433
#include <fstream>
3534
#include <sstream>

ddprof-lib/src/main/cpp/profiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "thread.h"
2929
#include "tsc.h"
3030
#include "hotspot/vmStructs.h"
31-
#include "wallClock.h"
31+
#include "hotspot/wallClock.h"
3232
#include <algorithm>
3333
#include <dlfcn.h>
3434
#include <fstream>
Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef JAVA_PROFILER_LIBRARY_THREAD_STATE_H
22
#define JAVA_PROFILER_LIBRARY_THREAD_STATE_H
33

4-
#include "jvmti.h"
54

65
enum class OSThreadState : int {
76
UNKNOWN = 0,
@@ -26,48 +25,6 @@ enum class ExecutionMode : int {
2625
SYSCALL = 5
2726
};
2827

29-
static ExecutionMode convertJvmExecutionState(int state) {
30-
switch (state) {
31-
case 4:
32-
case 5:
33-
return ExecutionMode::NATIVE;
34-
case 6:
35-
case 7:
36-
return ExecutionMode::JVM;
37-
case 8:
38-
case 9:
39-
return ExecutionMode::JAVA;
40-
case 10:
41-
case 11:
42-
return ExecutionMode::SAFEPOINT;
43-
default:
44-
return ExecutionMode::UNKNOWN;
45-
}
46-
}
47-
48-
/**
49-
* Determines the execution mode from a VMThread's state.
50-
*
51-
* This function distinguishes Java threads from JVM internal threads based on their state.
52-
* Java threads have states in [_thread_in_native, _thread_max_state) range [4, 12).
53-
* JVM internal threads (GC, Compiler) have state 0 or outside this range.
54-
*
55-
* CRITICAL: This function is safe to call from signal handlers. It does NOT call VM::jni()
56-
* which would trigger __tls_get_addr for thread-local JNIEnv lookup. If the signal interrupts
57-
* during TLS initialization (e.g., ForkJoinWorkerThread startup), VM::jni() would cause
58-
* re-entrant TLS allocation and heap corruption.
59-
*
60-
* Thread states are defined in OpenJDK:
61-
* https://github.com/openjdk/jdk/blob/master/src/hotspot/share/utilities/globalDefinitions.hpp
62-
* Search for "enum JavaThreadState"
63-
*
64-
* @param vm_thread The VMThread pointer (can be null)
65-
* @return ExecutionMode::UNKNOWN if vm_thread is null,
66-
* ExecutionMode::JVM for JVM internal threads,
67-
* or the appropriate execution mode for Java threads
68-
*/
69-
class VMThread;
70-
7128
inline ExecutionMode getThreadExecutionMode();
7229

7330
#endif // JAVA_PROFILER_LIBRARY_THREAD_STATE_H

ddprof-lib/src/main/cpp/threadState.inline.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)