From 22d2db5e089c9efcf9dd21085e09100c260043f6 Mon Sep 17 00:00:00 2001 From: Bart Wiegmans Date: Sun, 18 Feb 2018 15:18:11 +0100 Subject: [PATCH] [Spesh] Move annotations to istrue when split from if_o In commit c7774e37d2 we unconditionally split if_o/unless_o into istrue + if_i/unless_i, which fixed rakudo issue #1483. However, the annotations that would indicate the start of the if_o instruction, would now inadvertently be placed in the middle of the split instruction (between istrue and if_i). This would then presumably fail, e.g. when the istrue would throw an exception (frame handler would exclude it) or the exception would be 'caught' between them (FH_GOTO would point between istrue/if_i rather than before). I couldn't find any case where the frame handler annotation should be on the if_i rather than the istrue, so that's what I changed to do. I believe this fixes MoarVM issue #804. --- src/spesh/optimize.c | 4 ++++ tools/jit-bisect.pl | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/spesh/optimize.c b/src/spesh/optimize.c index 332e541b61..f8450a4812 100644 --- a/src/spesh/optimize.c +++ b/src/spesh/optimize.c @@ -570,6 +570,10 @@ static void decompose_object_conditional(MVMThreadContext *tc, MVMSpeshGraph *g, MVM_spesh_use_facts(tc, g, flag_facts); MVM_spesh_manipulate_release_temp_reg(tc, g, temp); + /* Now that we *have* decomposed the if_o, annotations should be moved to + * the new_ins */ + new_ins->annotations = ins->annotations; + ins->annotations = NULL; /* If the boolification mode was "not type object" then we might know * that from the facts, and may even be able to elimiante this diff --git a/tools/jit-bisect.pl b/tools/jit-bisect.pl index 2b5dc23c2f..6b31e61698 100644 --- a/tools/jit-bisect.pl +++ b/tools/jit-bisect.pl @@ -162,6 +162,12 @@ sub bisect { )} if $OPTS{spesh}; $ENV{MVM_SPESH_BLOCKING} = 1; +# I find that the addition of the MVM_SPESH_LOG / MVM_JIT_LOG +# environment variable can sometimes change the spesh order of +# frames. So let's add it always so that when we run it for logging +# output, we don't accidentally log the wrong frame. +$ENV{$_} = File::Spec->devnull for qw(MVM_SPESH_LOG MVM_JIT_LOG); + quietly { run_with(\@command, {}, $timeout) } or do { die "This program is quite alright"; }; @@ -197,21 +203,14 @@ sub bisect { printf STDERR ("SPESH Broken frame: %d.\n", $last_good_frame); # alright, get a spesh diff - my ($good_log, $bad_log) = map sprintf("spesh-%04d.txt", $_), ($last_good_frame, $last_good_frame+1); - printf STDERR ("SPESH Acquiring log: %s\n", $good_log); - run_with(\@command, { - %$spesh_flags, - MVM_SPESH_LOG => sprintf('spesh-%04d.txt', $last_good_frame), - MVM_SPESH_LIMIT => $last_good_frame - }, $timeout); - - printf STDERR ("SPESH Acquiring log: %s\n", $bad_log); + my $log_file = sprintf("spesh-%04d.txt", $last_good_frame+1); + printf STDERR ("SPESH Acquiring log: %s\n", $log_file); run_with(\@command, { %$spesh_flags, - MVM_SPESH_LOG => $bad_log, + MVM_SPESH_LOG => $log_file, MVM_SPESH_LIMIT => $last_good_frame + 1 }, $timeout); - print STDERR "Done\n"; + print STDERR "Done\n"; } else { my $last_good_frame = bisect('MVM_JIT_EXPR_LAST_FRAME', \@command, {}, $timeout); my $last_good_block = bisect('MVM_JIT_EXPR_LAST_BB', \@command, {