Does .NET JIT compiler generate different code for generic parameterized with different enums? -
if write (or use) generic class, e.g. list, , parameterize 2 different enumerated types, 2 copies of code jitted? given following articles discuss how jitter generates 1 copy reference types, , 1 copy each value type, think boils down to, "is each specific enum considered different value type purpose of jitting?"
http://msdn.microsoft.com/en-us/library/ms379564%28v=vs.80%29.aspx#csharp_generics_topic1
in c# code:
using system.collections.generic; namespace z { class program { enum {a} enum b {b} class c<t> { } static void main(string[] args) { var x = new c<a>(); var y = new c<b>(); // jit new c constructor enum type b? } } }
i'm interested know in general, .net cf 3.5 (windowsce) jit compiler (edit: because i'm interested in possible code bloat implications). suggestions on best way find out? thinking of writing function in class c p/invokes native code, can break debugger , examine callstack - return address, perhaps can answer authoritatively based on language rules of i'm not aware...
so went ahead , put p/invoke function call c<t>.test function. broke debugger (desktop windows supporting managed , native debugging) in native function, dropped assembly, tracked past ret instruction native function. eip (instruction pointer) after ret consistent returning 2 different routines, 1 c<a>.test, , other c<b>.test. multiple calls through these 2 functions common native function (with breakpoint) showed consistent results. further, post ret eips 0x2e0246 , 0x2e02be, near each other , not mapped loaded dlls's address space. indicates me jitted, , jitted close in time each other, , size of jitted methods small (as expected).
so answer, @ least desktop, generics templated different enums jit different routines.
Comments
Post a Comment