Common Type System—Interface Method Dispatch


Jump to: navigation, search
Visual C# Tutorials
.NET Framework Tutorials

Common Type System

© 2006 Wiley Publishing Inc.

Interface Method Dispatch

An interface call is roughly equivalent to making a virtual method call. While the IL looks the same— that is, it gets emitted as a callvirt instruction—there is actually an extra layer of indirection in the implementation necessary to perform the method dispatch. If you look at the machine code that the JIT produces, it includes a lookup into the interface map (which hangs off the method table) in order to correlate the implementation of an interface to the correct slot in the method table. In most circumstances, this performance overhead shouldn’t be a concern.

As noted earlier—and it applies here too—to make a virtual method invocation on a value type requires the value to be boxed first. Constrained calls, a new feature in 2.0, enable the runtime to optimize this away in some circumstances.


Previous_Page_.gif Next_Page_.gif





Personal tools
Share this page