November 14, 2015 Re: DMD is faster than LDC and GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 13 November 2015 at 19:59:51 UTC, Ali Çehreli wrote: > On 11/12/2015 11:50 AM, Ali Çehreli wrote: >> I would love to be convinced. :) Can someone come up with a reduced >> example please? >> >> On 11/12/2015 03:59 AM, Daniel Kozak wrote: >> >> > for (i=0; i < 1000000; ++i) { >> > fmttable(table); >> > } >> >> I think what we are seeing here is more due to the unused side-effect in >> the loop, where compiling with -w fails compilation: >> >> Warning: calling deneme.fmttable without side effects discards return >> value of type string, prepend a cast(void) if intentional >> >> Ali >> > > Can someone please tell me if I am mistaken not. > > Once again, I don't think this example is fast because the compiler reuses the return value of fmttable() in the loop. Rather, it simply removes the whole expression because its only side-effect is not used in the program. > > Perhaps that's what everybody else is saying anyway. :) > > (Why don't I look at the assembly myself? Going to a meeting... :p) > > Ali I confirm it, here is the loop part: 0x004375c2 31db xor ebx, ebx ┌─> 0x004375c4 ffc3 inc ebx │ 0x004375c6 81fb40420f00 cmp ebx, 0xf4240 └─< 0x004375cc 72f6 jb 0x4375c4 0x004375ce 8bfb mov edi, ebx 0x004375d0 e8230d0000 call sym._D3std5stdio14__T7writelnTiZ7writelnFNfiZv (DMD 2.069 -O -release -inline -boundscheck=off, code from the first post) |
November 14, 2015 Re: DMD is faster than LDC and GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Saturday, 14 November 2015 at 00:37:51 UTC, Manu wrote:
> In the meantime, there probably needs to be strong warnings about violating attributes, and if patterns have emerged that rely on violating such attributes, we should publish a recommended alternative.
One pattern that comes to mind immediately is lazily initialized members in a const object.
Another one that's already officially supported is impure debug statements in pure functions.
|
Copyright © 1999-2021 by the D Language Foundation