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
91 changes: 5 additions & 86 deletions src/coreclr/inc/contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
// ModeViolation
// FaultViolation
// FaultNotFatal
// HostViolation
// LoadsTypeViolation
// TakesLockViolation
//
Expand Down Expand Up @@ -378,7 +377,7 @@ struct DbgStateLockState

#define CONTRACT_BITMASK_OK_TO_THROW 0x1 << 0
#define CONTRACT_BITMASK_FAULT_FORBID 0x1 << 1
#define CONTRACT_BITMASK_HOSTCALLS 0x1 << 2
// Unused 0x1 << 2
#define CONTRACT_BITMASK_SOTOLERANT 0x1 << 3
#define CONTRACT_BITMASK_DEBUGONLY 0x1 << 4
#define CONTRACT_BITMASK_SONOTMAINLINE 0x1 << 5
Expand Down Expand Up @@ -422,7 +421,6 @@ struct ClrDebugState
// By default, GetThread() is perfectly fine to call
// By default, it's ok to take a lock (or call someone who does)
m_flags = CONTRACT_BITMASK_OK_TO_THROW|
CONTRACT_BITMASK_HOSTCALLS|
CONTRACT_BITMASK_SOTOLERANT|
CONTRACT_BITMASK_OK_TO_LOCK|
CONTRACT_BITMASK_OK_TO_RETAKE_LOCK;
Expand Down Expand Up @@ -512,30 +510,6 @@ struct ClrDebugState
CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_FAULT_FORBID);
}

//--//
BOOL IsHostCaller()
{
return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_HOSTCALLS);
}

void SetHostCaller()
{
CONTRACT_BITMASK_SET(CONTRACT_BITMASK_HOSTCALLS);
}


BOOL SetHostCaller(BOOL value)
{
BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_HOSTCALLS);
CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_HOSTCALLS,value);
return prevState;
}

void ResetHostCaller()
{
CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_HOSTCALLS);
}

//--//
BOOL IsDebugOnly()
{
Expand Down Expand Up @@ -896,11 +870,8 @@ class BaseContract

SO_MAINLINE_No = 0x00000800, // code is not part of our mainline SO scenario

// Any place where we can't safely call into the host should have a HOST_NoCalls contract
HOST_Mask = 0x00003000,
HOST_Calls = 0x00002000,
HOST_NoCalls = 0x00001000,
HOST_Disabled = 0x00000000, // the default
// Unused = 0x00002000,
// Unused = 0x00001000,

// These enforce the CAN_TAKE_LOCK / CANNOT_TAKE_LOCK contracts
CAN_TAKE_LOCK_Mask = 0x00060000,
Expand All @@ -920,7 +891,7 @@ class BaseContract
LOADS_TYPE_Disabled = 0x00000000, // the default

ALL_Disabled = THROWS_Disabled|GC_Disabled|FAULT_Disabled|MODE_Disabled|LOADS_TYPE_Disabled|
HOST_Disabled|CAN_TAKE_LOCK_Disabled|CAN_RETAKE_LOCK_No_Disabled
CAN_TAKE_LOCK_Disabled|CAN_RETAKE_LOCK_No_Disabled

};

Expand Down Expand Up @@ -1124,7 +1095,6 @@ enum ContractViolationBits
FaultNotFatal = 0x00000010, // suppress INJECT_FAULT but not fault injection by harness
LoadsTypeViolation = 0x00000040, // suppress LOADS_TYPE tags in this scope
TakesLockViolation = 0x00000080, // suppress CAN_TAKE_LOCK tags in this scope
HostViolation = 0x00000100, // suppress HOST_CALLS tags in this scope

//These are not violation bits. We steal some bits out of the violation mask to serve as
// general flag bits.
Expand Down Expand Up @@ -1667,7 +1637,7 @@ class ContractViolationHolder
FORCEINLINE void EnterInternal(UINT_PTR violationMask)
{
_ASSERTE(0 == (violationMask & ~(ThrowsViolation | GCViolation | ModeViolation | FaultViolation |
FaultNotFatal | HostViolation |
FaultNotFatal |
TakesLockViolation | LoadsTypeViolation)) ||
violationMask == AllViolation);

Expand Down Expand Up @@ -1738,9 +1708,6 @@ enum PermanentContractViolationReason
ReasonIBC, // Code runs in IBC scenarios only and the violation is safe.
ReasonNGEN, // Code runs in NGEN scenarios only and the violation is safe.
ReasonProfilerCallout, // Profiler implementers are guaranteed not to throw.
ReasonUnsupportedForSQLF1Profiling, // This code path violates HOST_NOCALLS, but that's ok b/c SQL will never
// invoke it, and thus SQL/F1 profiling (the primary reason to enforce
// HOST_NOCALLS) is not in danger.
ReasonRuntimeReentrancy, // e.g. SafeQueryInterface
ReasonShutdownOnly, // Code path only runs as part of Shutdown and the violation is safe.
ReasonSOTolerance, // We would like to redesign SO contracts anyways
Expand Down Expand Up @@ -2006,54 +1973,6 @@ inline ClrDebugState *GetClrDebugState(BOOL fAlloc)

return NULL;
}
#endif // ENABLE_CONTRACTS_IMPL

#ifdef ENABLE_CONTRACTS_IMPL

class HostNoCallHolder
{
public:
DEBUG_NOINLINE HostNoCallHolder()
{
SCAN_SCOPE_BEGIN;
STATIC_CONTRACT_HOST_NOCALLS;

m_clrDebugState = GetClrDebugState();
m_previousState = m_clrDebugState->SetHostCaller(FALSE);
}

DEBUG_NOINLINE ~HostNoCallHolder()
{
SCAN_SCOPE_END;

m_clrDebugState->SetHostCaller(m_previousState);
}

private:
BOOL m_previousState;
ClrDebugState* m_clrDebugState;

};

#define BEGIN_HOST_NOCALL_CODE \
{ \
HostNoCallHolder __hostNoCallHolder; \
CantAllocHolder __cantAlloc;

#define END_HOST_NOCALL_CODE \
}

#else // ENABLE_CONTRACTS_IMPL
#define BEGIN_HOST_NOCALL_CODE \
{ \
CantAllocHolder __cantAlloc; \

#define END_HOST_NOCALL_CODE \
}
#endif


#if defined(ENABLE_CONTRACTS_IMPL)

// Macros to indicate we're taking or releasing locks

Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/inc/staticcontract.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@
#define ANNOTATION_FN_MODE_COOPERATIVE __annotation(W("MODE_COOPERATIVE ") SCAN_WIDEN(__FUNCTION__))
#define ANNOTATION_FN_MODE_PREEMPTIVE __annotation(W("MODE_PREEMPTIVE ") SCAN_WIDEN(__FUNCTION__))
#define ANNOTATION_FN_MODE_ANY __annotation(W("MODE_ANY ") SCAN_WIDEN(__FUNCTION__))
#define ANNOTATION_FN_HOST_NOCALLS __annotation(W("HOST_NOCALLS ") SCAN_WIDEN(__FUNCTION__))
#define ANNOTATION_FN_HOST_CALLS __annotation(W("HOST_CALLS ") SCAN_WIDEN(__FUNCTION__))

#define ANNOTATION_ENTRY_POINT __annotation(W("SO_EP ") SCAN_WIDEN(__FUNCTION__))

Expand Down Expand Up @@ -135,9 +133,6 @@
#define ANNOTATION_TRY_MARKER { }
#define ANNOTATION_CATCH_MARKER { }

#define ANNOTATION_FN_HOST_NOCALLS { }
#define ANNOTATION_FN_HOST_CALLS { }

#define ANNOTATION_FN_SPECIAL_HOLDER_BEGIN { }
#define ANNOTATION_SPECIAL_HOLDER_END { }
#define ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT { }
Expand All @@ -155,8 +150,6 @@
#define ANNOTATION_FN_MODE_COOPERATIVE { }
#define ANNOTATION_FN_MODE_PREEMPTIVE { }
#define ANNOTATION_FN_MODE_ANY { }
#define ANNOTATION_FN_HOST_NOCALLS { }
#define ANNOTATION_FN_HOST_CALLS { }

#define ANNOTATION_SUPPORTS_DAC { }
#define ANNOTATION_SUPPORTS_DAC_HOST_ONLY { }
Expand All @@ -179,8 +172,6 @@
#define STATIC_CONTRACT_FORBID_FAULT ANNOTATION_FN_FORBID_FAULT
#define STATIC_CONTRACT_GC_TRIGGERS ANNOTATION_FN_GC_TRIGGERS
#define STATIC_CONTRACT_GC_NOTRIGGER ANNOTATION_FN_GC_NOTRIGGER
#define STATIC_CONTRACT_HOST_NOCALLS ANNOTATION_FN_HOST_NOCALLS
#define STATIC_CONTRACT_HOST_CALLS ANNOTATION_FN_HOST_CALLS

#define STATIC_CONTRACT_SUPPORTS_DAC ANNOTATION_SUPPORTS_DAC
#define STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY ANNOTATION_SUPPORTS_DAC_HOST_ONLY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#define CONTRACTL_END
#define NOTHROW
#define GC_NOTRIGGER
#define HOST_NOCALLS

#include "../../inc/gcdecoder.cpp"
#include "../../inc/gc_unwind_x86.h"
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/utilcode/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ SPECIALIZED_VIOLATION(GCViolation);
SPECIALIZED_VIOLATION(ModeViolation);
SPECIALIZED_VIOLATION(FaultViolation);
SPECIALIZED_VIOLATION(FaultNotFatal);
SPECIALIZED_VIOLATION(HostViolation);
SPECIALIZED_VIOLATION(TakesLockViolation);
SPECIALIZED_VIOLATION(LoadsTypeViolation);

Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/utilcode/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,6 @@ VOID DbgAssertDialog(const char *szFile, int iLine, const char *szExpr)

SUPPRESS_ALLOCATION_ASSERTS_IN_THIS_SCOPE;

// Raising the assert dialog can cause us to re-enter the host when allocating
// memory for the string. Since this is debug-only code, we can safely skip
// violation asserts here, particularly since they can also cause infinite
// recursion.
PERMANENT_CONTRACT_VIOLATION(HostViolation, ReasonDebugOnly);

dbgForceToMemory = &szFile; //make certain these args are available in the debugger
dbgForceToMemory = &iLine;
dbgForceToMemory = &szExpr;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/amd64/cgenamd64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats
#ifdef PROFILING_SUPPORTED
PRECONDITION(CORProfilerStackSnapshotEnabled() || InlinedCallFrame::FrameHasActiveCall(this));
#endif
HOST_NOCALLS;
MODE_ANY;
SUPPORTS_DAC;
}
Expand Down
18 changes: 2 additions & 16 deletions src/coreclr/vm/amd64/gmsamd64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
void LazyMachState::unwindLazyState(LazyMachState* baseState,
MachState* unwoundState,
DWORD threadId,
int funCallDepth /* = 1 */,
HostCallPreference hostCallPreference /* = (HostCallPreference)(-1) */)
int funCallDepth /* = 1 */)
{
CONTRACTL
{
Expand Down Expand Up @@ -83,20 +82,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
{
// Determine whether given IP resides in JITted code. (It returns nonzero in that case.)
// Use it now to see if we've unwound to managed code yet.
BOOL fFailedReaderLock = FALSE;
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc, hostCallPreference, &fFailedReaderLock);
if (fFailedReaderLock)
{
// We don't know if we would have been able to find a JIT
// manager, because we couldn't enter the reader lock without
// yielding (and our caller doesn't want us to yield). So abort
// now.

// Invalidate the lazyState we're returning, so the caller knows
// we aborted before we could fully unwind
unwoundState->_pRetAddr = NULL;
return;
}
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc);

if (fIsManagedCode)
break;
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/amd64/gmscpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ struct LazyMachState : public MachState
static void unwindLazyState(LazyMachState* baseState,
MachState* lazyState,
DWORD threadId,
int funCallDepth = 1,
HostCallPreference hostCallPreference = AllowHostCalls);
int funCallDepth = 1);

friend class HelperMethodFrame;
friend class CheckAsmOffsets;
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/arm/gmscpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ struct LazyMachState : public MachState {
static void unwindLazyState(LazyMachState* baseState,
MachState* lazyState,
DWORD threadId,
int funCallDepth = 1,
HostCallPreference hostCallPreference = AllowHostCalls);
int funCallDepth = 1);

friend class HelperMethodFrame;
friend class CheckAsmOffsets;
Expand Down
19 changes: 2 additions & 17 deletions src/coreclr/vm/arm/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ void FlushWriteBarrierInstructionCache()
void LazyMachState::unwindLazyState(LazyMachState* baseState,
MachState* unwoundstate,
DWORD threadId,
int funCallDepth,
HostCallPreference hostCallPreference)
int funCallDepth)
{
T_CONTEXT ctx;
T_KNONVOLATILE_CONTEXT_POINTERS nonVolRegPtrs;
Expand Down Expand Up @@ -575,20 +574,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
{
// Determine whether given IP resides in JITted code. (It returns nonzero in that case.)
// Use it now to see if we've unwound to managed code yet.
BOOL fFailedReaderLock = FALSE;
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc, hostCallPreference, &fFailedReaderLock);
if (fFailedReaderLock)
{
// We don't know if we would have been able to find a JIT
// manager, because we couldn't enter the reader lock without
// yielding (and our caller doesn't want us to yield). So abort
// now.

// Invalidate the lazyState we're returning, so the caller knows
// we aborted before we could fully unwind
unwoundstate->_isValid = false;
return;
}
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc);

if (fIsManagedCode)
break;
Expand Down Expand Up @@ -1583,7 +1569,6 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats
#ifdef PROFILING_SUPPORTED
PRECONDITION(CORProfilerStackSnapshotEnabled() || InlinedCallFrame::FrameHasActiveCall(this));
#endif
HOST_NOCALLS;
MODE_ANY;
SUPPORTS_DAC;
}
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/arm64/gmscpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ struct LazyMachState : public MachState{
static void unwindLazyState(LazyMachState* baseState,
MachState* lazyState,
DWORD threadId,
int funCallDepth = 1,
HostCallPreference hostCallPreference = AllowHostCalls);
int funCallDepth = 1);
};

inline void LazyMachState::setLazyStateFromUnwind(MachState* copy)
Expand Down
19 changes: 2 additions & 17 deletions src/coreclr/vm/arm64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ void ClearRegDisplayArgumentAndScratchRegisters(REGDISPLAY * pRD)
void LazyMachState::unwindLazyState(LazyMachState* baseState,
MachState* unwoundstate,
DWORD threadId,
int funCallDepth,
HostCallPreference hostCallPreference)
int funCallDepth)
{
T_CONTEXT context;
T_KNONVOLATILE_CONTEXT_POINTERS nonVolContextPtrs;
Expand Down Expand Up @@ -357,20 +356,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
{
// Determine whether given IP resides in JITted code. (It returns nonzero in that case.)
// Use it now to see if we've unwound to managed code yet.
BOOL fFailedReaderLock = FALSE;
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc, hostCallPreference, &fFailedReaderLock);
if (fFailedReaderLock)
{
// We don't know if we would have been able to find a JIT
// manager, because we couldn't enter the reader lock without
// yielding (and our caller doesn't want us to yield). So abort
// now.

// Invalidate the lazyState we're returning, so the caller knows
// we aborted before we could fully unwind
unwoundstate->_isValid = false;
return;
}
BOOL fIsManagedCode = ExecutionManager::IsManagedCode(pvControlPc);

if (fIsManagedCode)
break;
Expand Down Expand Up @@ -684,7 +670,6 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats
#ifdef PROFILING_SUPPORTED
PRECONDITION(CORProfilerStackSnapshotEnabled() || InlinedCallFrame::FrameHasActiveCall(this));
#endif
HOST_NOCALLS;
MODE_ANY;
SUPPORTS_DAC;
}
Expand Down
Loading