Skip to content

Commit

Permalink
Turns out in bind_signature we need to save some state now too, other…
Browse files Browse the repository at this point in the history
…wise it can get scribbled over a bunch. I fear there's an underlying problem or other change that is hurting us somewhere here, and it'll come back and bite us later, but this at least gets us able to start up (though we fail most of the sanity tests).
  • Loading branch information
jnthn committed Oct 26, 2009
1 parent 552431e commit 6b04b37
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
18 changes: 18 additions & 0 deletions src/ops/perl6.ops
Expand Up @@ -610,8 +610,26 @@ inline op bind_signature(in PMC, in PMC) :base_core {
INTVAL noms_checked = PObj_flag_TEST(P6S_ALREADY_CHECKED, ctx);
STRING *error = NULL;

/* Need to make sure some stuff doesn't get destroyed. */
PMC * ctx = CURRENT_CONTEXT(interp);
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, ctx);
PMC * const saved_rs = Parrot_pcc_get_results_signature(interp, ctx);
opcode_t * const saved_cr = Parrot_pcc_get_results(interp, ctx);
opcode_t * const current_pc = Parrot_pcc_get_pc(interp, ctx);

/* Call signature binder. */
INTVAL bind_error = bind_signature_func(interp, lexpad, signature, $1, $2, noms_checked, &error);

/* Re-instate anything we may have damaged. */
CURRENT_CONTEXT(interp) = ctx;
interp->current_cont = saved_ccont;
Parrot_pcc_set_signature(interp, ctx, saved_sig);
Parrot_pcc_set_results_signature(interp, ctx, saved_rs);
Parrot_pcc_set_results(interp, ctx, saved_cr);
Parrot_pcc_set_pc(interp, ctx, current_pc);

/* Bind ok? */
if (!bind_error) {
goto NEXT();
}
Expand Down
11 changes: 8 additions & 3 deletions src/pmc/p6opaque.pmc
Expand Up @@ -34,8 +34,11 @@ static PMC *do_handles(PARROT_INTERP, PMC *cur_class, PMC *handlers, STRING *nam

/* Need to make sure a some stuff doesn't get destroyed, since we very
* liekly have a call set up when we are running this code. */
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC * ctx = CURRENT_CONTEXT(interp);
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, ctx);
PMC * const saved_rs = Parrot_pcc_get_results_signature(interp, ctx);
opcode_t * const saved_cr = Parrot_pcc_get_results(interp, ctx);

/* Iterate over the handlers. */
PMC *iter = VTABLE_get_iter(interp, handlers);
Expand Down Expand Up @@ -90,7 +93,9 @@ static PMC *do_handles(PARROT_INTERP, PMC *cur_class, PMC *handlers, STRING *nam

/* Restore stuff that might have got overwriten. */
interp->current_cont = saved_ccont;
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), saved_sig);
Parrot_pcc_set_signature(interp, ctx, saved_sig);
Parrot_pcc_set_results_signature(interp, ctx, saved_rs);
Parrot_pcc_set_results(interp, ctx, saved_cr);

/* Did we find anything? */
if (attr) {
Expand Down
28 changes: 21 additions & 7 deletions src/pmc/perl6multisub.pmc
Expand Up @@ -127,7 +127,7 @@ get_args(PARROT_INTERP, PMC **pos_args, PMC **named_args)
*pos_args = sig;
*named_args = pmc_new(interp, enum_class_Hash);
if (!PMC_IS_NULL(names)) {
PMC *iter = VTABLE_get_iter(interp, names);
PMC *iter = VTABLE_get_iter(interp, names);
while (VTABLE_get_bool(interp, iter)) {
STRING *name = VTABLE_shift_string(interp, iter);
PMC *value = VTABLE_get_pmc_keyed_str(interp, sig, name);
Expand Down Expand Up @@ -465,6 +465,7 @@ static PMC* do_dispatch(PARROT_INTERP, PMC *self, candidate_info **candidates, P
for (i = 0; i < possibles_count; i++) {
interp->current_cont = NEED_CONTINUATION;
interp->current_object = NULL;
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), NULL);

/* First, if there's a required named parameter and it was not
* passed, we can very quickly eliminate this candidate without
Expand Down Expand Up @@ -719,8 +720,11 @@ static PMC *find_many_candidates_with_arg_list(PARROT_INTERP, PMC *SELF, PMC *po
MMD_Cache *cache;

/* Need to make sure some bits don't get destroyed. */
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC * ctx = CURRENT_CONTEXT(interp);
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, ctx);
PMC * const saved_rs = Parrot_pcc_get_results_signature(interp, ctx);
opcode_t * const saved_cr = Parrot_pcc_get_results(interp, ctx);

/* See if we have a cache entry. */
GETATTR_Perl6MultiSub_cache_many(interp, SELF, cache);
Expand Down Expand Up @@ -751,7 +755,9 @@ static PMC *find_many_candidates_with_arg_list(PARROT_INTERP, PMC *SELF, PMC *po
/* Restore stuff that might have got overwriten by calls during the
* dispatch algorithm. */
interp->current_cont = saved_ccont;
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), saved_sig);
Parrot_pcc_set_signature(interp, ctx, saved_sig);
Parrot_pcc_set_results_signature(interp, ctx, saved_rs);
Parrot_pcc_set_results(interp, ctx, saved_cr);

return results;
}
Expand Down Expand Up @@ -928,8 +934,12 @@ the Perl 6 MMD algorithm.
PMC *unsorted;

/* Need to make sure some stuff doesn't get destroyed. */
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC * ctx = CURRENT_CONTEXT(interp);
PMC * const saved_ccont = interp->current_cont;
PMC * const saved_sig = Parrot_pcc_get_signature(interp, ctx);
PMC * const saved_rs = Parrot_pcc_get_results_signature(interp, ctx);
opcode_t * const saved_cr = Parrot_pcc_get_results(interp, ctx);
opcode_t * const current_pc = Parrot_pcc_get_pc(interp, ctx);

/* Get arguments. */
PMC *pos_args, *named_args;
Expand Down Expand Up @@ -965,8 +975,12 @@ the Perl 6 MMD algorithm.

/* Restore stuff that might have got overwriten by calls during the
* dispatch algorithm. */
CURRENT_CONTEXT(interp) = ctx;
interp->current_cont = saved_ccont;
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), saved_sig);
Parrot_pcc_set_signature(interp, ctx, saved_sig);
Parrot_pcc_set_results_signature(interp, ctx, saved_rs);
Parrot_pcc_set_results(interp, ctx, saved_cr);
Parrot_pcc_set_pc(interp, ctx, current_pc);

/* Invoke the winner, and mark the context so we know not to re-do a
* bunch of type checks. */
Expand Down

0 comments on commit 6b04b37

Please sign in to comment.