[svn:parrot] r43094 - in branches/context_unify3: include/parrot src/call src/ops

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Dec 16 12:32:45 UTC 2009


Author: bacek
Date: Wed Dec 16 12:32:44 2009
New Revision: 43094
URL: https://trac.parrot.org/parrot/changeset/43094

Log:
Made tailcall to push new CallContext instead of reusing old one. Apparently we need new CallContext to store LexPad information and other bits

Modified:
   branches/context_unify3/include/parrot/call.h
   branches/context_unify3/src/call/args.c
   branches/context_unify3/src/call/pcc.c
   branches/context_unify3/src/ops/core.ops
   branches/context_unify3/src/ops/object.ops

Modified: branches/context_unify3/include/parrot/call.h
==============================================================================
--- branches/context_unify3/include/parrot/call.h	Wed Dec 16 11:57:28 2009	(r43093)
+++ branches/context_unify3/include/parrot/call.h	Wed Dec 16 12:32:44 2009	(r43094)
@@ -82,7 +82,6 @@
         __attribute__nonnull__(3);
 
 PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC* Parrot_pcc_prepare_call(PARROT_INTERP,
     ARGIN(PMC *call_object),

Modified: branches/context_unify3/src/call/args.c
==============================================================================
--- branches/context_unify3/src/call/args.c	Wed Dec 16 11:57:28 2009	(r43093)
+++ branches/context_unify3/src/call/args.c	Wed Dec 16 12:32:44 2009	(r43094)
@@ -2421,53 +2421,23 @@
         return;
     else {
         /* Broke encapuslation. Direct poking into CallContext is much faster */
-        /* In tailcall we don't push freshly created CallContext. Instead we
-         * are copying parameters into current one and destroy new.
-         * Ok-ok. Not actually copying, but swapping to avoid memory
-         * management hassle */
-        struct Pcc_cell *pos1, *pos2;
-        PMC      *pmc1, *pmc2;
-        STRING   *string1, *string2;
-        INTVAL    int1, int2;
-        Hash     *hash1, *hash2;
-
-        GETATTR_CallContext_positionals(interp, parent, pos1);
-        GETATTR_CallContext_positionals(interp, tailcall, pos2);
-        SETATTR_CallContext_positionals(interp, parent, pos2);
-        SETATTR_CallContext_positionals(interp, tailcall, pos1);
-
-        GETATTR_CallContext_type_tuple(interp, parent, pmc1);
-        GETATTR_CallContext_type_tuple(interp, tailcall, pmc2);
-        SETATTR_CallContext_type_tuple(interp, parent, pmc2);
-        SETATTR_CallContext_type_tuple(interp, tailcall, pmc1);
-
-        GETATTR_CallContext_short_sig(interp, parent, string1);
-        GETATTR_CallContext_short_sig(interp, tailcall, string2);
-        SETATTR_CallContext_short_sig(interp, parent, string2);
-        SETATTR_CallContext_short_sig(interp, tailcall, string1);
-
-        GETATTR_CallContext_arg_flags(interp, parent, pmc1);
-        GETATTR_CallContext_arg_flags(interp, tailcall, pmc2);
-        SETATTR_CallContext_arg_flags(interp, parent, pmc2);
-        SETATTR_CallContext_arg_flags(interp, tailcall, pmc1);
-
-        /* XXX Do we need it? */
-        /*
-        GETATTR_CallContext_return_flags(interp, parent, pmc1);
-        GETATTR_CallContext_return_flags(interp, tailcall, pmc2);
-        SETATTR_CallContext_return_flags(interp, parent, pmc2);
-        SETATTR_CallContext_return_flags(interp, tailcall, pmc1);
-        */
-
-        GETATTR_CallContext_hash(interp, parent, hash1);
-        GETATTR_CallContext_hash(interp, tailcall, hash2);
-        SETATTR_CallContext_hash(interp, parent, hash2);
-        SETATTR_CallContext_hash(interp, tailcall, hash1);
-
-        GETATTR_CallContext_num_positionals(interp, parent, int1);
-        GETATTR_CallContext_num_positionals(interp, tailcall, int2);
-        SETATTR_CallContext_num_positionals(interp, parent, int2);
-        SETATTR_CallContext_num_positionals(interp, tailcall, int1);
+        void ** returns_values;
+        void ** tailcall_returns_values;
+        INTVAL  returns_size;
+        PMC * return_flags;
+
+        GETATTR_CallContext_returns_size(interp, parent, returns_size);
+        GETATTR_CallContext_returns_values(interp, parent, returns_values);
+
+        /* Resize tailcall.returns_values to new size */
+        tailcall_returns_values = csr_reallocate_return_values(interp, tailcall, returns_size);
+
+        /* And copy values over it */
+        mem_copy_n_typed(tailcall_returns_values, returns_values, returns_size, void**);
+
+        /* Store raw signature */
+        GETATTR_CallContext_return_flags(interp, parent, return_flags);
+        SETATTR_CallContext_return_flags(interp, tailcall, return_flags);
 
     }
 }

Modified: branches/context_unify3/src/call/pcc.c
==============================================================================
--- branches/context_unify3/src/call/pcc.c	Wed Dec 16 11:57:28 2009	(r43093)
+++ branches/context_unify3/src/call/pcc.c	Wed Dec 16 12:32:44 2009	(r43094)
@@ -265,7 +265,6 @@
 
 */
 PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC*
 Parrot_pcc_prepare_call(PARROT_INTERP, ARGIN(PMC *call_object),

Modified: branches/context_unify3/src/ops/core.ops
==============================================================================
--- branches/context_unify3/src/ops/core.ops	Wed Dec 16 11:57:28 2009	(r43093)
+++ branches/context_unify3/src/ops/core.ops	Wed Dec 16 12:32:44 2009	(r43094)
@@ -462,8 +462,11 @@
     PMC * const p               = $1;
     opcode_t   *dest            = expr NEXT();
     PMC * const ctx             = CURRENT_CONTEXT(interp);
+    PMC        *call_object     = Parrot_pcc_get_signature(interp, ctx);
     interp->current_cont        = Parrot_pcc_get_continuation(interp, ctx);
-    Parrot_pcc_merge_signature_for_tailcall(interp, ctx, Parrot_pcc_get_signature(interp, ctx));
+
+    Parrot_pcc_merge_signature_for_tailcall(interp, ctx, call_object);
+    Parrot_pcc_prepare_call(interp, call_object, interp->current_cont, interp->current_object);
 
     SUB_FLAG_TAILCALL_SET(interp->current_cont);
     dest = VTABLE_invoke(interp, p, dest);

Modified: branches/context_unify3/src/ops/object.ops
==============================================================================
--- branches/context_unify3/src/ops/object.ops	Wed Dec 16 11:57:28 2009	(r43093)
+++ branches/context_unify3/src/ops/object.ops	Wed Dec 16 12:32:44 2009	(r43094)
@@ -130,6 +130,7 @@
     STRING   * const meth       = $2;
     PMC      * const method_pmc = VTABLE_find_method(interp, object, meth);
     PMC      * const ctx        = CURRENT_CONTEXT(interp);
+    PMC      *       call_object = Parrot_pcc_get_signature(interp, ctx);
 
     opcode_t *dest;
 
@@ -139,10 +140,10 @@
             VTABLE_get_string(interp, VTABLE_get_class(interp, object)));
     }
     else {
-        interp->current_cont = Parrot_pcc_get_continuation(interp, ctx);
+        Parrot_pcc_merge_signature_for_tailcall(interp, ctx, call_object);
+        Parrot_pcc_prepare_call(interp, call_object,
+                Parrot_pcc_get_continuation(interp, ctx), object);
         SUB_FLAG_TAILCALL_SET(interp->current_cont);
-        interp->current_object = object;
-        Parrot_pcc_merge_signature_for_tailcall(interp, ctx, Parrot_pcc_get_signature(interp, ctx));
         dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
     }
     goto ADDRESS(dest);
@@ -153,13 +154,14 @@
     PMC      * const object     = $1;
     PMC      * const method_pmc = $2;
     PMC      * const ctx        = CURRENT_CONTEXT(interp);
+    PMC      *       call_object = Parrot_pcc_get_signature(interp, ctx);
 
     opcode_t *dest;
 
-    interp->current_cont = Parrot_pcc_get_continuation(interp, ctx);
+    Parrot_pcc_merge_signature_for_tailcall(interp, ctx, call_object);
+    Parrot_pcc_prepare_call(interp, call_object,
+            Parrot_pcc_get_continuation(interp, ctx), object);
     SUB_FLAG_TAILCALL_SET(interp->current_cont);
-    interp->current_object = object;
-    Parrot_pcc_merge_signature_for_tailcall(interp, ctx, Parrot_pcc_get_signature(interp, ctx));
     dest = (opcode_t *)VTABLE_invoke(interp, method_pmc, next);
     goto ADDRESS(dest);
 }


More information about the parrot-commits mailing list