dmd 1.045 / 2.030 release

bearophile bearophileHUGS at lycos.com
Tue May 12 13:06:34 PDT 2009


Walter Bright:
> I suppose at this point we might as well make it official.

I can see a large number of bugfixes. Lot of work.

DMD v1.042 compiles my dlibs fine. But if I try to compile them with v1.045 the compiler prints before stopping:

Assertion failure: '0' on line 136 in file 'statement.c'

So I'll keep using v1.042 for now.


I can't see the "vtls" switch when dmd v2.030 prints its usage switches, but it works.



>added .typeinfo to ClassInfo<

Can someone explain me a bit the purpose/usefulness of this?


>As D is a systems language, of course there's a way to do this. Use the storage class __gshared:<

In future this may change, but at the moment a significant percentage of the little programs is single-thread. So if the decrease of performance is significant (and I don't know if it is, see below) then a compiler switch may be added that defaults all global variables to __gshared (and if possible optionally uses simple means to try to forbid multi-threaded code).

I have done a tiny benchmark:


import std.c.stdio: printf;

//int x; // global
__gshared int x;
//shared int x;

void main() {
    //int x; // local

    //for (int i; i < 1_000_000_000; i++)
    foreach (i; 0 .. 1_000_000_000)
        x++;
    printf("%d\n", x);
}


Timings, n=1_000_000_000, best of 6, seconds:
  DMD2:
    global for:        2.72
    global foreach:    2.62
    __gshared for:     3.03
    __gshared foreach: 3.09
    shared for:        3.07
    shared foreach:    3.08
    local for:         0.57
    local foreach:     0.57

  DMD1:
    global for:        3.08
    local for:         0.55

For this tiny code it seems that __gshared reduces the loop performance.

---------------------------

DMD2 __gshared for:

L0:     push    EAX
        xor EAX,EAX
L3:     inc dword ptr _D17thread_local_test1xi
        inc EAX
        cmp EAX,03B9ACA00h
        jb  L3
        push    dword ptr _D17thread_local_test1xi
        mov EAX,offset FLAT:_DATA
        push    EAX
        call    near ptr _printf
        [...]        

---------------------------

DMD2 global for:

L0:     push    EAX
        xor ECX,ECX
        push    EBX
        push    ESI
L5:     mov EAX,FS:__tls_array
        mov EDX,[EAX]
        inc ECX
        inc dword ptr _D17thread_local_test1xi[EDX]
        cmp ECX,03B9ACA00h
        jb  L5
        mov ECX,FS:__tls_array
        mov EBX,[ECX]
        mov ESI,offset FLAT:_DATA
        push    dword ptr _D17thread_local_test1xi[EBX]
        push    ESI
        call    near ptr _printf
        [...]

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list