Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy APIs for MCG support #106568

Merged
merged 2 commits into from
Aug 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
<Compile Include="$(BclSourcesRoot)\System\Reflection\TypeNameResolver.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Metadata\RuntimeTypeMetadataUpdateHandler.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\CastHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\ICastableHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\RuntimeHelpers.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\ControlledExecution.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\DependentHandle.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ internal unsafe struct MethodTable
// Types that require non-trivial interface cast have this bit set in the category
private const uint enum_flag_NonTrivialInterfaceCast = 0x00080000 // enum_flag_Category_Array
| 0x40000000 // enum_flag_ComObject
| 0x00400000 // enum_flag_ICastable;
| 0x10000000 // enum_flag_IDynamicInterfaceCastable;
| 0x00040000; // enum_flag_Category_ValueType

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/clr.featuredefines.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<FeatureCoreCLR>true</FeatureCoreCLR>
<FeatureEventTrace>true</FeatureEventTrace>
<FeatureICastable>true</FeatureICastable>
<FeaturePerfTracing>true</FeaturePerfTracing>
<FeatureTypeEquivalence>true</FeatureTypeEquivalence>
<ProfilingSupportedBuild>true</ProfilingSupportedBuild>
Expand Down Expand Up @@ -35,7 +34,6 @@
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
<DefineConstants Condition="'$(FeatureTypeEquivalence)' == 'true'">$(DefineConstants);FEATURE_TYPEEQUIVALENCE</DefineConstants>
<DefineConstants Condition="'$(FeatureICastable)' == 'true'">$(DefineConstants);FEATURE_ICASTABLE</DefineConstants>
<DefineConstants Condition="'$(FeatureEHFunclets)' == 'true'">$(DefineConstants);FEATURE_EH_FUNCLETS</DefineConstants>

<DefineConstants Condition="'$(ProfilingSupportedBuild)' == 'true'">$(DefineConstants);PROFILING_SUPPORTED</DefineConstants>
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ endif(CLR_CMAKE_TARGET_LINUX)
if(NOT CLR_CMAKE_TARGET_NETBSD)
add_definitions(-DFEATURE_HIJACK)
endif(NOT CLR_CMAKE_TARGET_NETBSD)
add_definitions(-DFEATURE_ICASTABLE)
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
add_definitions(-DFEATURE_INTEROP_DEBUGGING)
endif (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pBaseCOMObject, ::g_pBaseCOMObject)

DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pIDynamicInterfaceCastableInterface, ::g_pIDynamicInterfaceCastableInterface)

#ifdef FEATURE_ICASTABLE
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pICastableInterface, ::g_pICastableInterface)
#endif // FEATURE_ICASTABLE

DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pObjectFinalizerMD, ::g_pObjectFinalizerMD)

DEFINE_DACVAR(bool, dac__g_fProcessDetach, ::g_fProcessDetach)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"FEATURE_DEFAULT_INTERFACES",
"FEATURE_EVENT_TRACE=1",
"FEATURE_HIJACK",
"FEATURE_ICASTABLE",
"FEATURE_INTEROP_DEBUGGING",
"FEATURE_ISYM_READER",
"FEATURE_MULTICASTSTUB_AS_IL",
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,10 +1268,6 @@ void SystemDomain::LoadBaseSystemClasses()
}
#endif

#ifdef FEATURE_ICASTABLE
g_pICastableInterface = CoreLibBinder::GetClass(CLASS__ICASTABLE);
#endif // FEATURE_ICASTABLE

#ifdef FEATURE_EH_FUNCLETS
g_pEHClass = CoreLibBinder::GetClass(CLASS__EH);
g_pExceptionServicesInternalCallsClass = CoreLibBinder::GetClass(CLASS__EXCEPTIONSERVICES_INTERNALCALLS);
Expand Down
44 changes: 11 additions & 33 deletions src/coreclr/vm/callconvbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,37 +490,23 @@ bool CallConv::TryGetCallingConventionFromUnmanagedCallersOnly(_In_ MethodDesc*
BYTE* pData = NULL;
LONG cData = 0;

bool nativeCallableInternalData = false;
HRESULT hr = pMD->GetCustomAttribute(WellKnownAttribute::UnmanagedCallersOnly, (const VOID **)(&pData), (ULONG *)&cData);
if (hr == S_FALSE)
{
hr = pMD->GetCustomAttribute(WellKnownAttribute::NativeCallableInternal, (const VOID **)(&pData), (ULONG *)&cData);
nativeCallableInternalData = SUCCEEDED(hr);
}

IfFailThrow(hr);

_ASSERTE(cData > 0);

CustomAttributeParser ca(pData, cData);

// UnmanagedCallersOnly and NativeCallableInternal each
// UnmanagedCallersOnly each
// have optional named arguments.
CaNamedArg namedArgs[2];

// For the UnmanagedCallersOnly scenario.
CaType caCallConvs;

// Define attribute specific optional named properties
if (nativeCallableInternalData)
{
namedArgs[0].InitI4FieldEnum("CallingConvention", "System.Runtime.InteropServices.CallingConvention", (ULONG)(CorPinvokeMap)0);
}
else
{
caCallConvs.Init(SERIALIZATION_TYPE_SZARRAY, SERIALIZATION_TYPE_TYPE, SERIALIZATION_TYPE_UNDEFINED, NULL, 0);
namedArgs[0].Init("CallConvs", SERIALIZATION_TYPE_SZARRAY, caCallConvs);
}
caCallConvs.Init(SERIALIZATION_TYPE_SZARRAY, SERIALIZATION_TYPE_TYPE, SERIALIZATION_TYPE_UNDEFINED, NULL, 0);
namedArgs[0].Init("CallConvs", SERIALIZATION_TYPE_SZARRAY, caCallConvs);

// Define common optional named properties
CaTypeCtor caEntryPoint(SERIALIZATION_TYPE_STRING);
Expand All @@ -542,25 +528,17 @@ bool CallConv::TryGetCallingConventionFromUnmanagedCallersOnly(_In_ MethodDesc*
if (namedArgs[0].val.type.tag == SERIALIZATION_TYPE_UNDEFINED)
return false;

CorInfoCallConvExtension callConvLocal;
if (nativeCallableInternalData)
CallConvBuilder builder;
if (!TryGetCallingConventionFromTypeArray(&namedArgs[0].val, &builder))
{
callConvLocal = (CorInfoCallConvExtension)(namedArgs[0].val.u4 << 8);
// We found a second base calling convention.
return false;
}
else
{
CallConvBuilder builder;
if (!TryGetCallingConventionFromTypeArray(&namedArgs[0].val, &builder))
{
// We found a second base calling convention.
return false;
}

callConvLocal = builder.GetCurrentCallConv();
if (callConvLocal == CallConvBuilder::UnsetValue)
{
callConvLocal = CallConv::GetDefaultUnmanagedCallingConvention();
}
CorInfoCallConvExtension callConvLocal = builder.GetCurrentCallConv();
if (callConvLocal == CallConvBuilder::UnsetValue)
{
callConvLocal = CallConv::GetDefaultUnmanagedCallingConvention();
}

*pCallConv = callConvLocal;
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1124,15 +1124,6 @@ DEFINE_FIELD_U(_condition, ContractExceptionObject, _Condition)

DEFINE_CLASS(MODULEBASE, Reflection, Module)

#ifdef FEATURE_ICASTABLE
DEFINE_CLASS(ICASTABLE, CompilerServices, ICastable)

DEFINE_CLASS(ICASTABLEHELPERS, CompilerServices, ICastableHelpers)
DEFINE_METHOD(ICASTABLEHELPERS, ISINSTANCEOF, IsInstanceOfInterface, SM_ICastable_RtType_RefException_RetBool)
DEFINE_METHOD(ICASTABLEHELPERS, GETIMPLTYPE, GetImplType, SM_ICastable_RtType_RetRtType)

#endif // FEATURE_ICASTABLE

DEFINE_CLASS(STACKALLOCATEDBOX, CompilerServices, StackAllocatedBox`1)

DEFINE_CLASS(UTF8STRINGMARSHALLER, Marshalling, Utf8StringMarshaller)
Expand Down
29 changes: 0 additions & 29 deletions src/coreclr/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,35 +1080,6 @@ BOOL ObjIsInstanceOfCore(Object *pObject, TypeHandle toTypeHnd, BOOL throwCastEx
}
else
#endif // FEATURE_COMINTEROP
#ifdef FEATURE_ICASTABLE
// If type implements ICastable interface we give it a chance to tell us if it can be casted
// to a given type.
if (pMT->IsICastable())
{
// Make actual call to ICastableHelpers.IsInstanceOfInterface(obj, interfaceTypeObj, out exception)
OBJECTREF exception = NULL;
GCPROTECT_BEGIN(exception);

PREPARE_NONVIRTUAL_CALLSITE(METHOD__ICASTABLEHELPERS__ISINSTANCEOF);

OBJECTREF managedType = toTypeHnd.GetManagedClassObject(); //GC triggers

DECLARE_ARGHOLDER_ARRAY(args, 3);
args[ARGNUM_0] = OBJECTREF_TO_ARGHOLDER(obj);
args[ARGNUM_1] = OBJECTREF_TO_ARGHOLDER(managedType);
args[ARGNUM_2] = PTR_TO_ARGHOLDER(&exception);

CALL_MANAGED_METHOD(fCast, BOOL, args);
INDEBUG(managedType = NULL); // managedType isn't protected during the call

if (!fCast && throwCastException && exception != NULL)
{
RealCOMPlusThrow(exception);
}
GCPROTECT_END(); //exception
}
else
#endif // FEATURE_ICASTABLE
if (pMT->IsIDynamicInterfaceCastable())
{
fCast = DynamicInterfaceCastable::IsInstanceOf(&obj, toTypeHnd, throwCastException);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4209,8 +4209,8 @@ TypeCompareState CEEInfo::compareTypesForCast(
else
#endif // FEATURE_COMINTEROP

// If casting from ICastable or IDynamicInterfaceCastable, don't try to optimize
if (fromHnd.GetMethodTable()->IsICastable() || fromHnd.GetMethodTable()->IsIDynamicInterfaceCastable())
// If casting from IDynamicInterfaceCastable, don't try to optimize
if (fromHnd.GetMethodTable()->IsIDynamicInterfaceCastable())
{
result = TypeCompareState::May;
}
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/vm/metasig.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,6 @@ DEFINE_METASIG(IM(PtrVoid_RetVoid, P(v), v))
DEFINE_METASIG_T(IM(PtrCopyConstructorCookie_RetVoid, P(g(COPY_CONSTRUCTOR_COOKIE)), v))
#endif // defined(TARGET_X86) && defined(TARGET_WINDOWS)


#ifdef FEATURE_ICASTABLE
DEFINE_METASIG_T(SM(ICastable_RtType_RefException_RetBool, C(ICASTABLE) C(CLASS) r(C(EXCEPTION)), F))
DEFINE_METASIG_T(SM(ICastable_RtType_RetRtType, C(ICASTABLE) C(CLASS), C(CLASS)))
#endif // FEATURE_ICASTABLE

DEFINE_METASIG_T(SM(IDynamicInterfaceCastable_RuntimeType_Bool_RetBool, C(IDYNAMICINTERFACECASTABLE) C(CLASS) F, F))
DEFINE_METASIG_T(SM(IDynamicInterfaceCastable_RuntimeType_RetRtType, C(IDYNAMICINTERFACECASTABLE) C(CLASS), C(CLASS)))

Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3517,14 +3517,6 @@ BOOL MethodDesc::HasUnmanagedCallersOnlyAttribute()
WellKnownAttribute::UnmanagedCallersOnly,
nullptr,
nullptr);
if (hr != S_OK)
{
// See https://github.com/dotnet/runtime/issues/37622
hr = GetCustomAttribute(
WellKnownAttribute::NativeCallableInternal,
nullptr,
nullptr);
}

return (hr == S_OK) ? TRUE : FALSE;
}
Expand Down
58 changes: 2 additions & 56 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,24 +375,6 @@ void MethodTable::SetComObjectType()
SetFlag(enum_flag_ComObject);
}

#ifdef FEATURE_ICASTABLE
void MethodTable::SetICastable()
{
LIMITED_METHOD_CONTRACT;
SetFlag(enum_flag_ICastable);
}
#endif

BOOL MethodTable::IsICastable()
{
LIMITED_METHOD_DAC_CONTRACT;
#ifdef FEATURE_ICASTABLE
return GetFlag(enum_flag_ICastable);
#else
return FALSE;
#endif
}

void MethodTable::SetIDynamicInterfaceCastable()
{
LIMITED_METHOD_CONTRACT;
Expand Down Expand Up @@ -499,42 +481,6 @@ PTR_MethodTable InterfaceInfo_t::GetApproxMethodTable(Module * pContainingModule
MethodTable *pServerMT = (*pServer)->GetMethodTable();
PREFIX_ASSUME(pServerMT != NULL);

#ifdef FEATURE_ICASTABLE
// In case of ICastable, instead of trying to find method implementation in the real object type
// we call GetMethodDescForInterfaceMethod() again with whatever type it returns.
// It allows objects that implement ICastable to mimic behavior of other types.
if (pServerMT->IsICastable() &&
!pItfMD->HasMethodInstantiation() &&
!TypeHandle(pServerMT).CanCastTo(ownerType)) // we need to make sure object doesn't implement this interface in a natural way
{
GCStress<cfg_any>::MaybeTrigger();

// Make call to ICastableHelpers.GetImplType(obj, interfaceTypeObj)
PREPARE_NONVIRTUAL_CALLSITE(METHOD__ICASTABLEHELPERS__GETIMPLTYPE);

OBJECTREF ownerManagedType = ownerType.GetManagedClassObject(); //GC triggers

DECLARE_ARGHOLDER_ARRAY(args, 2);
args[ARGNUM_0] = OBJECTREF_TO_ARGHOLDER(*pServer);
args[ARGNUM_1] = OBJECTREF_TO_ARGHOLDER(ownerManagedType);

OBJECTREF impTypeObj = NULL;
CALL_MANAGED_METHOD_RETREF(impTypeObj, OBJECTREF, args);

INDEBUG(ownerManagedType = NULL); //ownerManagedType wasn't protected during the call
if (impTypeObj == NULL) // GetImplType returns default(RuntimeTypeHandle)
{
COMPlusThrow(kEntryPointNotFoundException);
}

ReflectClassBaseObject* resultTypeObj = ((ReflectClassBaseObject*)OBJECTREFToObject(impTypeObj));
TypeHandle resultTypeHnd = resultTypeObj->GetType();
MethodTable *pResultMT = resultTypeHnd.GetMethodTable();

RETURN(pResultMT->GetMethodDescForInterfaceMethod(ownerType, pItfMD, TRUE /* throwOnConflict */));
}
#endif

// For IDynamicInterfaceCastable, instead of trying to find method implementation in the real object type
// we call GetInterfaceImplementation on the object and call GetMethodDescForInterfaceMethod
// with whatever type it returns.
Expand Down Expand Up @@ -1462,8 +1408,8 @@ BOOL MethodTable::CanCastTo(MethodTable* pTargetMT, TypeHandlePairList* pVisited
CanCastToClass(pTargetMT, pVisited);

// We only consider type-based conversion rules here.
// Therefore a negative result cannot rule out convertibility for ICastable, IDynamicInterfaceCastable, and COM objects
if (result || !(pTargetMT->IsInterface() && (this->IsComObjectType() || this->IsICastable() || this->IsIDynamicInterfaceCastable())))
// Therefore a negative result cannot rule out convertibility for IDynamicInterfaceCastable and COM objects
if (result || !(pTargetMT->IsInterface() && (this->IsComObjectType() || this->IsIDynamicInterfaceCastable())))
{
CastCache::TryAddToCache(this, pTargetMT, (BOOL)result);
}
Expand Down
9 changes: 1 addition & 8 deletions src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1031,12 +1031,6 @@ class MethodTable
// mark the class type as COM object class
void SetComObjectType();

#ifdef FEATURE_ICASTABLE
void SetICastable();
#endif

BOOL IsICastable(); // This type implements ICastable interface

void SetIDynamicInterfaceCastable();
BOOL IsIDynamicInterfaceCastable();

Expand Down Expand Up @@ -3697,7 +3691,7 @@ public :

enum_flag_HasFinalizer = 0x00100000, // instances require finalization. GC depends on this bit.
enum_flag_Collectible = 0x00200000, // GC depends on this bit.
enum_flag_ICastable = 0x00400000, // class implements ICastable interface
// enum_flag_unused = 0x00400000,

#ifdef FEATURE_64BIT_ALIGNMENT
enum_flag_RequiresAlign8 = 0x00800000, // Type requires 8-byte alignment (only set on platforms that require this and don't get it implicitly)
Expand All @@ -3717,7 +3711,6 @@ public :
// Types that require non-trivial interface cast have this bit set in the category
enum_flag_NonTrivialInterfaceCast = enum_flag_Category_Array
| enum_flag_ComObject
| enum_flag_ICastable
| enum_flag_IDynamicInterfaceCastable
| enum_flag_Category_ValueType

Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,13 +1998,6 @@ MethodTableBuilder::BuildMethodTableThrowing(

if (!IsValueClass())
{
#ifdef FEATURE_ICASTABLE
if (g_pICastableInterface != NULL && pMT->CanCastToInterface(g_pICastableInterface))
{
pMT->SetICastable();
}
#endif // FEATURE_ICASTABLE

if (g_pIDynamicInterfaceCastableInterface != NULL && pMT->CanCastToInterface(g_pIDynamicInterfaceCastableInterface))
{
pMT->SetIDynamicInterfaceCastable();
Expand Down
Loading
Loading