[svn:parrot] r39811 - in branches/context_pmc: include/parrot lib/Parrot/Ops2c src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat Jun 27 21:57:42 UTC 2009


Author: whiteknight
Date: Sat Jun 27 21:57:40 2009
New Revision: 39811
URL: https://trac.parrot.org/parrot/changeset/39811

Log:
[context_pmc] adding some vtables necessary to calculate all the offsets in JIT, but haven't put together the necessary macros yet. Also switched over some other stuff

Modified:
   branches/context_pmc/include/parrot/register.h
   branches/context_pmc/lib/Parrot/Ops2c/Utils.pm
   branches/context_pmc/src/pmc/context.pmc

Modified: branches/context_pmc/include/parrot/register.h
==============================================================================
--- branches/context_pmc/include/parrot/register.h	Sat Jun 27 19:39:09 2009	(r39810)
+++ branches/context_pmc/include/parrot/register.h	Sat Jun 27 21:57:40 2009	(r39811)
@@ -21,15 +21,15 @@
  * Macros to make accessing registers more convenient/readable.
  */
 
-#define CTX_REG_NUM(ctx, x) (ctx)->bp.regs_n[-1L-(x)]
-#define CTX_REG_INT(ctx, x) (ctx)->bp.regs_i[x]
-#define CTX_REG_PMC(ctx, x) (ctx)->bp_ps.regs_p[-1L-(x)]
-#define CTX_REG_STR(ctx, x) (ctx)->bp_ps.regs_s[x]
-
-#define REG_NUM(interp, x) CTX_REG_NUM(&(interp)->ctx, (x))
-#define REG_INT(interp, x) CTX_REG_INT(&(interp)->ctx, (x))
-#define REG_PMC(interp, x) CTX_REG_PMC(&(interp)->ctx, (x))
-#define REG_STR(interp, x) CTX_REG_STR(&(interp)->ctx, (x))
+#define CTX_REG_NUM(interp, ctx, x) VTABLE_get_number_keyed_int((interp), (ctx), x)
+#define CTX_REG_INT(interp, ctx, x) VTABLE_get_integer_keyed_int((interp), (ctx), x)
+#define CTX_REG_PMC(interp, ctx, x) VTABLE_get_pmc_keyed_int((interp), (ctx), x)
+#define CTX_REG_STR(interp, ctx, x) VTABLE_get_string_keyed_int((interp), (ctx), x)
+
+#define REG_NUM(interp, x) CTX_REG_NUM((interp), &(interp)->ctx, (x))
+#define REG_INT(interp, x) CTX_REG_INT((interp), &(interp)->ctx, (x))
+#define REG_PMC(interp, x) CTX_REG_PMC((interp), &(interp)->ctx, (x))
+#define REG_STR(interp, x) CTX_REG_STR((interp), &(interp)->ctx, (x))
 
 /*
  * and a set of macros to access a register by offset, used

Modified: branches/context_pmc/lib/Parrot/Ops2c/Utils.pm
==============================================================================
--- branches/context_pmc/lib/Parrot/Ops2c/Utils.pm	Sat Jun 27 19:39:09 2009	(r39810)
+++ branches/context_pmc/lib/Parrot/Ops2c/Utils.pm	Sat Jun 27 21:57:40 2009	(r39811)
@@ -476,6 +476,7 @@
     print $fh <<END_C;
 #include "parrot/parrot.h"
 #include "parrot/oplib.h"
+#include "../pmc/pmc_context.h"
 
 $self->{sym_export} op_lib_t *$self->{init_func}(long init);
 

Modified: branches/context_pmc/src/pmc/context.pmc
==============================================================================
--- branches/context_pmc/src/pmc/context.pmc	Sat Jun 27 19:39:09 2009	(r39810)
+++ branches/context_pmc/src/pmc/context.pmc	Sat Jun 27 21:57:40 2009	(r39811)
@@ -84,7 +84,6 @@
 #define ALIGNED_CTX_SIZE (((sizeof (Parrot_Context) + NUMVAL_SIZE - 1) \
         / NUMVAL_SIZE) * NUMVAL_SIZE)
 
-
 /*
 
 =item C<static void clear_regs(PARROT_INTERP, Parrot_Context *ctx)>
@@ -135,7 +134,7 @@
     ATTR void *    regs;        /* register storage */
 
     /* end common header */
-    ATTR INTVAL    n_regs_used[4];   /* INSP in PBC points to Sub */
+    ATTR INTVAL    n_regs_used[4];  /* INSP in PBC points to Sub */
     ATTR PMC      *lex_pad;         /* LexPad PMC */
     ATTR PMC      *outer_ctx;       /* outer context, if a closure */
 
@@ -318,7 +317,37 @@
             VTABLE_set_string_keyed_int(INTERP, SELF, i, val);
     }
 
+    VTABLE INTVAL get_integer_keyed_int(INTVAL x) {
+        return PARROT_CONTEXT(SELF)->bp.regs_i[x];
+    }
+
+    VTABLE FLOATVAL get_number_keyed_int(INTVAL x) {
+        return PARROT_CONTEXT(SELF)->bp.regs_n[-1L-x];
+    }
+
+    VTABLE PMC* get_pmc_keyed_int(INTVAL x) {
+        return PARROT_CONTEXT(SELF)->bp_ps.regs_p[-1L-x];
+    }
+
+    VTABLE STRING* get_string_keyed_int(INTVAL x) {
+        return PARROT_CONTEXT(SELF)->bp_ps.regs_s[x];
+    }
+
+    VTABLE void set_integer_keyed_int(INTVAL key, INTVAL val) {
+        PARROT_CONTEXT(SELF)->bp.regs_i[key] = val;
+    }
+
+    VTABLE void set_number_keyed_int(INTVAL x, FLOATVAL val) {
+        PARROT_CONTEXT(SELF)->bp.regs_n[-1L-x] = val;
+    }
 
+    VTABLE void set_pmc_keyed_int(INTVAL x, PMC * val) {
+        PARROT_CONTEXT(SELF)->bp_ps.regs_p[-1L-x] = val;
+    }
+
+    VTABLE void set_string_keyed_int(INTVAL x, STRING *val) {
+        PARROT_CONTEXT(SELF)->bp_ps.regs_s[x] = val;
+    }
 
     VTABLE void set_pointer(void *number_regs_used) {
         Parrot_Context_attributes * const ctx = PARROT_CONTEXT(SELF);
@@ -346,6 +375,23 @@
         ctx->bp_ps.regs_s = (STRING **)((char *)ctx_regs + size_nip);
     }
 
+    VTABLE void * get_pointer() {
+        return PARROT_CONTEXT(SELF)->regs;
+    }
+
+    VTABLE void * get_pointer_keyed_int(INTVAL regtype) {
+        switch (regtype) {
+            case REGNO_INT:
+            case REGNO_NUM:
+                return PARROT_CONTEXT(SELF)->regs_ni;
+            case REGNO_PMC:
+            case REGNO_STR:
+                return PARROT_CONTEXT(SELF)->regs_ps;
+            default:
+                return NULL;
+        }
+    }
+
     VTABLE void destroy() {
         Parrot_Context_attributes * const data = PARROT_CONTEXT(SELF);
         if (data) {


More information about the parrot-commits mailing list