Inline Functions

dsimcha dsimcha at yahoo.com
Tue Feb 24 13:54:07 PST 2009


== Quote from Bill Baxter (wbaxter at gmail.com)'s article
> I seem to remember from a previous discussion about  optimizing a
> ray-tracer that DMD will not inline functions that take reference
> parameters.   Can anyone else confirm this?
> --bb

Here's a test program I wrote and the relevant parts of the disassembly.  It was
compiled w/ -O -inline -release.  I think you're right, strange as it seems.  I
wonder why ref is never inlined.

void main() {
    uint foo;
    inc(foo);
}

void inc(ref uint num) {
    num++;
}

__Dmain PROC NEAR
;  COMDEF __Dmain
        push    eax
        lea     eax, [esp]
        mov     dword ptr [esp], 0
        call    _D4test3incFKkZv
        xor     eax, eax
        pop     ecx
        ret
__Dmain ENDP

_text$__Dmain ENDS

_text$_D4test3incFKkZv SEGMENT DWORD PUBLIC 'CODE'

_D4test3incFKkZv PROC NEAR
;  COMDEF _D4test3incFKkZv
        inc     dword ptr [eax]
        ret
_D4test3incFKkZv ENDP



More information about the Digitalmars-d mailing list