[svn:parrot] r40803 - in branches/context_pmc3: include/parrot src src/call src/jit/i386 src/ops src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Aug 25 23:30:41 UTC 2009
Author: bacek
Date: Tue Aug 25 23:30:41 2009
New Revision: 40803
URL: https://trac.parrot.org/parrot/changeset/40803
Log:
[core] Add current_result accessor to Context and use it
Modified:
branches/context_pmc3/include/parrot/context.h
branches/context_pmc3/src/call/pcc.c
branches/context_pmc3/src/context.c
branches/context_pmc3/src/jit/i386/jit_defs.c
branches/context_pmc3/src/ops/core.ops
branches/context_pmc3/src/ops/pic.ops
branches/context_pmc3/src/pic.c
branches/context_pmc3/src/pmc/continuation.pmc
branches/context_pmc3/src/sub.c
Modified: branches/context_pmc3/include/parrot/context.h
==============================================================================
--- branches/context_pmc3/include/parrot/context.h Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/include/parrot/context.h Tue Aug 25 23:30:41 2009 (r40803)
@@ -138,6 +138,11 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+opcode_t* Parrot_cx_get_results(PARROT_INTERP, ARGIN(PMC *ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
PARROT_CAN_RETURN_NULL
STRING* Parrot_cx_get_string_constant(PARROT_INTERP,
ARGIN(PMC *ctx),
@@ -220,6 +225,13 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+void Parrot_cx_set_results(PARROT_INTERP,
+ ARGIN(PMC *ctx),
+ ARGIN_NULLOK(opcode_t *pc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
void Parrot_cx_set_sub(PARROT_INTERP,
ARGIN(PMC *ctx),
ARGIN_NULLOK(PMC *sub))
@@ -267,6 +279,9 @@
#define ASSERT_ARGS_Parrot_cx_get_recursion_depth __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_get_results __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_get_string_constant __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
@@ -306,6 +321,9 @@
#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_results __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/src/call/pcc.c
==============================================================================
--- branches/context_pmc3/src/call/pcc.c Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/call/pcc.c Tue Aug 25 23:30:41 2009 (r40803)
@@ -531,10 +531,10 @@
* in the constants table. */
if (CONTEXT_FIELD(interp, ctx, results_signature))
Parrot_init_arg_indexes_and_sig_pmc(interp, ctx,
- CONTEXT_FIELD(interp, ctx, current_results),
+ Parrot_cx_get_results(interp, ctx),
CONTEXT_FIELD(interp, ctx, results_signature), &st->dest);
else
- Parrot_init_arg_op(interp, ctx, CONTEXT_FIELD(interp, ctx, current_results), &st->dest);
+ Parrot_init_arg_op(interp, ctx, Parrot_cx_get_results(interp, ctx), &st->dest);
}
@@ -2632,7 +2632,7 @@
interp->current_args = indexes[0];
interp->args_signature = sigs[0];
- CONTEXT_FIELD(interp, ctx, current_results) = indexes[1];
+ Parrot_cx_set_results(interp, ctx, indexes[1]);
CONTEXT_FIELD(interp, ctx, results_signature) = sigs[1];
return ret_x;
}
@@ -2867,7 +2867,7 @@
interp->current_args = arg_indexes;
interp->args_signature = args_sig;
- CONTEXT_FIELD(interp, ctx, current_results) = result_indexes;
+ Parrot_cx_set_results(interp, ctx, result_indexes);
CONTEXT_FIELD(interp, ctx, results_signature) = results_sig;
/* arg_accessors assigned in loop above */
Modified: branches/context_pmc3/src/context.c
==============================================================================
--- branches/context_pmc3/src/context.c Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/context.c Tue Aug 25 23:30:41 2009 (r40803)
@@ -523,6 +523,45 @@
c->current_pc = pc;
}
+/*
+
+=item C<opcode_t* Parrot_cx_get_results(PARROT_INTERP, PMC *ctx)>
+
+Set ptr into code with get_results opcode.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+opcode_t*
+Parrot_cx_get_results(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_cx_get_results)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ return c->current_results;
+}
+
+
+/*
+
+=item C<void Parrot_cx_set_results(PARROT_INTERP, PMC *ctx, opcode_t *pc)>
+
+Set ptr into code with get_results opcode.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_cx_set_results(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(opcode_t *pc))
+{
+ ASSERT_ARGS(Parrot_cx_set_results)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ c->current_results = pc;
+}
+
/*
Modified: branches/context_pmc3/src/jit/i386/jit_defs.c
==============================================================================
--- branches/context_pmc3/src/jit/i386/jit_defs.c Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/jit/i386/jit_defs.c Tue Aug 25 23:30:41 2009 (r40803)
@@ -1739,7 +1739,6 @@
*/
if (jit_info->flags & JIT_CODE_RECURSIVE) {
char * L1;
- PackFile_Constant ** constants;
PMC *sig_result;
opcode_t *result;
@@ -1748,9 +1747,8 @@
L1 = NATIVECODE;
emitm_calll(NATIVECODE, 0);
/* check type of return value */
- constants = CURRENT_CONTEXT_FIELD(interp, constants);
- result = CURRENT_CONTEXT_FIELD(interp, current_results);
- sig_result = constants[result[1]]->u.key;
+ result = Parrot_cx_get_results(interp, CONTEXT(interp));
+ sig_result = Parrot_cx_get_pmc_constant(interp, CONTEXT(interp), result[1]);
if (!VTABLE_elements(interp, sig_result))
goto no_result;
/* fetch args to %edx */
Modified: branches/context_pmc3/src/ops/core.ops
==============================================================================
--- branches/context_pmc3/src/ops/core.ops Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/ops/core.ops Tue Aug 25 23:30:41 2009 (r40803)
@@ -527,7 +527,7 @@
PMC * const signature = $1;
INTVAL argc;
- CURRENT_CONTEXT_FIELD(interp, current_results) = _this;
+ Parrot_cx_set_results(interp, CONTEXT(interp), _this);
argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
}
@@ -586,8 +586,8 @@
exit_fatal(1, "No caller_ctx for continuation %p.", ccont);
}
- src_indexes = interp->current_returns;
- dest_indexes = CONTEXT_FIELD(interp, caller_ctx, current_results);
+ src_indexes = interp->current_returns;
+ dest_indexes = Parrot_cx_get_results(interp, caller_ctx);
interp->current_returns = NULL;
/* does this need to be here */
interp->current_args = NULL;
@@ -597,7 +597,7 @@
else if (CONTEXT_FIELD(interp, caller_ctx, results_signature)) {
/* We have a dynamic result signature, from pcc_invoke */
parrot_pass_args(interp, ctx, caller_ctx, interp->current_returns,
- CONTEXT_FIELD(interp, caller_ctx, current_results), PARROT_PASS_RESULTS);
+ Parrot_cx_get_results(interp, caller_ctx), PARROT_PASS_RESULTS);
}
argc = VTABLE_elements(interp, signature);
goto OFFSET(argc + 2);
@@ -618,7 +618,7 @@
PMC *sig = NULL;
if (cc && PMC_cont(cc)->to_ctx) {
/* caller context has results */
- opcode_t * const results = CONTEXT_FIELD(interp, PMC_cont(cc)->to_ctx, current_results);
+ opcode_t * const results = Parrot_cx_get_results(interp, PMC_cont(cc)->to_ctx);
if (results) {
/* get results PMC index and get PMC. */
sig = PF_CONST(PMC_cont(cc)->seg, results[1])->u.key;
Modified: branches/context_pmc3/src/ops/pic.ops
==============================================================================
--- branches/context_pmc3/src/ops/pic.ops Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/ops/pic.ops Tue Aug 25 23:30:41 2009 (r40803)
@@ -198,7 +198,7 @@
}
caller_ctx = cc->to_ctx;
interp->current_args = NULL;
- dest_pc = CONTEXT_FIELD(interp, caller_ctx, current_results);
+ dest_pc = Parrot_cx_get_results(interp, caller_ctx);
if (dest_pc) {
dest_pred = (void**) dest_pc - Parrot_cx_get_pred_offset(interp, caller_ctx);
sig = (PMC*)(dest_pred[1]);
@@ -248,7 +248,7 @@
ctx = CONTEXT(interp);
mic = (Parrot_MIC *) cur_opcode[1];
/* get_results */
- pc = CONTEXT_FIELD(interp, ctx, current_results);
+ pc = Parrot_cx_get_results(interp, ctx);
if (pc) {
pred_pc = (void**) pc - Parrot_cx_get_pred_offset(interp, ctx);
sig = (PMC*)(pred_pc[1]);
Modified: branches/context_pmc3/src/pic.c
==============================================================================
--- branches/context_pmc3/src/pic.c Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/pic.c Tue Aug 25 23:30:41 2009 (r40803)
@@ -709,7 +709,7 @@
if (!PMC_cont(ccont)->address)
return 0;
caller_ctx = PMC_cont(ccont)->to_ctx;
- args = CONTEXT_FIELD(interp, caller_ctx, current_results);
+ args = Parrot_cx_get_results(interp, caller_ctx);
}
else {
caller_ctx = Parrot_cx_get_caller_ctx(interp, ctx);
@@ -830,7 +830,7 @@
sig_results = (PMC *)(pc[1]);
ASSERT_SIG_PMC(sig_results);
- CONTEXT_FIELD(interp, ctx, current_results) = (opcode_t *)pc + Parrot_cx_get_pred_offset(interp, ctx);
+ Parrot_cx_set_results(interp, ctx, (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/pmc/continuation.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/continuation.pmc Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/pmc/continuation.pmc Tue Aug 25 23:30:41 2009 (r40803)
@@ -231,9 +231,9 @@
/* pass args to where caller wants result */
if (cc->current_results)
- CONTEXT_FIELD(interp, to_ctx, current_results) = cc->current_results;
+ Parrot_cx_set_results(interp, to_ctx, cc->current_results);
- if (CONTEXT_FIELD(interp, to_ctx, current_results) && INTERP->current_args) {
+ if (Parrot_cx_get_results(interp, to_ctx) && INTERP->current_args) {
/*
* the register pointer is already switched back
* to the caller, therefore the registers of the
@@ -242,7 +242,7 @@
* therefore we have to block GC
*/
opcode_t *src_indexes = interp->current_args;
- opcode_t *dest_indexes = CONTEXT_FIELD(interp, to_ctx, current_results);
+ opcode_t *dest_indexes = Parrot_cx_get_results(interp, to_ctx);
interp->current_args = NULL;
Parrot_block_GC_mark(INTERP);
Modified: branches/context_pmc3/src/sub.c
==============================================================================
--- branches/context_pmc3/src/sub.c Tue Aug 25 23:30:05 2009 (r40802)
+++ branches/context_pmc3/src/sub.c Tue Aug 25 23:30:41 2009 (r40803)
@@ -80,7 +80,7 @@
cc->address = NULL;
}
- cc->current_results = CONTEXT_FIELD(interp, to_ctx, current_results);
+ cc->current_results = Parrot_cx_get_results(interp, to_ctx);
return cc;
}
More information about the parrot-commits
mailing list