<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 13 August 2015 at 04:33, Daniel Murphy <span dir="ltr"><<a href="mailto:yebblies@gmail.com" target="_blank">yebblies@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Aug 13, 2015 at 12:53 AM, Iain Buclaw via dmd-internals<br>
<<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a>> wrote:<br>
> On 12 August 2015 at 00:59, Martin Nowak <<a href="mailto:code@dawg.eu">code@dawg.eu</a>> wrote:<br>
><br>
</span><span class="">> These are all places where class allocations occur the most it seems.<br>
><br>
> I was about to propose making this change:<br>
><br>
>  extern (C) Object _d_newclass(const ClassInfo ci)<br>
>  {<br>
>      auto p = allocmemory(ci.init.length);<br>
> +    *(cast(void **) p) = cast(void*) ci.vtbl;<br>
> -    p[0 .. ci.init.length] = cast(void[])ci.init[];<br>
>      return cast(Object)p;<br>
>  }<br>
><br>
> But then I checked and found out that Daniel removes all ctors in the D<br>
> conversion. =)<br>
><br>
> I guess this is the reason why memcpy calls have increased!<br>
><br>
<br>
</span>We don't have support for constructing classes across the language<br>
boundary, and without the memcpy the member variables will be<br>
uninitialized.  D (or at least dmd's druntime) requires the init[]<br>
blit before constructor calls anyway.<br>
</blockquote></div><br><br></div><div class="gmail_extra">I did some testing with gdc and made another discovery:<br><br><a href="https://issues.dlang.org/show_bug.cgi?id=14912">https://issues.dlang.org/show_bug.cgi?id=14912</a><br><br></div><div class="gmail_extra">This is a sometimes-used pattern in dmd is to do the following when lowering code in the frontend.<br><br></div><div class="gmail_extra">  FooExp *fe = new FooExp(type, e);<br></div><div class="gmail_extra">  return fe->semantic(sc);<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards<br></div><div class="gmail_extra">Iain<br></div></div>