From cc58f38be5965e0fedf62882440a6bf6811e3a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 8 Mar 2018 19:39:43 +0100 Subject: Fix up handling of Delegate.Invoke in the scanner (#5515) We special case the method to avoid unnecessarily creating the body (it's pretty big). The codegen might ask questions about the vtable before realizing it's this special method. If the delegate type is not allocated, (not a ConstructedEEType) we wouldn't have vtable information for it from the scanner. Fixing that. --- src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs b/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs index 009dc068b..17bfecd2a 100644 --- a/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs +++ b/src/ILCompiler.Compiler/src/IL/ILImporter.Scanner.cs @@ -354,10 +354,14 @@ namespace Internal.IL } } - if (method.OwningType.IsDelegate && method.Name == "Invoke") + if (method.OwningType.IsDelegate && method.Name == "Invoke" && + opcode != ILOpcode.ldftn && opcode != ILOpcode.ldvirtftn) { - // TODO: might not want to do this if scanning for reflection. - // This is expanded as an intrinsic, not a function call. + // This call is expanded as an intrinsic; it's not an actual function call. + // Before codegen realizes this is an intrinsic, it might still ask questions about + // the vtable of this virtual method, so let's make sure it's marked in the scanner's + // dependency graph. + _dependencies.Add(_factory.VTable(method.OwningType), reason); return; } -- cgit v1.2.3