restore a fast path for a procedure chaperone

When the representation of a redirect changed, the fast
path wasn't updated.
This commit is contained in:
Matthew Flatt 2015-12-22 14:15:28 -07:00
parent c73bcceafe
commit e8073e699e
2 changed files with 17 additions and 3 deletions

View File

@ -3750,7 +3750,20 @@ Scheme_Object *scheme_apply_chaperone(Scheme_Object *o, int argc, Scheme_Object
/* communicate `self_proc` to the next layer: */
scheme_current_thread->self_for_proc_chaperone = self_proc;
}
return _scheme_tail_apply(px->prev, argc, argv);
if (checks) {
/* cannot return a tail call */
MZ_CONT_MARK_POS -= 2;
if (checks & 0x1) {
v = _scheme_apply(px->prev, argc, argv);
} else if (SAME_TYPE(SCHEME_TYPE(px->prev), scheme_native_closure_type)) {
v = _apply_native(px->prev, argc, argv);
} else {
v = _scheme_apply_multi(px->prev, argc, argv);
}
MZ_CONT_MARK_POS += 2;
return v;
} else
return _scheme_tail_apply(px->prev, argc, argv);
}
/* Ensure that the original procedure accepts `argc' arguments: */

View File

@ -62,8 +62,9 @@ Scheme_Object *PRIM_APPLY_NAME(Scheme_Object *rator,
if (t == scheme_prim_type) {
return PRIM_APPLY_NAME_FAST(rator, argc, argv);
} if ((t == scheme_proc_chaperone_type)
&& SCHEME_MPAIRP(((Scheme_Chaperone *)rator)->redirects)) {
} else if ((t == scheme_proc_chaperone_type)
&& SCHEME_VECTORP(((Scheme_Chaperone *)rator)->redirects)
&& (SCHEME_VEC_SIZE(((Scheme_Chaperone *)rator)->redirects) & 0x1)) {
return scheme_apply_chaperone(rator, argc, argv, NULL, PRIM_CHECK_MULTI | (PRIM_CHECK_VALUE << 1));
}
}