JIT: simplify output for begin0 that's just for its non-tail effect

Don't store away and restore multiple results if it's obvious
that nothing happens in between.
This commit is contained in:
Matthew Flatt 2016-12-13 18:25:20 -07:00
parent 7204d3136b
commit 6ec5b27f81

View File

@ -2253,7 +2253,7 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
{
Scheme_Sequence *seq;
GC_CAN_IGNORE jit_insn *ref, *ref2;
int i;
int i, count;
START_JIT_DATA();
LOG_IT(("begin0\n"));
@ -2264,8 +2264,13 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
scheme_generate_non_tail(seq->array[0], jitter, multi_ok, 1, result_ignored);
CHECK_LIMIT();
count = seq->count;
/* Ignore an obviously useless expression: */
if ((count == 2) && (SCHEME_TYPE(seq->array[1]) > _scheme_values_types_))
count = 1;
/* Save value(s) */
if (!result_ignored) {
if (!result_ignored && (count > 1)) {
mz_pushr_p(JIT_R0);
if (multi_ok) {
mz_pushr_p(JIT_R0);
@ -2310,6 +2315,7 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
/* Restore values, if necessary */
if (!result_ignored) {
if (count > 1) {
mz_popr_p(JIT_R0);
if (multi_ok) {
mz_popr_p(JIT_R1);
@ -2328,6 +2334,7 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
mz_patch_branch(ref);
__END_TINY_JUMPS__(1);
}
}
if (target != JIT_R0)
jit_movr_p(target, JIT_R0);