Skip to content

Commit

Permalink
Fix contract violations. (#81727)
Browse files Browse the repository at this point in the history
Removes GC_TRIGGERS contract for functions that
do not trigger a GC. The removed contract definition
appears to be out of date.

Fallout from #81571
  • Loading branch information
AaronRobinsonMSFT authored Feb 7, 2023
1 parent d666c6e commit fe4760c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/coreclr/vm/assemblyspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,12 @@ AssemblySpecHash::~AssemblySpecHash()

HRESULT AssemblySpec::InitializeSpecInternal(mdToken kAssemblyToken,
IMDInternalImport *pImport,
DomainAssembly *pStaticParent,
BOOL fAllowAllocation)
DomainAssembly *pStaticParent)
{
CONTRACTL
{
INSTANCE_CHECK;
if (fAllowAllocation) {GC_TRIGGERS;} else {GC_NOTRIGGER;};
if (fAllowAllocation) {INJECT_FAULT(COMPlusThrowOM());} else {FORBID_FAULT;};
GC_NOTRIGGER;
NOTHROW;
MODE_ANY;
PRECONDITION(pImport->IsValidToken(kAssemblyToken));
Expand Down Expand Up @@ -194,7 +192,7 @@ void AssemblySpec::InitializeSpec(PEAssembly * pFile)
{
INSTANCE_CHECK;
THROWS;
GC_TRIGGERS;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(CheckPointer(pFile));
INJECT_FAULT(COMPlusThrowOM(););
Expand Down
7 changes: 3 additions & 4 deletions src/coreclr/vm/assemblyspec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class AssemblySpec : public BaseAssemblySpec

HRESULT InitializeSpecInternal(mdToken kAssemblyRefOrDef,
IMDInternalImport *pImport,
DomainAssembly *pStaticParent,
BOOL fAllowAllocation);
DomainAssembly *pStaticParent);

// InitializeSpecInternal should be used very carefully so it's made private.
// functions that take special care (and thus are allowed to use the function) are listed below
Expand Down Expand Up @@ -88,12 +87,12 @@ class AssemblySpec : public BaseAssemblySpec
CONTRACTL
{
INSTANCE_CHECK;
GC_TRIGGERS;
GC_NOTRIGGER;
THROWS;
MODE_ANY;
}
CONTRACTL_END;
HRESULT hr=InitializeSpecInternal(kAssemblyRefOrDef, pImport,pStaticParent,TRUE);
HRESULT hr=InitializeSpecInternal(kAssemblyRefOrDef, pImport,pStaticParent);
if(FAILED(hr))
EEFileLoadException::Throw(this,hr);
};
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2983,8 +2983,7 @@ Module::GetAssemblyIfLoaded(
AssemblySpec spec;
if (FAILED(spec.InitializeSpecInternal(kAssemblyRef,
pMDImport,
pCurAssemblyInExamineDomain,
FALSE /*fAllowAllocation*/)))
pCurAssemblyInExamineDomain)))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/peassembly.inl
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ inline void PEAssembly::GetDisplayName(SString &result, DWORD flags)
{
PRECONDITION(CheckValue(result));
THROWS;
GC_TRIGGERS;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
Expand Down

0 comments on commit fe4760c

Please sign in to comment.