Re: Garbage collection problems




"jacob navia" <jacob@xxxxxxxxxx> wrote in message
news:fi1c6s$pvc$1@xxxxxxxxxxx
cr88192 wrote:
"jacob navia" <jacob@xxxxxxxxxx> wrote in message
news:fi13tb$rbr$2@xxxxxxxxxxx
cr88192 wrote:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote in message
news:47439D4C.F140EE6C@xxxxxxxxxxxx
Paul Hsieh wrote:
... snip ...
It forces call stack uniformity (the EH needs to be able to crawl up
the stack and unwind the stack in a uniform way.) So for example,
To bring things back to reality, there is no reason to have a stack
in any C system.

errm?...

what kind of 'reality' is it you are living in?...


Mr Falconer has his own world, as many people here around.

A stack is not necessary, one complement or sign magnitude
representations rule the world, etc etc.

I think we have touched a trap representation
:-)


yes, ok.


but, it is maybe interesting from a theoretical perspective, aka:
a C-implementation allocating all the call frames on a heap.

so, we want a call frame?
grab it from a free-list (or, somehow, allocate more if needed).

need to store locals? grab a chunk of memory for this and attach to call
frame.
need space for args? likewise, grab a chunk of memory, evaluate and store
in the args, and attach it to the (newly created) call frame of the
function being called.


So, you are implementig the stack in software. Instead of doing a
single register subtract, you allocate memory, put that in the list
of active frames, etc etc!

That would be really bad for performance

yes, as noted in the prev post, a notable performance hit...

a special purpse allocator would be needed hopefully to keep the performance
from being too horrible (in this case, allocating each frame would consist
of a few operations to grab the pieces from the appropriate free-lists).

for example:
;grab a frame
mov ecx, [__magic_frame_free_list]
mov eax, [ecx]
mov [__magic_frame_free_list], eax
;grab args
mov edx, [__magic_args_free_list2]
mov eax, [edx]
mov [__magic_args_free_list2], eax
;do other stuff
....

note that, some means would be needed to make sure free-lists are never
empty (that, or, insert code to check, but this is worse...).


though, it may not be worthwhile in terms of supporting continuations, it
could be worthwhile in allowing an implementation which allows lexical
scoping and closures (assuming some more explicit and cheaper means were not
used in implementing closures instead).


...

afaik, this particular approach is used in many scheme implementations,
for the reason that it makes implementing call/cc really fast and easy
(we can jump outword to some enclosing call frame, do stuff, or jump
right back into a call frame we had previously jumped out of).


call/cc is completely UNREADABlE. You do not see in the program text
where the program is going, you have to figure out what is the current
continuation!!!!!

That was something completely NUTS!


yes...

well, in some of my previous VMs, I generally ended up preferring stacks
over heap-based frames, since function calls are all the time, but
continuations are rare...

it is then acceptable to allow call/cc to do some pretty drastic stuff
(stack cloning, ...), but otherwise have fairly fast execution...

actually, in my last lang which still had continuations, I ended up
initially spliting full and partial continuations, allowing much faster
exit-only continuations (since, IME, this is about the only way I ever
really used them).

I think in this case I may have neglected to fully implement full
continuations.



some people have used call/cc as a way of implementing multithreading
from within scheme itself, ...


Fine... When it works. When it doesn't, I would not like to be
the one debugging that stuff.


yeah, I had typically implemented more traditional threading.




interesting? maybe.
practical? probably not.

I agree with that!


yes.


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32


.



Relevant Pages

  • Re: [OT] [Question]activities of stack pointer and frame pointer when function called
    ... >>I suspect you don't understand what as stack frame is. ... A function stack frame is a method to keep track of function ... At the point of creation the caller is ... When the callee returns to its ...
    (comp.lang.c)
  • Re: [PATCH 2/2] function-graph: add stack frame test
    ... In case gcc does something funny with the stack frames, ... frame of the parent function, and will test that frame on exit. ... This modifies the parameters of one of the functions that the arch ... movl 0xc, %edx ...
    (Linux-Kernel)
  • Re: What is a stack frame?
    ... There is no need for a separate "this frame" pointer. ... In any case, the more general term, which covers what a C compiler ... hardware-provided stack to implement the stack-like data structure ... manner since the current stack frame is "deformed" by alloca. ...
    (comp.lang.c)
  • Re: LPC900/80C51 Compiler Toolchain
    ... Although the fixed-size frame optimization is orthogonal to removing ... storing stack arguments is less important in such cases. ... storing data at (SP + offset) takes exactly the same time ... up and uses up another 2 registers. ...
    (comp.arch.embedded)
  • Re: Continuations simulieren?
    ... Continuations sind lange nicht so elegant wie die aus anderen Sprachen. ... nur leider hat man in Java keine Zugriff auf den Stack. ... dass sie in der Lage sind den normale Programmpfad zu umgehen und direkt zum jeweilligen Methodenaufruf zu springen... ...
    (de.comp.lang.java)