Object.factory() and exe file size bloat

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 22 01:53:39 PDT 2015


Am Fri, 21 Aug 2015 11:46:21 +0000
schrieb "Kagamin" <spam at here.lot>:

> On Friday, 21 August 2015 at 11:03:09 UTC, Mike wrote:
> > * postblit - 
> > https://github.com/D-Programming-GDC/GDC/pull/100/files?diff=unified#diff-1f51c84492753de4c1863d02e24318bbR918
> > * destructor - 
> > https://github.com/D-Programming-GDC/GDC/pull/100/files?diff=unified#diff-1f51c84492753de4c1863d02e24318bbR1039
> 
> Looks like these are generated for fixed sized array of structs 
> in a struct.
> 
> > * slicing - 
> > https://github.com/D-Programming-GDC/GDC/pull/100/files?diff=unified#diff-5960d486a42197785b9eee4ba95c6b95R11857
> 
> Can't even understand, what is this. Array op? But array ops are 
> handled just above.

If you do
'array[] = n'
the compiler calls one of _d_arraysetctor,
_d_arraysetassign, _d_arrayassign, _d_arrayctor or _d_arraycopy.

http://wiki.dlang.org/Runtime_Hooks

The calls basically copy n to the array and call the postblit for every
value in array[]. They also call 'TypeInfo.destroy' (destructor) on old
values before overwriting. arraycopy doesn't use TypeInfo. The rest
could be easily rewritten to be templated* or completely compiler
generated.

* I'm not sure if we support manually accessing the postblit of a type.
  OTOH if these functions were templated the compiler would likely emit
  the correct postblit/destroy calls automatically.


More information about the Digitalmars-d mailing list