6

.NET compilation has two phases

  • 1 . Compilation to IL code.

  • 2 . JIT compilation to native code.

Can both these stages can be categorized as compile time? Or does the JIT compilation to native code comes under runtime ?

In terms of error, if an error occurs at the phase two, is it a run time error? (Any error that occurs after the phase 2 ie, when the native code is actually executed should be a run time error )

2 Answers 2

4

As per my understanding -

Compiling C# to MSIL and compiling MSIL to native code are two stages of the compilation process. Errors occurring in both stages are compile time errors.

However, it is unlikely that there will be any compilation errors in second stage (JIT). If your C# code compiles correctly to MSIL then it will certainly be JITed to the native code without any problems.

IMO the most important thing that happens during JITing is optimizations for the native platform.

Run-time errors are those which happen during executing your JITed native code.

2
  • 1
    That should be if your MSIL is verifiable IL; non-verifiable IL can cause buffer overflows & other bugs just like normal assembler (although these are often picked up by the CLR which throws an exception).
    – thecoop
    Feb 10, 2011 at 9:09
  • download.microsoft.com/download/2/4/d/… As per the PPT the JIT compiler and the Native Code both comes under the execution section.This should mean compile time as compiling to IL only. JIT phase should be run time. Another related presentation can be accessed from below link download.microsoft.com/download/e/2/1/…
    – rjv
    Feb 11, 2011 at 3:42
0

A case in which the JIT compilation could fail is when building dynamic assemblies with System.Reflection.Emit members.

I'd consider it a runtime error, a compile time error being an error raised when the C# compiler detects an error in the code that emits the IL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.