[svn:parrot] r41397 - in trunk: compilers/imcc t/compilers/imcc/imcpasm t/compilers/imcc/syn
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Sep 21 09:40:55 UTC 2009
Author: bacek
Date: Mon Sep 21 09:40:55 2009
New Revision: 41397
URL: https://trac.parrot.org/parrot/changeset/41397
Log:
[cage][core] Emit additional noop after C<exit> if it's last in sub.
Closes TT#1009.
Modified:
trunk/compilers/imcc/pcc.c
trunk/t/compilers/imcc/imcpasm/opt0.t
trunk/t/compilers/imcc/syn/regressions.t
Modified: trunk/compilers/imcc/pcc.c
==============================================================================
--- trunk/compilers/imcc/pcc.c Mon Sep 21 09:40:19 2009 (r41396)
+++ trunk/compilers/imcc/pcc.c Mon Sep 21 09:40:55 2009 (r41397)
@@ -447,6 +447,11 @@
IMCC_debug(interp, DEBUG_IMC, "add sub ret - %I\n", tmp);
insert_ins(unit, unit->last_ins, tmp);
}
+ else if(STREQ(unit->last_ins->opname, "exit")) {
+ /* C<exit> builds RetContinuation pointing to next op_code. So insert some */
+ Instruction *tmp = INS(interp, unit, "noop", NULL, regs, 0, 0, 0);
+ insert_ins(unit, unit->last_ins, tmp);
+ }
}
/*
Modified: trunk/t/compilers/imcc/imcpasm/opt0.t
==============================================================================
--- trunk/t/compilers/imcc/imcpasm/opt0.t Mon Sep 21 09:40:19 2009 (r41396)
+++ trunk/t/compilers/imcc/imcpasm/opt0.t Mon Sep 21 09:40:55 2009 (r41397)
@@ -86,6 +86,7 @@
_test:
noop
exit 0
+ noop
OUT
##############################
Modified: trunk/t/compilers/imcc/syn/regressions.t
==============================================================================
--- trunk/t/compilers/imcc/syn/regressions.t Mon Sep 21 09:40:19 2009 (r41396)
+++ trunk/t/compilers/imcc/syn/regressions.t Mon Sep 21 09:40:55 2009 (r41397)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 16;
+use Parrot::Test tests => 17;
pir_error_output_like( <<'CODE', <<'OUT', 'invalid get_results syntax');
.sub main :main
@@ -230,6 +230,13 @@
OUT
}
+# We shouldn't crash (and valgrind shoudn't report invalid reads)
+pir_output_is( <<'CODE', <<'OUT', 'exit is last op in sub (TT#1009)');
+.sub main :main
+ exit 0
+.end
+CODE
+OUT
More information about the parrot-commits
mailing list