D on next-gen consoles and for game development

Manu turkeyman at gmail.com
Thu May 23 22:37:39 PDT 2013


On 24 May 2013 15:29, deadalnix <deadalnix at gmail.com> wrote:

> On Friday, 24 May 2013 at 05:02:33 UTC, Manu wrote:
>
>> On 24 May 2013 14:11, Marco Leise <Marco.Leise at gmx.de> wrote:
>> I don't think it's hack-ish at all, that's precisely what the stack is
>> there for. It would be awesome for people to use alloca in places that it
>> makes sense.
>> Especially in cases where the function is a leaf or leaf-stem (ie, if
>> there
>> is no possibility of recursion), then using the stack should be
>> encouraged.
>> For safety, obviously phobos should do something like:
>>   void[] buffer = bytes < reasonable_anticipated_buffer_**size ?
>> alloca(bytes) : new void[bytes];
>>
>>
> That is probably something that could be handled in the optimizer in many
> cases.
>

The optimiser probably can't predict if the function may recurse, and as
such, the amount of memory you feel is reasonable to take from the stack is
hard to predict...
It could possibly do so for leaf functions only, but then most of the
opportunities aren't in leaf functions. I'd say a majority of phobos
allocations are created when passing strings through to library/system
calls.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130524/7ef9da52/attachment.html>


More information about the Digitalmars-d mailing list