On 13 August 2015 at 04:33, Daniel Murphy <[email protected]> wrote:
> On Thu, Aug 13, 2015 at 12:53 AM, Iain Buclaw via dmd-internals > <[email protected]> wrote: > > On 12 August 2015 at 00:59, Martin Nowak <[email protected]> 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
_______________________________________________ dmd-internals mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-internals
