Re: Can you write code directly in CIL ???




"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
news:O%23d6lF5CGHA.1032@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Peter Olcott" <olcott@xxxxxxx> wrote in message
> news:egksf.38007$QW2.25703@xxxxxxxxxxxxx
>>
>> "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
>> news:MPG.1e1b84c73d78be9098cbe4@xxxxxxxxxxxxxxxxxxxxxxx
>>> Nicholas Paldino [.NET/C# MVP] <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>> I will second that the C++ compiler is better at optimizing IL output
>>>> than the C# compiler. However, as Willy stated, it will not always produce
>>>> verifiable code... I believe the article you were looking for is in MSDN
>>>> magazine.
>>>
>>> No, the article was definitely someone posting in this group saying, "I
>>> want to be able to embed IL in my C# code, here's why." He then
>>> produced some better IL (which I suspect *was* verifiable) which the C#
>>> compiler "could" have produced from the source C# (i.e. the behaviour
>>> was identical).
>>>
>>> I'm sure this will improve over time, but to be honest it's usually the
>>> JIT that has more to do with optimisation IMO.
>>
>> I wouldn't think that this would be the case for two reasons:
>> (1) CIL (for the most part) forms a one-to-one mapping with assembly language
>
> Not true, IL is kind of high level language compared to X86 assembly, one
> single IL instruction translates to x assembly level instructions where x is
> certainly not 1.
Many of the instructions (all the ones in my critical 100 line function) would
map one-to-one with assembly language. All of the code in this critical 100 line
function is comparisons, branches, and the data movement of single integers.

>
>> (2) End users are waiting on the JIT to complete, no time to waste doing
>> optimizations that could have been done before the softwae shipped.
>>
>
> Wrong again, IL is not optimized that much, THE optimizer is the JIT. It's
The JIT probably does all the processor specific optimizations. These don't
affect performance nearly as much as the ones that are not processor specific.

> the JIT that knows at run-time what kind of optmizations can be performed
> depending on the characteristics of the HW like CPU type 32bit/64 bit, number
> of registers, L1 and L2 cache sizes, MMX/SSE enabled etc.
> The CLR is a run-time optimizing execution engine, whether you believe it or
> not.
>
>
> Willy.
>
>


.



Relevant Pages

  • JIT compiler optimizations (inlining threshold too low?)
    ... I noticed that the performance of the JIT optimizer has not improved as much ... I know that there is a tradeoff between JIT optimizations and startup speed. ... public static Complex Zero ... double xre, xim, cre, cim, t; ...
    (microsoft.public.dotnet.framework.performance)
  • Re: JIT Optimizations Lacking!
    ... Nathan Zaugg wrote: ... performed during the JIT compilation is not nearly as good as the ... optimizations done by C++ at compile time. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: optimized code
    ... > loop invariants are handled by the JIT not by the compiler fron-ends. ... generates the best optimized MSIL of any of the .NET languages. ... standard native code optimizations on MSIL code. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: optimized code
    ... All depends on what exactly you are measuring, how you are comparing and ... produced by the C++ compiler, when enabling max. optimizations (enables the ... > "Floating Point?The v1 JIT does not currently perform all the FP-specific ... > optimizations that the VC++ backend does, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: interpreter vs. compiled
    ... there is a process that runs product instructions, ... the notion that JIT technology compiles code. ... my C implementation a compiler. ... new machine language for each one. ...
    (comp.lang.python)

Loading