[svn:parrot] r41200 - in trunk/src: call pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Fri Sep 11 08:05:18 UTC 2009


Author: chromatic
Date: Fri Sep 11 08:05:15 2009
New Revision: 41200
URL: https://trac.parrot.org/parrot/changeset/41200

Log:
[pcc] Added context struct initialization to Parrot_pcc_set_sub(), specifically
the program counter, current HLL, and current namespace.  The Sub and Coroutine
PMCs already did this directly in their invokes, so moving this code here gets
rid of a few function calls.  There's a modest (0.733%) performance improvement
in the oofib PIR benchmark, but the biggest benefit is removing duplicate code.
There's more to go; perhaps the lex pad initialization code can move here too.

Modified:
   trunk/src/call/context.c
   trunk/src/pmc/coroutine.pmc
   trunk/src/pmc/sub.pmc

Modified: trunk/src/call/context.c
==============================================================================
--- trunk/src/call/context.c	Fri Sep 11 01:13:57 2009	(r41199)
+++ trunk/src/call/context.c	Fri Sep 11 08:05:15 2009	(r41200)
@@ -675,7 +675,17 @@
 {
     ASSERT_ARGS(Parrot_pcc_set_sub)
     Parrot_Context *c = get_context_struct_fast(interp, ctx);
-    c->current_sub = sub;
+    c->current_sub    = sub;
+
+    if (sub && !PMC_IS_NULL(sub)) {
+        Parrot_Sub_attributes *subattr;
+
+        PMC_get_sub(interp, sub, subattr);
+
+        c->current_pc        = subattr->seg->base.data + subattr->start_offs;
+        c->current_HLL       = subattr->HLL_id;
+        c->current_namespace = subattr->namespace_stash;
+    }
 }
 
 /*
@@ -1167,6 +1177,7 @@
         ctx->current_namespace = old->current_namespace;
         /* end COW */
         ctx->recursion_depth   = old->recursion_depth;
+        ctx->caller_ctx        = pmcold;
     }
     else {
         ctx->constants         = NULL;
@@ -1205,8 +1216,6 @@
     PMC * const old = CURRENT_CONTEXT(interp);
     PMC * const ctx = Parrot_set_new_context(interp, n_regs_used);
 
-    Parrot_pcc_set_caller_ctx(interp, ctx, old);
-
     /* doesn't change */
     Parrot_pcc_set_sub(interp, ctx, Parrot_pcc_get_sub(interp, old));
 

Modified: trunk/src/pmc/coroutine.pmc
==============================================================================
--- trunk/src/pmc/coroutine.pmc	Fri Sep 11 01:13:57 2009	(r41199)
+++ trunk/src/pmc/coroutine.pmc	Fri Sep 11 08:05:15 2009	(r41200)
@@ -144,11 +144,8 @@
 
             co->ctx = ctx;
 
-            Parrot_pcc_set_caller_ctx(INTERP, ctx, caller_ctx);
             PARROT_CONTINUATION(ccont)->from_ctx = ctx;
             Parrot_pcc_set_sub(INTERP, ctx, SELF);
-            Parrot_pcc_set_HLL(interp, ctx, co->HLL_id);
-            Parrot_pcc_set_namespace(INTERP, ctx, co->namespace_stash);
             Parrot_pcc_set_continuation(INTERP, ctx, ccont);
             Parrot_pcc_set_object(interp, ctx, PMCNULL);
             INTERP->current_object = PMCNULL;

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Fri Sep 11 01:13:57 2009	(r41199)
+++ trunk/src/pmc/sub.pmc	Fri Sep 11 08:05:15 2009	(r41200)
@@ -278,8 +278,6 @@
          * create new context, place it in interpreter */
         context               = Parrot_set_new_context(INTERP, sub->n_regs_used);
         Parrot_pcc_set_sub(interp, context, SELF);
-        Parrot_pcc_set_caller_ctx(interp, context, caller_ctx);
-        Parrot_pcc_set_pc(interp, context, pc);
         Parrot_pcc_set_continuation(interp, context, ccont);
 
         /* check recursion/call depth */
@@ -304,9 +302,6 @@
             INTERP->current_object  = NULL;
         }
 
-        Parrot_pcc_set_HLL(interp, context, sub->HLL_id);
-        Parrot_pcc_set_namespace(interp, context, sub->namespace_stash);
-
         /* create pad if needed
          * TODO move this up in front of argument passing
          *      and factor out common code with coroutine pmc


More information about the parrot-commits mailing list