Skip to content

Commit

Permalink
Remove RetContinuation PMC. Closes TT#1427. Coke++ for all hard work.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@45867 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bacek committed Apr 21, 2010
1 parent 19af788 commit 78ab762
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 258 deletions.
2 changes: 0 additions & 2 deletions MANIFEST
Expand Up @@ -1465,7 +1465,6 @@ src/pmc/resizablefloatarray.pmc []
src/pmc/resizableintegerarray.pmc []
src/pmc/resizablepmcarray.pmc []
src/pmc/resizablestringarray.pmc []
src/pmc/retcontinuation.pmc []
src/pmc/role.pmc []
src/pmc/scalar.pmc []
src/pmc/scheduler.pmc []
Expand Down Expand Up @@ -1949,7 +1948,6 @@ t/pmc/resizablefloatarray.t [test]
t/pmc/resizableintegerarray.t [test]
t/pmc/resizablepmcarray.t [test]
t/pmc/resizablestringarray.t [test]
t/pmc/retcontinuation.t [test]
t/pmc/ro.t [test]
t/pmc/role.t [test]
t/pmc/scalar.t [test]
Expand Down
1 change: 1 addition & 0 deletions PBC_COMPAT
Expand Up @@ -27,6 +27,7 @@

# please insert tab separated entries at the top of the list

6.7 2010.04.17 coke remove RetContinuation PMC
6.6 2010.04.17 bacek add replace op
6.5 2010.03.09 cotto remove cpu_ret op
6.4 2010.03.02 cotto remove prederef__ and reserved
Expand Down
17 changes: 0 additions & 17 deletions include/parrot/sub.h
Expand Up @@ -171,13 +171,6 @@ typedef struct Parrot_Context_info {
/* HEADERIZER BEGIN: src/sub.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */

PARROT_EXPORT
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
PMC * new_ret_continuation_pmc(PARROT_INTERP,
ARGIN_NULLOK(opcode_t *address))
__attribute__nonnull__(1);

PARROT_EXPORT
void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc))
__attribute__nonnull__(1)
Expand Down Expand Up @@ -219,11 +212,6 @@ PMC* parrot_new_closure(PARROT_INTERP, ARGIN(PMC *sub_pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

void invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*cont);

void mark_context_start(void);
void Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc))
__attribute__nonnull__(1)
Expand Down Expand Up @@ -262,8 +250,6 @@ INTVAL Parrot_Sub_get_line_from_pc(PARROT_INTERP,
ARGIN_NULLOK(opcode_t *pc))
__attribute__nonnull__(1);

#define ASSERT_ARGS_new_ret_continuation_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_capture_lex __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sub_pmc))
Expand All @@ -283,9 +269,6 @@ INTVAL Parrot_Sub_get_line_from_pc(PARROT_INTERP,
#define ASSERT_ARGS_parrot_new_closure __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sub_pmc))
#define ASSERT_ARGS_invalidate_retc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(cont))
#define ASSERT_ARGS_mark_context_start __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
Expand Down
2 changes: 1 addition & 1 deletion src/call/pcc.c
Expand Up @@ -340,7 +340,7 @@ Parrot_pcc_invoke_from_sig_object(PARROT_INTERP, ARGIN(PMC *sub_obj),
opcode_t *dest;
UINTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
PMC *ctx = Parrot_push_context(interp, n_regs_used);
PMC * const ret_cont = new_ret_continuation_pmc(interp, NULL);
PMC * const ret_cont = pmc_new(interp, enum_class_Continuation);

Parrot_pcc_set_signature(interp, ctx, call_object);
Parrot_pcc_set_continuation(interp, ctx, ret_cont);
Expand Down
3 changes: 0 additions & 3 deletions src/interp/inter_misc.c
Expand Up @@ -283,9 +283,6 @@ interpinfo_p(PARROT_INTERP, INTVAL what)
case CURRENT_CONT:
{
PMC * const cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
if (!PMC_IS_NULL(cont) && cont->vtable->base_type ==
enum_class_RetContinuation)
return VTABLE_clone(interp, cont);
return cont;
}
case CURRENT_OBJECT:
Expand Down
16 changes: 12 additions & 4 deletions src/ops/core.ops
Expand Up @@ -746,7 +746,9 @@ inline op throw(invar PMC) :flow {
PMC * except = $1;
opcode_t *dest;
opcode_t * const ret = expr NEXT();
PMC * const resume = new_ret_continuation_pmc(interp, ret);
PMC * const resume = pmc_new(interp, enum_class_Continuation);

VTABLE_set_pointer(interp, resume, ret);

if (PMC_IS_NULL(except) || except->vtable->base_type != enum_class_Exception)
except = Parrot_ex_build_exception(interp, EXCEPT_fatal,
Expand Down Expand Up @@ -792,10 +794,12 @@ inline op count_eh(out INT) {
inline op die(in STR) :flow {
opcode_t *dest;
opcode_t * const ret = expr NEXT();
PMC * const resume = new_ret_continuation_pmc(interp, ret);
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, EXCEPT_error,
CONTROL_ERROR, $1);

VTABLE_set_pointer(interp, resume, ret);

VTABLE_set_attr_str(interp, exception,
Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
Expand All @@ -805,11 +809,13 @@ inline op die(in STR) :flow {
inline op die(in PMC) :flow {
opcode_t *dest;
opcode_t * const ret = expr NEXT();
PMC * const resume = new_ret_continuation_pmc(interp, ret);
PMC * const resume = pmc_new(interp, enum_class_Continuation);
STRING * const msg = PMC_IS_NULL($1) ? NULL : VTABLE_get_string(interp, $1);
PMC * const exception =
Parrot_ex_build_exception(interp, EXCEPT_error, CONTROL_ERROR, msg);

VTABLE_set_pointer(interp, resume, ret);

VTABLE_set_attr_str(interp, exception,
Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
Expand All @@ -831,9 +837,11 @@ inline op die(in INT, in INT) :flow {
inline op exit(in INT) :flow {
opcode_t *dest;
opcode_t * const ret = expr NEXT();
PMC * const resume = new_ret_continuation_pmc(interp, ret);
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, $1, NULL);

VTABLE_set_pointer(interp, resume, ret);

VTABLE_set_attr_str(interp, exception,
Parrot_str_new_constant(interp, "resume"), resume);
VTABLE_set_integer_keyed_str(interp, exception,
Expand Down
18 changes: 0 additions & 18 deletions src/pmc/continuation.pmc
Expand Up @@ -78,15 +78,6 @@ Initializes the continuation.
SET_ATTR_address(INTERP, SELF, NULL);

PObj_custom_mark_SET(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*/
Expand All @@ -109,15 +100,6 @@ Initializes the continuation.
SET_ATTR_address(INTERP, SELF, address);

PObj_custom_mark_SET(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);
}


Expand Down
6 changes: 4 additions & 2 deletions src/pmc/coroutine.pmc
Expand Up @@ -169,8 +169,10 @@ Swaps the "context".
PMC *ctx = Parrot_pcc_get_signature(INTERP, caller_ctx);
PMC *ccont = INTERP->current_cont;

if (ccont == NEED_CONTINUATION)
ccont = (PMC *)new_ret_continuation_pmc(INTERP, next_op);
if (ccont == NEED_CONTINUATION) {
ccont = pmc_new(interp, enum_class_Continuation);
VTABLE_set_pointer(interp, ccont, next_op);
}

if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL)
Parrot_ex_throw_from_c_args(INTERP, NULL, CONTROL_ERROR,
Expand Down
118 changes: 0 additions & 118 deletions src/pmc/retcontinuation.pmc

This file was deleted.

11 changes: 5 additions & 6 deletions src/pmc/sub.pmc
Expand Up @@ -392,8 +392,10 @@ Invokes the subroutine.
pc = sub->seg->base.data + sub->start_offs;
INTERP->current_cont = NULL;

if (ccont == NEED_CONTINUATION)
ccont = new_ret_continuation_pmc(interp, (opcode_t *)next);
if (ccont == NEED_CONTINUATION) {
ccont = pmc_new(interp, enum_class_Continuation);
VTABLE_set_pointer(interp, ccont, next);
}

PARROT_ASSERT(!PMC_IS_NULL(ccont));

Expand Down Expand Up @@ -421,12 +423,9 @@ Invokes the subroutine.
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
* retcontinuation to a normal continuation. */
* to the new context (refcounted) */
if (PObj_get_FLAGS(SELF) & SUB_FLAG_IS_OUTER) {
sub->ctx = context;
/* convert retcontinuation to a continuation */
ccont->vtable = interp->vtables[enum_class_Continuation];
}

/* create pad if needed
Expand Down
54 changes: 0 additions & 54 deletions src/sub.c
Expand Up @@ -47,60 +47,6 @@ mark_context_start(void)
}


/*
=item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)>
Returns a new C<RetContinuation> PMC, and sets address field to C<address>
=cut
*/

PARROT_EXPORT
PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
PMC *
new_ret_continuation_pmc(PARROT_INTERP, ARGIN_NULLOK(opcode_t *address))
{
ASSERT_ARGS(new_ret_continuation_pmc)
PMC* const continuation = Parrot_pmc_new(interp, enum_class_RetContinuation);
VTABLE_set_pointer(interp, continuation, address);
return continuation;
}

/*
=item C<void invalidate_retc_context(PARROT_INTERP, PMC *cont)>
Make true Continuations from all RetContinuations up the call chain.
=cut
*/

void
invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont))
{
ASSERT_ARGS(invalidate_retc_context)

PMC *ctx = PARROT_CONTINUATION(cont)->from_ctx;
cont = Parrot_pcc_get_continuation(interp, ctx);

while (1) {
/*
* We stop if we encounter a true continuation, because
* if one were created, everything up the chain would have been
* invalidated earlier.
*/
if (!cont || cont->vtable != interp->vtables[enum_class_RetContinuation])
break;
cont->vtable = interp->vtables[enum_class_Continuation];
ctx = Parrot_pcc_get_caller_ctx(interp, ctx);
cont = Parrot_pcc_get_continuation(interp, ctx);
}
}

/*
=item C<STRING* Parrot_full_sub_name(PARROT_INTERP, PMC* sub_pmc)>
Expand Down
Binary file modified t/native_pbc/annotations.pbc
Binary file not shown.
Binary file modified t/native_pbc/integer_1.pbc
Binary file not shown.
Binary file modified t/native_pbc/number_1.pbc
Binary file not shown.
Binary file modified t/native_pbc/string_1.pbc
Binary file not shown.

0 comments on commit 78ab762

Please sign in to comment.