Skip to content
11 changes: 1 addition & 10 deletions src/coreclr/inc/cor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1582,18 +1582,9 @@ DECLARE_INTERFACE_(IMetaDataInfo, IUnknown)
//**********************************************************************

//
// Native Link method custom value definitions. This is for N-direct support.
// Native Link method custom value definitions. This is for P/Invoke support.
//

#include <pshpack1.h>
typedef struct
{
BYTE m_linkType; // see CorNativeLinkType below
BYTE m_flags; // see CorNativeLinkFlags below
mdMemberRef m_entryPoint; // member ref token giving entry point, format is lib:entrypoint
} COR_NATIVE_LINK;
#include <poppack.h>

typedef enum
{
nltNone = 1, // none of the keywords are specified
Expand Down
51 changes: 1 addition & 50 deletions src/coreclr/tools/metainfo/mdinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2914,56 +2914,7 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL
return hr;
} // HRESULT MDInfo::GetOneElementType()

// Display the fields of the PInvoke custom value structure.

void MDInfo::DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix)
{
// Print the LinkType.
const char *curField = "\tLink Type : ";
switch(pCorNLnk->m_linkType)
{
case nltNone:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nltNone", pCorNLnk->m_linkType);
break;
case nltAnsi:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nltAnsi", pCorNLnk->m_linkType);
break;
case nltUnicode:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nltUnicode", pCorNLnk->m_linkType);
break;
case nltAuto:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nltAuto", pCorNLnk->m_linkType);
break;
default:
_ASSERTE(!"Invalid Native Link Type!");
}

// Print the link flags
curField = "\tLink Flags : ";
switch(pCorNLnk->m_flags)
{
case nlfNone:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nlfNone", pCorNLnk->m_flags);
break;
case nlfLastError:
VWriteLine("%s%s%s(%02x)", preFix, curField, "nlfLastError", pCorNLnk->m_flags);
break;
default:
_ASSERTE(!"Invalid Native Link Flags!");
}

// Print the entry point.
WCHAR memRefName[STRING_BUFFER_LEN];
char memRefNameUtf8[ARRAY_SIZE(memRefName) * MAX_UTF8_CVT];
HRESULT hr;
hr = m_pImport->GetMemberRefProps( pCorNLnk->m_entryPoint, NULL, memRefName,
STRING_BUFFER_LEN, NULL, NULL, NULL);
if (FAILED(hr)) Error("GetMemberRefProps failed.", hr);
VWriteLine("%s\tEntry Point : %s (0x%08x)",
preFix, ConvertToUtf8(memRefName, memRefNameUtf8, ARRAY_SIZE(memRefNameUtf8)), pCorNLnk->m_entryPoint);
} // void MDInfo::DisplayCorNativeLink()

// Fills given varaint with value given in pValue and of type in bCPlusTypeFlag
// Fills given variant with value given in pValue and of type in bCPlusTypeFlag
//
// Taken from MetaInternal.cpp
#ifdef FEATURE_COMINTEROP
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/tools/metainfo/mdinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class MDInfo {
void DisplayMethodSpecs(void);
void DisplayMethodSpecInfo(mdMethodSpec ms, const char *preFix);

void DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix);
void DisplayCustomAttributeInfo(mdCustomAttribute inValue, const char *preFix);
void DisplayCustomAttributes(mdToken inToken, const char *preFix);

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/callhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ void* DispatchCallSimple(
void CopyReturnedFpStructFromRegisters(void* dest, UINT64 returnRegs[2], FpStructInRegistersInfo info, bool handleGcRefs);
#endif // defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64)

bool IsCerRootMethod(MethodDesc *pMD);

class MethodDescCallSite
{
private:
Expand Down
31 changes: 0 additions & 31 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ DEFINE_CLASS(HANDLE_REF, Interop, HandleRef)
DEFINE_FIELD(HANDLE_REF, WRAPPER, _wrapper)
DEFINE_FIELD(HANDLE_REF, HANDLE, _handle)

DEFINE_CLASS(CRITICAL_FINALIZER_OBJECT, ConstrainedExecution, CriticalFinalizerObject)
DEFINE_METHOD(CRITICAL_FINALIZER_OBJECT, FINALIZE, Finalize, IM_RetVoid)

DEFINE_CLASS_U(Reflection, RuntimeConstructorInfo, NoClass)
DEFINE_FIELD_U(m_handle, ReflectMethodObject, m_pMD)
DEFINE_CLASS(CONSTRUCTOR, Reflection, RuntimeConstructorInfo)
Expand All @@ -214,25 +211,9 @@ DEFINE_METHOD(STUBMETHODINFO, FROMPTR, FromPtr,

DEFINE_CLASS(CONSTRUCTOR_INFO, Reflection, ConstructorInfo)

DEFINE_CLASS_U(Globalization, CultureInfo, CultureInfoBaseObject)
DEFINE_FIELD_U(_compareInfo, CultureInfoBaseObject, _compareInfo)
DEFINE_FIELD_U(_textInfo, CultureInfoBaseObject, _textInfo)
DEFINE_FIELD_U(_numInfo, CultureInfoBaseObject, _numInfo)
DEFINE_FIELD_U(_dateTimeInfo, CultureInfoBaseObject, _dateTimeInfo)
DEFINE_FIELD_U(_calendar, CultureInfoBaseObject, _calendar)
DEFINE_FIELD_U(_consoleFallbackCulture, CultureInfoBaseObject, _consoleFallbackCulture)
DEFINE_FIELD_U(_name, CultureInfoBaseObject, _name)
DEFINE_FIELD_U(_nonSortName, CultureInfoBaseObject, _nonSortName)
DEFINE_FIELD_U(_sortName, CultureInfoBaseObject, _sortName)
DEFINE_FIELD_U(_parent, CultureInfoBaseObject, _parent)
DEFINE_FIELD_U(_isReadOnly, CultureInfoBaseObject, _isReadOnly)
DEFINE_FIELD_U(_isInherited, CultureInfoBaseObject, _isInherited)
DEFINE_CLASS(CULTURE_INFO, Globalization, CultureInfo)
DEFINE_FIELD(CULTURE_INFO, CURRENT_CULTURE, s_userDefaultCulture)
DEFINE_METHOD(CULTURE_INFO, INT_CTOR, .ctor, IM_Int_RetVoid)
DEFINE_PROPERTY(CULTURE_INFO, ID, LCID, Int)
DEFINE_FIELD(CULTURE_INFO, CULTURE, s_currentThreadCulture)
DEFINE_FIELD(CULTURE_INFO, UI_CULTURE, s_currentThreadUICulture)
DEFINE_STATIC_SET_PROPERTY(CULTURE_INFO, CURRENT_CULTURE, CurrentCulture, CultureInfo)
DEFINE_STATIC_SET_PROPERTY(CULTURE_INFO, CURRENT_UI_CULTURE, CurrentUICulture, CultureInfo)

Expand Down Expand Up @@ -892,8 +873,6 @@ DEFINE_CLASS(CALLCONV_SWIFT, CompilerServices, CallConvSwi
DEFINE_CLASS(SAFE_HANDLE, Interop, SafeHandle)
DEFINE_FIELD(SAFE_HANDLE, HANDLE, handle)

DEFINE_CLASS(SECURITY_EXCEPTION, Security, SecurityException)

DEFINE_CLASS_U(Diagnostics, StackFrameHelper, StackFrameHelper)
DEFINE_FIELD_U(rgiOffset, StackFrameHelper, rgiOffset)
DEFINE_FIELD_U(rgiILOffset, StackFrameHelper, rgiILOffset)
Expand Down Expand Up @@ -1000,9 +979,6 @@ DEFINE_METHOD(AUTORELEASEPOOL, CREATEAUTORELEASEPOOL, CreateAutoreleasePoo
DEFINE_METHOD(AUTORELEASEPOOL, DRAINAUTORELEASEPOOL, DrainAutoreleasePool, SM_RetVoid)
#endif // FEATURE_OBJCMARSHAL

DEFINE_CLASS(TIMESPAN, System, TimeSpan)


DEFINE_CLASS(TYPE, System, Type)
DEFINE_METHOD(TYPE, GET_TYPE_FROM_HANDLE, GetTypeFromHandle, SM_RuntimeTypeHandle_RetType)
DEFINE_PROPERTY(TYPE, IS_IMPORT, IsImport, Bool)
Expand Down Expand Up @@ -1251,13 +1227,6 @@ DEFINE_CLASS_U(Reflection, LoaderAllocatorScout, LoaderAllocator
DEFINE_FIELD_U(m_nativeLoaderAllocator, LoaderAllocatorScoutObject, m_nativeLoaderAllocator)
DEFINE_CLASS(LOADERALLOCATORSCOUT, Reflection, LoaderAllocatorScout)

DEFINE_CLASS(CONTRACTEXCEPTION, CodeContracts, ContractException)

DEFINE_CLASS_U(CodeContracts, ContractException, ContractExceptionObject)
DEFINE_FIELD_U(_kind, ContractExceptionObject, _Kind)
DEFINE_FIELD_U(_userMessage, ContractExceptionObject, _UserMessage)
DEFINE_FIELD_U(_condition, ContractExceptionObject, _Condition)

DEFINE_CLASS(MODULEBASE, Reflection, Module)

DEFINE_CLASS(UTF8STRINGMARSHALLER, Marshalling, Utf8StringMarshaller)
Expand Down
105 changes: 0 additions & 105 deletions src/coreclr/vm/dwreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,108 +1000,3 @@ VOID WINAPI DoFaultReportDoFavorCallback(LPVOID pFaultReportInfoAsVoid)
CloseHandle(hThread);
}
}

// look at the type of the contract failure. if it's a precondition then we want to blame the caller
// of the method that originated the ContractException not just the first non-contract runtime frame.
// if this isn't a ContractException then we default to Invariant which won't skip the extra frame.
ContractFailureKind GetContractFailureKind(OBJECTREF obj)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
PRECONDITION(obj != NULL);
}
CONTRACTL_END;

PTR_MethodTable pMT = obj->GetMethodTable();

if (CoreLibBinder::IsException(pMT, kContractException))
return CONTRACTEXCEPTIONREF(obj)->GetContractFailureKind();

// there are cases where the code contracts rewriter will use a ContractException
// type that's compiled into the user's assembly. if we get here then this is
// one of those cases. we will make a best guess if this is a ContractException
// so that we can return the value in the _Kind field.

// NOTE: this really isn't meant to be a general-purpose solution for identifying ContractException types.
// we're making a few assumptions here since we're being called in context of WER bucket parameter generation.

// just return anything that isn't precondition so that an extra frame won't be skipped.
ContractFailureKind result = CONTRACT_FAILURE_INVARIANT;

// first compare the exception name.
PTR_MethodTable pContractExceptionMT = CoreLibBinder::GetClassIfExist(CLASS__CONTRACTEXCEPTION);
_ASSERTE(pContractExceptionMT);

if (pContractExceptionMT)
{
LPCUTF8 contractExceptionNamespace = NULL;
LPCUTF8 contractExceptionName = pContractExceptionMT->GetFullyQualifiedNameInfo(&contractExceptionNamespace);
_ASSERTE(contractExceptionName);

LPCUTF8 incomingExceptionNamespace = NULL;
LPCUTF8 incomingExceptionName = pMT->GetFullyQualifiedNameInfo(&incomingExceptionNamespace);
_ASSERTE(incomingExceptionName);

// NOTE: we can't compare the namespaces since sometimes it comes back as an empty string
if (contractExceptionName && incomingExceptionName && strcmp(incomingExceptionName, contractExceptionName) == 0)
{
WORD requiredNumFields = pContractExceptionMT->GetNumInstanceFields();
WORD numFields = pMT->GetNumInstanceFields();

// now see if this exception object has the required number of fields
if (numFields == requiredNumFields)
{
// getting closer, now look for all three fields on ContractException
const int requiredFieldMatches = 3;

PTR_EEClass pEEClass = pMT->GetClass();

PTR_FieldDesc pFD = pEEClass->GetFieldDescList();
PTR_FieldDesc pFDEnd = pFD + numFields;
PTR_FieldDesc pKindFD = NULL;

int numMatchedFields = 0;
while ((pFD < pFDEnd) && (numMatchedFields != requiredFieldMatches))
{
CorElementType fieldType = pFD->GetFieldType();
if (fieldType == ELEMENT_TYPE_I4)
{
// found the _Kind field
LPCUTF8 name = NULL;
HRESULT hr = pFD->GetName_NoThrow(&name);
if (SUCCEEDED(hr) && name && (strcmp(name, "_Kind") == 0))
{
// found the _Kind field, remember this FieldDesc in case we have a match
pKindFD = pFD;
++numMatchedFields;
}
}
else if (fieldType == ELEMENT_TYPE_CLASS)
{
LPCUTF8 name = NULL;
HRESULT hr = pFD->GetName_NoThrow(&name);
if (SUCCEEDED(hr) && name && ((strcmp(name, "_UserMessage") == 0) || (strcmp(name, "_Condition") == 0)))
{
// found another matching field
++numMatchedFields;
}
}

++pFD;
}

if (numMatchedFields == requiredFieldMatches)
{
_ASSERTE(pKindFD != NULL);
ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE();
pKindFD->GetInstanceField(obj, reinterpret_cast<void*>(&result));
}
}
}
}

return result;
}
2 changes: 0 additions & 2 deletions src/coreclr/vm/dwreport.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,4 @@ struct FaultReportInfo

VOID WINAPI DoFaultReportDoFavorCallback(LPVOID pFaultReportInfoAsVoid);

ContractFailureKind GetContractFailureKind(OBJECTREF obj);

#endif // __DWREPORT_H__
20 changes: 0 additions & 20 deletions src/coreclr/vm/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,26 +805,6 @@ STRINGREF StringObject::NewString(LPCUTF8 psz, int cBytes)
STRINGREF* StringObject::EmptyStringRefPtr = NULL;
bool StringObject::EmptyStringIsFrozen = false;

//The special string helpers are used as flag bits for weird strings that have bytes
//after the terminating 0. The only case where we use this right now is the VB BSTR as
//byte array which is described in MakeStringAsByteArrayFromBytes.
#define SPECIAL_STRING_VB_BYTE_ARRAY 0x100

FORCEINLINE BOOL MARKS_VB_BYTE_ARRAY(WCHAR x)
{
return static_cast<BOOL>(x & SPECIAL_STRING_VB_BYTE_ARRAY);
}

FORCEINLINE WCHAR MAKE_VB_TRAIL_BYTE(BYTE x)
{
return static_cast<WCHAR>(x) | SPECIAL_STRING_VB_BYTE_ARRAY;
}

FORCEINLINE BYTE GET_VB_TRAIL_BYTE(WCHAR x)
{
return static_cast<BYTE>(x & 0xFF);
}


/*==============================InitEmptyStringRefPtr============================
**Action: Gets an empty string refptr, cache the result.
Expand Down
Loading
Loading