summaryrefslogtreecommitdiff
path: root/src/vm/method.cpp
diff options
context:
space:
mode:
authorYi Zhang (CLR) <yizhang82@users.noreply.github.com>2017-04-05 21:04:25 -0700
committerYi Zhang (CLR) <yzha@microsoft.com>2017-07-19 11:16:55 -0700
commitdcf60f83a0557b3c2fbb705a4fdb3bade0e14854 (patch)
treeab25f5065a1777493e6da4d6330aa873bb8908e0 /src/vm/method.cpp
parent8a163ca04ae8734f4a9ee51e470beda933c96333 (diff)
downloadcoreclr-dcf60f83a0557b3c2fbb705a4fdb3bade0e14854.tar.gz
coreclr-dcf60f83a0557b3c2fbb705a4fdb3bade0e14854.tar.bz2
coreclr-dcf60f83a0557b3c2fbb705a4fdb3bade0e14854.zip
Default Interface Method Prototype (#10505)
* allow non-zero RVA on abstract interface method in ilasm * Revert "allow non-zero RVA on abstract interface method in ilasm" This reverts commit eecb8024e58f14a20e5e49359f38019f5768ac41. * add a test case and allow virtual non-abstract method in ilasm * allow non-abstract methods in the loader * fixup dispatch map * support for simple default interface method scenario * fix a bug with incorrect usage of MethodIterator skpping the first method. add a test case for overriding but it may not be what we want * add another simple test case for base class * allow private/internal methods in ilasm and add a explict impl test * update reference to mscorlib in il test * add shared generics and variance case * allow interface dispatch to return instantiating stubs with the right PARAM_TYPE calling conv * simple factoring and add a valuetype test case * add a test case for generic virtual methods * a bit more refactoring by moving the CALLCONV_PARAMTYPE logic inside getMethodSigInternal * support explicit methodimpl and remove implicit methodimpl test case * update test cases to give more clear output * Fix a bug where GetMethodDescForSlot chokes on interface MethodDesc without precode. This is accdentally discovered by methodimpl test case when iterating methods on a default interface method that has already been JITted * cleanup code after review and add a bit more comments * update comments * only use custom ILAsm for default interface methods tests - some tests are choking on CoreCLR ilasm for security related stuff * address comments and allow instance methods, and add a constraint value type call test scenario * disable the failing protected method scenario
Diffstat (limited to 'src/vm/method.cpp')
-rw-r--r--src/vm/method.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/vm/method.cpp b/src/vm/method.cpp
index 241a0ccee0..5ac5cafd01 100644
--- a/src/vm/method.cpp
+++ b/src/vm/method.cpp
@@ -1762,7 +1762,11 @@ BOOL MethodDesc::IsSharedByGenericMethodInstantiations()
// Does this method require an extra MethodTable argument for instantiation information?
// This is the case for
// * per-inst static methods in shared-code instantiated generic classes (e.g. static void MyClass<string>::m())
+// - there is no this pointer providing generic dictionary info
// * shared-code instance methods in instantiated generic structs (e.g. void MyValueType<string>::m())
+// - unboxed 'this' pointer in value-type instance methods don't have MethodTable pointer by definition
+// * default interface method called via interface dispatch (e. g. IFoo<string>.Foo calling into IFoo<object>::Foo())
+// - this pointer is ambiguous as it can implement more than one IFoo<T>
BOOL MethodDesc::RequiresInstMethodTableArg()
{
LIMITED_METHOD_DAC_CONTRACT;
@@ -1770,7 +1774,7 @@ BOOL MethodDesc::RequiresInstMethodTableArg()
return
IsSharedByGenericInstantiations() &&
!HasMethodInstantiation() &&
- (IsStatic() || GetMethodTable()->IsValueType());
+ (IsStatic() || GetMethodTable()->IsValueType() || IsDefaultInterfaceMethod());
}
//*******************************************************************************
@@ -1792,7 +1796,7 @@ BOOL MethodDesc::RequiresInstArg()
LIMITED_METHOD_DAC_CONTRACT;
BOOL fRet = IsSharedByGenericInstantiations() &&
- (HasMethodInstantiation() || IsStatic() || GetMethodTable()->IsValueType());
+ (HasMethodInstantiation() || IsStatic() || GetMethodTable()->IsValueType() || IsDefaultInterfaceMethod());
_ASSERT(fRet == (RequiresInstMethodTableArg() || RequiresInstMethodDescArg()));
return fRet;
@@ -1868,7 +1872,8 @@ BOOL MethodDesc::AcquiresInstMethodTableFromThis() {
IsSharedByGenericInstantiations() &&
!HasMethodInstantiation() &&
!IsStatic() &&
- !GetMethodTable()->IsValueType();
+ !GetMethodTable()->IsValueType() &&
+ !IsDefaultInterfaceMethod();
}
//*******************************************************************************
@@ -2582,7 +2587,10 @@ BOOL MethodDesc::RequiresStableEntryPoint(BOOL fEstimateForChunk /*=FALSE*/)
return TRUE;
// TODO: Can we avoid early allocation of precodes for interfaces and cominterop?
- if ((IsInterface() && !IsStatic()) || IsComPlusCall())
+ // Only abstract virtual interface method need precode
+ // @DIM_TODO - We need to decide what is the right approach for precode for default
+ // interface methods
+ if ((IsInterface() && IsAbstract() && IsVirtual() && !IsStatic()) || IsComPlusCall())
return TRUE;
}
@@ -2678,7 +2686,7 @@ BOOL MethodDesc::MayHaveNativeCode()
_ASSERTE(IsIL());
- if ((IsInterface() && !IsStatic()) || IsWrapperStub() || ContainsGenericVariables() || IsAbstract())
+ if (IsWrapperStub() || ContainsGenericVariables() || IsAbstract())
{
return FALSE;
}