Example of Rust code

Timon Gehr timon.gehr at gmx.ch
Sat Aug 11 15:57:37 PDT 2012


On 08/12/2012 12:34 AM, David Nadlinger wrote:
> On Saturday, 11 August 2012 at 22:17:44 UTC, Timon Gehr wrote:
>>> Will generated code differ?
>>
>> Only the mangled symbol name will differ. (unlike when scope is used on
>> delegate parameters, in this case it prevents closure allocation at
>> the call site.)
>
> The code for callee stays the same, yes, but the code for the caller
> might change as the optimizer is free to take advantage of the fact that
> any reference in the parameters will not be escaped by the function. For
> example, LDC will stack-allocate dynamic arrays and objects if they are
> local to the function. [1]
>
> David
>
>
> [1] The fine print: We currently don't take advantage of "scope"
> parameters for this yet, though (it seems too dangerous with the related
> analysis not being implemented in the frontend),  and for a completely
> unrelated reason, the code which performs the mentioned optimization is
> disabled in current master (but will be re-enabled in the near future,
> before the September release).

Is there an upper bound on the amount of allocated memory? Implicit
stack-allocation of arbitrarily-sized dynamic arrays seems dangerous.


More information about the Digitalmars-d mailing list