[Issue 3490] New: DMD Never Inlines Functions that Could Throw

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 9 06:26:20 PST 2009


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

           Summary: DMD Never Inlines Functions that Could Throw
           Product: D
           Version: 2.036
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2009-11-09 06:26:18 PST ---
Here's an absurdly simple test program.  enforceStuff() does not get inlined,
as the disassembly below shows.  I couldn't find anything about exceptions in
inline.c, but if this doesn't get inlined, I assume nothing that could throw
ever does.  

This severely affects the performance of std.range, since Andrei uses enforce()
all over the place, causing lots of stuff not to be inlined.  For example, I
read disassemblies involving std.range.Take and it seems like Take.popFront()
and Take.front() are never inlined.

void main() {
    enforceStuff(1);
}

void enforceStuff(uint num) {  // Not inlined.
   if(num == 0) {
       throw new Exception("");
   }
}

Disassembly of main():

__Dmain PROC NEAR
;  COMDEF __Dmain
        push    eax                                     ; 0000 _ 50
        mov     eax, 1                                  ; 0001 _ B8, 00000001
        call    _D5test812enforceStuffFkZv              ; 0006 _ E8,
00000000(rel)
        xor     eax, eax                                ; 000B _ 31. C0
        pop     ecx                                     ; 000D _ 59
        ret                                             ; 000E _ 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