Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/coreclr/vm/amd64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,15 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod

#ifdef TARGET_UNIX
#ifdef _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb00
#define OFFSETOF__Thread__m_pInterpThreadContext 0xaf8
#else // _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0x298
#define OFFSETOF__Thread__m_pInterpThreadContext 0x290
#endif // _DEBUG
#else // TARGET_UNIX
#ifdef _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb58
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb50
#else // _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0x2e0
#define OFFSETOF__Thread__m_pInterpThreadContext 0x2d8
#endif // _DEBUG
#endif // TARGET_UNIX
ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/arm/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc
ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub))

#ifdef TARGET_UNIX
#define OFFSETOF__Thread__m_pInterpThreadContext 0x634
#define OFFSETOF__Thread__m_pInterpThreadContext 0x630
#else // TARGET_UNIX
#define OFFSETOF__Thread__m_pInterpThreadContext 0x0
#endif // TARGET_UNIX
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/arm64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod

#ifdef TARGET_UNIX
#ifdef _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb28
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb20
#else // _DEBUG
#define OFFSETOF__Thread__m_pInterpThreadContext 0x2c0
#define OFFSETOF__Thread__m_pInterpThreadContext 0x2b8
#endif // _DEBUG
#else // TARGET_UNIX
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb50
#define OFFSETOF__Thread__m_pInterpThreadContext 0xb48
#endif // TARGET_UNIX
ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext))

Expand Down
10 changes: 3 additions & 7 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ walk_managed_stack_for_threads (

// Walk the stack and write it out as an event.
if (ep_rt_coreclr_walk_managed_stack_for_thread (target_thread, current_stack_contents) && !ep_stack_contents_is_empty (current_stack_contents)) {
// Set the payload. If the GC mode on suspension > 0, then the thread was in cooperative mode.
// Even though there are some cases where this is not managed code, we assume it is managed code here.
// If the GC mode on suspension == 0 then the thread was in preemptive mode, which we qualify as external here.
uint32_t payload_data = target_thread->GetGCModeOnSuspension () ? EP_SAMPLE_PROFILER_SAMPLE_TYPE_MANAGED : EP_SAMPLE_PROFILER_SAMPLE_TYPE_EXTERNAL;
// Set the payload. If the thread is trapped for suspension, it was in cooperative mode (managed code).
// Otherwise, it was in preemptive mode (external code).
uint32_t payload_data = target_thread->HasThreadState (Thread::TS_SuspensionTrapped) ? EP_SAMPLE_PROFILER_SAMPLE_TYPE_MANAGED : EP_SAMPLE_PROFILER_SAMPLE_TYPE_EXTERNAL;

// Write the sample.
ep_write_sample_profile_event (
Expand All @@ -141,9 +140,6 @@ walk_managed_stack_for_threads (
(uint8_t *)&payload_data,
sizeof (payload_data));
}

// Reset the GC mode.
target_thread->ClearGCModeOnSuspension ();
}

ep_stack_contents_fini (current_stack_contents);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/riscv64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadLocalInfo__m_pThread == offsetof(ThreadLoc
#endif
ASMCONSTANTS_C_ASSERT(OFFSETOF__InterpMethod__pCallStub == offsetof(InterpMethod, pCallStub))

#define OFFSETOF__Thread__m_pInterpThreadContext 0xB28
#define OFFSETOF__Thread__m_pInterpThreadContext 0xB20
ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pInterpThreadContext == offsetof(Thread, m_pInterpThreadContext))

#define OFFSETOF__InterpThreadContext__pStackPointer 0x10
Expand Down
23 changes: 1 addition & 22 deletions src/coreclr/vm/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class Thread

TS_AbortRequested = 0x00000001, // Abort the thread

// unused = 0x00000002,
TS_SuspensionTrapped = 0x00000002, // Thread is trapped waiting for suspension to complete (was in managed code)
TS_GCSuspendRedirected = 0x00000004, // ThreadSuspend::SuspendRuntime has redirected the thread to suspention routine.

TS_DebugSuspendPending = 0x00000008, // Is the debugger suspending threads?
Expand Down Expand Up @@ -3584,32 +3584,11 @@ class Thread
#ifdef FEATURE_PERFTRACING
private:

// SampleProfiler thread state. This is set on suspension and cleared before restart.
// True if the thread was in cooperative mode. False if it was in preemptive when the suspension started.
Volatile<ULONG> m_gcModeOnSuspension;

// The activity ID for the current thread.
// An activity ID of zero means the thread is not executing in the context of an activity.
GUID m_activityId;

public:
bool GetGCModeOnSuspension()
{
LIMITED_METHOD_CONTRACT;
return m_gcModeOnSuspension != 0U;
}

void SaveGCModeOnSuspension()
{
LIMITED_METHOD_CONTRACT;
m_gcModeOnSuspension = m_fPreemptiveGCDisabled;
}

void ClearGCModeOnSuspension()
{
m_gcModeOnSuspension = 0;
}

LPCGUID GetActivityId() const
{
LIMITED_METHOD_CONTRACT;
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,10 @@ void Thread::RareDisablePreemptiveGC()

if (ThreadStore::IsTrappingThreadsForSuspension())
{
// Mark that this thread is trapped for suspension.
// Used by the sample profiler to determine this thread was in managed code.
SetThreadState(TS_SuspensionTrapped);

EnablePreemptiveGC();

#ifdef PROFILING_SUPPORTED
Expand Down Expand Up @@ -2177,6 +2181,9 @@ void Thread::RareDisablePreemptiveGC()
// disable preemptive gc.
m_fPreemptiveGCDisabled.StoreWithoutBarrier(1);

// Clear the suspension trapped flag now that we're resuming.
ResetThreadState(TS_SuspensionTrapped);

// check again if we have something to do
continue;
}
Expand Down
Loading