views:

59

answers:

1

I would like to use directly the .NET JIT Compiler, is it possible ?

I mean, I would like to do a thing like :

?> jit.exe myfile.msil myfile.exe

Or in a c# code ?

+3  A: 

I think what you're looking for is roughly ngen.

Note that although this generates native code:

  • It still runs within the CLR (the managed runtime)
  • The original IL is still maintained (so it can be recompiled if the processor has changed or something similar)
  • The optimizations performed by ngen and the JIT can differ

IMO, ngen is usually not appropriate... what are you trying to do?

Jon Skeet
Hmm not sure it's a good way because what I want to do is to test JIT compiler... (fuzzing, performance, etc...)
MickAA
@Thomas: What *exactly* are you trying to achieve? Do you need to examine the JIT-compiled code? What couldn't you do just by running the code and letting the JIT do its stuff at execution time?
Jon Skeet
No I can't because if my code is malformed, it will not pass the PEVerifier...
MickAA
@Thomas: If your code is malformed, won't that mess up the JIT as well? Starting with malformed code doesn't sound like a good plan. Again, it would really help if you would provide more context.
Jon Skeet
@Jon Skeet: Fuzzing
MickAA
@Thomas: Given that we're trying to help you, you might want to provide more than single word responses. Edit your question to give the full background of what you're trying to do, why, why you need to JIT compile for it to work, and why you believe that JIT compilation would be successful but just running it wouldn't. The word "fuzzing" could have a number of different meanings here - the more detail you can give, the less likely it will be that we'll misunderstand you.
Jon Skeet