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-04-26 06:45:26 +0300
committerJan Kotas <jkotas@microsoft.com>2018-04-26 06:45:26 +0300
commitaa517a501cff11952a366f080a4bae74488ca9ef (patch)
tree752634e7e4d3421392d9959a6ff4facba5fb30bd /src/ILCompiler.Compiler
parentf771b2f01a2e2fd75e50cd548de7e28c200f20e7 (diff)
Devirtualize delegate creation to sealed virtuals (#5749)
These could be in sealed vtable slots.
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/Compilation.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/Compilation.cs b/src/ILCompiler.Compiler/src/Compiler/Compilation.cs
index dcf64de1a..7df723cb5 100644
--- a/src/ILCompiler.Compiler/src/Compiler/Compilation.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/Compilation.cs
@@ -90,6 +90,12 @@ namespace ILCompiler
public DelegateCreationInfo GetDelegateCtor(TypeDesc delegateType, MethodDesc target, bool followVirtualDispatch)
{
+ // If we're creating a delegate to a virtual method that cannot be overriden, devirtualize.
+ // This is not just an optimization - it's required for correctness in the presence of sealed
+ // vtable slots.
+ if (followVirtualDispatch && (target.IsFinal || target.OwningType.IsSealed()))
+ followVirtualDispatch = false;
+
return DelegateCreationInfo.Create(delegateType, target, NodeFactory, followVirtualDispatch);
}