Re: C# and compiler optimizer.



Olaf Baeyens wrote:

I am trying to understand the IL assembler created by C# but as far as I can
see, there is no optimizing done by the C# compiler.
Optimizing is done by the JIT, but it can only go so far.

<theory>
A JIT can just start by running the optimizations a traditional compiler would do. Offline compilers can never be more "optimizing" than JIT.
</theory>


In C++ you can put the 'inline' keyword for properties and methods that
could be inserted into the generated code so you avoid a call and thus the
overhead, but as far as I can see, C# does not seem to have this
functionality.

Even in C++, "inline" is a linkage-specifier, not a specification of inling. The c++ compiler can choose to emit it as a separate function and call-instructions, but the function must have internal linkage.


You can easily verify this by compiling a recursive function:

  inline int f(int x) { return f(x+1); }
  int main(int argc, string** argv) { return f(0); }

Compilers (and some JIT's) today have *very* advanced analysis of when inlining should be applied and when it should not.

Which specific performance problem do you have which can be solved by letting you specify inlining?

--
Helge Jensen
  mailto:helge.jensen@xxxxxxx
  sip:helge.jensen@xxxxxxx
               -=> Sebastian cover-music: http://ungdomshus.nu <=-
.



Relevant Pages

  • Re: "Sorting" assignment
    ... too slow, other times for optimizing too much, some times for being too ... That is a rather bizarre, not-quite-C compiler, but ok. ... The overlap issue is a different problem, but performing a "swap" on ... CPU hardware feature differences that can be incredibly important to ...
    (comp.programming)
  • Re: C# and compiler optimizer.
    ... letting you specify inlining? ... A JIT can just start by running the optimizations a traditional compiler would do. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why INFINITE loop in a thread occupy so much CPU time??
    ... measuring code quality or program efficiency. ... You stated the K&R compiler did the silly thing of testing ... In debug mode, nothing, repeat nothing, matters. ... my Ph.D. is in optimizing compiler technology. ...
    (microsoft.public.vc.mfc)
  • Re: Compiler code optimization: see code below
    ... >>I'm writing some C to be used in an embedded environment and the code ... I'm using GCC for the workstation and Diab compiler for the ... >>sure what exactly a good optimizing compiler can optimize away. ... > Neither optimization nor efficiency is defined by the C standard. ...
    (comp.lang.c)
  • RE: Constant expressions implicit conversions not performed at ru
    ... an optimizing compiler would produce same code ... decrease performance. ... I haven't checked to see whether or not the JIT *does* optimise ...
    (microsoft.public.dotnet.languages.csharp)

Loading