[svn:parrot] r43414 - trunk/src/ops

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Jan 9 22:24:09 UTC 2010


Author: bacek
Date: Sat Jan  9 22:24:08 2010
New Revision: 43414
URL: https://trac.parrot.org/parrot/changeset/43414

Log:
Detach RetContinuation from current CallContext in tailcall. Closes TT#1393.

Modified:
   trunk/src/ops/core.ops
   trunk/src/ops/object.ops

Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops	Sat Jan  9 22:23:25 2010	(r43413)
+++ trunk/src/ops/core.ops	Sat Jan  9 22:24:08 2010	(r43414)
@@ -464,8 +464,17 @@
     PMC * const this_call_sig   = Parrot_pcc_get_signature(interp, ctx);
     PMC * const parent_call_sig = Parrot_pcc_get_signature(interp, parent_ctx);
     interp->current_cont        = Parrot_pcc_get_continuation(interp, ctx);
+
     Parrot_pcc_merge_signature_for_tailcall(interp, parent_call_sig, this_call_sig);
 
+    /* Detach continuation from current CallContext to avoid marking dead object. */
+    /* RetContinuation will kill itself after invoke */
+    if (interp->current_cont->vtable->base_type == enum_class_RetContinuation
+        && Parrot_pcc_do_run_ops(interp, p)) {
+        PMC_cont(interp->current_cont)->from_ctx = parent_ctx;
+        Parrot_pcc_set_continuation(interp, ctx, PMCNULL);
+    }
+
     SUB_FLAG_TAILCALL_SET(interp->current_cont);
     dest = VTABLE_invoke(interp, p, dest);
     goto ADDRESS(dest);

Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops	Sat Jan  9 22:23:25 2010	(r43413)
+++ trunk/src/ops/object.ops	Sat Jan  9 22:24:08 2010	(r43414)
@@ -138,6 +138,15 @@
     else {
         interp->current_cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
         PObj_get_FLAGS(interp->current_cont) |= SUB_FLAG_TAILCALL;
+        /* Detach continuation from current CallContext to avoid marking dead object. */
+        /* RetContinuation will kill itself after invoke */
+        if (interp->current_cont->vtable->base_type == enum_class_RetContinuation
+            && Parrot_pcc_do_run_ops(interp, method_pmc)) {
+            PMC * const ctx             = CURRENT_CONTEXT(interp);
+            PMC * const parent_ctx      = Parrot_pcc_get_caller_ctx(interp, ctx);
+            PMC_cont(interp->current_cont)->from_ctx = parent_ctx;
+            Parrot_pcc_set_continuation(interp, ctx, PMCNULL);
+        }
         interp->current_object = object;
         dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
     }
@@ -153,6 +162,16 @@
 
     interp->current_cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
     PObj_get_FLAGS(interp->current_cont) |= SUB_FLAG_TAILCALL;
+    /* Detach continuation from current CallContext to avoid marking dead object. */
+    /* RetContinuation will kill itself after invoke */
+    if (interp->current_cont->vtable->base_type == enum_class_RetContinuation
+        && Parrot_pcc_do_run_ops(interp, method_pmc)) {
+        PMC * const ctx             = CURRENT_CONTEXT(interp);
+        PMC * const parent_ctx      = Parrot_pcc_get_caller_ctx(interp, ctx);
+        PMC_cont(interp->current_cont)->from_ctx = parent_ctx;
+        Parrot_pcc_set_continuation(interp, ctx, PMCNULL);
+    }
+
     interp->current_object = object;
     dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
     goto ADDRESS(dest);


More information about the parrot-commits mailing list