Leopold Toetsch <[EMAIL PROTECTED]> writes:

> Dan Sugalski <[EMAIL PROTECTED]> wrote:
>> Okay, as I see it there are two big things that we can do to speed
>> objects up. (Well, besides speeding up the creation of continuation
>> PMCs, which I am, at the moment, sorely tempted to put in a special
>> pool for fast allocation)
>
> I though about that already. Returncontinuations created via the *cc
> opcode variants are created in the opcode and used exactly once just for
> returning from the sub.  So I'd do for these a per-interpreter
> freelist, where they get put back after invokeing the return
> contination.

How hard would it be to stick all continuations onto a 'weak'
continuation stack (not seen by DOD) then, during DOD, mark the freed
continuations (or the live ones). After DOD do the following

   # Assume cpool_head = top of stack
   #        cpool_last = last continuation in stack
   #        end_of_chain = guard object, is never free
   

   return if cpool_head.isfree
   last = cpool_head
   this = cpool_head.next
   while !this.is_free {
     last = this
     this = this.next
   }
   last.next = end_of_chain
   cpool_last.next = cpool_head
   cpool_head = this

When you come to allocate a continuation, you know that, if the
head of the continuation list isn't free, there are no free
continuations on the list, so you allocate a new one and push it onto
the list.

If the head of the list is free, grab it, mark it as used, rerun the
above algorithm, populate your continuation and continue on your merry
way. 

If we use a single value per stack frame approach to the stack we can
recycle stack frames in the same way. 

(I know, patches welcome, but my C sucks)

-- 
Piers

Reply via email to