[svn:parrot] r41111 - in trunk: include/parrot src/call src/gc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Mon Sep 7 13:49:30 UTC 2009
Author: whiteknight
Date: Mon Sep 7 13:49:29 2009
New Revision: 41111
URL: https://trac.parrot.org/parrot/changeset/41111
Log:
[ctx] move most of the guts from register.h to context.h. Fix POD errors in alloc_register.c and context.c
Modified:
trunk/include/parrot/context.h
trunk/include/parrot/interpreter.h
trunk/include/parrot/parrot.h
trunk/include/parrot/register.h
trunk/src/call/context.c
trunk/src/gc/alloc_register.c
Modified: trunk/include/parrot/context.h
==============================================================================
--- trunk/include/parrot/context.h Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/include/parrot/context.h Mon Sep 7 13:49:29 2009 (r41111)
@@ -9,6 +9,49 @@
#ifndef PARROT_CONTEXT_H_GUARD
#define PARROT_CONTEXT_H_GUARD
+#include "parrot/string.h"
+#include "parrot/compiler.h"
+
+/*
+ * Macros to make accessing registers more convenient/readable.
+ */
+
+#define CTX_REG_NUM(p, x) (*Parrot_pcc_get_FLOATVAL_reg(interp, (p), (x)))
+#define CTX_REG_INT(p, x) (*Parrot_pcc_get_INTVAL_reg(interp, (p), (x)))
+#define CTX_REG_PMC(p, x) (*Parrot_pcc_get_PMC_reg(interp, (p), (x)))
+#define CTX_REG_STR(p, x) (*Parrot_pcc_get_STRING_reg(interp, (p), (x)))
+
+#define REG_NUM(interp, x) (*Parrot_pcc_get_FLOATVAL_reg((interp), (interp)->ctx, (x)))
+#define REG_INT(interp, x) (*Parrot_pcc_get_INTVAL_reg((interp), (interp)->ctx, (x)))
+#define REG_PMC(interp, x) (*Parrot_pcc_get_PMC_reg((interp), (interp)->ctx, (x)))
+#define REG_STR(interp, x) (*Parrot_pcc_get_STRING_reg((interp), (interp)->ctx, (x)))
+
+/*
+ * and a set of macros to access a register by offset, used
+ * in JIT emit prederef code
+ * The offsets are relative to interp->ctx.bp.
+ *
+ * Reg order in imcc/reg_alloc.c is "INSP" TODO make defines
+ */
+
+#define REGNO_INT 0
+#define REGNO_NUM 1
+#define REGNO_STR 2
+#define REGNO_PMC 3
+
+#define __CTX Parrot_pcc_get_context_struct(interp, interp->ctx)
+#define _SIZEOF_INTS (sizeof (INTVAL) * __CTX->n_regs_used[REGNO_INT])
+#define _SIZEOF_NUMS (sizeof (FLOATVAL) * __CTX->n_regs_used[REGNO_NUM])
+#define _SIZEOF_PMCS (sizeof (PMC*) * __CTX->n_regs_used[REGNO_PMC])
+#define _SIZEOF_STRS (sizeof (STRING*) * __CTX->n_regs_used[REGNO_STR])
+
+#define REG_OFFS_NUM(x) (sizeof (FLOATVAL) * (-1L - (x)))
+#define REG_OFFS_INT(x) (sizeof (INTVAL) * (x))
+#define REG_OFFS_PMC(x) (_SIZEOF_INTS + sizeof (PMC*) * \
+ (__CTX->n_regs_used[REGNO_PMC] - 1L - (x)))
+#define REG_OFFS_STR(x) (sizeof (STRING*) * (x) + _SIZEOF_INTS + _SIZEOF_PMCS)
+
+
struct PackFile_Constant;
typedef union {
Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/include/parrot/interpreter.h Mon Sep 7 13:49:29 2009 (r41111)
@@ -133,6 +133,7 @@
#define Interp_core_TEST(interp, core) ((interp)->run_core == (core))
#include "parrot/register.h"
+#include "parrot/context.h"
#include "parrot/parrot.h"
#include "parrot/warnings.h"
Modified: trunk/include/parrot/parrot.h
==============================================================================
--- trunk/include/parrot/parrot.h Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/include/parrot/parrot.h Mon Sep 7 13:49:29 2009 (r41111)
@@ -268,6 +268,7 @@
#include "parrot/pmc_freeze.h"
#include "parrot/vtable.h"
#include "parrot/register.h"
+#include "parrot/context.h"
#include "parrot/exceptions.h"
#include "parrot/warnings.h"
#include "parrot/memory.h"
Modified: trunk/include/parrot/register.h
==============================================================================
--- trunk/include/parrot/register.h Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/include/parrot/register.h Mon Sep 7 13:49:29 2009 (r41111)
@@ -13,232 +13,9 @@
#ifndef PARROT_REGISTER_H_GUARD
#define PARROT_REGISTER_H_GUARD
-#include "parrot/string.h"
-#include "parrot/compiler.h"
-#include "parrot/context.h" /* Parrot_Context */
-
-/*
- * Macros to make accessing registers more convenient/readable.
- */
-
-#define CTX_REG_NUM(p, x) (*Parrot_pcc_get_FLOATVAL_reg(interp, (p), (x)))
-#define CTX_REG_INT(p, x) (*Parrot_pcc_get_INTVAL_reg(interp, (p), (x)))
-#define CTX_REG_PMC(p, x) (*Parrot_pcc_get_PMC_reg(interp, (p), (x)))
-#define CTX_REG_STR(p, x) (*Parrot_pcc_get_STRING_reg(interp, (p), (x)))
-
-#define REG_NUM(interp, x) (*Parrot_pcc_get_FLOATVAL_reg((interp), (interp)->ctx, (x)))
-#define REG_INT(interp, x) (*Parrot_pcc_get_INTVAL_reg((interp), (interp)->ctx, (x)))
-#define REG_PMC(interp, x) (*Parrot_pcc_get_PMC_reg((interp), (interp)->ctx, (x)))
-#define REG_STR(interp, x) (*Parrot_pcc_get_STRING_reg((interp), (interp)->ctx, (x)))
-
-/*
- * and a set of macros to access a register by offset, used
- * in JIT emit prederef code
- * The offsets are relative to interp->ctx.bp.
- *
- * Reg order in imcc/reg_alloc.c is "INSP" TODO make defines
- */
-
-#define REGNO_INT 0
-#define REGNO_NUM 1
-#define REGNO_STR 2
-#define REGNO_PMC 3
-
-#define __CTX Parrot_pcc_get_context_struct(interp, interp->ctx)
-#define _SIZEOF_INTS (sizeof (INTVAL) * __CTX->n_regs_used[REGNO_INT])
-#define _SIZEOF_NUMS (sizeof (FLOATVAL) * __CTX->n_regs_used[REGNO_NUM])
-#define _SIZEOF_PMCS (sizeof (PMC*) * __CTX->n_regs_used[REGNO_PMC])
-#define _SIZEOF_STRS (sizeof (STRING*) * __CTX->n_regs_used[REGNO_STR])
-
-#define REG_OFFS_NUM(x) (sizeof (FLOATVAL) * (-1L - (x)))
-#define REG_OFFS_INT(x) (sizeof (INTVAL) * (x))
-#define REG_OFFS_PMC(x) (_SIZEOF_INTS + sizeof (PMC*) * \
- (__CTX->n_regs_used[REGNO_PMC] - 1L - (x)))
-#define REG_OFFS_STR(x) (sizeof (STRING*) * (x) + _SIZEOF_INTS + _SIZEOF_PMCS)
/* HEADERIZER BEGIN: src/gc/alloc_register.c */
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-
-PARROT_EXPORT
-void Parrot_clear_i(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void Parrot_clear_n(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void Parrot_clear_p(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-void Parrot_clear_s(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-FLOATVAL * Parrot_pcc_get_FLOATVAL_reg(PARROT_INTERP,
- ARGIN(PMC *ctx),
- UINTVAL idx)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-INTVAL * Parrot_pcc_get_INTVAL_reg(PARROT_INTERP,
- ARGIN(PMC *ctx),
- UINTVAL idx)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-PMC ** Parrot_pcc_get_PMC_reg(PARROT_INTERP, ARGIN(PMC *ctx), UINTVAL idx)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-Regs_ni* Parrot_pcc_get_regs_ni(PARROT_INTERP, ARGIN(PMC *ctx))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-Regs_ps* Parrot_pcc_get_regs_ps(PARROT_INTERP, ARGIN(PMC *ctx))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-UINTVAL Parrot_pcc_get_regs_used(PARROT_INTERP, ARGIN(PMC *ctx), int type)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-STRING ** Parrot_pcc_get_STRING_reg(PARROT_INTERP,
- ARGIN(PMC *ctx),
- UINTVAL idx)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-void Parrot_pcc_set_regs_ni(PARROT_INTERP,
- ARGIN(PMC *ctx),
- ARGIN(Regs_ni *bp))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-void Parrot_pcc_set_regs_ps(PARROT_INTERP,
- ARGIN(PMC *ctx),
- ARGIN(Regs_ps *bp_ps))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-PARROT_EXPORT
-void Parrot_pcc_set_regs_used(PARROT_INTERP,
- ARGIN(PMC *ctx),
- int type,
- INTVAL num)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-void Parrot_pop_context(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-PMC * Parrot_push_context(PARROT_INTERP, ARGIN(const INTVAL *n_regs_used))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-void create_initial_context(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-PMC * Parrot_alloc_context(PARROT_INTERP,
- ARGIN(const INTVAL *number_regs_used),
- ARGIN_NULLOK(PMC *old))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-size_t Parrot_pcc_calculate_context_size(SHIM_INTERP,
- ARGIN(const UINTVAL *number_regs_used))
- __attribute__nonnull__(2);
-
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-PMC * Parrot_set_new_context(PARROT_INTERP,
- ARGIN(const INTVAL *number_regs_used))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-#define ASSERT_ARGS_Parrot_clear_i __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_clear_n __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_clear_p __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_clear_s __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_pcc_get_FLOATVAL_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_INTVAL_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_PMC_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_regs_ni __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_regs_ps __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_regs_used __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_get_STRING_reg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#define ASSERT_ARGS_Parrot_pcc_set_regs_ni __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx) \
- || PARROT_ASSERT_ARG(bp)
-#define ASSERT_ARGS_Parrot_pcc_set_regs_ps __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx) \
- || PARROT_ASSERT_ARG(bp_ps)
-#define ASSERT_ARGS_Parrot_pcc_set_regs_used __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(ctx)
-#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_create_initial_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_pcc_calculate_context_size \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(number_regs_used)
-#define ASSERT_ARGS_Parrot_set_new_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(number_regs_used)
-/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/gc/alloc_register.c */
#endif /* PARROT_REGISTER_H_GUARD */
Modified: trunk/src/call/context.c
==============================================================================
--- trunk/src/call/context.c Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/src/call/context.c Mon Sep 7 13:49:29 2009 (r41111)
@@ -8,10 +8,6 @@
=head1 DESCRIPTION
-=head2 Functions
-
-=over 4
-
=cut
*/
@@ -23,7 +19,6 @@
#include "parrot/register.h"
#include "../pmc/pmc_sub.h"
-
/* set CTX_LEAK_DEBUG_FULL to 1 for enhanced context debugging.
* When set (1) freed contexts are "poisoned" so that any dangling
* references produce segfaults, and (2) contexts are not recycled
@@ -32,8 +27,8 @@
*/
#define CTX_LEAK_DEBUG_FULL 0
-
/*
+
=head2 Context and register frame layout
+----------++----+------+------------+----+
@@ -52,13 +47,12 @@
*/
-
#define ALIGNED_CTX_SIZE (((sizeof (Parrot_Context) + NUMVAL_SIZE - 1) \
/ NUMVAL_SIZE) * NUMVAL_SIZE)
/*
-=pod
+=head2 Allocation Size
Round register allocation size up to the nearest multiple of 8. A granularity
of 8 is arbitrary, it could have been some bigger power of 2. A "slot" is an
@@ -105,6 +99,10 @@
/*
+=head2 Context API Functions
+
+=over 4
+
=item C<void Parrot_pcc_set_constants(PARROT_INTERP, PMC *ctx, struct
PackFile_Constant **constants)>
@@ -1016,17 +1014,12 @@
/*
+=back
+
=head2 Context and Register Allocation Functions
=over 4
-=cut
-
-*/
-
-
-/*
-
=item C<void create_initial_context(PARROT_INTERP)>
Creates the interpreter's initial context.
Modified: trunk/src/gc/alloc_register.c
==============================================================================
--- trunk/src/gc/alloc_register.c Mon Sep 7 13:22:34 2009 (r41110)
+++ trunk/src/gc/alloc_register.c Mon Sep 7 13:49:29 2009 (r41111)
@@ -21,8 +21,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/register.h> and F<src/stacks.c>.
More information about the parrot-commits
mailing list