[svn:parrot] r40764 - in branches/context_pmc3/src: . gc ops pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Aug 24 12:11:03 UTC 2009


Author: bacek
Date: Mon Aug 24 12:11:02 2009
New Revision: 40764
URL: https://trac.parrot.org/parrot/changeset/40764

Log:
[core] Use Parrot_cx_get|set_caller_ctx instead of poking directly into
struct.

Modified:
   branches/context_pmc3/src/gc/alloc_register.c
   branches/context_pmc3/src/ops/core.ops
   branches/context_pmc3/src/ops/pic.ops
   branches/context_pmc3/src/ops/var.ops
   branches/context_pmc3/src/pic.c
   branches/context_pmc3/src/pmc/coroutine.pmc
   branches/context_pmc3/src/pmc/exception.pmc
   branches/context_pmc3/src/pmc/sub.pmc
   branches/context_pmc3/src/scheduler.c
   branches/context_pmc3/src/sub.c

Modified: branches/context_pmc3/src/gc/alloc_register.c
==============================================================================
--- branches/context_pmc3/src/gc/alloc_register.c	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/gc/alloc_register.c	Mon Aug 24 12:11:02 2009	(r40764)
@@ -323,7 +323,7 @@
     PMC * const old = CONTEXT(interp);
     PMC * const ctx = Parrot_set_new_context(interp, n_regs_used);
 
-    CONTEXT_FIELD(interp, ctx, caller_ctx)  = old;
+    Parrot_cx_set_caller_ctx(interp, ctx, old);
 
     /* doesn't change */
     CONTEXT_FIELD(interp, ctx, current_sub) = CONTEXT_FIELD(interp, old, current_sub);
@@ -350,7 +350,7 @@
 {
     ASSERT_ARGS(Parrot_pop_context)
     PMC * const ctx = CONTEXT(interp);
-    PMC * const old = CONTEXT_FIELD(interp, ctx, caller_ctx);
+    PMC * const old = Parrot_cx_get_caller_ctx(interp, ctx);
 
     /* restore old, set cached interpreter base pointers */
     CONTEXT(interp) = old;

Modified: branches/context_pmc3/src/ops/core.ops
==============================================================================
--- branches/context_pmc3/src/ops/core.ops	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/ops/core.ops	Mon Aug 24 12:11:02 2009	(r40764)
@@ -544,7 +544,7 @@
     ctx     = CONTEXT(interp);
     ccont   = CONTEXT_FIELD(interp, ctx, current_cont);
 
-    caller_ctx  = CONTEXT_FIELD(interp, ctx, caller_ctx);
+    caller_ctx  = Parrot_cx_get_caller_ctx(interp, ctx);
 
     src_indexes = interp->current_args;
     dst_indexes = interp->current_params;
@@ -553,10 +553,11 @@
     interp->current_params = NULL;
 
     parrot_pass_args(interp, caller_ctx, ctx, src_indexes, dst_indexes, PARROT_PASS_PARAMS);
+    /* TODO Factor out with Sub.invoke */
     if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) {
         PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
         Parrot_cx_dec_recursion_depth(interp, ctx);
-        CONTEXT_FIELD(interp, ctx, caller_ctx) = CONTEXT_FIELD(interp, caller_ctx, caller_ctx);
+        Parrot_cx_set_caller_ctx(interp, ctx, Parrot_cx_get_caller_ctx(interp, caller_ctx));
         interp->current_args = NULL;
     }
     argc = VTABLE_elements(interp, signature);
@@ -573,7 +574,7 @@
 
     interp->current_returns = _this;
     ctx                     = CONTEXT(interp);
-    caller_ctx              = CONTEXT_FIELD(interp, ctx, caller_ctx);
+    caller_ctx              = Parrot_cx_get_caller_ctx(interp, ctx);
     ccont                   = CONTEXT_FIELD(interp, ctx, current_cont);
 
     if (PMC_cont(ccont)->address) {

Modified: branches/context_pmc3/src/ops/pic.ops
==============================================================================
--- branches/context_pmc3/src/ops/pic.ops	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/ops/pic.ops	Mon Aug 24 12:11:02 2009	(r40764)
@@ -141,7 +141,7 @@
     ctx         = CONTEXT(interp);
     src_pc      = interp->current_args;
     mic         = (Parrot_MIC *) cur_opcode[1];
-    caller_ctx  = CONTEXT_FIELD(interp, ctx, caller_ctx);
+    caller_ctx  = Parrot_cx_get_caller_ctx(interp, ctx);
     if (src_pc) {
         src_pred = (void**) src_pc - CONTEXT_FIELD(interp, caller_ctx, pred_offset);
         sig = (PMC*)(src_pred[1]);
@@ -163,7 +163,8 @@
         if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) {
             PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
             Parrot_cx_dec_recursion_depth(interp, ctx);
-            CONTEXT_FIELD(interp, ctx, caller_ctx) = CONTEXT_FIELD(interp, caller_ctx, caller_ctx);
+            Parrot_cx_set_caller_ctx(interp, ctx,
+                    Parrot_cx_get_caller_ctx(interp, caller_ctx));
             interp->current_args = NULL;
         }
 

Modified: branches/context_pmc3/src/ops/var.ops
==============================================================================
--- branches/context_pmc3/src/ops/var.ops	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/ops/var.ops	Mon Aug 24 12:11:02 2009	(r40764)
@@ -95,9 +95,9 @@
     PMC     * ctx            = CONTEXT(interp);
     PMC     * result         = PMCNULL;
 
-    for (ctx = CONTEXT_FIELD(interp, ctx, caller_ctx);
+    for (ctx = Parrot_cx_get_caller_ctx(interp, ctx);
             !PMC_IS_NULL(ctx) && PMC_IS_NULL(result);
-            ctx = CONTEXT_FIELD(interp, ctx, caller_ctx))
+            ctx = Parrot_cx_get_caller_ctx(interp, ctx))
     {
         PMC * const lex_pad = Parrot_find_pad(interp, lex_name, ctx);
         if (!PMC_IS_NULL(lex_pad)) {

Modified: branches/context_pmc3/src/pic.c
==============================================================================
--- branches/context_pmc3/src/pic.c	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/pic.c	Mon Aug 24 12:11:02 2009	(r40764)
@@ -77,6 +77,7 @@
 */
 
 #include "parrot/parrot.h"
+#include "parrot/context.h"
 #include "parrot/oplib/ops.h"
 #include "pmc/pmc_fixedintegerarray.h"
 #include "pmc/pmc_continuation.h"
@@ -711,7 +712,7 @@
         args       = CONTEXT_FIELD(interp, caller_ctx, current_results);
     }
     else {
-        caller_ctx = CONTEXT_FIELD(interp, ctx, caller_ctx);
+        caller_ctx = Parrot_cx_get_caller_ctx(interp, ctx);
         args       = interp->current_args;
     }
 
@@ -720,7 +721,7 @@
         int          n;
 
         /* check current_args signature */
-        sig2 = CONTEXT_FIELD(interp, caller_ctx, constants[const_nr])->u.key;
+        sig2 = Parrot_cx_get_pmc_constant(interp, caller_ctx, const_nr);
         n    = parrot_pic_check_sig(interp, sig1, sig2, &type);
 
         if (n == -1)

Modified: branches/context_pmc3/src/pmc/coroutine.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/coroutine.pmc	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/pmc/coroutine.pmc	Mon Aug 24 12:11:02 2009	(r40764)
@@ -49,7 +49,7 @@
     if (co->ctx && (PObj_get_FLAGS(sub_pmc) & SUB_FLAG_CORO_FF)) {
         Parrot_io_eprintf(tracer, " to '%Ss'",
                 Parrot_full_sub_name(interp,
-                    CONTEXT_FIELD(interp, CONTEXT_FIELD(interp, co->ctx, caller_ctx), current_sub)));
+                    CONTEXT_FIELD(interp, Parrot_cx_get_caller_ctx(interp, co->ctx), current_sub)));
     }
 
     Parrot_io_eprintf(tracer, "\n# ");
@@ -150,7 +150,7 @@
             co->ctx                   = ctx;
 
             CONTEXT_FIELD(INTERP, ctx, caller_ctx)          = caller_ctx;
-            PMC_cont(ccont)->from_ctx               = ctx;
+            PMC_cont(ccont)->from_ctx                       = ctx;
             CONTEXT_FIELD(INTERP, ctx, current_sub)         = SELF;
             CONTEXT_FIELD(INTERP, ctx, current_HLL)         = co->HLL_id;
             CONTEXT_FIELD(INTERP, ctx, current_namespace)   = co->namespace_stash;
@@ -186,9 +186,9 @@
             ctx                   = co->ctx;
 
             /* and the recent call context */
-            ccont                 = CONTEXT_FIELD(INTERP, ctx, current_cont);
-            CONTEXT_FIELD(INTERP, ctx, caller_ctx) = PMC_cont(ccont)->to_ctx
-                                  = CONTEXT(interp);
+            ccont                   = CONTEXT_FIELD(INTERP, ctx, current_cont);
+            PMC_cont(ccont)->to_ctx = CONTEXT(interp);
+            Parrot_cx_set_caller_ctx(interp, ctx, CONTEXT(interp));
 
             /* set context to coro context */
             CONTEXT(interp) = ctx;

Modified: branches/context_pmc3/src/pmc/exception.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/exception.pmc	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/pmc/exception.pmc	Mon Aug 24 12:11:02 2009	(r40764)
@@ -793,7 +793,7 @@
 
                 /* Push frame and go to next caller. */
                 VTABLE_push_pmc(interp, result, frame);
-                cur_ctx = CONTEXT_FIELD(interp, cur_ctx, caller_ctx);
+                cur_ctx = Parrot_cx_get_caller_ctx(interp, cur_ctx);
             }
         }
 

Modified: branches/context_pmc3/src/pmc/sub.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/sub.pmc	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/pmc/sub.pmc	Mon Aug 24 12:11:02 2009	(r40764)
@@ -376,7 +376,8 @@
                 Parrot_cx_dec_recursion_depth(INTERP, context);
 
                 PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
-                CONTEXT_FIELD(interp, context, caller_ctx) = CONTEXT_FIELD(interp, caller_ctx, caller_ctx);
+                Parrot_cx_set_caller_ctx(interp, context,
+                        Parrot_cx_get_caller_ctx(interp, caller_ctx));
 
                 //Parrot_free_context(INTERP, caller_ctx, 1);
             }

Modified: branches/context_pmc3/src/scheduler.c
==============================================================================
--- branches/context_pmc3/src/scheduler.c	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/scheduler.c	Mon Aug 24 12:11:02 2009	(r40764)
@@ -865,7 +865,7 @@
          * Note that we are now trying to handle the new exception,
          * not the initial task argument (exception or whatever).
          */
-        context = CONTEXT_FIELD(interp, keep_context, caller_ctx);
+        context = Parrot_cx_get_caller_ctx(interp, keep_context);
         keep_context = NULL;
         if (context && !PMC_IS_NULL(CONTEXT_FIELD(interp, context, handlers)))
             iter = VTABLE_get_iter(interp, CONTEXT_FIELD(interp, context, handlers));
@@ -916,7 +916,7 @@
         }
 
         /* Continue the search in the next context up the chain. */
-        context = CONTEXT_FIELD(interp, context, caller_ctx);
+        context = Parrot_cx_get_caller_ctx(interp, context);
         if (context && !PMC_IS_NULL(CONTEXT_FIELD(interp, context, handlers)))
             iter = VTABLE_get_iter(interp, CONTEXT_FIELD(interp, context, handlers));
         else

Modified: branches/context_pmc3/src/sub.c
==============================================================================
--- branches/context_pmc3/src/sub.c	Mon Aug 24 12:10:29 2009	(r40763)
+++ branches/context_pmc3/src/sub.c	Mon Aug 24 12:11:02 2009	(r40764)
@@ -160,7 +160,7 @@
         if (!cont || cont->vtable != interp->vtables[enum_class_RetContinuation])
             break;
         cont->vtable = interp->vtables[enum_class_Continuation];
-        ctx  = CONTEXT_FIELD(interp, ctx, caller_ctx);
+        ctx  = Parrot_cx_get_caller_ctx(interp, ctx);
         cont = CONTEXT_FIELD(interp, ctx, current_cont);
     }
 


More information about the parrot-commits mailing list