<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 19 August 2015 at 21:00, deadalnix via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wednesday, 19 August 2015 at 18:47:21 UTC, Paulo Pinto wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wednesday, 19 August 2015 at 18:41:07 UTC, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 8/19/2015 11:03 AM, Jacob Carlborg wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Not sure how the compilers behave in this case but what about devirtualization?<br>
Since I think most developers compile their D programs with all files at once<br>
there should be pretty good opportunities to do devirtualization.<br>
</blockquote>
<br>
It's true that if generating an exe, the compiler can mark leaf classes as final and get devirtualization. (Of course, you can manually add 'final' to classes.)<br>
<br>
It's one way D can generate faster code than C++.<br>
</blockquote>
<br>
C++ also has final and if I am not mistaken both LLVM and Visual C++ do devirtualization, not sure about other compilers.<br>
</blockquote>
<br></div></div>
GCC is much better than LLVM at this. This is an active area of work in both compiler right now.<br><br></blockquote><div><br></div><div>Can't speak for LLVM, but scope classes in GDC are *always* devirtualized because the compiler knows the vtable layout and using constant propagation to find the direct call.<br><br></div><div>You *could* do this with all classes in general, but this is a missed opportunity because the vtable is initialized in the library using memcpy, rather than by the compiler using a direct copy assignment.<br><br><a href="https://issues.dlang.org/show_bug.cgi?id=14912">https://issues.dlang.org/show_bug.cgi?id=14912</a><br><br></div><div>I not sure even LTO/PGO could see through the memcpy to devirtualize even the most basic calls.<br></div><div> <br></div></div></div></div>