new should lower to a template function call
Per Nordlöw
per.nordlow at gmail.com
Thu Jul 23 11:54:20 UTC 2020
On Thursday, 23 July 2020 at 05:12:30 UTC, Walter Bright wrote:
> The compiler already does this if the variable being new`d is
> `scope`.
Interesting.
BTW:
1. could such `scope`d new's be allocated on a thread-local heap
(instead of the global GC heap) thereby eliding the costly
spinlock in the current GC implementation, given that we provide
a separate lock-less interface in the GC for scoped allocations?
That would make new's even faster for small sizes.
2. how could this `scope`-qualification of `new`s be inferred by
the compiler using escape analysis of the `new`-ed variable? Do
you any plans on implementing this for the simple cases, Walter?
If it's costly could be activated in release mode?
More information about the Digitalmars-d
mailing list