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

--- Comment #0 from David Simcha <> 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() {

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

Disassembly of main():

;  COMDEF __Dmain
        push    eax                                     ; 0000 _ 50
        mov     eax, 1                                  ; 0001 _ B8, 00000001
        call    _D5test812enforceStuffFkZv              ; 0006 _ E8,
        xor     eax, eax                                ; 000B _ 31. C0
        pop     ecx                                     ; 000D _ 59
        ret                                             ; 000E _ C3
__Dmain ENDP

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to