Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2018-03-09 01:03:54 +0300
committerJan Kotas <jkotas@microsoft.com>2018-03-09 01:03:54 +0300
commit05387754f374ab9fc68eae7123a9b18c5bafd73c (patch)
treecc5c06a42b7ad19f154938c1d6f7ae61a1a9289b
parentf6435d0812fd50927d1dff32c2a811117e50a1fc (diff)
Fix IL of open instance thunk (#5516)
When we have an open instance thunk for a method on a valuetype (i.e. a delegate whose signature has a `ref` (valuetype) first parameter), we shouldn't push the first argument to `GetActualTargetFunctionPointer` because that method expects a reference type. Project N delegate transform already has this fix.
-rw-r--r--src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
index af8cb9a05..c7e798122 100644
--- a/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
+++ b/src/Common/src/TypeSystem/IL/Stubs/DelegateThunks.cs
@@ -187,11 +187,20 @@ namespace Internal.IL.Stubs
// Call a helper to get the actual method target
codeStream.EmitLdArg(0);
- codeStream.EmitLdArg(1);
- if (boxThisType != null)
+
+ if (Signature[0].IsByRef)
{
- codeStream.Emit(ILOpcode.box, emitter.NewToken(boxThisType));
+ codeStream.Emit(ILOpcode.ldnull);
+ }
+ else
+ {
+ codeStream.EmitLdArg(1);
+ if (boxThisType != null)
+ {
+ codeStream.Emit(ILOpcode.box, emitter.NewToken(boxThisType));
+ }
}
+
codeStream.Emit(ILOpcode.call, emitter.NewToken(SystemDelegateType.GetKnownMethod("GetActualTargetFunctionPointer", null)));
MethodSignature targetSignature = new MethodSignature(0, 0, Signature.ReturnType, parameters);