[dmd-internals] 3rd Biweekly Sprint Planning

Iain Buclaw via dmd-internals dmd-internals at puremagic.com
Wed Aug 12 21:57:00 PDT 2015


On 13 August 2015 at 04:33, Daniel Murphy <yebblies at gmail.com> wrote:

> On Thu, Aug 13, 2015 at 12:53 AM, Iain Buclaw via dmd-internals
> <dmd-internals at puremagic.com> wrote:
> > On 12 August 2015 at 00:59, Martin Nowak <code at dawg.eu> wrote:
> >
> > These are all places where class allocations occur the most it seems.
> >
> > I was about to propose making this change:
> >
> >  extern (C) Object _d_newclass(const ClassInfo ci)
> >  {
> >      auto p = allocmemory(ci.init.length);
> > +    *(cast(void **) p) = cast(void*) ci.vtbl;
> > -    p[0 .. ci.init.length] = cast(void[])ci.init[];
> >      return cast(Object)p;
> >  }
> >
> > But then I checked and found out that Daniel removes all ctors in the D
> > conversion. =)
> >
> > I guess this is the reason why memcpy calls have increased!
> >
>
> We don't have support for constructing classes across the language
> boundary, and without the memcpy the member variables will be
> uninitialized.  D (or at least dmd's druntime) requires the init[]
> blit before constructor calls anyway.
>


I did some testing with gdc and made another discovery:

https://issues.dlang.org/show_bug.cgi?id=14912

This is a sometimes-used pattern in dmd is to do the following when
lowering code in the frontend.

  FooExp *fe = new FooExp(type, e);
  return fe->semantic(sc);

Regards
Iain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20150813/11fcd717/attachment-0001.html>


More information about the dmd-internals mailing list