digitalmars.D.bugs - [Issue 21065] New: the new operator should lower to a template
- d-bugmail puremagic.com (28/28) Jul 22 2020 https://issues.dlang.org/show_bug.cgi?id=21065
https://issues.dlang.org/show_bug.cgi?id=21065 Issue ID: 21065 Summary: the new operator should lower to a template function call in object.d Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: andrei erdani.com Currently the new expression lowers to a nontemplate call in druntime: extern (C) Object _d_newclass(const ClassInfo ci); followed by a call to the appropriate __ctor() if any. This approach has the usual rigidity disadvantages of a runtime solution: loss of compile-time type information in the implementation, awkward to instrument, bulkier code due to indirections. Calls to "new C(a1, a2, a3) should lower to ".object.__makeClassObject!(C)(a1, a2, a3)". That way a function such as: T __makeClassObject(T, A...)(auto ref A); in object.d would carry the allocation and initialization. Such a function would be trivial to instrument, see https://github.com/dlang/dmd/pull/11381. In contrast, the current new instrumentation code is unbearably slow because it uses hash tables. --
Jul 22 2020