ldc 0.9.1 released
bearophile
bearophileHUGS at lycos.com
Wed May 27 14:19:08 PDT 2009
Frits van Bommel:
Thank you for your answers.
> This one is only done for certain GC allocations by the way, not all of them.
> The ones currently implemented are:
> * new Struct/int/float/etc.,
> * uninitialized arrays (used for arr1 ~ arr2, for instance),
> * zero-initialized arrays (e.g. new int[N])
> * new Class, unless
> a) it has a destructor,
> b) it has a custom allocator (overloads new), or
> c) it has a custom deallocator (overloads delete).
I'm trying to find situations where that's true, but in two small programs that use both structs and classes (that don't escape the scope and follow your unless list) I see:
call _d_allocmemoryT
call _d_allocclass
Are those calls to variants of alloca()?
While looking for those alloca I have also tested code that has the following two lines one after the other:
auto a = new int[1000];
a[] = 2;
That code is very common, because you currently can't write:
auto a = new int[1000] = 2;
The latest LDC compiles that as:
pushl %esi
subl $4016, %esp
leal 16(%esp), %esi
movl %esi, (%esp)
movl $4000, 8(%esp)
movl $0, 4(%esp)
call memset
movl %esi, (%esp)
movl $2, 8(%esp)
movl $1000, 4(%esp)
call _d_array_init_i32
I think the memset may be avoided.
Bye and thank you,
bearophile
More information about the Digitalmars-d-announce
mailing list