Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1d77e2f
Reduce constraint loading by not forcing constraints to be loaded eag…
davidwrighton Oct 6, 2025
bb4a3d2
Clear up the issues around GetDeclaringMethodTableFromTypeVarTypeDesc
davidwrighton Oct 6, 2025
db83d47
Tweak, and add comments...
davidwrighton Oct 7, 2025
c0ae70d
Fix build errors
davidwrighton Oct 7, 2025
1f742a3
Fix bugs making it not work properly
davidwrighton Oct 7, 2025
4e4a395
Rework the special instantiation type logic to be more effective
davidwrighton Dec 1, 2023
bef91a8
Fix interface matching bug found in testing
davidwrighton Oct 7, 2025
2bdfc3c
Optimize virtual static and default interface method resolution logic
davidwrighton Oct 8, 2025
3b937fd
Update loader/classloader/generics/ByRefLike/ValidateNegative test
davidwrighton Oct 8, 2025
64d10ff
Pass around the type I want passed around
davidwrighton Oct 8, 2025
9eef0b3
Remove WhichConstraintsToLoad::TypeOrMethodVarsOnly
davidwrighton Oct 8, 2025
4a6a81c
Fix out of date comment
davidwrighton Oct 8, 2025
18214f8
Merge branch 'main' into reduce_constraint_load
davidwrighton Oct 9, 2025
533e8ca
- Add support for doing circularity checks on type and method generic…
davidwrighton Oct 10, 2025
ebca7a6
Code review feedback
davidwrighton Oct 10, 2025
9d8b167
- Flesh out implementation of sig parser for constraint accessibility
davidwrighton Oct 10, 2025
d5fad7d
- Add crossgen2 validation of interface impl variance rules
davidwrighton Oct 13, 2025
12511ff
- Adjust contracts as suggested
davidwrighton Oct 13, 2025
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
8 changes: 4 additions & 4 deletions src/coreclr/vm/comdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2403,16 +2403,16 @@ static bool IsLocationAssignable(TypeHandle fromHandle, TypeHandle toHandle, boo
// We need to check whether constraints of fromHandle have been loaded, because the
// CanCastTo operation might have made its decision without enumerating constraints
// (e.g. when toHandle is System.Object).
if (!fromHandleVar->ConstraintsLoaded())
fromHandleVar->LoadConstraints(CLASS_DEPENDENCIES_LOADED);
if (!fromHandleVar->ConstraintsLoaded(WhichConstraintsToLoad::TypeOrMethodVarsAndNonInterfacesOnly))
fromHandleVar->LoadConstraints(CLASS_DEPENDENCIES_LOADED, WhichConstraintsToLoad::TypeOrMethodVarsAndNonInterfacesOnly);

if (toHandle.IsGenericVariable())
{
TypeVarTypeDesc *toHandleVar = toHandle.AsGenericVariable();

// Constraints of toHandleVar were not touched by CanCastTo.
if (!toHandleVar->ConstraintsLoaded())
toHandleVar->LoadConstraints(CLASS_DEPENDENCIES_LOADED);
if (!toHandleVar->ConstraintsLoaded(WhichConstraintsToLoad::TypeOrMethodVarsAndNonInterfacesOnly))
toHandleVar->LoadConstraints(CLASS_DEPENDENCIES_LOADED, WhichConstraintsToLoad::TypeOrMethodVarsAndNonInterfacesOnly);

// Both handles are type variables. The following table lists all possible combinations.
//
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/vm/genmeth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ BOOL Bounded(TypeVarTypeDesc *tyvar, DWORD depth) {
}

DWORD numConstraints;
TypeHandle *constraints = tyvar->GetConstraints(&numConstraints, CLASS_DEPENDENCIES_LOADED);
TypeHandle *constraints = tyvar->GetConstraints(&numConstraints, CLASS_DEPENDENCIES_LOADED, WhichConstraintsToLoad::TypeOrMethodVarsAndNonInterfacesOnly);
for (unsigned i = 0; i < numConstraints; i++)
{
TypeHandle constraint = constraints[i];
Expand Down Expand Up @@ -1570,20 +1570,12 @@ void MethodDesc::LoadConstraintsForTypicalMethodDefinition(BOOL *pfHasCircularCl

// Force a load of the constraints on the type parameters
Instantiation classInst = GetClassInstantiation();
for (DWORD i = 0; i < classInst.GetNumArgs(); i++)
{
TypeVarTypeDesc* tyvar = classInst[i].AsGenericVariable();
_ASSERTE(tyvar != NULL);
tyvar->LoadConstraints(level);
}

Instantiation methodInst = GetMethodInstantiation();
for (DWORD i = 0; i < methodInst.GetNumArgs(); i++)
{
TypeVarTypeDesc* tyvar = methodInst[i].AsGenericVariable();
_ASSERTE(tyvar != NULL);
tyvar->LoadConstraints(level);

VOID DoAccessibilityCheckForConstraints(MethodTable *pAskingMT, TypeVarTypeDesc *pTyVar, UINT resIDWhy);
DoAccessibilityCheckForConstraints(GetMethodTable(), tyvar, E_ACCESSDENIED);
}
Expand Down Expand Up @@ -1662,8 +1654,6 @@ BOOL MethodDesc::SatisfiesMethodConstraints(TypeHandle thParent, BOOL fThrowIfNo
_ASSERTE(tyvar != NULL);
_ASSERTE(TypeFromToken(tyvar->GetTypeOrMethodDef()) == mdtMethodDef);

tyvar->LoadConstraints(); //TODO: is this necessary for anything but the typical method?

// Pass in the InstatiationContext so constraints can be correctly evaluated
// if this is an instantiation where the type variable is in its open position
if (!tyvar->SatisfiesConstraints(&typeContext,thArg, typicalInstMatchesMethodInst ? &instContext : NULL))
Expand Down
Loading
Loading