Re: run-time stack-based allocation

2012-07-09 Thread David Piepgrass
On Thursday, 10 May 2012 at 03:03:22 UTC, Andrei Alexandrescu wrote: On 5/9/12 3:17 PM, Tove wrote: On Tuesday, 8 May 2012 at 07:03:35 UTC, Gor Gyolchanyan wrote: Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D I just invented an absolutely wicked way of using alloca() in

Re: run-time stack-based allocation

2012-05-10 Thread Tove
On Thursday, 10 May 2012 at 03:03:22 UTC, Andrei Alexandrescu wrote: On 5/9/12 3:17 PM, Tove wrote: On Tuesday, 8 May 2012 at 07:03:35 UTC, Gor Gyolchanyan wrote: Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D I just invented an absolutely wicked way of using alloca() in

Re: run-time stack-based allocation

2012-05-09 Thread Tove
On Tuesday, 8 May 2012 at 07:03:35 UTC, Gor Gyolchanyan wrote: Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D I just invented an absolutely wicked way of using alloca() in the parent context... unfortunately frame_size is static but with some work, it's still an usable

Re: run-time stack-based allocation

2012-05-09 Thread Gor Gyolchanyan
I thought function default parameters need to be statically known... isn't it the case? On Thu, May 10, 2012 at 12:17 AM, Tove t...@fransson.se wrote: On Tuesday, 8 May 2012 at 07:03:35 UTC, Gor Gyolchanyan wrote: Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D I just

Re: run-time stack-based allocation

2012-05-09 Thread David Nadlinger
On Wednesday, 9 May 2012 at 20:52:33 UTC, Gor Gyolchanyan wrote: I thought function default parameters need to be statically known... isn't it the case? Nope – AFAIK you can also do something like (Foo param = new Foo). David

Re: run-time stack-based allocation

2012-05-09 Thread Andrei Alexandrescu
On 5/9/12 3:17 PM, Tove wrote: On Tuesday, 8 May 2012 at 07:03:35 UTC, Gor Gyolchanyan wrote: Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D I just invented an absolutely wicked way of using alloca() in the parent context... Yah, me too.

Re: run-time stack-based allocation

2012-05-08 Thread Gor Gyolchanyan
Cool! Thanks! I'l definitely check it out! I hope it's DDOCed :-D On Tue, May 8, 2012 at 5:29 AM, dsimcha dsim...@yahoo.com wrote: On 5/7/2012 12:08 PM, Gor Gyolchanyan wrote: Wasn't there an allocator mechanism under development for phobos? I remember there was a StackAllocator, that can

run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
I'm working on dynamic memory layout manager. Simply put, it will allow one to create and use struct types at run-time. Normally, you create a struct at compile-time type by specifying an ordered list of fields, each with its own type (basically a size) and name. You then access those fields by

Re: run-time stack-based allocation

2012-05-07 Thread Alex Rønne Petersen
On 07-05-2012 13:58, Gor Gyolchanyan wrote: I'm working on dynamic memory layout manager. Simply put, it will allow one to create and use struct types at run-time. Normally, you create a struct at compile-time type by specifying an ordered list of fields, each with its own type (basically a

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
I can't use alloca, because the stack-based allocation will be done in the constructor and alloca will free the memory as soon as the constructor exists. On Mon, May 7, 2012 at 4:01 PM, Alex Rønne Petersen xtzgzo...@gmail.com wrote: On 07-05-2012 13:58, Gor Gyolchanyan wrote: I'm working on

Re: run-time stack-based allocation

2012-05-07 Thread Alex Rønne Petersen
On 07-05-2012 14:37, Gor Gyolchanyan wrote: I can't use alloca, because the stack-based allocation will be done in the constructor and alloca will free the memory as soon as the constructor exists. On Mon, May 7, 2012 at 4:01 PM, Alex Rønne Petersenxtzgzo...@gmail.com wrote: On 07-05-2012

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
Basically I want what alloca does, but instead of considering the constructor's scope, I want it to hand to the constructor call's enclosing scope. On Mon, May 7, 2012 at 5:29 PM, Alex Rønne Petersen xtzgzo...@gmail.com wrote: On 07-05-2012 14:37, Gor Gyolchanyan wrote: I can't use alloca,

Re: run-time stack-based allocation

2012-05-07 Thread Mehrdad
On Monday, 7 May 2012 at 13:36:02 UTC, Gor Gyolchanyan wrote: Basically I want what alloca does, but instead of considering the constructor's scope, I want it to hand to the constructor call's enclosing scope. I think you'd need to modify the compiler for this, since alloca is 'magical'.

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
I'd decrease ESP to allocate my space, but the problem arises when I try to determine when should I increase it back where it was. Any suggestions on how to do this using asm? On Mon, May 7, 2012 at 8:03 PM, Mehrdad wfunct...@hotmail.com wrote: On Monday, 7 May 2012 at 13:36:02 UTC, Gor

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
Wasn't there an allocator mechanism under development for phobos? I remember there was a StackAllocator, that can span for arbitrary scopes. What's up with that? On Mon, May 7, 2012 at 8:03 PM, Mehrdad wfunct...@hotmail.com wrote: On Monday, 7 May 2012 at 13:36:02 UTC, Gor Gyolchanyan wrote:

Re: run-time stack-based allocation

2012-05-07 Thread Mehrdad
No idea, sorry. :\ On Monday, 7 May 2012 at 16:08:42 UTC, Gor Gyolchanyan wrote: Wasn't there an allocator mechanism under development for phobos? I remember there was a StackAllocator, that can span for arbitrary scopes. What's up with that? On Mon, May 7, 2012 at 8:03 PM, Mehrdad

Re: run-time stack-based allocation

2012-05-07 Thread Arne
On Monday, 7 May 2012 at 16:03:15 UTC, Mehrdad wrote: On Monday, 7 May 2012 at 13:36:02 UTC, Gor Gyolchanyan wrote: Basically I want what alloca does, but instead of considering the constructor's scope, I want it to hand to the constructor call's enclosing scope. I think you'd need to modify

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
That won't do. This is way too ugly, considering, that it needs to be heavily used in user code. I'm thinking an inline ASM solution, but can't figure out when to deallocate. On Mon, May 7, 2012 at 8:52 PM, Arne a...@linux.nu wrote: On Monday, 7 May 2012 at 16:03:15 UTC, Mehrdad wrote: On

Re: run-time stack-based allocation

2012-05-07 Thread dsimcha
On 5/7/2012 12:08 PM, Gor Gyolchanyan wrote: Wasn't there an allocator mechanism under development for phobos? I remember there was a StackAllocator, that can span for arbitrary scopes. What's up with that? I wrote one. It's at https://github.com/dsimcha/TempAlloc . It hasn't been accepted