Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer is more likely: no one did more than PGO for C++ because the benefits are likely unnoticeable.</p> <p>Let me elaborate: <em>JIT</em> engines/runtimes have both blesses and drawbacks from their developer's view: they have more information at runtime but much little time to analyze. Some optimizations are really expensive and you will unlikely see without a huge impact on start time are those one like: loop unrolling, auto-vectorization (which in most cases is also based on loop unrolling), instruction selection (to use SSE4.1 for CPU that use SSE4.1) combined with instruction scheduling and reordering (to use better super-scalar CPUs). This kind of optimizations combine great with C like code (that is accessible from C++). </p> <p>The single full-blown compiler architecture to do advanced compilation (as far as I know) is the Java <em>Hotspot</em> compilation and architectures with similar principles using tiered compilation (Java <em>Azul</em>'s systems, the popular to the day <em>JaegerMonkey</em> JS engine).</p> <p>But one of the biggest optimization on runtime is the following:</p> <p><strong>Polymorphic inline caching</strong> (meaning that if you run the first loop with some types, the second time, the code of the loop will be specialized types that were from previous loop, and the <em>JIT</em> will put a guard and will put as default branch the inlined types, and based on it, from this specialized form using a <em>SSA</em>-form engine based will apply constant folding/propagation, inlining, dead-code-elimination optimizations, and depends of how "advanced" the <em>JIT</em> is, will do an improved or less improved CPU register assignment.) As you may notice, the <em>JIT</em> (hotspots) will improve mostly the branchy code, and with runtime information will get better than a C++ code, but a static compiler, having at it's side the time to do analysis, instruction reordering, for simple loops, will likely get a little better performance. Also, typically, the C++ code, areas that need to be fast tends to not be OOP, so the information of the <em>JIT</em> optimizations will not bring such an amazing improvement.</p> <p>Another advantage of <em>JITs</em> is that <em>JIT</em> works cross assemblies, so it has more information if it wants to do inlining. </p> <p>Let me elaborate: let's say that you have a base class A and you have <strong>just one</strong> implementation of it namely B in another package/assembly/gem/etc. and is loaded dynamically.</p> <p>The <em>JIT</em> as it see that B is the only implementation of A, it can replace everywhere in it's internal representation the A calls with B codes, and the method calls will not do a dispatch (look on vtable) but will be direct calls. Those direct calls may be inlined also. For example this B have a method: <code>getLength()</code> which returns 2, all calls of <code>getLength()</code> may be reduced to constant 2 all over. At the end a C++ code will not be able to skip the virtual call of B from another dll.</p> <p>Some implementations of C++ do not support to optimize over more .cpp files (even today there is the -lto flag in recent versions of <em>GCC</em> that makes this possible). But if you are a C++ developer, concerned about speed, you will likely put the all sensitive classes in the same static library or even in the same file, so the compiler can inline it nicely, making the extra information that JIT have it by design, to be provided by developer itself, so no performance loss.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload