[svn:parrot] r40802 - in branches/context_pmc3: include/parrot lib/Parrot/OpTrans src src/ops src/runcore
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Aug 25 23:30:06 UTC 2009
Author: bacek
Date: Tue Aug 25 23:30:05 2009
New Revision: 40802
URL: https://trac.parrot.org/parrot/changeset/40802
Log:
[core] Add pred_offset accessor to Context and use it
Modified:
branches/context_pmc3/include/parrot/context.h
branches/context_pmc3/lib/Parrot/OpTrans/CGP.pm
branches/context_pmc3/lib/Parrot/OpTrans/CPrederef.pm
branches/context_pmc3/lib/Parrot/OpTrans/CSwitch.pm
branches/context_pmc3/src/context.c
branches/context_pmc3/src/ops/pic.ops
branches/context_pmc3/src/packfile.c
branches/context_pmc3/src/pic.c
branches/context_pmc3/src/runcore/main.c
Modified: branches/context_pmc3/include/parrot/context.h
==============================================================================
--- branches/context_pmc3/include/parrot/context.h Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/include/parrot/context.h Tue Aug 25 23:30:05 2009 (r40802)
@@ -128,6 +128,11 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+size_t Parrot_cx_get_pred_offset(PARROT_INTERP, ARGIN(PMC *ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
UINTVAL Parrot_cx_get_recursion_depth(PARROT_INTERP, ARGIN(PMC *ctx))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -208,6 +213,13 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+void Parrot_cx_set_pred_offset(PARROT_INTERP,
+ ARGIN(PMC *ctx),
+ size_t pred_offset)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
void Parrot_cx_set_sub(PARROT_INTERP,
ARGIN(PMC *ctx),
ARGIN_NULLOK(PMC *sub))
@@ -249,6 +261,9 @@
#define ASSERT_ARGS_Parrot_cx_get_pmc_constant __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_get_pred_offset __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_get_recursion_depth __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
@@ -288,6 +303,9 @@
#define ASSERT_ARGS_Parrot_cx_set_pc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_set_pred_offset __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_set_sub __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
Modified: branches/context_pmc3/lib/Parrot/OpTrans/CGP.pm
==============================================================================
--- branches/context_pmc3/lib/Parrot/OpTrans/CGP.pm Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/lib/Parrot/OpTrans/CGP.pm Tue Aug 25 23:30:05 2009 (r40802)
@@ -68,7 +68,7 @@
return $pred_def . <<END;
/* defines - $0 -> $type */
# define opcode_to_prederef(i, op) \\
- (opcode_t *) (op - CONTEXT_FIELD(interp, i->ctx, pred_offset))
+ (opcode_t *) (op - Parrot_cx_get_pred_offset(interp, i->ctx))
END
}
Modified: branches/context_pmc3/lib/Parrot/OpTrans/CPrederef.pm
==============================================================================
--- branches/context_pmc3/lib/Parrot/OpTrans/CPrederef.pm Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/lib/Parrot/OpTrans/CPrederef.pm Tue Aug 25 23:30:05 2009 (r40802)
@@ -38,7 +38,7 @@
/* defines - $0 -> $type */
#define REL_PC ((size_t)(cur_opcode - (opcode_t*)interp->code->prederef.code))
#define CUR_OPCODE \\
- ((opcode_t*)cur_opcode + CURRENT_CONTEXT_FIELD(interp, pred_offset))
+ ((opcode_t*)cur_opcode + Parrot_cx_get_pred_offset(interp, CONTEXT(interp)))
#define OP_AS_OFFS(o) (_reg_base + ((opcode_t*)cur_opcode)[o])
END
Modified: branches/context_pmc3/lib/Parrot/OpTrans/CSwitch.pm
==============================================================================
--- branches/context_pmc3/lib/Parrot/OpTrans/CSwitch.pm Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/lib/Parrot/OpTrans/CSwitch.pm Tue Aug 25 23:30:05 2009 (r40802)
@@ -76,7 +76,7 @@
return $pred_def . <<END;
/* defines - $0 -> $type */
# define opcode_to_prederef(i, op) (op ? \\
- (opcode_t*) (op - CONTEXT_FIELD(interp, i->ctx, pred_offset)) : (opcode_t*)NULL)
+ (opcode_t*) (op - Parrot_cx_get_pred_offset(interp, i->ctx)) : (opcode_t*)NULL)
END
}
Modified: branches/context_pmc3/src/context.c
==============================================================================
--- branches/context_pmc3/src/context.c Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/src/context.c Tue Aug 25 23:30:05 2009 (r40802)
@@ -526,6 +526,54 @@
/*
+=item C<size_t Parrot_cx_get_pred_offset(PARROT_INTERP, PMC *ctx)>
+
+Get pred_offset
+
+=cut
+
+*/
+
+PARROT_EXPORT
+size_t
+Parrot_cx_get_pred_offset(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_cx_get_pred_offset)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ return c->pred_offset;
+}
+
+
+/*
+
+=item C<void Parrot_cx_set_pred_offset(PARROT_INTERP, PMC *ctx, size_t
+pred_offset)>
+
+Set pred_offset
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_cx_set_pred_offset(PARROT_INTERP, ARGIN(PMC *ctx), size_t pred_offset)
+{
+ ASSERT_ARGS(Parrot_cx_set_pred_offset)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ c->pred_offset = pred_offset;
+}
+
+
+/*
+
+=back
+
+*/
+
+
+/*
+
=back
*/
Modified: branches/context_pmc3/src/ops/pic.ops
==============================================================================
--- branches/context_pmc3/src/ops/pic.ops Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/src/ops/pic.ops Tue Aug 25 23:30:05 2009 (r40802)
@@ -143,7 +143,7 @@
mic = (Parrot_MIC *) cur_opcode[1];
caller_ctx = Parrot_cx_get_caller_ctx(interp, ctx);
if (src_pc) {
- src_pred = (void**) src_pc - CONTEXT_FIELD(interp, caller_ctx, pred_offset);
+ src_pred = (void**) src_pc - Parrot_cx_get_pred_offset(interp, caller_ctx);
sig = (PMC*)(src_pred[1]);
}
else {
@@ -200,7 +200,7 @@
interp->current_args = NULL;
dest_pc = CONTEXT_FIELD(interp, caller_ctx, current_results);
if (dest_pc) {
- dest_pred = (void**) dest_pc - CONTEXT_FIELD(interp, caller_ctx, pred_offset);
+ dest_pred = (void**) dest_pc - Parrot_cx_get_pred_offset(interp, caller_ctx);
sig = (PMC*)(dest_pred[1]);
}
else {
@@ -250,7 +250,7 @@
/* get_results */
pc = CONTEXT_FIELD(interp, ctx, current_results);
if (pc) {
- pred_pc = (void**) pc - CONTEXT_FIELD(interp, ctx, pred_offset);
+ pred_pc = (void**) pc - Parrot_cx_get_pred_offset(interp, ctx);
sig = (PMC*)(pred_pc[1]);
ASSERT_SIG_PMC(sig);
PARROT_ASSERT(VTABLE_elements(interp, sig) <= 1);
Modified: branches/context_pmc3/src/packfile.c
==============================================================================
--- branches/context_pmc3/src/packfile.c Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/src/packfile.c Tue Aug 25 23:30:05 2009 (r40802)
@@ -3088,8 +3088,8 @@
: new_cs->const_table->constants;
/* new_cs->const_table->constants; */
- CURRENT_CONTEXT_FIELD(interp, pred_offset) =
- new_cs->base.data - (opcode_t*) new_cs->prederef.code;
+ Parrot_cx_set_pred_offset(interp, CONTEXT(interp),
+ new_cs->base.data - (opcode_t*) new_cs->prederef.code);
if (really)
prepare_for_run(interp);
Modified: branches/context_pmc3/src/pic.c
==============================================================================
--- branches/context_pmc3/src/pic.c Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/src/pic.c Tue Aug 25 23:30:05 2009 (r40802)
@@ -805,9 +805,9 @@
ASSERT_SIG_PMC(sig_args);
n = VTABLE_elements(interp, sig_args);
- interp->current_args = (opcode_t*)pc + CONTEXT_FIELD(interp, ctx, pred_offset);
+ interp->current_args = (opcode_t*)pc + Parrot_cx_get_pred_offset(interp, ctx);
pc += 2 + n;
- op = (opcode_t*)pc + CONTEXT_FIELD(interp, ctx, pred_offset);
+ op = (opcode_t*)pc + Parrot_cx_get_pred_offset(interp, ctx);
if (*op != PARROT_OP_set_p_pc)
return 0;
@@ -821,7 +821,7 @@
return 0;
pc += 3; /* results */
- op = (opcode_t *)pc + CONTEXT_FIELD(interp, ctx, pred_offset);
+ op = (opcode_t *)pc + Parrot_cx_get_pred_offset(interp, ctx);
if (*op != PARROT_OP_get_results_pc)
return 0;
@@ -830,7 +830,7 @@
sig_results = (PMC *)(pc[1]);
ASSERT_SIG_PMC(sig_results);
- CONTEXT_FIELD(interp, ctx, current_results) = (opcode_t *)pc + CONTEXT_FIELD(interp, ctx, pred_offset);
+ CONTEXT_FIELD(interp, ctx, current_results) = (opcode_t *)pc + Parrot_cx_get_pred_offset(interp, ctx);
if (!parrot_pic_is_safe_to_jit(interp, sub, sig_args, sig_results, &flags))
return 0;
Modified: branches/context_pmc3/src/runcore/main.c
==============================================================================
--- branches/context_pmc3/src/runcore/main.c Tue Aug 25 23:29:24 2009 (r40801)
+++ branches/context_pmc3/src/runcore/main.c Tue Aug 25 23:30:05 2009 (r40802)
@@ -541,7 +541,7 @@
N * sizeof (void *));
#endif
/* calc and remember pred_offset */
- CURRENT_CONTEXT_FIELD(interp, pred_offset) = pc - (opcode_t *)temp;
+ Parrot_cx_set_pred_offset(interp, CONTEXT(interp), pc - (opcode_t *)temp);
/* fill with the prederef__ opcode function */
if (which == PARROT_SWITCH_CORE || which == PARROT_SWITCH_JIT_CORE)
More information about the parrot-commits
mailing list