[svn:parrot] r40595 - in branches/context_pmc2: include/parrot src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sun Aug 16 14:52:13 UTC 2009
Author: whiteknight
Date: Sun Aug 16 14:52:13 2009
New Revision: 40595
URL: https://trac.parrot.org/parrot/changeset/40595
Log:
[context_pmc2] add some register accessor API functions. Use them. Headerizer
Modified:
branches/context_pmc2/include/parrot/interpreter.h
branches/context_pmc2/include/parrot/register.h
branches/context_pmc2/include/parrot/sub.h
branches/context_pmc2/src/gc/alloc_register.c
Modified: branches/context_pmc2/include/parrot/interpreter.h
==============================================================================
--- branches/context_pmc2/include/parrot/interpreter.h Sun Aug 16 14:11:55 2009 (r40594)
+++ branches/context_pmc2/include/parrot/interpreter.h Sun Aug 16 14:52:13 2009 (r40595)
@@ -248,7 +248,7 @@
size_t n_allocated; /* allocated size of it */
} Prederef;
-#define CONTEXT(interp) (Parrot_ctx_get_context_struct((interp)->ctx))
+#define CONTEXT(interp) (Parrot_ctx_get_context_struct((interp), (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 Sun Aug 16 14:11:55 2009 (r40594)
+++ branches/context_pmc2/include/parrot/register.h Sun Aug 16 14:52:13 2009 (r40595)
@@ -20,15 +20,17 @@
* Macros to make accessing registers more convenient/readable.
*/
+/* Macros for interfacing with the Parrot_Context structure */
#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))
+/* Macros for interfacing with the Context PMC */
+#define REG_NUM(interp, x) *(Parrot_ctx_FLOATVAL_reg((interp), (interp)->ctx, (x)))
+#define REG_INT(interp, x) *(Parrot_ctx_INTVA_reg((interp), (interp)->ctx, (x)))
+#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)))
/*
* and a set of macros to access a register by offset, used
@@ -78,60 +80,58 @@
__attribute__nonnull__(1);
PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-Parrot_Context * Parrot_context_ref_trace(PARROT_INTERP,
- ARGMOD(Parrot_Context *ctx),
- ARGIN(const char *file),
- int line)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*ctx);
-
-PARROT_EXPORT
-void Parrot_free_context(PARROT_INTERP,
- ARGMOD(Parrot_Context *ctx),
- int deref)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*ctx);
-
-PARROT_EXPORT
-void parrot_gc_context(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
void Parrot_pop_context(PARROT_INTERP)
__attribute__nonnull__(1);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-Parrot_Context * Parrot_push_context(PARROT_INTERP,
- ARGIN(const INTVAL *n_regs_used))
+PMC * Parrot_push_context(PARROT_INTERP, ARGIN(const INTVAL *n_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-PARROT_EXPORT
-void Parrot_set_context_threshold(SHIM_INTERP, SHIM(Parrot_Context *ctx));
-
void create_initial_context(PARROT_INTERP)
__attribute__nonnull__(1);
-void destroy_context(PARROT_INTERP)
- __attribute__nonnull__(1);
-
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
-Parrot_Context * Parrot_alloc_context(PARROT_INTERP,
+PMC * Parrot_alloc_context(PARROT_INTERP,
ARGIN(const INTVAL *number_regs_used),
ARGIN_NULLOK(Parrot_Context *old))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CANNOT_RETURN_NULL
+FLOATVAL * Parrot_ctx_FLOATVAL_reg(PARROT_INTERP,
+ ARGIN(PMC *ctx),
+ INTVAL idx)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_CAN_RETURN_NULL
+Parrot_Context * 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)
+ __attribute__nonnull__(2);
+
+PARROT_CANNOT_RETURN_NULL
+PMC ** Parrot_ctx_PMC_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_CANNOT_RETURN_NULL
+STRING ** Parrot_ctx_STRING_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
-Parrot_Context * Parrot_set_new_context(PARROT_INTERP,
+PMC * Parrot_set_new_context(PARROT_INTERP,
ARGIN(const INTVAL *number_regs_used))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -144,28 +144,31 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_clear_s __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_context_ref_trace __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx) \
- || PARROT_ASSERT_ARG(file)
-#define ASSERT_ARGS_Parrot_free_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_parrot_gc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_pop_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_push_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(n_regs_used)
-#define ASSERT_ARGS_Parrot_set_context_threshold __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_create_initial_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_destroy_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_alloc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(number_regs_used)
+#define ASSERT_ARGS_Parrot_ctx_FLOATVAL_reg __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)
+#define ASSERT_ARGS_Parrot_ctx_PMC_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_ctx_STRING_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_set_new_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(number_regs_used)
Modified: branches/context_pmc2/include/parrot/sub.h
==============================================================================
--- branches/context_pmc2/include/parrot/sub.h Sun Aug 16 14:11:55 2009 (r40594)
+++ branches/context_pmc2/include/parrot/sub.h Sun Aug 16 14:52:13 2009 (r40595)
@@ -293,12 +293,6 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*cont);
-void mark_context(PARROT_INTERP, ARGMOD(Parrot_Context* ctx))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(* ctx);
-
-void mark_context_start(void);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Parrot_cont * new_continuation(PARROT_INTERP,
@@ -368,10 +362,6 @@
#define ASSERT_ARGS_invalidate_retc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(cont)
-#define ASSERT_ARGS_mark_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_mark_context_start __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_new_continuation __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_new_coroutine __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Modified: branches/context_pmc2/src/gc/alloc_register.c
==============================================================================
--- branches/context_pmc2/src/gc/alloc_register.c Sun Aug 16 14:11:55 2009 (r40594)
+++ branches/context_pmc2/src/gc/alloc_register.c Sun Aug 16 14:52:13 2009 (r40595)
@@ -28,11 +28,6 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void clear_regs(PARROT_INTERP, ARGMOD(Parrot_Context *ctx))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*ctx);
-
static void init_context(PARROT_INTERP,
ARGMOD(Parrot_Context *ctx),
ARGIN_NULLOK(const Parrot_Context *old))
@@ -40,9 +35,6 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*ctx);
-#define ASSERT_ARGS_clear_regs __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_init_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
@@ -108,7 +100,8 @@
/*
-=item C<Parrot_Context * Parrot_ctx_get_context_struct(PARROT_INTERP, PMC * context)>
+=item C<Parrot_Context * Parrot_ctx_get_context_struct(PARROT_INTERP, PMC *
+context)>
=cut
@@ -147,8 +140,7 @@
/*
-=item C<Parrot_Context * Parrot_push_context(PARROT_INTERP, const INTVAL
-*n_regs_used)>
+=item C<PMC * Parrot_push_context(PARROT_INTERP, const INTVAL *n_regs_used)>
Creates and sets the current context to a new context, remembering the old
context in C<caller_ctx>. Suitable to use with C<Parrot_pop_context>.
@@ -201,7 +193,7 @@
/*
-=item C<Parrot_Context * Parrot_set_new_context(PARROT_INTERP, const INTVAL
+=item C<PMC * Parrot_set_new_context(PARROT_INTERP, const INTVAL
*number_regs_used)>
Allocates and returns a new context as the current context. Note that the
@@ -227,7 +219,7 @@
/*
-=item C<Parrot_Context * Parrot_alloc_context(PARROT_INTERP, const INTVAL
+=item C<PMC * Parrot_alloc_context(PARROT_INTERP, const INTVAL
*number_regs_used, Parrot_Context *old)>
Allocates and returns a new context. Does not set this new context as the
@@ -439,6 +431,47 @@
REG_NUM(interp, i) = 0.0;
}
+PARROT_CANNOT_RETURN_NULL
+INTVAL *
+Parrot_ctx_INTVAL_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+{
+ ASSERT_ARGS(Parrot_ctx_get_INTVAL_reg)
+ return &(PARROT_CONTEXT(ctx)->bp.regs_i[idx]);
+}
+
+PARROT_CANNOT_RETURN_NULL
+FLOATVAL *
+Parrot_ctx_FLOATVAL_reg(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+{
+ ASSERT_ARGS(Parrot_ctx_get_FLOATVAL_reg)
+ return &(PARROT_CONTEXT(ctx)->bp.regs_n[-1L - idx]);
+}
+
+PARROT_CANNOT_RETURN_NULL
+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]);
+}
+
+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]);
+}
+
+PARROT_CANNOT_RETURN_NULL
+PMC *
+Parrot_ctx_get_caller(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_ctx_get_caller)
+ return PARROT_CONTEXT(ctx)->caller_ctx;
+}
+
+
/*
More information about the parrot-commits
mailing list