Optimization of proposed lambda expression for upcoming DIP

Johannes Pfau nospam at example.com
Sat Nov 11 10:19:47 UTC 2017


Am Fri, 10 Nov 2017 02:33:41 +0000
schrieb David Nadlinger <code at klickverbot.at>:

> On Friday, 10 November 2017 at 02:26:46 UTC, Michael V. Franklin 
> wrote:
> > `_Dmain` is equivalent, as I expected, but what's going on with 
> > `main`?  Anything to be concerned about?  
> 
> I think these are just the getter and setter implementation 
> bodies. (Note that main ends with an unconditional jmp to 
> _d_run_main.) No idea why the symbol labels aren't shown.

This is indeed just a bug in the compiler explorer. Disable the 'Remove
all lines which are only comments' option and you'll get this:

main:
        mov     rdx, QWORD PTR _Dmain at GOTPCREL[rip]
        jmp     _d_run_main at PLT
@property uint example.S.prop():
        mov     eax, DWORD PTR [rdi]
        ret
@property uint example.S.prop(uint):
        mov     eax, esi
        mov     DWORD PTR [rdi], esi
        ret
_Dmain:
...

One thing we could improve though is to not emit the lambda as a
separate function, as it can never be called anyway (the only possible
call is inlined).

-- Johannes



More information about the D.gnu mailing list