[svn:parrot] r40903 - in branches/context_pmc3: include/parrot src/gc
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Sep 1 10:17:45 UTC 2009
Author: bacek
Date: Tue Sep 1 10:17:43 2009
New Revision: 40903
URL: https://trac.parrot.org/parrot/changeset/40903
Log:
Add accessors to Regs_* structures. Move Parrot_Context definition into
separated file to avoid circular dependencies.
Added:
branches/context_pmc3/include/parrot/context.h
Modified:
branches/context_pmc3/include/parrot/call.h
branches/context_pmc3/include/parrot/register.h
branches/context_pmc3/src/gc/alloc_register.c
Modified: branches/context_pmc3/include/parrot/call.h
==============================================================================
--- branches/context_pmc3/include/parrot/call.h Tue Sep 1 09:22:28 2009 (r40902)
+++ branches/context_pmc3/include/parrot/call.h Tue Sep 1 10:17:43 2009 (r40903)
@@ -16,6 +16,8 @@
#ifndef PARROT_INTER_CALL_H_GUARD
#define PARROT_INTER_CALL_H_GUARD
+#include "parrot/context.h"
+
/* Wrap the jump buffer in a struct, to make it a linked list. Jump buffers are
* used to resume execution at a point in the runloop where an exception
* handler can be run. Ultimately this information should be part of
@@ -700,55 +702,6 @@
} while (0)
/* Context manipulating functions */
-struct PackFile_Constant;
-
-typedef union {
- PMC **regs_p;
- STRING **regs_s;
-} Regs_ps;
-
-typedef union {
- FLOATVAL *regs_n;
- INTVAL *regs_i;
-} Regs_ni;
-
-struct Parrot_Context {
- PMC *caller_ctx; /* caller context */
- Regs_ni bp; /* pointers to FLOATVAL & INTVAL */
- Regs_ps bp_ps; /* pointers to PMC & STR */
-
- /* end common header */
- INTVAL n_regs_used[4]; /* INSP in PBC points to Sub */
- PMC *lex_pad; /* LexPad PMC */
- PMC *outer_ctx; /* outer context, if a closure */
-
- /* new call scheme and introspective variables */
- PMC *current_sub; /* the Sub we are executing */
-
- /* for now use a return continuation PMC */
- PMC *handlers; /* local handlers for the context */
- PMC *current_cont; /* the return continuation PMC */
- PMC *current_object; /* current object if a method call */
- PMC *current_namespace; /* The namespace we're currently in */
- PMC *results_signature; /* non-const results signature PMC */
- opcode_t *current_pc; /* program counter of Sub invocation */
- opcode_t *current_results; /* ptr into code with get_results opcode */
-
- /* deref the constants - we need it all the time */
- struct PackFile_Constant **constants;
-
- INTVAL current_HLL; /* see also src/hll.c */
-
- UINTVAL warns; /* Keeps track of what warnings
- * have been activated */
- UINTVAL errors; /* fatals that can be turned off */
- UINTVAL trace_flags;
- UINTVAL recursion_depth; /* Sub call recursion depth */
-
- /* code->prederefed.code - code->base.data in opcodes
- * to simplify conversion between code ptrs in e.g. invoke */
- size_t pred_offset;
-};
/* HEADERIZER BEGIN: src/call/context.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Added: branches/context_pmc3/include/parrot/context.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/context_pmc3/include/parrot/context.h Tue Sep 1 10:17:43 2009 (r40903)
@@ -0,0 +1,74 @@
+/* context.h
+ * Copyright (C) 2009, Parrot Foundation.
+ * SVN Info
+ * $Id$
+ * Overview:
+ * Context
+ */
+
+#ifndef PARROT_CONTEXT_H_GUARD
+#define PARROT_CONTEXT_H_GUARD
+
+struct PackFile_Constant;
+
+typedef union {
+ PMC **regs_p;
+ STRING **regs_s;
+} Regs_ps;
+
+typedef union {
+ FLOATVAL *regs_n;
+ INTVAL *regs_i;
+} Regs_ni;
+
+struct Parrot_Context {
+ PMC *caller_ctx; /* caller context */
+ Regs_ni bp; /* pointers to FLOATVAL & INTVAL */
+ Regs_ps bp_ps; /* pointers to PMC & STR */
+
+ /* end common header */
+ INTVAL n_regs_used[4]; /* INSP in PBC points to Sub */
+ PMC *lex_pad; /* LexPad PMC */
+ PMC *outer_ctx; /* outer context, if a closure */
+
+ /* new call scheme and introspective variables */
+ PMC *current_sub; /* the Sub we are executing */
+
+ /* for now use a return continuation PMC */
+ PMC *handlers; /* local handlers for the context */
+ PMC *current_cont; /* the return continuation PMC */
+ PMC *current_object; /* current object if a method call */
+ PMC *current_namespace; /* The namespace we're currently in */
+ PMC *results_signature; /* non-const results signature PMC */
+ opcode_t *current_pc; /* program counter of Sub invocation */
+ opcode_t *current_results; /* ptr into code with get_results opcode */
+
+ /* deref the constants - we need it all the time */
+ struct PackFile_Constant **constants;
+
+ INTVAL current_HLL; /* see also src/hll.c */
+
+ UINTVAL warns; /* Keeps track of what warnings
+ * have been activated */
+ UINTVAL errors; /* fatals that can be turned off */
+ UINTVAL trace_flags;
+ UINTVAL recursion_depth; /* Sub call recursion depth */
+
+ /* code->prederefed.code - code->base.data in opcodes
+ * to simplify conversion between code ptrs in e.g. invoke */
+ size_t pred_offset;
+};
+
+typedef struct Parrot_Context Parrot_Context;
+
+#define PMC_context(pmc) Parrot_cx_get_context(interp, (pmc))
+
+
+#endif /* PARROT_CONTEXT_H_GUARD */
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
Modified: branches/context_pmc3/include/parrot/register.h
==============================================================================
--- branches/context_pmc3/include/parrot/register.h Tue Sep 1 09:22:28 2009 (r40902)
+++ branches/context_pmc3/include/parrot/register.h Tue Sep 1 10:17:43 2009 (r40903)
@@ -15,6 +15,7 @@
#include "parrot/string.h"
#include "parrot/compiler.h"
+#include "parrot/context.h" /* Parrot_Context */
/*
* Macros to make accessing registers more convenient/readable.
@@ -56,8 +57,6 @@
#define REG_OFFS_STR(x) (sizeof (STRING*) * (x) + _SIZEOF_INTS + _SIZEOF_PMCS)
-typedef struct Parrot_Context Parrot_Context; /* parrot/interpreter.h */
-
/* HEADERIZER BEGIN: src/gc/alloc_register.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
@@ -104,6 +103,18 @@
__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
int Parrot_pcc_get_regs_used(PARROT_INTERP, ARGIN(PMC *ctx), int type)
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -117,6 +128,24 @@
__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,
@@ -172,12 +201,26 @@
#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)
Modified: branches/context_pmc3/src/gc/alloc_register.c
==============================================================================
--- branches/context_pmc3/src/gc/alloc_register.c Tue Sep 1 09:22:28 2009 (r40902)
+++ branches/context_pmc3/src/gc/alloc_register.c Tue Sep 1 10:17:43 2009 (r40903)
@@ -649,6 +649,77 @@
/*
+=item C<Regs_ni* Parrot_pcc_get_regs_ni(PARROT_INTERP, PMC *ctx)>
+
+Get pointer to FLOANFAL and INTVAL registers.
+
+=cut
+
+*/
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+Regs_ni*
+Parrot_pcc_get_regs_ni(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_pcc_get_regs_ni)
+ return &(Parrot_pcc_get_context_struct(interp, ctx)->bp);
+}
+
+/*
+
+=item C<void Parrot_pcc_set_regs_ni(PARROT_INTERP, PMC *ctx, Regs_ni *bp)>
+
+Copy Regs_ni into Context.
+
+=cut
+
+*/
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+void
+Parrot_pcc_set_regs_ni(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(Regs_ni *bp))
+{
+ ASSERT_ARGS(Parrot_pcc_set_regs_ni)
+ Parrot_pcc_get_context_struct(interp, ctx)->bp = *bp;
+}
+
+/*
+
+=item C<Regs_ps* Parrot_pcc_get_regs_ps(PARROT_INTERP, PMC *ctx)>
+
+Get pointer to PMC and STRING registers.
+
+=cut
+
+*/
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+Regs_ps*
+Parrot_pcc_get_regs_ps(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_pcc_get_regs_ps)
+ return &(Parrot_pcc_get_context_struct(interp, ctx)->bp_ps);
+}
+
+/*
+
+=item C<void Parrot_pcc_set_regs_ps(PARROT_INTERP, PMC *ctx, Regs_ps *bp_ps)>
+
+Copy Regs_ps into Context.
+
+=cut
+
+*/
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+void
+Parrot_pcc_set_regs_ps(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(Regs_ps *bp_ps))
+{
+ ASSERT_ARGS(Parrot_pcc_set_regs_ps)
+ Parrot_pcc_get_context_struct(interp, ctx)->bp_ps = *bp_ps;
+}
+/*
+
=back
=head1 SEE ALSO
More information about the parrot-commits
mailing list