In Compiler::fgOptimizeDelegateConstructor(.), the JIT firstly obtains a reference to the correct delegate ctor, which in the simple case is CtorOpened(Object target, IntPtr methodPtr, IntPtr shuffleThunk) (link to C# code), before finally wiring up the ctor, inlining it if possible for maximum performance. These are methods marked with MethodImplAttribute(MethodImplOptions.InternalCall) attribute, delegate constructors and tlbimp constructors.Īt runtime this happens when the JIT compiles a method that contains IL code for creating a delegate. Internal methods implemented in unmanaged code. It starts by wiring up the delegate constructor (ctor), as per the BOTR page on ‘method descriptors’ So we’ve seen that the runtime has responsibility for creating the bodies of delegate methods, but how is this done. How the runtime creates delegates Inlining of delegate ctors NET Delegates and Events, By Practice (section on ‘Internal Delegates Representation’) NET Type Internals - From a Microsoft CLR Perspective (section on ‘Delegates’) and Understanding. There’s also more information available in these two excellent articles. implemented by the ‘Execution Engine’), from the ‘Book of the Runtime’ (BOTR) section ‘ Method Descriptor - Kinds of MethodDescs:ĭelegate methods whose implementation is provided by the runtime (Invoke, BeginInvoke, EndInvoke). Methods that are created in this way are technically know as EEImpl methods (i.e. This is because there needs to be complete control over those methods, delegates are a fundamental part of the CLR, any security issues, performance overhead or other inefficiencies would be a big problem. So the internal implementation of a delegate, the part responsible for calling a method, is created by the runtime. It turns out that this behaviour is manadated by the spec, from ECMA 335 Standard - Common Language Infrastructure (CLI): Public SimpleDelegate ( object, IntPtr method ) public virtual string Invoke ( int x )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |