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
6 changes: 6 additions & 0 deletions src/coreclr/src/vm/excep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7979,6 +7979,7 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo)
//
// 1) We have a valid Thread object (implies exception on managed thread)
// 2) Not a valid Thread object but the IP is in the execution engine (implies native thread within EE faulted)
// 3) The exception occurred in a GC marked location when no thread exists (i.e. reverse P/Invoke with NativeCallableAttribute).
if (pThread || fExceptionInEE)
{
if (!bIsGCMarker)
Expand Down Expand Up @@ -8066,6 +8067,11 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo)
#endif // FEATURE_EH_FUNCLETS

}
else if (bIsGCMarker)
{
_ASSERTE(pThread == NULL);
result = EXCEPTION_CONTINUE_EXECUTION;
}

SetLastError(dwLastError);

Expand Down
12 changes: 11 additions & 1 deletion src/coreclr/src/vm/gccover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,16 @@ BOOL OnGcCoverageInterrupt(PCONTEXT regs)
}

Thread* pThread = GetThread();
_ASSERTE(pThread);
if (!pThread)
{
// No thread at the moment so we aren't doing coverage for this function.
// This should only occur for methods with the NativeCallableAttribute,
// where the call could be coming from a thread unknown to the CLR and
// we haven't created a thread yet - see PreStubWorker_Preemptive().
_ASSERTE(pMD->HasNativeCallableAttribute());
RemoveGcCoverageInterrupt(instrPtr, savedInstrPtr);
return TRUE;
}

#if defined(USE_REDIRECT_FOR_GCSTRESS) && !defined(TARGET_UNIX)
// If we're unable to redirect, then we simply won't test GC at this
Expand Down Expand Up @@ -1452,6 +1461,7 @@ void DoGcStress (PCONTEXT regs, NativeCodeVersion nativeCodeVersion)
DWORD offset = codeInfo.GetRelOffset();

Thread *pThread = GetThread();
_ASSERTE(pThread);

if (!IsGcCoverageInterruptInstruction(instrPtr))
{
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12678,20 +12678,21 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,

flags = GetCompileFlags(ftn, flags, &methodInfo);

// If the reverse P/Invoke flag is used, we aren't going to support
// any tiered compilation.
if (flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_REVERSE_PINVOKE))
#ifdef FEATURE_TIERED_COMPILATION
// Clearing all tier flags and mark as optimized if the reverse P/Invoke
// flag is used and the function is eligible.
if (flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_REVERSE_PINVOKE)
&& ftn->IsEligibleForTieredCompilation())
{
_ASSERTE(config->GetCallerGCMode() != CallerGCMode::Coop);

// Clear all possible states.
flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_TIER0);
flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_TIER1);

#ifdef FEATURE_TIERED_COMPILATION
config->SetJitSwitchedToOptimized();
#endif // FEATURE_TIERED_COMPILATION
}
#endif // FEATURE_TIERED_COMPILATION

#ifdef _DEBUG
if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SKIP_VERIFICATION))
Expand Down