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 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. http://forum.dlang.org/thread/i1g

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 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 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

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 me

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 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 span for arbit

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 t

Re: run-time stack-based allocation

2012-05-07 Thread Gor Gyolchanyan
Yes! I really want it! There are tons of instances when a heap allocation is done instead of stack allocation because of dynamic size alone. If its lifetime is limited by a scope (any scope) - it doesn't belong on the heap! On Tue, May 8, 2012 at 2:07 AM, deadalnix wrote: > Le 07/05/2012 13:58, G

Re: run-time stack-based allocation

2012-05-07 Thread deadalnix
Le 07/05/2012 13:58, Gor Gyolchanyan a écrit : 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 si

Re: run-time stack-based allocation

2012-05-07 Thread Chris Cain
On Monday, 7 May 2012 at 20:20:34 UTC, Mehrdad wrote: Yeah, but mixins are so hacky. They're like C macros, basically. I'd have to say that C macros have many, _many_ more pitfalls than mixins.

Re: run-time stack-based allocation

2012-05-07 Thread Arne
On Monday, 7 May 2012 at 20:20:34 UTC, Mehrdad wrote: On Monday, 7 May 2012 at 16:52:18 UTC, Arne wrote: I think you'd need to modify the compiler for this, since alloca is 'magical'. wouldn't mixin's be a solution, one can inject an alloca to the current scope, and then call the constructor.

Re: run-time stack-based allocation

2012-05-07 Thread Mehrdad
On Monday, 7 May 2012 at 16:52:18 UTC, Arne wrote: I think you'd need to modify the compiler for this, since alloca is 'magical'. wouldn't mixin's be a solution, one can inject an alloca to the current scope, and then call the constructor... Yeah, but mixins are so hacky. They're like C macr

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 wrote: > On Monday, 7 May 2012 at 16:03:15 UTC, Mehrdad wrote: >> >> On Monday, 7 May

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 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 wrote: O

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 wrote: > On Monday, 7 May 2012 at 13:36:02 UTC, Gor Gyolchanyan wrote: >> >> Basically I want w

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 wrote: > On Monday, 7 May 2012 at 13:36:02 UTC, Gor Gyolchanyan wrote: >> >> Basi

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
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 wrote: > On 07-05-2012 14:37, Gor Gyolchanyan wrote: >> >> I can't use alloca, because the stack-

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 Petersen wrote: On 07-05-2012 13:58, Gor Gyolchanyan

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 wrote: > On 07-05-2012 13:58, Gor Gyolchanyan wrote: >> >> I'm working on dynamic memory la

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 size)

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 cal