[svn:parrot] r40901 - in branches/kill_parrot_cont: include/parrot lib/Parrot/Pmc2c src src/call src/ops src/pmc src/runcore
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Tue Sep 1 01:10:52 UTC 2009
Author: whiteknight
Date: Tue Sep 1 01:10:50 2009
New Revision: 40901
URL: https://trac.parrot.org/parrot/changeset/40901
Log:
[kill_parrot_cont] Apply patch from jrtayloriv++ in TT #926. Seeing failure in t/op/sprintf.t that is difficult to debug.
Modified:
branches/kill_parrot_cont/include/parrot/sub.h
branches/kill_parrot_cont/lib/Parrot/Pmc2c/PCCMETHOD.pm
branches/kill_parrot_cont/src/call/ops.c
branches/kill_parrot_cont/src/call/pcc.c
branches/kill_parrot_cont/src/debug.c
branches/kill_parrot_cont/src/exceptions.c
branches/kill_parrot_cont/src/ops/core.ops
branches/kill_parrot_cont/src/ops/pic.ops
branches/kill_parrot_cont/src/pic.c
branches/kill_parrot_cont/src/pmc/continuation.pmc
branches/kill_parrot_cont/src/pmc/coroutine.pmc
branches/kill_parrot_cont/src/pmc/exception.pmc
branches/kill_parrot_cont/src/pmc/exceptionhandler.pmc
branches/kill_parrot_cont/src/pmc/parrotinterpreter.pmc
branches/kill_parrot_cont/src/pmc/retcontinuation.pmc
branches/kill_parrot_cont/src/pmc/sub.pmc
branches/kill_parrot_cont/src/runcore/cores.c
branches/kill_parrot_cont/src/sub.c
Modified: branches/kill_parrot_cont/include/parrot/sub.h
==============================================================================
--- branches/kill_parrot_cont/include/parrot/sub.h Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/include/parrot/sub.h Tue Sep 1 01:10:50 2009 (r40901)
@@ -152,21 +152,9 @@
typedef struct Parrot_Sub_attributes Parrot_sub;
typedef struct Parrot_Coroutine_attributes Parrot_coro;
+typedef struct Parrot_Continuation_attributes Parrot_cont;
-typedef struct Parrot_cont {
- /* continuation destination */
- PackFile_ByteCode *seg; /* bytecode segment */
- opcode_t *address; /* start of bytecode, addr to continue */
- struct Parrot_Context *to_ctx; /* pointer to dest context */
- /* a Continuation keeps the from_ctx alive */
- struct Parrot_Context *from_ctx; /* sub, this cont is returning from */
- opcode_t *current_results; /* ptr into code with get_results opcode
- full continuation only */
- int runloop_id; /* id of the creating runloop. */
- int invoked; /* flag when a handler has been invoked. */
-} Parrot_cont;
-
-#define PMC_cont(pmc) (PARROT_CONTINUATION(pmc)->cont)
+#define PMC_cont(pmc) PARROT_CONTINUATION(pmc)
typedef struct Parrot_Context_info {
STRING *subname;
@@ -237,13 +225,13 @@
void mark_context_start(void);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Parrot_cont * new_continuation(PARROT_INTERP,
- ARGIN_NULLOK(const Parrot_cont *to))
+PMC * new_continuation(PARROT_INTERP,
+ ARGIN_NULLOK(PMC *to))
__attribute__nonnull__(1);
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Parrot_cont * new_ret_continuation(PARROT_INTERP)
+PMC * new_ret_continuation(PARROT_INTERP)
__attribute__nonnull__(1);
void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc))
@@ -252,17 +240,15 @@
FUNC_MODIFIES(*sub_pmc);
void Parrot_continuation_check(PARROT_INTERP,
- ARGIN(const PMC *pmc),
- ARGIN(const Parrot_cont *cc))
+ ARGIN(const PMC *pmc))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(2);
+
void Parrot_continuation_rewind_environment(PARROT_INTERP,
- SHIM(PMC *pmc),
- ARGIN(Parrot_cont *cc))
+ ARGIN(PMC *pmc))
__attribute__nonnull__(1)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
@@ -307,12 +293,11 @@
|| PARROT_ASSERT_ARG(sub_pmc)
#define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(pmc) \
- || PARROT_ASSERT_ARG(cc)
+ || PARROT_ASSERT_ARG(pmc)
#define ASSERT_ARGS_Parrot_continuation_rewind_environment \
__attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(cc)
+ || PARROT_ASSERT_ARG(pmc)
#define ASSERT_ARGS_Parrot_find_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(lex_name) \
Modified: branches/kill_parrot_cont/lib/Parrot/Pmc2c/PCCMETHOD.pm
==============================================================================
--- branches/kill_parrot_cont/lib/Parrot/Pmc2c/PCCMETHOD.pm Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/lib/Parrot/Pmc2c/PCCMETHOD.pm Tue Sep 1 01:10:50 2009 (r40901)
@@ -412,7 +412,7 @@
}
_ctx->current_cont = _ret_cont;
- PMC_cont(_ret_cont)->from_ctx = _ctx;
+ PARROT_CONTINUATION(_ret_cont)->from_ctx = _ctx;
_current_args = interp->current_args;
interp->current_args = NULL;
Modified: branches/kill_parrot_cont/src/call/ops.c
==============================================================================
--- branches/kill_parrot_cont/src/call/ops.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/call/ops.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -251,7 +251,7 @@
if (*sig_p && (dest[0] == PARROT_OP_get_params_pc
|| (sub->vtable->base_type == enum_class_ExceptionHandler
- && PMC_cont(sub)->current_results))) {
+ && PARROT_CONTINUATION(sub)->current_results))) {
dest = parrot_pass_args_fromc(interp, sig_p, dest, old_ctx, ap);
}
Modified: branches/kill_parrot_cont/src/call/pcc.c
==============================================================================
--- branches/kill_parrot_cont/src/call/pcc.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/call/pcc.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -517,7 +517,7 @@
/* if this NCI call was a taicall, return results to caller's get_results
* this also means that we pass the caller's register base pointer */
if (SUB_FLAG_TAILCALL_ISSET(current_cont))
- ctx = PMC_cont(current_cont)->to_ctx;
+ ctx = PARROT_CONTINUATION(current_cont)->to_ctx;
/* TODO simplify all */
Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL, &st->src);
@@ -2864,7 +2864,7 @@
interp->current_object = pmc;
interp->current_cont = NEED_CONTINUATION;
ctx->current_cont = ret_cont;
- PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
+ PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
pccinvoke_meth = VTABLE_find_method(interp, pmc, method_name);
if (PMC_IS_NULL(pccinvoke_meth))
@@ -3007,7 +3007,7 @@
}
interp->current_cont = NEED_CONTINUATION;
ctx->current_cont = ret_cont;
- PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
+ PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);
/* Invoke the function */
dest = VTABLE_invoke(interp, sub_obj, NULL);
Modified: branches/kill_parrot_cont/src/debug.c
==============================================================================
--- branches/kill_parrot_cont/src/debug.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/debug.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -3539,13 +3539,13 @@
/* backtrace: follow the continuation chain */
while (1) {
- Parrot_cont *sub_cont;
+ Parrot_Continuation_attributes *sub_cont;
sub = ctx->current_cont;
if (!sub)
break;
- sub_cont = PMC_cont(sub);
+ sub_cont = PARROT_CONTINUATION(sub);
if (!sub_cont)
break;
@@ -3556,11 +3556,11 @@
break;
/* recursion detection */
- if (!PMC_IS_NULL(old) && PMC_cont(old) &&
- PMC_cont(old)->to_ctx->current_pc ==
- PMC_cont(sub)->to_ctx->current_pc &&
- PMC_cont(old)->to_ctx->current_sub ==
- PMC_cont(sub)->to_ctx->current_sub) {
+ if (!PMC_IS_NULL(old) && PARROT_CONTINUATION(old) &&
+ PARROT_CONTINUATION(old)->to_ctx->current_pc ==
+ PARROT_CONTINUATION(sub)->to_ctx->current_pc &&
+ PARROT_CONTINUATION(old)->to_ctx->current_sub ==
+ PARROT_CONTINUATION(sub)->to_ctx->current_sub) {
++rec_level;
}
else if (rec_level != 0) {
@@ -3590,7 +3590,7 @@
}
/* get the next Continuation */
- ctx = PMC_cont(sub)->to_ctx;
+ ctx = PARROT_CONTINUATION(sub)->to_ctx;
old = sub;
if (!ctx)
Modified: branches/kill_parrot_cont/src/exceptions.c
==============================================================================
--- branches/kill_parrot_cont/src/exceptions.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/exceptions.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -251,7 +251,7 @@
passed properly. */
}
/* Set up the continuation context of the handler in the interpreter. */
- else if (PMC_cont(handler)->current_results)
+ else if (PARROT_CONTINUATION(handler)->current_results)
address = pass_exception_args(interp, "P", address,
CONTEXT(interp), exception);
@@ -400,7 +400,7 @@
/* Run the handler. */
address = VTABLE_invoke(interp, handler, NULL);
- if (PMC_cont(handler)->current_results)
+ if (PARROT_CONTINUATION(handler)->current_results)
address = pass_exception_args(interp, "P", address,
CONTEXT(interp), exception);
PARROT_ASSERT(return_point->handler_start == NULL);
Modified: branches/kill_parrot_cont/src/ops/core.ops
==============================================================================
--- branches/kill_parrot_cont/src/ops/core.ops Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/ops/core.ops Tue Sep 1 01:10:50 2009 (r40901)
@@ -578,9 +578,9 @@
ctx = CONTEXT(interp);
ccont = ctx->current_cont;
- if (PMC_cont(ccont)->address) {
+ if (PARROT_CONTINUATION(ccont)->address) {
/* Call is from runops_fromc */
- Parrot_Context * const caller_ctx = PMC_cont(ccont)->to_ctx;
+ Parrot_Context * const caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx;
if (! caller_ctx) {
/* there is no point calling Parrot_ex_throw_..., because
PDB_backtrace can't deal with a missing to_ctx either. */
@@ -617,12 +617,12 @@
/* Get context of callee from return continuation. */
PMC * const cc = CONTEXT(interp)->current_cont;
PMC *sig = NULL;
- if (cc && PMC_cont(cc)->to_ctx) {
+ if (cc && PARROT_CONTINUATION(cc)->to_ctx) {
/* caller context has results */
- opcode_t * const results = PMC_cont(cc)->to_ctx->current_results;
+ opcode_t * const results = PARROT_CONTINUATION(cc)->to_ctx->current_results;
if (results) {
/* get results PMC index and get PMC. */
- sig = PF_CONST(PMC_cont(cc)->seg, results[1])->u.key;
+ sig = PF_CONST(PARROT_CONTINUATION(cc)->seg, results[1])->u.key;
}
}
Modified: branches/kill_parrot_cont/src/ops/pic.ops
==============================================================================
--- branches/kill_parrot_cont/src/ops/pic.ops Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/ops/pic.ops Tue Sep 1 01:10:50 2009 (r40901)
@@ -184,13 +184,13 @@
opcode_t *dest_pc;
void **dest_pred;
Parrot_Context *caller_ctx, *ctx;
- Parrot_cont *cc;
+ Parrot_Continuation_attributes *cc;
int n;
ctx = CONTEXT(interp);
mic = (Parrot_MIC *) cur_opcode[1];
ccont = ctx->current_cont;
- cc = PMC_cont(ccont);
+ cc = PARROT_CONTINUATION(ccont);
if (!cc->address) {
interp->current_returns = CUR_OPCODE;
n = VTABLE_get_integer(interp, mic->m.sig);
Modified: branches/kill_parrot_cont/src/pic.c
==============================================================================
--- branches/kill_parrot_cont/src/pic.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pic.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -705,9 +705,9 @@
if (op == PARROT_OP_set_returns_pc) {
PMC * const ccont = ctx->current_cont;
- if (!PMC_cont(ccont)->address)
+ if (!PARROT_CONTINUATION(ccont)->address)
return 0;
- caller_ctx = PMC_cont(ccont)->to_ctx;
+ caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx;
args = caller_ctx->current_results;
}
else {
Modified: branches/kill_parrot_cont/src/pmc/continuation.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/continuation.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/continuation.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -46,8 +46,16 @@
*/
pmclass Continuation auto_attrs {
- ATTR struct Parrot_cont *cont; /* the continuation struct */
-
+ /* continuation destination */
+ ATTR PackFile_ByteCode *seg; /* bytecode segment */
+ ATTR opcode_t *address; /* start of bytecode, addr to continue */
+ ATTR Parrot_Context *to_ctx; /* pointer to dest context */
+ /* a Continuation keeps the from_ctx alive */
+ ATTR Parrot_Context *from_ctx; /* sub, this cont is returning from */
+ ATTR opcode_t *current_results; /* ptr into code with get_results opcode
+ full continuation only */
+ ATTR int runloop_id; /* id of the creating runloop. */
+ ATTR int invoked; /* flag when a handler has been invoked. */
/*
=item C<void init()>
@@ -59,11 +67,41 @@
*/
VTABLE void init() {
- Parrot_Continuation_attributes *attrs =
- (Parrot_Continuation_attributes *) PMC_data(SELF);
+ Parrot_Continuation_attributes *attrs = PARROT_CONTINUATION(SELF);
+
+ attrs->to_ctx = CONTEXT(interp);
+ attrs->from_ctx = Parrot_context_ref(interp, CONTEXT(interp));
+ attrs->runloop_id = 0;
+ attrs->seg = interp->code;
+ attrs->address = NULL;
+ attrs->current_results = attrs->to_ctx->current_results;
+
+ PObj_active_destroy_SET(SELF);
+ PObj_custom_mark_destroy_SETALL(SELF);
+
+ /* PANIC("don't do that"); */
+ /*
+ * Whenever we create a continuation, all return continuations
+ * up the call chain may be reused due to invoking the
+ * continuation. To avoid that all return continuations are
+ * converted to true continuations.
+ */
+ invalidate_retc_context(INTERP, SELF);
+ }
+
+ /*if they pass in a PMC to initialize with*/
+ VTABLE void init_pmc(PMC *values) {
+ Parrot_Continuation_attributes *attrs = PARROT_CONTINUATION(SELF);
+
+ attrs->to_ctx = PARROT_CONTINUATION(values)->to_ctx;
+ attrs->from_ctx = Parrot_context_ref(interp, CONTEXT(interp));
+ attrs->runloop_id = 0;
+ attrs->seg = PARROT_CONTINUATION(values)->seg;
+ attrs->address = PARROT_CONTINUATION(values)->address;
+ attrs->current_results = attrs->to_ctx->current_results;
- PMC_cont(SELF) = new_continuation(INTERP, NULL);
PObj_custom_mark_destroy_SETALL(SELF);
+
/* PANIC("don't do that"); */
/*
* Whenever we create a continuation, all return continuations
@@ -74,6 +112,8 @@
invalidate_retc_context(INTERP, SELF);
}
+
+
/*
=item C<void mark()>
@@ -85,7 +125,10 @@
*/
VTABLE void mark() {
- Parrot_cont *cc = PMC_cont(SELF);
+ Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF);
+
+ if(cc->seg)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)cc->seg);
if (cc->to_ctx)
mark_context(INTERP, cc->to_ctx);
@@ -104,7 +147,7 @@
*/
VTABLE void destroy() {
- Parrot_cont * const cc = PMC_cont(SELF);
+ Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
if (cc) {
#if CTX_LEAK_DEBUG
if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) {
@@ -117,7 +160,8 @@
if (cc->from_ctx)
Parrot_free_context(interp, cc->from_ctx, 1);
- mem_sys_free(cc);
+ if (cc->to_ctx)
+ Parrot_free_context(interp, cc->to_ctx, 1);
}
}
/*
@@ -131,20 +175,11 @@
*/
VTABLE PMC *clone() {
- Parrot_cont * const cc_self = PMC_cont(SELF);
- Parrot_cont * const cc = new_continuation(INTERP, cc_self);
- PMC * const ret = pmc_new(INTERP, enum_class_Continuation);
- Parrot_cont * const ret_cont = PMC_cont(ret);
- PObj_custom_mark_destroy_SETALL(ret);
+ PMC * ret = pmc_new_init(interp, enum_class_Continuation, SELF);
/* free ret's PMC_cont */
- Parrot_free_context(interp, ret_cont->from_ctx, 1);
- mem_sys_free(ret_cont);
-
- cc->runloop_id = cc_self->runloop_id;
- PMC_cont(ret) = cc;
-
+ Parrot_free_context(interp, PARROT_CONTINUATION(ret)->from_ctx, 1);
return ret;
}
@@ -158,8 +193,8 @@
*/
VTABLE void set_pmc(PMC *src) {
- Parrot_cont * const cc_self = PMC_cont(SELF);
- Parrot_cont * const cc_src = PMC_cont(src);
+ Parrot_Continuation_attributes * const cc_self = PARROT_CONTINUATION(SELF);
+ Parrot_Continuation_attributes * const cc_src = PARROT_CONTINUATION(src);
STRUCT_COPY(cc_self, cc_src);
}
@@ -176,7 +211,7 @@
VTABLE void set_pointer(void *value) {
opcode_t * const pos = (opcode_t *)value;
- Parrot_cont * const cc = PMC_cont(SELF);
+ Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
cc->address = (opcode_t *)value;
cc->runloop_id = INTERP->current_runloop_id;
@@ -198,7 +233,7 @@
*/
VTABLE void *get_pointer() {
- return PMC_cont(SELF)->address;
+ return PARROT_CONTINUATION(SELF)->address;
}
/*
@@ -213,11 +248,11 @@
*/
VTABLE INTVAL defined() {
- return PMC_cont(SELF)->address != NULL;
+ return PARROT_CONTINUATION(SELF)->address != NULL;
}
VTABLE INTVAL get_bool() {
- return PMC_cont(SELF)->address != NULL;
+ return PARROT_CONTINUATION(SELF)->address != NULL;
}
/*
@@ -232,18 +267,17 @@
*/
VTABLE opcode_t *invoke(void *next) {
- Parrot_cont *cc = PMC_cont(SELF);
- Parrot_Context *from_ctx = CONTEXT(interp);
- Parrot_Context *to_ctx = cc->to_ctx;
- opcode_t *pc = cc->address;
+ Parrot_Context *from_ctx = CONTEXT(interp);
+ Parrot_Context *to_ctx = PARROT_CONTINUATION(SELF)->to_ctx;
+ opcode_t *pc = PARROT_CONTINUATION(SELF)->address;
UNUSED(next)
- Parrot_continuation_check(interp, SELF, cc);
- Parrot_continuation_rewind_environment(interp, SELF, cc);
+ Parrot_continuation_check(interp, SELF);
+ Parrot_continuation_rewind_environment(interp, SELF);
/* pass args to where caller wants result */
- if (cc->current_results)
- to_ctx->current_results = cc->current_results;
+ if (PARROT_CONTINUATION(SELF)->current_results)
+ to_ctx->current_results = PARROT_CONTINUATION(SELF)->current_results;
if (to_ctx->current_results && INTERP->current_args) {
/*
@@ -266,8 +300,8 @@
/* switch segment */
INTERP->current_args = NULL;
- if (INTERP->code != cc->seg)
- Parrot_switch_to_cs(INTERP, cc->seg, 1);
+ if (INTERP->code != PARROT_CONTINUATION(SELF)->seg)
+ Parrot_switch_to_cs(INTERP, PARROT_CONTINUATION(SELF)->seg, 1);
return pc;
}
@@ -283,7 +317,7 @@
*/
VTABLE STRING *get_string() {
- return Parrot_Context_infostr(INTERP, PMC_cont(SELF)->to_ctx);
+ return Parrot_Context_infostr(INTERP, PARROT_CONTINUATION(SELF)->to_ctx);
}
/*
@@ -297,7 +331,7 @@
*/
METHOD caller() {
- Parrot_cont *cc = PMC_cont(SELF);
+ Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF);
PMC *caller = cc->to_ctx->current_sub;
Parrot_Sub_attributes *sub;
@@ -323,7 +357,7 @@
*/
METHOD continuation() {
- Parrot_cont *cc = PMC_cont(SELF);
+ Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF);
PMC *cont = cc->to_ctx->current_cont;
if (cont)
Modified: branches/kill_parrot_cont/src/pmc/coroutine.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/coroutine.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/coroutine.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -149,7 +149,7 @@
co->ctx = Parrot_context_ref(interp, ctx);
ctx->caller_ctx = caller_ctx;
- PMC_cont(ccont)->from_ctx = ctx;
+ PARROT_CONTINUATION(ccont)->from_ctx = ctx;
ctx->current_sub = SELF;
ctx->current_HLL = co->HLL_id;
ctx->current_namespace = co->namespace_stash;
@@ -186,7 +186,7 @@
/* and the recent call context */
ccont = ctx->current_cont;
- ctx->caller_ctx = PMC_cont(ccont)->to_ctx
+ ctx->caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx
= CONTEXT(interp);
/* set context to coro context */
@@ -203,7 +203,7 @@
wanted_seg = co->caller_seg;
ccont = co->ctx->current_cont;
- ctx = PMC_cont(ccont)->to_ctx;
+ ctx = PARROT_CONTINUATION(ccont)->to_ctx;
if (! ctx) {
/* This still isn't quite right, but it beats segfaulting. See
Modified: branches/kill_parrot_cont/src/pmc/exception.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/exception.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/exception.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -661,7 +661,7 @@
* XXX TT#596 - when we have Context PMCs, just take and set that. */
if (!PMC_IS_NULL(value) && VTABLE_isa(interp, value, CONST_STRING(interp, "Continuation"))) {
- Parrot_Context *ctx = PMC_cont(value)->from_ctx;
+ Parrot_Context *ctx = PARROT_CONTINUATION(value)->from_ctx;
if (ctx) {
Parrot_context_ref(interp, ctx);
SET_ATTR_thrower(interp, SELF, ctx);
@@ -728,7 +728,7 @@
/* Get resume continuation, to find location we failed at. */
GET_ATTR_resume(interp, SELF, resume);
if (!PMC_IS_NULL(resume)) {
- Parrot_cont *cont = PMC_cont(resume);
+ Parrot_Continuation_attributes *cont = PARROT_CONTINUATION(resume);
if (cont->seg != NULL && cont->seg->annotations != NULL)
result = PackFile_Annotations_lookup(interp, cont->seg->annotations,
cont->address - cont->seg->base.data, name);
@@ -762,14 +762,14 @@
PMC *result = pmc_new(interp, enum_class_ResizablePMCArray);
PMC *resume;
Parrot_Context *cur_ctx;
- Parrot_cont *cont;
+ Parrot_Continuation_attributes *cont;
/* Get starting context, then loop over them. */
GET_ATTR_resume(interp, SELF, resume);
if (!PMC_IS_NULL(resume)) {
/* We have a resume continuation, so we can get the address from
* that. */
- cont = PMC_cont(resume);
+ cont = PARROT_CONTINUATION(resume);
cur_ctx = cont->to_ctx;
}
else {
Modified: branches/kill_parrot_cont/src/pmc/exceptionhandler.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/exceptionhandler.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/exceptionhandler.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -40,23 +40,21 @@
*/
VTABLE void init() {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
(Parrot_ExceptionHandler_attributes *)PMC_data(SELF);
- Parrot_cont * const cc = new_continuation(INTERP, NULL);
-
- cc->invoked = 0;
- PMC_cont(SELF) = cc;
- core_struct->min_severity = 0;
- core_struct->max_severity = 0;
- core_struct->handled_types = PMCNULL;
- core_struct->handled_types_except = PMCNULL;
+ SUPER();
+ attrs->invoked = 0;
+ attrs->min_severity = 0;
+ attrs->max_severity = 0;
+ attrs->handled_types = PMCNULL;
+ attrs->handled_types_except = PMCNULL;
/* an exception handler has no separate context; it's only a snapshot
* of an "earlier" context, which is contained in the interpreter's
* context - the stacks can only be deeper in the interpreter - so no
* mark of context is needed */
PObj_custom_mark_SET(SELF);
- PObj_active_destroy_SET(SELF);
+ PObj_custom_mark_destroy_SETALL(SELF);
}
/*
@@ -69,12 +67,25 @@
*/
VTABLE void mark() {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
PARROT_EXCEPTIONHANDLER(SELF);
- if (core_struct->handled_types)
- Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types);
- if (core_struct->handled_types_except)
- Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types_except);
+ if (attrs->handled_types)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->handled_types);
+ if (attrs->handled_types_except)
+ Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->handled_types_except);
+ SUPER();
+ }
+
+ VTABLE void destroy(){
+
+ Parrot_ExceptionHandler_attributes *attrs = PARROT_EXCEPTIONHANDLER(SELF);
+
+ if (attrs->handled_types){
+ PObj_on_free_list_SET((PObj *) attrs->handled_types);
+ }
+ if (attrs->handled_types_except){
+ PObj_on_free_list_SET((PObj *) attrs->handled_types_except);
+ }
SUPER();
}
@@ -95,8 +106,7 @@
*/
VTABLE void set_integer_native(INTVAL value) {
- Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF);
- cc->invoked = value;
+ PARROT_CONTINUATION(SELF)->invoked = value;
}
/*
@@ -110,8 +120,7 @@
*/
VTABLE INTVAL get_integer() {
- const Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF);
- return cc->invoked;
+ return PARROT_CONTINUATION(SELF)->invoked;
}
/*
@@ -125,15 +134,14 @@
*/
VTABLE opcode_t *invoke(void *next) {
- Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF);
- opcode_t * const pc = cc->address;
+ opcode_t * const pc = PARROT_CONTINUATION(SELF)->address;
- Parrot_continuation_check(interp, SELF, cc);
- Parrot_continuation_rewind_environment(interp, SELF, cc);
+ Parrot_continuation_check(interp, SELF);
+ Parrot_continuation_rewind_environment(interp, SELF);
/* switch code segment if needed */
- if (INTERP->code != cc->seg)
- Parrot_switch_to_cs(INTERP, cc->seg, 1);
+ if (INTERP->code != PARROT_CONTINUATION(SELF)->seg)
+ Parrot_switch_to_cs(INTERP, PARROT_CONTINUATION(SELF)->seg, 1);
return pc;
}
@@ -232,13 +240,13 @@
*/
METHOD min_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
PARROT_EXCEPTIONHANDLER(SELF);
if (have_severity)
- core_struct->min_severity = severity;
+ attrs->min_severity = severity;
else
- severity = core_struct->min_severity;
+ severity = attrs->min_severity;
RETURN(INTVAL severity);
}
@@ -254,13 +262,13 @@
*/
METHOD max_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
PARROT_EXCEPTIONHANDLER(SELF);
if (have_severity)
- core_struct->max_severity = severity;
+ attrs->max_severity = severity;
else
- severity = core_struct->max_severity;
+ severity = attrs->max_severity;
RETURN(INTVAL severity);
}
@@ -276,9 +284,9 @@
*/
METHOD handle_types(PMC *types :slurpy) {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
PARROT_EXCEPTIONHANDLER(SELF);
- core_struct->handled_types =
+ attrs->handled_types =
VTABLE_elements(interp, types) > 0
? types
: PMCNULL;
@@ -295,9 +303,9 @@
*/
METHOD handle_types_except(PMC *types :slurpy) {
- Parrot_ExceptionHandler_attributes * const core_struct =
+ Parrot_ExceptionHandler_attributes * const attrs =
PARROT_EXCEPTIONHANDLER(SELF);
- core_struct->handled_types_except =
+ attrs->handled_types_except =
VTABLE_elements(interp, types) > 0
? types
: PMCNULL;
Modified: branches/kill_parrot_cont/src/pmc/parrotinterpreter.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/parrotinterpreter.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/parrotinterpreter.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -492,11 +492,11 @@
for (; level; --level) {
cont = ctx->current_cont;
- if (PMC_IS_NULL(cont) || !PMC_cont(cont)->seg)
+ if (PMC_IS_NULL(cont) || !PARROT_CONTINUATION(cont)->seg)
Parrot_ex_throw_from_c_args(interp, NULL,
CONTROL_ERROR, "No such caller depth");
- ctx = PMC_cont(cont)->to_ctx;
+ ctx = PARROT_CONTINUATION(cont)->to_ctx;
if (!ctx->current_sub)
Parrot_ex_throw_from_c_args(interp, NULL,
Modified: branches/kill_parrot_cont/src/pmc/retcontinuation.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/retcontinuation.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/retcontinuation.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -36,24 +36,18 @@
*/
VTABLE void init() {
- Parrot_RetContinuation_attributes * const attrs =
- (Parrot_RetContinuation_attributes *) PMC_data(SELF);
- PMC_cont(SELF) = new_ret_continuation(INTERP);
+ Parrot_RetContinuation_attributes * const attrs = PARROT_RETCONTINUATION(SELF);
- PObj_custom_mark_destroy_SETALL(SELF);
- }
+ attrs->to_ctx = CONTEXT(interp);
+ attrs->from_ctx = CONTEXT(interp); /* filled in during a call */
+ attrs->runloop_id = 0;
+ attrs->seg = interp->code;
+ attrs->current_results = NULL;
+ attrs->address = NULL;
- /*
- * XXX when reusing SUPER.destroy() RetContinuations
- * have to set ref_count initially to 1
- */
+ }
- VTABLE void destroy() {
- Parrot_cont * const cc = PMC_cont(SELF);
- if (cc)
- mem_sys_free(cc);
- }
/*
=item C<PMC *clone>
@@ -81,14 +75,13 @@
*/
VTABLE opcode_t *invoke(void *in_next) {
- Parrot_cont *cc = PMC_cont(SELF);
- Parrot_Context *from_ctx = cc->from_ctx;
- PackFile_ByteCode * const seg = cc->seg;
- opcode_t *next = cc->address;
+ Parrot_Context *from_ctx = PARROT_CONTINUATION(SELF)->from_ctx;
+ PackFile_ByteCode * const seg = PARROT_CONTINUATION(SELF)->seg;
+ opcode_t *next = PARROT_CONTINUATION(SELF)->address;
UNUSED(in_next)
- Parrot_continuation_check(interp, SELF, cc);
- Parrot_continuation_rewind_environment(interp, SELF, cc);
+ Parrot_continuation_check(interp, SELF);
+ Parrot_continuation_rewind_environment(interp, SELF);
Parrot_free_context(INTERP, from_ctx, 1);
/* the continuation is dead - delete and destroy it */
Modified: branches/kill_parrot_cont/src/pmc/sub.pmc
==============================================================================
--- branches/kill_parrot_cont/src/pmc/sub.pmc Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/pmc/sub.pmc Tue Sep 1 01:10:50 2009 (r40901)
@@ -292,7 +292,7 @@
"maximum recursion depth exceeded");
/* and copy set context variables */
- PMC_cont(ccont)->from_ctx = context;
+ PARROT_CONTINUATION(ccont)->from_ctx = context;
/* if this is an outer sub, then we need to set sub->ctx
* to the new context (refcounted) and convert the
Modified: branches/kill_parrot_cont/src/runcore/cores.c
==============================================================================
--- branches/kill_parrot_cont/src/runcore/cores.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/runcore/cores.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -382,7 +382,7 @@
PARROT_ASSERT(debugger);
/* set the top of the stack so GC can trace it for GC-able pointers
- * see trace_system_areas() in src/cpu_dep.c */
+ * see trace_system_areas() in src/gc/system.c */
debugger->lo_var_ptr = interp->lo_var_ptr;
pio = Parrot_io_STDERR(debugger);
Modified: branches/kill_parrot_cont/src/sub.c
==============================================================================
--- branches/kill_parrot_cont/src/sub.c Tue Sep 1 00:46:25 2009 (r40900)
+++ branches/kill_parrot_cont/src/sub.c Tue Sep 1 01:10:50 2009 (r40901)
@@ -127,9 +127,9 @@
/*
-=item C<Parrot_cont * new_continuation(PARROT_INTERP, const Parrot_cont *to)>
+=item C<PMC * new_continuation(PARROT_INTERP, const PMC *to)>
-Returns a new C<Parrot_cont> to the context of C<to> with its own copy of the
+Returns a new C<PMC> to the context of C<to> with its own copy of the
current interpreter context. If C<to> is C<NULL>, then the C<to_ctx> is set
to the current context.
@@ -139,34 +139,22 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Parrot_cont *
-new_continuation(PARROT_INTERP, ARGIN_NULLOK(const Parrot_cont *to))
+PMC *
+new_continuation(PARROT_INTERP, ARGIN_NULLOK(PMC *to))
{
ASSERT_ARGS(new_continuation)
- Parrot_cont * const cc = mem_allocate_typed(Parrot_cont);
- Parrot_Context * const to_ctx = to ? to->to_ctx : CONTEXT(interp);
-
- cc->to_ctx = to_ctx;
- cc->from_ctx = Parrot_context_ref(interp, CONTEXT(interp));
- cc->runloop_id = 0;
- if (to) {
- cc->seg = to->seg;
- cc->address = to->address;
- }
- else {
- cc->seg = interp->code;
- cc->address = NULL;
- }
-
- cc->current_results = to_ctx->current_results;
+
+ PMC * const cc = to ?
+ constant_pmc_new_init(interp, enum_class_Continuation, to) :
+ constant_pmc_new(interp, enum_class_Continuation);
return cc;
}
/*
-=item C<Parrot_cont * new_ret_continuation(PARROT_INTERP)>
+=item C<PMC * new_ret_continuation(PARROT_INTERP)>
-Returns a new C<Parrot_cont> pointing to the current context.
+Returns a new RetContinuation C<PMC> pointing to the current context.
=cut
@@ -174,27 +162,20 @@
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
-Parrot_cont *
+PMC *
new_ret_continuation(PARROT_INTERP)
{
ASSERT_ARGS(new_ret_continuation)
- Parrot_cont * const cc = mem_allocate_typed(Parrot_cont);
-
- cc->to_ctx = CONTEXT(interp);
- cc->from_ctx = CONTEXT(interp); /* filled in during a call */
- cc->runloop_id = 0;
- cc->seg = interp->code;
- cc->current_results = NULL;
- cc->address = NULL;
+ PMC * const cc = pmc_new(interp, enum_class_RetContinuation);
return cc;
}
+
/*
=item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)>
-Returns a new C<RetContinuation> PMC. Uses one from the cache,
-if possible; otherwise, creates a new one.
+Returns a new C<RetContinuation> PMC, and sets address field to C<address>
=cut
@@ -226,7 +207,8 @@
invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont))
{
ASSERT_ARGS(invalidate_retc_context)
- Parrot_Context *ctx = PMC_cont(cont)->from_ctx;
+
+ Parrot_Context *ctx = PARROT_CONTINUATION(cont)->from_ctx;
cont = ctx->current_cont;
Parrot_set_context_threshold(interp, ctx);
@@ -589,8 +571,7 @@
/*
-=item C<void Parrot_continuation_check(PARROT_INTERP, const PMC *pmc, const
-Parrot_cont *cc)>
+=item C<void Parrot_continuation_check(PARROT_INTERP, const PMC *pmc>
Verifies that the provided continuation is sane.
@@ -599,11 +580,10 @@
*/
void
-Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc),
- ARGIN(const Parrot_cont *cc))
+Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc))
{
ASSERT_ARGS(Parrot_continuation_check)
- Parrot_Context *to_ctx = cc->to_ctx;
+ Parrot_Context *to_ctx = PARROT_CONTINUATION(pmc)->to_ctx;
Parrot_Context *from_ctx = CONTEXT(interp);
#if CTX_LEAK_DEBUG
@@ -620,8 +600,7 @@
/*
-=item C<void Parrot_continuation_rewind_environment(PARROT_INTERP, PMC *pmc,
-Parrot_cont *cc)>
+=item C<void Parrot_continuation_rewind_environment(PARROT_INTERP, PMC *pmc>
Restores the appropriate context for the continuation.
@@ -630,11 +609,11 @@
*/
void
-Parrot_continuation_rewind_environment(PARROT_INTERP, SHIM(PMC *pmc),
- ARGIN(Parrot_cont *cc))
+Parrot_continuation_rewind_environment(PARROT_INTERP, ARGIN(PMC *pmc))
{
ASSERT_ARGS(Parrot_continuation_rewind_environment)
- Parrot_Context * const to_ctx = cc->to_ctx;
+
+ Parrot_Context * const to_ctx = PARROT_CONTINUATION(pmc)->to_ctx;
/* debug print before context is switched */
if (Interp_trace_TEST(interp, PARROT_TRACE_SUB_CALL_FLAG)) {
More information about the parrot-commits
mailing list