Piers Cawley wrote:

Leopold Toetsch <[EMAIL PROTECTED]> writes:

At (1) the continuation is marked with C<dont_cache_retc>. In C<save_context>
this flag is propagated to the stacks in the continuation's context. At
(2) or any other place, where this stacks are popped off, the stack
chunks are not put onto the stack chunk freelist.


That seems to make sense.

And it works (for your code)


Here is a proof of concept patchoid:

1) change to your example code:
     $P1 = clone P1
     store_lex 1, "cc", $P1
(the clone strips off all recycle flags)

2) Minimal patch (no prototypes, only pmc_reg stack)
--- parrot/classes/retcontinuation.pmc  Thu Mar 25 14:37:24 2004
+++ parrot-leo/classes/retcontinuation.pmc      Thu Apr  1 17:58:31 2004
@@ -90,6 +90,7 @@
         sub = PMC_sub(ret) = mem_sys_allocate(sizeof(struct Parrot_Sub));
         memcpy(sub, PMC_sub(SELF), sizeof(struct Parrot_Sub));
         PMC_struct_val(ret) = PMC_struct_val(SELF);
+        mark_stack_not_reusable(INTERP, &sub->ctx);
         return ret;
     }
 }
--- parrot/src/objects.c        Thu Apr  1 17:11:09 2004
+++ parrot-leo/src/objects.c    Thu Apr  1 17:45:25 2004
@@ -783,7 +783,7 @@
 /*
  * s. also src/stack_common.c:200
  */
-#define DISBALE_RETC_RECYCLING 1
+#define DISBALE_RETC_RECYCLING 0

 void add_to_retc_free_list(Parrot_Interp, PMC*);
 void disable_retc_free_list(Parrot_Interp);
--- parrot/src/stack_common.c   Thu Apr  1 17:11:09 2004
+++ parrot-leo/src/stack_common.c       Thu Apr  1 17:48:11 2004
@@ -199,11 +199,12 @@
     /*
      * turn this off for correct behavior with continuations
      */
-#if 0
+    if (! (PObj_get_FLAGS(chunk) & PObj_private0_FLAG)) {
     assert(s < MAX_CACHED_STACKS);
     chunk->free_p = e->free_list;
     e->free_list = chunk;
-#endif
+    }
+
     return STACK_DATAP(chunk);
 }

--- parrot/src/sub.c    Fri Mar 26 20:10:58 2004
+++ parrot-leo/src/sub.c        Thu Apr  1 17:57:51 2004
@@ -327,11 +327,23 @@

*/

+void
+mark_stack_not_reusable(Parrot_Interp interpreter, struct Parrot_Context *ctx)
+{
+ /*
+ * set continuation context stacks as not to be recycled
+ */
+ PObj_get_FLAGS(ctx->pmc_reg_stack) |= PObj_private0_FLAG;
+ /* ... */
+
+}
+
struct Parrot_Sub *
new_continuation(struct Parrot_Interp *interp)
{
struct Parrot_Sub *cc = new_sub(interp, sizeof(struct Parrot_Sub));
cow_copy_context(interp, &cc->ctx, &interp->ctx);
+ mark_stack_not_reusable(interp, &cc->ctx);
return cc;
}




Reply via email to