[Issue 4440] [patch] Inlining delegate literals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 29 14:27:03 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4440



--- Comment #9 from David Simcha <dsimcha at yahoo.com> 2010-08-29 14:26:50 PDT ---
I just tried this patch out and on second thought I'm not sure it's worth
integrating as-is because it's so limited.  It won't even handle the case where
a function that calls a delegate gets inlined and the delegate passed from the
call site is a literal.  Even the following doesn't get inlined:

bool evaluateDelegate(bool delegate() dg) {
    return dg();
}

void main() {
    evaluateDelegate({return false;});
}


Here's the disassembly of main():

__Dmain PROC NEAR
;  COMDEF __Dmain
        sub     esp, 24                                 ; 0000 _ 83. EC, 18
        xor     eax, eax                                ; 0003 _ 31. C0
        mov     ecx, offset _D5test94mainFZv12__dgliteral1MFZb; 0005 _ B9,
00000000(segrel)
        push    ebx                                     ; 000A _ 53
        mov     edx, ecx                                ; 000B _ 8B. D1
        mov     dword ptr [esp+4H], eax                 ; 000D _ 89. 44 24, 04
        mov     eax, dword ptr [esp+4H]                 ; 0011 _ 8B. 44 24, 04
        mov     ebx, dword ptr [esp+4H]                 ; 0015 _ 8B. 5C 24, 04
        mov     dword ptr [esp+8H], ecx                 ; 0019 _ 89. 4C 24, 08
        call    edx                                     ; 001D _ FF. D2
        xor     eax, eax                                ; 001F _ 31. C0
        pop     ebx                                     ; 0021 _ 5B
        add     esp, 24                                 ; 0022 _ 83. C4, 18
        ret                                             ; 0025 _ C3
__Dmain ENDP

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list