Skip to content

Commit

Permalink
only set a context *after* it has its registers allocated
Browse files Browse the repository at this point in the history
  • Loading branch information
plobsing committed Aug 20, 2011
1 parent 64438ce commit 2ef966f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/pmc/coroutine.pmc
Expand Up @@ -186,13 +186,14 @@ Swaps the "context".
"tail call to coroutine not allowed");

/* first time set current sub, cont, object */
if (PMC_IS_NULL(ctx))
if (PMC_IS_NULL(ctx)) {
ctx = Parrot_pmc_new(INTERP, enum_class_CallContext);
}
GET_ATTR_n_regs_used(INTERP, SELF, n_regs_used);
Parrot_pcc_allocate_registers(INTERP, ctx, n_regs_used);

Parrot_pcc_set_context(INTERP, ctx);

GET_ATTR_n_regs_used(INTERP, SELF, n_regs_used);
Parrot_pcc_allocate_registers(INTERP, ctx, n_regs_used);
Parrot_pcc_set_caller_ctx(INTERP, ctx, caller_ctx);
Parrot_pcc_init_context(INTERP, ctx, caller_ctx);

Expand Down
5 changes: 3 additions & 2 deletions src/pmc/sub.pmc
Expand Up @@ -423,12 +423,13 @@ Invokes the subroutine.

PARROT_ASSERT(!PMC_IS_NULL(ccont));

if (PMC_IS_NULL(context))
if (PMC_IS_NULL(context)) {
context = Parrot_pmc_new(INTERP, enum_class_CallContext);
}
Parrot_pcc_allocate_registers(INTERP, context, sub->n_regs_used);

Parrot_pcc_set_context(INTERP, context);
Parrot_pcc_set_caller_ctx(INTERP, context, caller_ctx);
Parrot_pcc_allocate_registers(INTERP, context, sub->n_regs_used);
/* Preserve object */
object = Parrot_pcc_get_object(INTERP, context);
Parrot_pcc_init_context(INTERP, context, caller_ctx);
Expand Down

0 comments on commit 2ef966f

Please sign in to comment.