[svn:parrot] r40655 - in branches/context_pmc2: include/parrot lib/Parrot/OpTrans src src/call src/gc src/interp src/ops

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Aug 19 12:44:39 UTC 2009


Author: bacek
Date: Wed Aug 19 12:44:38 2009
New Revision: 40655
URL: https://trac.parrot.org/parrot/changeset/40655

Log:
wip

Modified:
   branches/context_pmc2/include/parrot/interpreter.h
   branches/context_pmc2/include/parrot/register.h
   branches/context_pmc2/lib/Parrot/OpTrans/CSwitch.pm
   branches/context_pmc2/src/call/ops.c
   branches/context_pmc2/src/call/pcc.c
   branches/context_pmc2/src/debug.c
   branches/context_pmc2/src/embed.c
   branches/context_pmc2/src/exceptions.c
   branches/context_pmc2/src/extend.c
   branches/context_pmc2/src/gc/alloc_register.c
   branches/context_pmc2/src/gc/api.c
   branches/context_pmc2/src/gc/mark_sweep.c
   branches/context_pmc2/src/global.c
   branches/context_pmc2/src/global_setup.c
   branches/context_pmc2/src/hll.c
   branches/context_pmc2/src/interp/inter_create.c
   branches/context_pmc2/src/interp/inter_misc.c
   branches/context_pmc2/src/multidispatch.c
   branches/context_pmc2/src/oo.c
   branches/context_pmc2/src/ops/debug.ops
   branches/context_pmc2/src/ops/pic.ops
   branches/context_pmc2/src/ops/var.ops
   branches/context_pmc2/src/packfile.c

Modified: branches/context_pmc2/include/parrot/interpreter.h
==============================================================================
--- branches/context_pmc2/include/parrot/interpreter.h	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/include/parrot/interpreter.h	Wed Aug 19 12:44:38 2009	(r40655)
@@ -208,7 +208,7 @@
     size_t n_allocated;                 /* allocated size of it */
 } Prederef;
 
-#define CONTEXT(interp) (Parrot_ctx_get_context_struct((interp), (interp)->ctx))
+#define CONTEXT(interp) (PARROT_CONTEXT((interp)->ctx))
 
 #define CHUNKED_CTX_MEM 0           /* no longer works, but will be reinstated
                                      * some day; see src/register.c for details.

Modified: branches/context_pmc2/include/parrot/register.h
==============================================================================
--- branches/context_pmc2/include/parrot/register.h	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/include/parrot/register.h	Wed Aug 19 12:44:38 2009	(r40655)
@@ -33,6 +33,11 @@
 #define REG_PMC(interp, x) (*(Parrot_ctx_PMC_reg((interp), (interp)->ctx, (x))))
 #define REG_STR(interp, x) (*(Parrot_ctx_STRING_reg((interp), (interp)->ctx, (x))))
 
+#define PMCCTX_REG_NUM(ctx, x) PARROT_CONTEXT(ctx)->bp.regs_n[-1L-(x)]
+#define PMCCTX_REG_INT(ctx, x) PARROT_CONTEXT(ctx)->bp.regs_i[x]
+#define PMCCTX_REG_PMC(ctx, x) PARROT_CONTEXT(ctx)->bp_ps.regs_p[-1L-(x)]
+#define PMCCTX_REG_STR(ctx, x) PARROT_CONTEXT(ctx)->bp_ps.regs_s[x]
+
 /*
  * and a set of macros to access a register by offset, used
  * in JIT emit prederef code
@@ -59,7 +64,8 @@
 #define REG_OFFS_STR(x) (sizeof (STRING*) * (x) + _SIZEOF_INTS + _SIZEOF_PMCS)
 
 /* Forward declaration of Context PMC attributes */
-typedef struct Parrot_Context_attributes Parrot_Context_attributes;
+struct Parrot_Context_attributes;
+//typedef struct Parrot_Context_attributes Parrot_Context_attributes;
 
 /* HEADERIZER BEGIN: src/gc/alloc_register.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
@@ -114,12 +120,6 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-PARROT_CAN_RETURN_NULL
-Parrot_Context_attributes * Parrot_ctx_get_context_struct(PARROT_INTERP,
-    ARGIN(PMC * context))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
 PARROT_CANNOT_RETURN_NULL
 INTVAL * Parrot_ctx_INTVAL_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
         __attribute__nonnull__(1)
@@ -166,9 +166,6 @@
 #define ASSERT_ARGS_Parrot_ctx_get_caller __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_ctx_get_context_struct __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(context)
 #define ASSERT_ARGS_Parrot_ctx_INTVAL_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)

Modified: branches/context_pmc2/lib/Parrot/OpTrans/CSwitch.pm
==============================================================================
--- branches/context_pmc2/lib/Parrot/OpTrans/CSwitch.pm	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/lib/Parrot/OpTrans/CSwitch.pm	Wed Aug 19 12:44:38 2009	(r40655)
@@ -154,7 +154,7 @@
 #endif
 
 SWITCH_RELOAD:
-    _reg_base = (char*)interp->ctx.bp.regs_i;
+    _reg_base = (char*)PARROT_CONTEXT(interp->ctx)->bp.regs_i;
     do {
 SWITCH_AGAIN:
     Parrot_cx_handle_tasks(interp, interp->scheduler);

Modified: branches/context_pmc2/src/call/ops.c
==============================================================================
--- branches/context_pmc2/src/call/ops.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/call/ops.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -28,7 +28,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static Parrot_Context * runops_args(PARROT_INTERP,
+static PMC * runops_args(PARROT_INTERP,
     ARGIN(PMC *sub),
     ARGIN_NULLOK(PMC *obj),
     SHIM(STRING *meth),
@@ -152,7 +152,7 @@
 {
     ASSERT_ARGS(Parrot_runops_fromc)
     opcode_t offset, *dest;
-    Parrot_Context *ctx;
+    PMC *ctx;
 
     /* we need one return continuation with a NULL offset */
     PMC * const ret_c    = new_ret_continuation_pmc(interp, NULL);
@@ -178,8 +178,8 @@
 
 /*
 
-=item C<static Parrot_Context * runops_args(PARROT_INTERP, PMC *sub, PMC *obj,
-STRING *meth, const char *sig, va_list ap)>
+=item C<static PMC * runops_args(PARROT_INTERP, PMC *sub, PMC *obj, STRING
+*meth, const char *sig, va_list ap)>
 
 Calls the PMC subroutine C<sub> with optional name C<meth>. If PMC object
 C<obj> is provided, the call is treated as a method call on that object.
@@ -202,17 +202,17 @@
 
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
-static Parrot_Context *
+static PMC *
 runops_args(PARROT_INTERP, ARGIN(PMC *sub), ARGIN_NULLOK(PMC *obj),
         SHIM(STRING *meth), ARGIN(const char *sig), va_list ap)
 {
     ASSERT_ARGS(runops_args)
     opcode_t offset, *dest;
-    Parrot_Context *ctx;
+    PMC *ctx;
 
     char new_sig[10];
     const char *sig_p;
-    Parrot_Context * const old_ctx = CONTEXT(interp);
+    PMC * const old_ctx = interp->ctx;
 
     interp->current_cont   = new_ret_continuation_pmc(interp, NULL);
     interp->current_object = obj;
@@ -264,7 +264,6 @@
             "no get_params in sub");
      */
 
-    ctx    = Parrot_context_ref(interp, CONTEXT(interp));
     offset = dest - interp->code->base.data;
     runops(interp, offset);
     return ctx;
@@ -293,7 +292,7 @@
 Parrot_run_meth_fromc(PARROT_INTERP, ARGIN(PMC *sub), ARGIN_NULLOK(PMC *obj), SHIM(STRING *meth))
 {
     ASSERT_ARGS(Parrot_run_meth_fromc)
-    Parrot_Context *ctx;
+    PMC *ctx;
     opcode_t offset, *dest;
 
     interp->current_cont   = new_ret_continuation_pmc(interp, NULL);
@@ -304,7 +303,7 @@
         Parrot_ex_throw_from_c_args(interp, NULL, 1,
             "Subroutine returned a NULL address");
 
-    ctx    = CONTEXT(interp);
+    ctx    = interp->ctx;
     offset = dest - interp->code->base.data;
     runops(interp, offset);
     return set_retval(interp, 0, ctx);
@@ -331,14 +330,13 @@
 {
     ASSERT_ARGS(Parrot_runops_fromc_args)
     va_list args;
-    Parrot_Context *ctx;
+    PMC *ctx;
     PMC *retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
     va_end(args);
     retval = (PMC *)set_retval(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -364,7 +362,7 @@
 {
     ASSERT_ARGS(Parrot_runops_fromc_args_event)
     va_list args;
-    Parrot_Context *ctx;
+    PMC  *ctx;
     void *retval;
     /*
      * running code from event handlers isn't fully reentrant due to
@@ -380,7 +378,6 @@
     ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
     va_end(args);
     retval = set_retval(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
 
     interp->current_args     = cargs;
     interp->current_params   = params;
@@ -410,14 +407,13 @@
 {
     ASSERT_ARGS(Parrot_runops_fromc_args_reti)
     va_list args;
-    Parrot_Context *ctx;
-    INTVAL retval;
+    PMC    *ctx;
+    INTVAL  retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
     va_end(args);
     retval = set_retval_i(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -441,15 +437,14 @@
         ARGIN(const char *sig), ...)
 {
     ASSERT_ARGS(Parrot_runops_fromc_args_retf)
-    va_list args;
-    Parrot_Context *ctx;
+    va_list  args;
+    PMC     *ctx;
     FLOATVAL retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
     va_end(args);
     retval = set_retval_f(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -475,14 +470,13 @@
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_args)
     va_list args;
-    Parrot_Context *ctx;
-    void* retval;
+    PMC    *ctx;
+    void   *retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, obj, meth, sig, args);
     va_end(args);
     retval = set_retval(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -507,14 +501,13 @@
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_args_reti)
     va_list args;
-    Parrot_Context *ctx;
-    INTVAL retval;
+    PMC    *ctx;
+    INTVAL  retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, obj, meth, sig, args);
     va_end(args);
     retval = set_retval_i(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -538,15 +531,14 @@
         ARGIN(STRING *meth), ARGIN(const char *sig), ...)
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_args_retf)
-    va_list args;
-    Parrot_Context *ctx;
+    va_list  args;
+    PMC     *ctx;
     FLOATVAL retval;
 
     va_start(args, sig);
     ctx = runops_args(interp, sub, obj, meth, sig, args);
     va_end(args);
     retval = set_retval_f(interp, *sig, ctx);
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -571,10 +563,9 @@
         ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_runops_fromc_arglist)
-    Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
+    PMC  * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
     void * const retval = set_retval(interp, *sig, ctx);
 
-    Parrot_free_context(interp, ctx, 1);
     return retval;
 }
 
@@ -598,11 +589,8 @@
         ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_runops_fromc_arglist_reti)
-    Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
-    const INTVAL retval = set_retval_i(interp, *sig, ctx);
-
-    Parrot_free_context(interp, ctx, 1);
-    return retval;
+    PMC  * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
+    return set_retval_i(interp, *sig, ctx);
 }
 
 /*
@@ -625,11 +613,8 @@
         ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_runops_fromc_arglist_retf)
-    Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
-    const FLOATVAL retval = set_retval_f(interp, *sig, ctx);
-
-    Parrot_free_context(interp, ctx, 1);
-    return retval;
+    PMC * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
+    return set_retval_f(interp, *sig, ctx);
 }
 
 /*
@@ -653,11 +638,8 @@
         ARGIN(STRING *meth), ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_arglist)
-    Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig, args);
-    void * const retval = set_retval(interp, *sig, ctx);
-
-    Parrot_free_context(interp, ctx, 1);
-    return retval;
+    PMC * const ctx = runops_args(interp, sub, obj, meth, sig, args);
+    return set_retval(interp, *sig, ctx);
 }
 
 /*
@@ -682,11 +664,8 @@
         ARGIN(STRING *meth), ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_arglist_reti)
-    Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig, args);
-    const INTVAL retval = set_retval_i(interp, *sig, ctx);
-
-    Parrot_free_context(interp, ctx, 1);
-    return retval;
+    PMC * const ctx = runops_args(interp, sub, obj, meth, sig, args);
+    return set_retval_i(interp, *sig, ctx);
 }
 
 /*
@@ -710,11 +689,8 @@
         ARGIN(STRING *meth), ARGIN(const char *sig), va_list args)
 {
     ASSERT_ARGS(Parrot_run_meth_fromc_arglist_retf)
-    Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig, args);
-    const FLOATVAL retval = set_retval_f(interp, *sig, ctx);
-
-    Parrot_free_context(interp, ctx, 1);
-    return retval;
+    PMC * const ctx = runops_args(interp, sub, obj, meth, sig, args);
+    return set_retval_f(interp, *sig, ctx);
 }
 
 /*

Modified: branches/context_pmc2/src/call/pcc.c
==============================================================================
--- branches/context_pmc2/src/call/pcc.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/call/pcc.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -22,6 +22,7 @@
 #include "pcc.str"
 #include "../pmc/pmc_key.h"
 #include "../pmc/pmc_continuation.h"
+#include "../pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/call.h */
 
@@ -72,7 +73,7 @@
     int seen_arrow,
     ARGIN(PMC * const *sigs),
     ARGMOD(opcode_t **indexes),
-    ARGMOD(Parrot_Context *ctx),
+    ARGMOD(PMC *ctx),
     ARGIN(PMC *sig_obj))
         __attribute__nonnull__(1)
         __attribute__nonnull__(4)
@@ -105,7 +106,7 @@
         FUNC_MODIFIES(*st);
 
 PARROT_CANNOT_RETURN_NULL
-static Parrot_Context * count_signature_elements(PARROT_INTERP,
+static PMC * count_signature_elements(PARROT_INTERP,
     ARGIN(const char *signature),
     ARGMOD(PMC *args_sig),
     ARGMOD(PMC *results_sig),
@@ -156,7 +157,7 @@
     ARGMOD(INTVAL *n_regs_used),
     ARGMOD(PMC **sigs),
     ARGMOD(opcode_t **indexes),
-    ARGMOD(Parrot_Context *ctx),
+    ARGMOD(PMC *ctx),
     ARGMOD(PMC *sig_obj))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -172,7 +173,7 @@
         FUNC_MODIFIES(*sig_obj);
 
 static void set_context_sig_returns(PARROT_INTERP,
-    ARGMOD(Parrot_Context *ctx),
+    ARGMOD(PMC *ctx),
     ARGMOD(opcode_t **indexes),
     ARGIN_NULLOK(const char *ret_x),
     ARGMOD(PMC *result_list))
@@ -185,7 +186,7 @@
         FUNC_MODIFIES(*result_list);
 
 static void set_context_sig_returns_varargs(PARROT_INTERP,
-    ARGMOD(Parrot_Context *ctx),
+    ARGMOD(PMC *ctx),
     ARGMOD(opcode_t **indexes),
     ARGIN(const char *ret_x),
     va_list returns)
@@ -198,7 +199,7 @@
 
 static int set_retval_util(PARROT_INTERP,
     ARGIN(const char *sig),
-    ARGIN(Parrot_Context *ctx),
+    ARGIN(PMC *ctx),
     ARGMOD(call_state *st))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -335,15 +336,16 @@
 /* Make sure we don't conflict with any other MAX() macros defined elsewhere */
 #define PARROT_MAX(a, b) (((a)) > (b) ? (a) : (b))
 
+// XXX Remove this macro. It used once only
 #define SAVE_OFF_REGS(orig, next, save) \
-        (save).bp = (orig).bp;\
-        (save).bp_ps = (orig).bp_ps;\
-        (orig).bp = (next).bp;\
-        (orig).bp_ps = (next).bp_ps;
+        (save)->bp = (orig)->bp;\
+        (save)->bp_ps = (orig)->bp_ps;\
+        (orig)->bp = (next)->bp;\
+        (orig)->bp_ps = (next)->bp_ps;
 
 #define RESTORE_REGS(orig, save) \
-        (orig).bp = (save).bp;\
-        (orig).bp_ps = (save).bp_ps;
+        (orig)->bp = (save)->bp;\
+        (orig)->bp_ps = (save)->bp_ps;
 
 /*
 
@@ -484,13 +486,13 @@
     init_call_stats(st);
 
     if (PMC_IS_NULL(interp->args_signature))
-        Parrot_init_arg_op(interp, CONTEXT(interp), interp->current_args,
+        Parrot_init_arg_op(interp, interp->ctx, interp->current_args,
                            &st->src);
     else
-        Parrot_init_arg_indexes_and_sig_pmc(interp, CONTEXT(interp),
+        Parrot_init_arg_indexes_and_sig_pmc(interp, interp->ctx,
             interp->current_args, interp->args_signature, &st->src);
 
-    Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL, &st->dest);
+    Parrot_init_arg_sig(interp, interp->ctx, sig, NULL, &st->dest);
 }
 
 
@@ -511,8 +513,8 @@
 Parrot_init_ret_nci(PARROT_INTERP, ARGOUT(call_state *st), ARGIN(const char *sig))
 {
     ASSERT_ARGS(Parrot_init_ret_nci)
-    Parrot_Context *ctx                 = CONTEXT(interp);
-    PMC            * const current_cont = ctx->current_cont;
+    PMC       *ctx          = interp->ctx;
+    PMC* const current_cont = PARROT_CONTEXT(ctx)->current_cont;
 
     /* if this NCI call was a taicall, return results to caller's get_results
      * this also means that we pass the caller's register base pointer */
@@ -520,15 +522,16 @@
         ctx = PMC_cont(current_cont)->to_ctx;
 
     /* TODO simplify all */
-    Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL, &st->src);
+    Parrot_init_arg_sig(interp, interp->ctx, sig, NULL, &st->src);
 
     /* Non-constant signatures are stored in ctx->results_signature instead of
      * in the constants table. */
-    if (ctx->results_signature)
+    if (PARROT_CONTEXT(ctx)->results_signature)
         Parrot_init_arg_indexes_and_sig_pmc(interp, ctx,
-                ctx->current_results, ctx->results_signature, &st->dest);
+                PARROT_CONTEXT(ctx)->current_results,
+                PARROT_CONTEXT(ctx)->results_signature, &st->dest);
     else
-        Parrot_init_arg_op(interp, ctx, ctx->current_results, &st->dest);
+        Parrot_init_arg_op(interp, ctx, PARROT_CONTEXT(ctx)->current_results, &st->dest);
 
 }
 
@@ -569,7 +572,7 @@
     sti->i     = 0;
     sti->n     = 0;
     sti->mode  = CALL_STATE_OP;
-    sti->ctx   = ctx;
+    sti->ctx   = pmcctx;
     sti->sig   = 0;
     sti->slurp = NULL;
 
@@ -644,7 +647,7 @@
     sti->i    = 0;
     sti->n    = 0;
     sti->mode = CALL_STATE_SIG;
-    sti->ctx  = ctx;
+    sti->ctx  = pmcctx;
     sti->sig  = 0;
 
     if (*sig) {
@@ -824,29 +827,30 @@
     ASSERT_ARGS(fetch_arg_op)
     const int    constant = PARROT_ARG_CONSTANT_ISSET(st->src.sig);
     const INTVAL idx      = st->src.u.op.pc[st->src.i];
+    const Parrot_Context_attributes *srcctx = PARROT_CONTEXT(st->src.ctx);
 
     switch (PARROT_ARG_TYPE_MASK_MASK(st->src.sig)) {
         case PARROT_ARG_INTVAL:
-            UVal_int(st->val) = constant ? idx : CTX_REG_INT(st->src.ctx, idx);
+            UVal_int(st->val) = constant ? idx : CTX_REG_NUM(srcctx, idx);
             break;
         case PARROT_ARG_STRING:
         {
             /* ensure that callees don't modify constant caller strings */
             if (constant)
                 UVal_str(st->val) = Parrot_str_new_COW(interp,
-                                        st->src.ctx->constants[idx]->u.string);
+                                        srcctx->constants[idx]->u.string);
             else
-                UVal_str(st->val) = CTX_REG_STR(st->src.ctx, idx);
+                UVal_str(st->val) = CTX_REG_STR(srcctx, idx);
 
             break;
         }
         case PARROT_ARG_FLOATVAL:
-            UVal_num(st->val) = constant ? st->src.ctx->constants[idx]->u.number
-                                         : CTX_REG_NUM(st->src.ctx, idx);
+            UVal_num(st->val) = constant ? srcctx->constants[idx]->u.number
+                                         : CTX_REG_NUM(srcctx, idx);
             break;
         case PARROT_ARG_PMC:
-            UVal_pmc(st->val) = constant ? st->src.ctx->constants[idx]->u.key
-                                         : CTX_REG_PMC(st->src.ctx, idx);
+            UVal_pmc(st->val) = constant ? srcctx->constants[idx]->u.key
+                                         : CTX_REG_PMC(srcctx, idx);
 
             if (st->src.sig & PARROT_ARG_FLATTEN) {
                 int retval;
@@ -1171,7 +1175,7 @@
 
     --st->params;
     PARROT_ASSERT(idx >= 0);
-    CTX_REG_INT(st->dest.ctx, idx) = has_arg;
+    CTX_REG_INT(PARROT_CONTEXT(st->dest.ctx), idx) = has_arg;
 }
 
 
@@ -1205,9 +1209,9 @@
             Parrot_Context_attributes temp_ctx;
 
             /* clone sets key values according to refered register items */
-            SAVE_OFF_REGS(CONTEXT(interp), PARROT_CONTEXT(*(st->src.ctx)), temp_ctx)
+            SAVE_OFF_REGS(CONTEXT(interp), PARROT_CONTEXT(st->src.ctx), &temp_ctx)
             UVal_pmc(st->val) = VTABLE_clone(interp, key);
-            RESTORE_REGS(interp->ctx, temp_ctx)
+            RESTORE_REGS(CONTEXT(interp), &temp_ctx)
             return;
         }
     }
@@ -1262,7 +1266,7 @@
 
             /* pass the slurpy hash */
             idx = st->dest.u.op.pc[i];
-            CTX_REG_PMC(st->dest.ctx, idx) = st->dest.slurp;
+            CTX_REG_PMC(PARROT_CONTEXT(st->dest.ctx), idx) = st->dest.slurp;
         }
         /* must be the actual arg of a named arg, count it */
         else
@@ -1311,8 +1315,8 @@
         n_named++;
         idx   = st->dest.u.op.pc[i];
         param = PARROT_ARG_CONSTANT_ISSET(st->dest.sig)
-                ? st->dest.ctx->constants[idx]->u.string
-                : CTX_REG_STR(st->dest.ctx, idx);
+                ? PARROT_CONTEXT(st->dest.ctx)->constants[idx]->u.string
+                : PMCCTX_REG_STR(st->dest.ctx, idx);
 
         if (st->name == param || Parrot_str_equal(interp, st->name, param)) {
             ++i;
@@ -1351,16 +1355,16 @@
     ASSERT_ARGS(store_arg)
     switch (st->dest.sig & PARROT_ARG_TYPE_MASK) {
         case PARROT_ARG_INTVAL:
-            CTX_REG_INT(st->dest.ctx, idx) = UVal_int(st->val);
+            PMCCTX_REG_INT(st->dest.ctx, idx) = UVal_int(st->val);
             break;
         case PARROT_ARG_FLOATVAL:
-            CTX_REG_NUM(st->dest.ctx, idx) = UVal_num(st->val);
+            PMCCTX_REG_NUM(st->dest.ctx, idx) = UVal_num(st->val);
             break;
         case PARROT_ARG_STRING:
-            CTX_REG_STR(st->dest.ctx, idx) = UVal_str(st->val);
+            PMCCTX_REG_STR(st->dest.ctx, idx) = UVal_str(st->val);
             break;
         case PARROT_ARG_PMC:
-            CTX_REG_PMC(st->dest.ctx, idx) = UVal_pmc(st->val);
+            PMCCTX_REG_PMC(st->dest.ctx, idx) = UVal_pmc(st->val);
             break;
         default:
             break;
@@ -1557,15 +1561,15 @@
                 if (arg_sig & PARROT_ARG_OPT_FLAG) {
                     i++;
                     idx = st->dest.u.op.pc[i];
-                    CTX_REG_INT(st->dest.ctx, idx) = 0;
+                    PMCCTX_REG_INT(st->dest.ctx, idx) = 0;
                 }
                 continue;
             }
             else {
                 const   INTVAL idx   = st->dest.u.op.pc[last_name_pos];
                 STRING * const param = PARROT_ARG_CONSTANT_ISSET(sig)
-                    ? st->dest.ctx->constants[idx]->u.string
-                    : CTX_REG_STR(st->dest.ctx, idx);
+                    ? PARROT_CONTEXT(st->dest.ctx)->constants[idx]->u.string
+                    : PMCCTX_REG_STR(st->dest.ctx, idx);
 
                 Parrot_ex_throw_from_c_args(interp, NULL,
                     EXCEPTION_INVALID_OPERATION,
@@ -1738,7 +1742,7 @@
 
         /* Must register this PMC or it may get collected when only the struct
          * references it. */
-        CTX_REG_PMC(st->dest.ctx, idx) = array;
+        PMCCTX_REG_PMC(st->dest.ctx, idx) = array;
 
         while (Parrot_fetch_arg(interp, st)) {
             /* if the src arg is named, we're done here */
@@ -1883,15 +1887,15 @@
     }
     else /* (param_or_result == PARROT_PASS_RESULTS) */ {
         src_signature               = interp->returns_signature;
-        dest_signature              = dest_ctx->results_signature;
+        dest_signature              = PARROT_CONTEXT(dest_pmcctx)->results_signature;
         interp->returns_signature   = NULL;
-        dest_ctx->results_signature = NULL;
+        PARROT_CONTEXT(dest_pmcctx)->results_signature = NULL;
     }
 
-    Parrot_init_arg_indexes_and_sig_pmc(interp, src_ctx, src_indexes,
+    Parrot_init_arg_indexes_and_sig_pmc(interp, src_pmcctx, src_indexes,
         src_signature, &st.src);
 
-    Parrot_init_arg_indexes_and_sig_pmc(interp, dest_ctx, dest_indexes,
+    Parrot_init_arg_indexes_and_sig_pmc(interp, dest_pmcctx, dest_indexes,
         dest_signature, &st.dest);
 
     Parrot_process_args(interp, &st, param_or_result);
@@ -1931,8 +1935,8 @@
 
 /*
 
-=item C<static int set_retval_util(PARROT_INTERP, const char *sig,
-Parrot_Context *ctx, call_state *st)>
+=item C<static int set_retval_util(PARROT_INTERP, const char *sig, PMC *ctx,
+call_state *st)>
 
 Adds the current return parameter to the current context, and fetches
 the next return parameter from the call state object.
@@ -1943,7 +1947,7 @@
 
 static int
 set_retval_util(PARROT_INTERP, ARGIN(const char *sig),
-    ARGIN(Parrot_Context *ctx), ARGMOD(call_state *st))
+    ARGIN(PMC *ctx), ARGMOD(call_state *st))
 {
     ASSERT_ARGS(set_retval_util)
     opcode_t * const src_pc = interp->current_returns;
@@ -1952,8 +1956,7 @@
     interp->current_returns = NULL;
 
     if (todo) {
-        todo = Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL,
-            &st->dest);
+        todo = Parrot_init_arg_sig(interp, interp->ctx, sig, NULL, &st->dest);
 
         if (todo) {
             Parrot_fetch_arg(interp, st);
@@ -1983,7 +1986,6 @@
 set_retval(PARROT_INTERP, int sig_ret, ARGIN(PMC *pmcctx))
 {
     ASSERT_ARGS(set_retval)
-    Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);
     call_state st;
 
     if (!sig_ret || sig_ret == 'v')
@@ -1991,10 +1993,10 @@
 
     switch (sig_ret) {
         case 'S':
-            if (set_retval_util(interp, "S", ctx, &st))
+            if (set_retval_util(interp, "S", pmcctx, &st))
                 return UVal_str(st.val);
         case 'P':
-            if (set_retval_util(interp, "P", ctx, &st)) {
+            if (set_retval_util(interp, "P", pmcctx, &st)) {
                 PMC *retval = UVal_pmc(st.val);
                 return (void *)retval;
             }
@@ -2018,14 +2020,13 @@
 set_retval_i(PARROT_INTERP, int sig_ret, ARGIN(PMC *pmcctx))
 {
     ASSERT_ARGS(set_retval_i)
-    Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);
     call_state st;
 
     if (sig_ret != 'I')
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
             "return signature not 'I'");
 
-    if (set_retval_util(interp, "I", ctx, &st))
+    if (set_retval_util(interp, "I", pmcctx, &st))
         return UVal_int(st.val);
 
     return 0;
@@ -2047,14 +2048,13 @@
 set_retval_f(PARROT_INTERP, int sig_ret, ARGIN(PMC *pmcctx))
 {
     ASSERT_ARGS(set_retval_f)
-    Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);
     call_state st;
 
     if (sig_ret != 'N')
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
             "return signature not 'N'");
 
-    if (set_retval_util(interp, "N", ctx, &st))
+    if (set_retval_util(interp, "N", pmcctx, &st))
         return UVal_num(st.val);
 
     return 0.0;
@@ -2084,7 +2084,7 @@
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
             "return signature not 'S'");
 
-    if (set_retval_util(interp, "S", ctx, &st))
+    if (set_retval_util(interp, "S", pmcctx, &st))
         return UVal_str(st.val);
 
     return NULL;
@@ -2108,14 +2108,13 @@
 set_retval_p(PARROT_INTERP, int sig_ret, ARGIN(PMC *pmcctx))
 {
     ASSERT_ARGS(set_retval_p)
-    Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);
     call_state st;
 
     if (sig_ret != 'P')
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
             "return signature not 'P'");
 
-    if (set_retval_util(interp, "P", ctx, &st))
+    if (set_retval_util(interp, "P", pmcctx, &st))
         return UVal_pmc(st.val);
 
     return NULL;
@@ -2192,8 +2191,8 @@
 
 /*
 
-=item C<static Parrot_Context * count_signature_elements(PARROT_INTERP, const
-char *signature, PMC *args_sig, PMC *results_sig, int flag)>
+=item C<static PMC * count_signature_elements(PARROT_INTERP, const char
+*signature, PMC *args_sig, PMC *results_sig, int flag)>
 
 Counts the number of each type of register in a signature object. Returns
 the total number of parameter arguments, the total number of result
@@ -2205,7 +2204,7 @@
 */
 
 PARROT_CANNOT_RETURN_NULL
-static Parrot_Context *
+static PMC *
 count_signature_elements(PARROT_INTERP, ARGIN(const char *signature),
     ARGMOD(PMC *args_sig), ARGMOD(PMC *results_sig), int flag)
 {
@@ -2305,7 +2304,7 @@
 
 =item C<static void commit_last_arg_sig_object(PARROT_INTERP, int index, int
 cur, opcode_t *n_regs_used, int seen_arrow, PMC * const *sigs, opcode_t
-**indexes, Parrot_Context *ctx, PMC *sig_obj)>
+**indexes, PMC *ctx, PMC *sig_obj)>
 
 Called by Parrot_pcc_invoke_from_sig_object when it reaches the end of each
 arg in the arg signature.  See C<Parrot_pcc_invoke_from_sig_object> for
@@ -2318,7 +2317,7 @@
 static void
 commit_last_arg_sig_object(PARROT_INTERP, int index, int cur,
     ARGMOD(opcode_t *n_regs_used), int seen_arrow, ARGIN(PMC * const *sigs),
-    ARGMOD(opcode_t **indexes), ARGMOD(Parrot_Context *ctx),
+    ARGMOD(opcode_t **indexes), ARGMOD(PMC *ctx),
     ARGIN(PMC *sig_obj))
 {
     ASSERT_ARGS(commit_last_arg_sig_object)
@@ -2365,18 +2364,18 @@
     if (!seen_arrow) {
         switch (cur & PARROT_ARG_TYPE_MASK) {
             case PARROT_ARG_INTVAL:
-                CTX_REG_INT(ctx, reg_offset) = VTABLE_get_integer_keyed_int(interp, sig_obj, index);
+                PMCCTX_REG_INT(ctx, reg_offset) = VTABLE_get_integer_keyed_int(interp, sig_obj, index);
                 break;
             case PARROT_ARG_FLOATVAL:
-                CTX_REG_NUM(ctx, reg_offset) = VTABLE_get_number_keyed_int(interp, sig_obj, index);
+                PMCCTX_REG_NUM(ctx, reg_offset) = VTABLE_get_number_keyed_int(interp, sig_obj, index);
                 break;
             case PARROT_ARG_STRING:
-                CTX_REG_STR(ctx, reg_offset) = VTABLE_get_string_keyed_int(interp, sig_obj, index);
+                PMCCTX_REG_STR(ctx, reg_offset) = VTABLE_get_string_keyed_int(interp, sig_obj, index);
                 break;
             case PARROT_ARG_PMC:
-                CTX_REG_PMC(ctx, reg_offset) = VTABLE_get_pmc_keyed_int(interp, sig_obj, index);
+                PMCCTX_REG_PMC(ctx, reg_offset) = VTABLE_get_pmc_keyed_int(interp, sig_obj, index);
                 if (cur & PARROT_ARG_INVOCANT) {
-                    interp->current_object = CTX_REG_PMC(ctx, reg_offset);
+                    interp->current_object = PMCCTX_REG_PMC(ctx, reg_offset);
                 }
                 break;
             default:
@@ -2389,8 +2388,8 @@
 
 /*
 
-=item C<static void set_context_sig_returns(PARROT_INTERP, Parrot_Context *ctx,
-opcode_t **indexes, const char *ret_x, PMC *result_list)>
+=item C<static void set_context_sig_returns(PARROT_INTERP, PMC *ctx, opcode_t
+**indexes, const char *ret_x, PMC *result_list)>
 
 Sets the subroutine return arguments in the context C<ctx>. Takes a C string
 for the return signature C<ret_x> and a list of return parameters C<result_list>.
@@ -2401,7 +2400,7 @@
 
 static void
 set_context_sig_returns(PARROT_INTERP,
-    ARGMOD(Parrot_Context *ctx), ARGMOD(opcode_t **indexes),
+    ARGMOD(PMC *ctx), ARGMOD(opcode_t **indexes),
     ARGIN_NULLOK(const char *ret_x), ARGMOD(PMC *result_list))
 {
     ASSERT_ARGS(set_context_sig_returns)
@@ -2419,25 +2418,25 @@
                 case 'I':
                     {
                     VTABLE_set_integer_native(interp, result_item,
-                            CTX_REG_INT(ctx, indexes[seen_arrow][index]));
+                            PMCCTX_REG_INT(ctx, indexes[seen_arrow][index]));
                     }
                     break;
                 case 'N':
                     {
                     VTABLE_set_number_native(interp, result_item,
-                            CTX_REG_NUM(ctx, indexes[seen_arrow][index]));
+                            PMCCTX_REG_NUM(ctx, indexes[seen_arrow][index]));
                     }
                     break;
                 case 'S':
                     {
                     VTABLE_set_string_native(interp, result_item,
-                            CTX_REG_STR(ctx, indexes[seen_arrow][index]));
+                            PMCCTX_REG_STR(ctx, indexes[seen_arrow][index]));
                     }
                     break;
                 case 'P':
                     {
                     VTABLE_set_pmc(interp, result_item,
-                            CTX_REG_PMC(ctx, indexes[seen_arrow][index]));
+                            PMCCTX_REG_PMC(ctx, indexes[seen_arrow][index]));
                     }
                     break;
                 default:
@@ -2458,8 +2457,8 @@
 
 /*
 
-=item C<static void set_context_sig_returns_varargs(PARROT_INTERP,
-Parrot_Context *ctx, opcode_t **indexes, const char *ret_x, va_list returns)>
+=item C<static void set_context_sig_returns_varargs(PARROT_INTERP, PMC *ctx,
+opcode_t **indexes, const char *ret_x, va_list returns)>
 
 Sets the subroutine return arguments in the context C<ctx>. Takes a C string
 for the return signature C<ret_x> and a varargs list of return parameters C<returns>.
@@ -2474,7 +2473,7 @@
 */
 
 static void
-set_context_sig_returns_varargs(PARROT_INTERP, ARGMOD(Parrot_Context *ctx),
+set_context_sig_returns_varargs(PARROT_INTERP, ARGMOD(PMC *ctx),
     ARGMOD(opcode_t **indexes), ARGIN(const char *ret_x), va_list returns)
 {
     ASSERT_ARGS(set_context_sig_returns_varargs)
@@ -2490,25 +2489,25 @@
                 case 'I':
                     {
                     INTVAL * const tmpINTVAL = va_arg(returns, INTVAL*);
-                    *tmpINTVAL = CTX_REG_INT(ctx, indexes[seen_arrow][index]);
+                    *tmpINTVAL = PMCCTX_REG_INT(ctx, indexes[seen_arrow][index]);
                     }
                     break;
                 case 'N':
                     {
                     FLOATVAL * const tmpFLOATVAL = va_arg(returns, FLOATVAL*);
-                    *tmpFLOATVAL = CTX_REG_NUM(ctx, indexes[seen_arrow][index]);
+                    *tmpFLOATVAL = PMCCTX_REG_NUM(ctx, indexes[seen_arrow][index]);
                     }
                     break;
                 case 'S':
                     {
                     STRING ** const tmpSTRING = va_arg(returns, STRING**);
-                    *tmpSTRING = CTX_REG_STR(ctx, indexes[seen_arrow][index]);
+                    *tmpSTRING = PMCCTX_REG_STR(ctx, indexes[seen_arrow][index]);
                     }
                     break;
                 case 'P':
                     {
                     PMC ** const tmpPMC = va_arg(returns, PMC**);
-                    *tmpPMC = CTX_REG_PMC(ctx, indexes[seen_arrow][index]);
+                    *tmpPMC = PMCCTX_REG_PMC(ctx, indexes[seen_arrow][index]);
                     }
                     break;
                 default:
@@ -2524,8 +2523,8 @@
 /*
 
 =item C<static const char * set_context_sig_params(PARROT_INTERP, const char
-*signature, INTVAL *n_regs_used, PMC **sigs, opcode_t **indexes, Parrot_Context
-*ctx, PMC *sig_obj)>
+*signature, INTVAL *n_regs_used, PMC **sigs, opcode_t **indexes, PMC *ctx, PMC
+*sig_obj)>
 
 Sets the subroutine arguments in the C<ctx> context, according to the
 signature string C<signature>. Currently this function is only called
@@ -2542,7 +2541,7 @@
 static const char *
 set_context_sig_params(PARROT_INTERP, ARGIN(const char *signature),
     ARGMOD(INTVAL *n_regs_used), ARGMOD(PMC **sigs),
-    ARGMOD(opcode_t **indexes), ARGMOD(Parrot_Context *ctx),
+    ARGMOD(opcode_t **indexes), ARGMOD(PMC *ctx),
     ARGMOD(PMC *sig_obj))
 {
     ASSERT_ARGS(set_context_sig_params)
@@ -2624,10 +2623,10 @@
         commit_last_arg_sig_object(interp, index, cur, n_regs_used, seen_arrow, sigs,
             indexes, ctx, sig_obj);
 
-    interp->current_args   = indexes[0];
-    interp->args_signature = sigs[0];
-    ctx->current_results   = indexes[1];
-    ctx->results_signature = sigs[1];
+    interp->current_args                   = indexes[0];
+    interp->args_signature                 = sigs[0];
+    PARROT_CONTEXT(ctx)->current_results   = indexes[1];
+    PARROT_CONTEXT(ctx)->results_signature = sigs[1];
     return ret_x;
 }
 
@@ -2736,12 +2735,12 @@
     PMC * const results_sig = pmc_new(interp, enum_class_FixedIntegerArray);
     PMC * const ret_cont    = new_ret_continuation_pmc(interp, NULL);
 
-    Parrot_Context *ctx;              /* The newly created context */
-    PMC              *pccinvoke_meth;
+    PMC         *ctx;              /* The newly created context */
+    PMC         *pccinvoke_meth;
 
-    opcode_t         *save_current_args;
-    PMC              *save_args_signature;
-    PMC              *save_current_object;
+    opcode_t    *save_current_args;
+    PMC         *save_args_signature;
+    PMC         *save_current_object;
 
     /* temporary state vars for building PCC index and PCC signature arrays. */
 
@@ -2780,7 +2779,7 @@
     indexes[0][0] = 0;
 
     VTABLE_set_integer_keyed_int(interp, sigs[0], 0, PARROT_ARG_PMC);
-    CTX_REG_PMC(ctx, 0) = pmc;
+    PMCCTX_REG_PMC(ctx, 0) = pmc;
 
     n_regs_used[REGNO_PMC]++;
     index = 0;
@@ -2859,18 +2858,18 @@
     save_args_signature    = interp->args_signature;
     save_current_object    = interp->current_object;
 
-    interp->current_args   = arg_indexes;
-    interp->args_signature = args_sig;
-    ctx->current_results   = result_indexes;
-    ctx->results_signature = results_sig;
+    interp->current_args                    = arg_indexes;
+    interp->args_signature                  = args_sig;
+    PARROT_CONTEXT(ctx)->current_results    = result_indexes;
+    PARROT_CONTEXT(ctx)->results_signature  = results_sig;
 
     /* arg_accessors assigned in loop above */
 
-    interp->current_object       = pmc;
-    interp->current_cont         = NEED_CONTINUATION;
-    ctx->current_cont            = ret_cont;
-    PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
-    pccinvoke_meth               = VTABLE_find_method(interp, pmc, method_name);
+    interp->current_object              = pmc;
+    interp->current_cont                = NEED_CONTINUATION;
+    PARROT_CONTEXT(ctx)->current_cont   = ret_cont;
+    PMC_cont(ret_cont)->from_ctx        = ctx;
+    pccinvoke_meth                      = VTABLE_find_method(interp, pmc, method_name);
 
     if (PMC_IS_NULL(pccinvoke_meth))
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_METHOD_NOT_FOUND,
@@ -2966,11 +2965,11 @@
     PMC * const ret_cont    = new_ret_continuation_pmc(interp, NULL);
     PMC * const result_list = VTABLE_get_attr_str(interp, sig_obj, CONST_STRING(interp, "returns"));
 
-    Parrot_Context *ctx;
-    opcode_t         *dest;
-    opcode_t         *save_current_args;
-    PMC              *save_args_signature;
-    PMC              *save_current_object;
+    PMC         *ctx;
+    opcode_t    *dest;
+    opcode_t    *save_current_args;
+    PMC         *save_args_signature;
+    PMC         *save_current_object;
 
     /* temporary state vars for building PCC index and PCC signature arrays. */
 
@@ -3008,11 +3007,12 @@
         interp->current_object = VTABLE_get_pmc_keyed_int(interp, sig_obj, 0);
     }
     else {
-        interp->current_object       = PMCNULL;
+        interp->current_object = PMCNULL;
     }
-    interp->current_cont         = NEED_CONTINUATION;
-    ctx->current_cont            = ret_cont;
-    PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
+
+    interp->current_cont                = NEED_CONTINUATION;
+    PARROT_CONTEXT(ctx)->current_cont   = ret_cont;
+    PMC_cont(ret_cont)->from_ctx        = ctx;
 
     /* Invoke the function */
     dest = VTABLE_invoke(interp, sub_obj, NULL);

Modified: branches/context_pmc2/src/debug.c
==============================================================================
--- branches/context_pmc2/src/debug.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/debug.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -32,6 +32,7 @@
 #include "parrot/runcore_trace.h"
 #include "debug.str"
 #include "pmc/pmc_continuation.h"
+#include "pmc/pmc_context.h"
 
 /* Hand switched debugger tracing
  * Set to 1 to enable tracing to stderr
@@ -2211,7 +2212,7 @@
 PDB_check_condition(PARROT_INTERP, ARGIN(const PDB_condition_t *condition))
 {
     ASSERT_ARGS(PDB_check_condition)
-    Parrot_Context *ctx = CONTEXT(interp);
+    Parrot_Context_attributes *ctx = CONTEXT(interp);
 
     TRACEDEB_MSG("PDB_check_condition");
 
@@ -3511,11 +3512,11 @@
     int               rec_level = 0;
 
     /* information about the current sub */
-    PMC              *sub = interpinfo_p(interp, CURRENT_SUB);
-    Parrot_Context   *ctx = CONTEXT(interp);
+    PMC                         *sub = interpinfo_p(interp, CURRENT_SUB);
+    Parrot_Context_attributes   *ctx = CONTEXT(interp);
 
     if (!PMC_IS_NULL(sub)) {
-        str = Parrot_Context_infostr(interp, ctx);
+        str = Parrot_Context_infostr(interp, interp->ctx);
         if (str) {
             Parrot_io_eprintf(interp, "%Ss", str);
             if (interp->code->annotations) {
@@ -3557,10 +3558,10 @@
 
         /* recursion detection */
         if (!PMC_IS_NULL(old) && PMC_cont(old) &&
-            PMC_cont(old)->to_ctx->current_pc ==
-            PMC_cont(sub)->to_ctx->current_pc &&
-            PMC_cont(old)->to_ctx->current_sub ==
-            PMC_cont(sub)->to_ctx->current_sub) {
+            PARROT_CONTEXT(PMC_cont(old)->to_ctx)->current_pc ==
+            PARROT_CONTEXT(PMC_cont(sub)->to_ctx)->current_pc &&
+            PARROT_CONTEXT(PMC_cont(old)->to_ctx)->current_sub ==
+            PARROT_CONTEXT(PMC_cont(sub)->to_ctx)->current_sub) {
                 ++rec_level;
         }
         else if (rec_level != 0) {
@@ -3573,7 +3574,7 @@
             Parrot_io_eprintf(interp, "%Ss", str);
             if (interp->code->annotations) {
                 PMC *annot = PackFile_Annotations_lookup(interp, interp->code->annotations,
-                        sub_cont->to_ctx->current_pc - interp->code->base.data + 1, NULL);
+                        PARROT_CONTEXT(sub_cont->to_ctx)->current_pc - interp->code->base.data + 1, NULL);
                 if (!PMC_IS_NULL(annot)) {
                     PMC *pfile = VTABLE_get_pmc_keyed_str(interp, annot,
                             Parrot_str_new_constant(interp, "file"));
@@ -3590,7 +3591,7 @@
         }
 
         /* get the next Continuation */
-        ctx = PMC_cont(sub)->to_ctx;
+        ctx = PARROT_CONTEXT(PMC_cont(sub)->to_ctx);
         old = sub;
 
         if (!ctx)

Modified: branches/context_pmc2/src/embed.c
==============================================================================
--- branches/context_pmc2/src/embed.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/embed.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -22,6 +22,7 @@
 #include "parrot/embed.h"
 #include "parrot/oplib/ops.h"
 #include "pmc/pmc_sub.h"
+#include "pmc/pmc_context.h"
 
 #include "../compilers/imcc/imc.h"
 

Modified: branches/context_pmc2/src/exceptions.c
==============================================================================
--- branches/context_pmc2/src/exceptions.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/exceptions.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -23,6 +23,7 @@
 #include "parrot/exceptions.h"
 #include "exceptions.str"
 #include "pmc/pmc_continuation.h"
+#include "pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/exceptions.h */
 
@@ -41,7 +42,7 @@
 static opcode_t * pass_exception_args(PARROT_INTERP,
     ARGIN(const char *sig),
     ARGIN(opcode_t *dest),
-    ARGIN(Parrot_Context * old_ctx),
+    ARGIN(PMC * old_ctx),
     ...)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -253,7 +254,7 @@
     /* Set up the continuation context of the handler in the interpreter. */
     else if (PMC_cont(handler)->current_results)
         address = pass_exception_args(interp, "P", address,
-                CONTEXT(interp), exception);
+                interp->ctx, exception);
 
     if (PObj_get_FLAGS(handler) & SUB_FLAG_C_HANDLER) {
         /* it's a C exception handler */
@@ -268,7 +269,7 @@
 /*
 
 =item C<static opcode_t * pass_exception_args(PARROT_INTERP, const char *sig,
-opcode_t *dest, Parrot_Context * old_ctx, ...)>
+opcode_t *dest, PMC * old_ctx, ...)>
 
 Passes arguments to the exception handler routine. These are retrieved with
 the .get_results() directive in PIR code.
@@ -280,7 +281,7 @@
 PARROT_CAN_RETURN_NULL
 static opcode_t *
 pass_exception_args(PARROT_INTERP, ARGIN(const char *sig),
-        ARGIN(opcode_t *dest), ARGIN(Parrot_Context * old_ctx), ...)
+        ARGIN(opcode_t *dest), ARGIN(PMC * old_ctx), ...)
 {
     ASSERT_ARGS(pass_exception_args)
     va_list   ap;
@@ -401,8 +402,7 @@
     /* Run the handler. */
     address = VTABLE_invoke(interp, handler, NULL);
     if (PMC_cont(handler)->current_results)
-        address = pass_exception_args(interp, "P", address,
-                CONTEXT(interp), exception);
+        address = pass_exception_args(interp, "P", address, interp->ctx, exception);
     PARROT_ASSERT(return_point->handler_start == NULL);
     return_point->handler_start = address;
     longjmp(return_point->resume, 2);

Modified: branches/context_pmc2/src/extend.c
==============================================================================
--- branches/context_pmc2/src/extend.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/extend.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -61,6 +61,7 @@
 #include "parrot/parrot.h"
 #include "parrot/extend.h"
 #include "pmc/pmc_sub.h"
+#include "pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/extend.h */
 

Modified: branches/context_pmc2/src/gc/alloc_register.c
==============================================================================
--- branches/context_pmc2/src/gc/alloc_register.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/gc/alloc_register.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -29,15 +29,15 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 static void init_context(PARROT_INTERP,
-    ARGMOD(Parrot_Context *ctx),
-    ARGIN_NULLOK(const Parrot_Context *old))
+    ARGMOD(PMC *pmcctx),
+    ARGIN_NULLOK(const PMC *pmcold))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
-        FUNC_MODIFIES(*ctx);
+        FUNC_MODIFIES(*pmcctx);
 
 #define ASSERT_ARGS_init_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(ctx)
+    || PARROT_ASSERT_ARG(pmcctx)
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: static */
 
@@ -100,23 +100,6 @@
 
 /*
 
-=item C<Parrot_Context_attributes * Parrot_ctx_get_context_struct(PARROT_INTERP,
-PMC * context)>
-
-=cut
-
-*/
-
-PARROT_CAN_RETURN_NULL
-Parrot_Context_attributes *
-Parrot_ctx_get_context_struct(PARROT_INTERP, ARGIN(PMC * context))
-{
-    ASSERT_ARGS(Parrot_ctx_get_context_struct)
-    return PARROT_CONTEXT(context);
-}
-
-/*
-
 =item C<void create_initial_context(PARROT_INTERP)>
 
 Creates the interpreter's initial context.
@@ -130,7 +113,7 @@
 {
     ASSERT_ARGS(create_initial_context)
     static INTVAL   num_regs[] = {32, 32, 32, 32};
-    Parrot_Context *ignored;
+    PMC *ignored;
 
     /* For now create context with 32 regs each. Some src tests (and maybe
      * other extenders) assume the presence of these registers */
@@ -210,7 +193,7 @@
 {
     ASSERT_ARGS(Parrot_set_new_context)
     PMC * const old = interp->ctx;
-    PMC * const ctx = Parrot_alloc_context(interp, number_regs_used, PARROT_CONTEXT(old));
+    PMC * const ctx = Parrot_alloc_context(interp, number_regs_used, old);
 
     interp->ctx = ctx;
 
@@ -276,15 +259,14 @@
     /* ctx.bp_ps points to S0, which has Px on the left */
     ctx->bp_ps.regs_s = (STRING **)((char *)p + size_nip);
 
-    init_context(interp, ctx, old);
+    init_context(interp, pmcctx, old);
 
     return pmcctx;
 }
 
 /*
 
-=item C<static void init_context(PARROT_INTERP, Parrot_Context *ctx, const
-Parrot_Context *old)>
+=item C<static void init_context(PARROT_INTERP, PMC *pmcctx, const PMC *pmcold)>
 
 Initializes a freshly allocated or recycled context.
 
@@ -293,12 +275,13 @@
 */
 
 static void
-init_context(PARROT_INTERP, ARGMOD(Parrot_Context *ctx),
-        ARGIN_NULLOK(const Parrot_Context *old))
+init_context(PARROT_INTERP, ARGMOD(PMC *pmcctx),
+        ARGIN_NULLOK(const PMC *pmcold))
 {
     ASSERT_ARGS(init_context)
-    ctx->ref_count         = 0;
-    ctx->gc_mark           = 0;
+    Parrot_Context_attributes *ctx = PARROT_CONTEXT(pmcctx);
+    Parrot_Context_attributes *old = PARROT_CONTEXT(pmcold);
+
     ctx->current_results   = NULL;
     ctx->results_signature = NULL;
     ctx->lex_pad           = PMCNULL;
@@ -332,7 +315,9 @@
     }
 
     /* other stuff is set inside Sub.invoke */
-    clear_regs(interp, ctx);
+    // XXX clear_regs is in Context PMC. Do we really need it?
+    //clear_regs(interp, ctx);
+    // (c++ style comment to bring attention)
 }
 
 /*
@@ -426,7 +411,7 @@
     ASSERT_ARGS(Parrot_clear_n)
     int i;
     const int n_regs_used = CONTEXT(interp)->n_regs_used[REGNO_NUM];
-    for (i = 0; i < nregs_used; ++i)
+    for (i = 0; i < n_regs_used; ++i)
         REG_NUM(interp, i) = 0.0;
 }
 
@@ -434,7 +419,7 @@
 INTVAL *
 Parrot_ctx_INTVAL_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
 {
-    ASSERT_ARGS(Parrot_ctx_get_INTVAL_reg)
+    ASSERT_ARGS(Parrot_ctx_INTVAL_reg)
     return &(PARROT_CONTEXT(ctx)->bp.regs_i[idx]);
 }
 
@@ -442,7 +427,7 @@
 FLOATVAL *
 Parrot_ctx_FLOATVAL_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
 {
-    ASSERT_ARGS(Parrot_ctx_get_FLOATVAL_reg)
+    ASSERT_ARGS(Parrot_ctx_FLOATVAL_reg)
     return &(PARROT_CONTEXT(ctx)->bp.regs_n[-1L - idx]);
 }
 
@@ -450,16 +435,16 @@
 STRING **
 Parrot_ctx_STRING_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
 {
-    ASSERT_ARGS(Parrot_ctx_get_FLOATVAL_reg)
-    return &(PARROT_CONTEXT(ctx)->bp.regs_s[idx]);
+    ASSERT_ARGS(Parrot_ctx_FLOATVAL_reg)
+    return &(PARROT_CONTEXT(ctx)->bp_ps.regs_s[idx]);
 }
 
 PARROT_CANNOT_RETURN_NULL
 PMC **
 Parrot_ctx_PMC_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
 {
-    ASSERT_ARGS(Parrot_ctx_get_FLOATVAL_reg)
-    return &(PARROT_CONTEXT(ctx)->bp.regs_p[-1L - idx]);
+    ASSERT_ARGS(Parrot_ctx_FLOATVAL_reg)
+    return &(PARROT_CONTEXT(ctx)->bp_ps.regs_p[-1L - idx]);
 }
 
 PARROT_CANNOT_RETURN_NULL

Modified: branches/context_pmc2/src/gc/api.c
==============================================================================
--- branches/context_pmc2/src/gc/api.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/gc/api.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -861,7 +861,7 @@
 {
     ASSERT_ARGS(Parrot_gc_mark_and_sweep)
     interp->arena_base->do_gc_mark(interp, flags);
-    parrot_gc_context(interp);
+    //parrot_gc_context(interp);
 }
 
 /*

Modified: branches/context_pmc2/src/gc/mark_sweep.c
==============================================================================
--- branches/context_pmc2/src/gc/mark_sweep.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/gc/mark_sweep.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -178,11 +178,10 @@
 {
     ASSERT_ARGS(Parrot_gc_trace_root)
     Arenas           * const arena_base = interp->arena_base;
-    Parrot_Context   *ctx;
     PObj             *obj;
 
     /* note: adding locals here did cause increased GC runs */
-    mark_context_start();
+    //mark_context_start();
 
     if (trace == GC_TRACE_SYSTEM_ONLY) {
         trace_system_areas(interp);
@@ -208,8 +207,7 @@
         Parrot_gc_mark_PObj_alive(interp, obj);
 
     /* mark the current context. */
-    ctx = CONTEXT(interp);
-    mark_context(interp, ctx);
+    Parrot_gc_mark_PObj_alive(interp, (PObj*)interp->ctx);
 
     /* mark the dynamic environment. */
     Parrot_gc_mark_PObj_alive(interp, (PObj*)interp->dynamic_env);

Modified: branches/context_pmc2/src/global.c
==============================================================================
--- branches/context_pmc2/src/global.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/global.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -19,6 +19,7 @@
 #include "parrot/parrot.h"
 #include "global.str"
 #include "pmc/pmc_sub.h"
+#include "pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/global.h */
 /* HEADERIZER BEGIN: static */
@@ -678,8 +679,7 @@
 Parrot_find_name_op(PARROT_INTERP, ARGIN(STRING *name), SHIM(void *next))
 {
     ASSERT_ARGS(Parrot_find_name_op)
-    Parrot_Context * const ctx = CONTEXT(interp);
-    PMC * const lex_pad = Parrot_find_pad(interp, name, ctx);
+    PMC * const lex_pad = Parrot_find_pad(interp, name, interp->ctx);
     PMC *g;
 
     if (PMC_IS_NULL(lex_pad))

Modified: branches/context_pmc2/src/global_setup.c
==============================================================================
--- branches/context_pmc2/src/global_setup.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/global_setup.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -23,6 +23,7 @@
 
 #define INSIDE_GLOBAL_SETUP
 #include "parrot/parrot.h"
+#include "pmc/pmc_context.h"
 #include "global_setup.str"
 
 /* These functions are defined in the auto-generated file core_pmcs.c */

Modified: branches/context_pmc2/src/hll.c
==============================================================================
--- branches/context_pmc2/src/hll.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/hll.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -31,6 +31,7 @@
 
 #include "parrot/parrot.h"
 #include "parrot/dynext.h"
+#include "pmc/pmc_context.h"
 #include "hll.str"
 
 /* HEADERIZER HFILE: include/parrot/hll.h */

Modified: branches/context_pmc2/src/interp/inter_create.c
==============================================================================
--- branches/context_pmc2/src/interp/inter_create.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/interp/inter_create.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -23,6 +23,7 @@
 #include "parrot/runcore_api.h"
 #include "parrot/oplib/core_ops.h"
 #include "../compilers/imcc/imc.h"
+#include "../pmc/pmc_context.h"
 #include "inter_create.str"
 
 /* HEADERIZER HFILE: include/parrot/interpreter.h */
@@ -416,7 +417,6 @@
         interp->profile = NULL;
     }
 
-    destroy_context(interp);
     destroy_runloop_jump_points(interp);
 
     if (interp->evc_func_table) {

Modified: branches/context_pmc2/src/interp/inter_misc.c
==============================================================================
--- branches/context_pmc2/src/interp/inter_misc.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/interp/inter_misc.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -22,6 +22,7 @@
 #include "parrot/parrot.h"
 #include "inter_misc.str"
 #include "../compilers/imcc/imc.h"
+#include "../pmc/pmc_context.h"
 
 #include "parrot/has_header.h"
 

Modified: branches/context_pmc2/src/multidispatch.c
==============================================================================
--- branches/context_pmc2/src/multidispatch.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/multidispatch.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -47,6 +47,7 @@
 #include "multidispatch.str"
 #include "pmc/pmc_nci.h"
 #include "pmc/pmc_sub.h"
+#include "pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/multidispatch.h */
 

Modified: branches/context_pmc2/src/oo.c
==============================================================================
--- branches/context_pmc2/src/oo.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/oo.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -24,6 +24,7 @@
 #include "parrot/oo_private.h"
 #include "pmc/pmc_class.h"
 #include "pmc/pmc_object.h"
+#include "pmc/pmc_context.h"
 
 #include "oo.str"
 

Modified: branches/context_pmc2/src/ops/debug.ops
==============================================================================
--- branches/context_pmc2/src/ops/debug.ops	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/ops/debug.ops	Wed Aug 19 12:44:38 2009	(r40655)
@@ -121,7 +121,7 @@
 
 inline op getline(out INT) {
   Parrot_Context_info info;
-  Parrot_Context_get_info(interp, CONTEXT(interp), &info);
+  Parrot_Context_get_info(interp, interp->ctx, &info);
   $1 = info.line;
 }
 
@@ -133,7 +133,7 @@
 
 inline op getfile(out STR) {
   Parrot_Context_info info;
-  Parrot_Context_get_info(interp, CONTEXT(interp), &info);
+  Parrot_Context_get_info(interp, interp->ctx, &info);
   $1 = info.file;
 }
 

Modified: branches/context_pmc2/src/ops/pic.ops
==============================================================================
--- branches/context_pmc2/src/ops/pic.ops	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/ops/pic.ops	Wed Aug 19 12:44:38 2009	(r40655)
@@ -132,7 +132,8 @@
     PMC *sig, *ccont;
     opcode_t *src_pc;
     void **src_pred;
-    Parrot_Context *caller_ctx, *ctx;
+    PMC *caller_ctx;
+    Parrot_Context_attributes *ctx;
     int n;
 
     /* avoid load dependencies - intermix derefs
@@ -143,7 +144,7 @@
     mic = (Parrot_MIC *) cur_opcode[1];
     caller_ctx = ctx->caller_ctx;
     if (src_pc) {
-        src_pred = (void**) src_pc - caller_ctx->pred_offset;
+        src_pred = (void**) src_pc - PARROT_CONTEXT(caller_ctx)->pred_offset;
         sig = (PMC*)(src_pred[1]);
     }
     else {
@@ -154,7 +155,7 @@
     if (lru->u.signature == sig) {
         if (sig) {
             n = ((arg_pass_f)lru->f.real_function)(interp, sig,
-                    (char*)caller_ctx->bp.regs_i, src_pred,
+                    (char*)PARROT_CONTEXT(caller_ctx)->bp.regs_i, src_pred,
                     _reg_base, (void**)cur_opcode);
         }
         else
@@ -163,8 +164,7 @@
         if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) {
             PObj_get_FLAGS(ccont) &= ~SUB_FLAG_TAILCALL;
             --ctx->recursion_depth;
-            ctx->caller_ctx = caller_ctx->caller_ctx;
-            Parrot_free_context(interp, caller_ctx, 1);
+            ctx->caller_ctx = PARROT_CONTEXT(caller_ctx)->caller_ctx;
             interp->current_args = NULL;
         }
 
@@ -183,7 +183,8 @@
     PMC *sig, *ccont;
     opcode_t *dest_pc;
     void **dest_pred;
-    Parrot_Context *caller_ctx, *ctx;
+    PMC *caller_ctx;
+    Parrot_Context_attributes *ctx;
     Parrot_cont *cc;
     int n;
 
@@ -198,9 +199,9 @@
     }
     caller_ctx = cc->to_ctx;
     interp->current_args = NULL;
-    dest_pc = caller_ctx->current_results;
+    dest_pc = PARROT_CONTEXT(caller_ctx)->current_results;
     if (dest_pc) {
-        dest_pred = (void**) dest_pc - caller_ctx->pred_offset;
+        dest_pred = (void**) dest_pc - PARROT_CONTEXT(caller_ctx)->pred_offset;
         sig = (PMC*)(dest_pred[1]);
     }
     else {
@@ -212,7 +213,7 @@
         if (sig) {
             n = ((arg_pass_f)lru->f.real_function)(interp, mic->m.sig,
                     _reg_base, (void**)cur_opcode,
-                    (char*)caller_ctx->bp.regs_i, dest_pred);
+                    (char*)PARROT_CONTEXT(caller_ctx)->bp.regs_i, dest_pred);
         }
         else
             n = 2;
@@ -239,7 +240,7 @@
     Parrot_MIC *mic;
     Parrot_PIC_lru *lru;
     void *args[6];      /* RT#42355 ARG_MAX */
-    Parrot_Context *ctx;
+    Parrot_Context_attributes *ctx;
     opcode_t *pc;
     void **pred_pc;
     INTVAL i, n_args, *sig_bits;

Modified: branches/context_pmc2/src/ops/var.ops
==============================================================================
--- branches/context_pmc2/src/ops/var.ops	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/ops/var.ops	Wed Aug 19 12:44:38 2009	(r40655)
@@ -37,9 +37,9 @@
 =cut
 
 op store_lex(in STR, invar PMC) {
-    Parrot_Context   * const ctx      = CONTEXT(interp);
-    STRING           * const lex_name = $1;
-    PMC              * const lex_pad  = Parrot_find_pad(interp, lex_name, ctx);
+    PMC     * const ctx      = interp->ctx;
+    STRING  * const lex_name = $1;
+    PMC     * const lex_pad  = Parrot_find_pad(interp, lex_name, ctx);
 
     if (PMC_IS_NULL(lex_pad)) {
         opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, NULL,
@@ -62,9 +62,9 @@
 =cut
 
 op find_lex(out PMC, in STR) {
-    Parrot_Context   * const ctx      = CONTEXT(interp);
-    STRING           * const lex_name = $2;
-    PMC              * const lex_pad  = Parrot_find_pad(interp, lex_name, ctx);
+    PMC     * const ctx      = interp->ctx;
+    STRING  * const lex_name = $2;
+    PMC     * const lex_pad  = Parrot_find_pad(interp, lex_name, ctx);
 
     PMC * const result =
         PMC_IS_NULL(lex_pad)
@@ -91,11 +91,11 @@
 =cut
 
 op find_caller_lex(out PMC, in STR) {
-    STRING         * const lex_name = $2;
-    Parrot_Context * ctx            = CONTEXT(interp);
-    PMC            * result         = PMCNULL;
+    STRING  * const lex_name = $2;
+    PMC     * ctx            = interp->ctx;
+    PMC     * result         = PMCNULL;
 
-    for (ctx = ctx->caller_ctx; ctx && PMC_IS_NULL(result); ctx = ctx->caller_ctx) {
+    for (ctx = PARROT_CONTEXT(ctx)->caller_ctx; ctx && PMC_IS_NULL(result); ctx = PARROT_CONTEXT(ctx)->caller_ctx) {
         PMC * const lex_pad = Parrot_find_pad(interp, lex_name, ctx);
         if (!PMC_IS_NULL(lex_pad)) {
             result = VTABLE_get_pmc_keyed_str(interp, lex_pad, lex_name);

Modified: branches/context_pmc2/src/packfile.c
==============================================================================
--- branches/context_pmc2/src/packfile.c	Wed Aug 19 12:43:44 2009	(r40654)
+++ branches/context_pmc2/src/packfile.c	Wed Aug 19 12:44:38 2009	(r40655)
@@ -32,6 +32,7 @@
 #include "packfile.str"
 #include "pmc/pmc_sub.h"
 #include "pmc/pmc_key.h"
+#include "pmc/pmc_context.h"
 
 /* HEADERIZER HFILE: include/parrot/packfile.h */
 
@@ -618,7 +619,7 @@
      * These casts are a quick fix to allow parrot build with c++,
      * a refactor of the macros will be a cleaner solution.  */
     DECL_CONST_CAST;
-    Parrot_sub *sub;
+    Parrot_Sub_attributes *sub;
     int         todo    = 0;
     const int   pragmas = PObj_get_FLAGS(sub_pmc) &  SUB_FLAG_PF_MASK
                                                   & ~SUB_FLAG_IS_OUTER;
@@ -707,7 +708,7 @@
 do_1_sub_pragma(PARROT_INTERP, ARGMOD(PMC *sub_pmc), pbc_action_enum_t action)
 {
     ASSERT_ARGS(do_1_sub_pragma)
-    Parrot_sub *sub;
+    Parrot_Sub_attributes *sub;
     PMC_get_sub(interp, sub_pmc, sub);
 
     switch (action) {
@@ -922,7 +923,7 @@
             {
                 /* offset is an index into const_table holding the Sub PMC */
                 PMC           *sub_pmc;
-                Parrot_sub    *sub;
+                Parrot_Sub_attributes    *sub;
                 const opcode_t ci = ft->fixups[i]->offset;
 
                 if (ci < 0 || ci >= ct->const_count)
@@ -1005,7 +1006,7 @@
     /* Ensure the bytecode version is one we can read. Currently, we only
      * support bytecode versions matching the current one.
      *
-     * tools/dev/pbc_header.pl --upd t/native_pbc/*.pbc
+     * tools/dev/pbc_header.pl --upd t/native_pbc/ *.pbc
      * stamps version and fingerprint in the native tests. */
     if (header->bc_major != PARROT_PBC_MAJOR
     ||  header->bc_minor != PARROT_PBC_MINOR) {
@@ -3119,7 +3120,7 @@
     if (old_const->type == PFC_PMC
     &&  VTABLE_isa(interp, old_const->u.key, _sub)) {
         PMC        *old_sub_pmc, *new_sub_pmc;
-        Parrot_sub *old_sub,     *new_sub;
+        Parrot_Sub_attributes *old_sub,     *new_sub;
         PackFile_Constant * const ret = mem_allocate_typed(PackFile_Constant);
 
         ret->type = old_const->type;


More information about the parrot-commits mailing list